geonik
https://www.seattletimes.com/nation-world/chaser-border-coll...
APIs are not a one-size-fits-all problem, and while general trends and paradigms are a nice thing to have, developers should not be restricted by whatever is the hottest buzzword today.
A nice and clean API will always be pleasant to use, and this has nothing to do with RESTful awesomeness or SOAP verbosity.
- constructors, private fields, methods, addressing the "separations of concerns" - how about Enum.valueOf(enumClass, text.toUpperCase()) to avoid the "classic shadow array of string literals"?
Here is an example of what can be achieved by Java enums
enum Type {
ANIMAL(null),
MAMMAL(ANIMAL),
DOG(MAMMAL) {
public void makeNoise() {
System.out.println("Woof");
}
},
CAT(MAMMAL) {
public void makeNoise() {
System.out.println("Meow");
}
};
private Type parent;
Type(Type parent) {
this.parent = parent;
}
public boolean isA(Type type) {
if(this == type) return true;
if(parent != null) return parent.isA(type);
return false;
}
public void makeNoise() { }
}
assert Type.DOG.isA(Type.MAMMAL) == true;
assert Type.CAT.isA(Type.DOG) == false;
Type.CAT.makeNoise(); // "Meow"And these are exactly those who will never "get" that XML is much more than a data container for tree-like structures. They should stick to JSON or CSV for that matter.
1. parsed on server startup for setting up persistence, business rules, REST endpoints etc
2. transformed by XSLT to a) produce nice HTML documentation, including DOT class diagrams b) generate Java source code c) validate declaration integrity and cross-referencing
With the right XSDs, IDE support is excellent (auto complete for everything). Take the time to learn it, apply it according to your needs, and reap the benefits- in the long run, maintenance work is down by an order of magnitude.
You scored 666 You are better than 100 %