https://github.com/lue-bird/java-coding-style
https://github.com/lue-bird/java-coding-style
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/lue-bird/java-coding-style
- Owner: lue-bird
- Created: 2022-01-27T05:56:23.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-01-27T09:07:16.000Z (over 3 years ago)
- Last Synced: 2025-03-27T08:48:01.382Z (7 months ago)
- Language: Java
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Java by default means
- mutable objects: `person.setName`
- references to mutable objects
- overriding `equals` and `hashCode`
- statements > expressions:
```java
doX();
doY();
```
- `RuntimeException`s en masse
- bad error messages
- mutable variables: `setName(`~~`final`~~` String name)`
- package public members:
- ~~`private`~~` String name;`
- (implicit) constructors
- extensible classes: ~~`final`~~` class Person;`
- no exhaustive type matching (only as a [java 17 preview feature](https://docs.oracle.com/en/java/javase/17/language/pattern-matching-switch-expressions-and-statements.html))
- eager evaluation
- unreadable formatting
- actually useful info near the end of the line:
```java
public final class {
public static void {
System.out.;
}
}
```
- all-caps:
```java
enum Fruit { BANANA }
static final Fruit YELLOW_FRUIT= BANANA;
```
- 1-letter type variable names:
```java
V
map2(... ..., ... ...)
```
- verbosity
- gotchas:
```java
'h' + 'e' + 'l' + 'l' + 'o' // == 532
```... **it's easy to write bad code in java**.
After a year with [elm](https://elm-lang.org/), I disagree with nearly every basic design decision.
If you are required to use java – just like me, here are some tips to make the best of java:
- [union-type](union-type.md)
- [`final`-everywhere*](final-everywhere.md)
- [`static` functions](static-functions.md)
- [formatting](formatting.md)Note: This list covers _only a few tips_.