Good article about inheritance - http://berniesumption.com/software/inheritance-is-evil-and-must-be-destroyed/.
Mix-in and Strategy are great replacements for it.
Mix-in and Strategy are great replacements for it.
private static interface Amoeba<Value> {
boolean consume(Amoeba<Value> amoeba);
Value produce() throws Exception;
}
private static class AmoebaUtils {
static <Value> boolean populate(Collection<Amoeba<Value>> colony, Amoeba<Value> nominate) {
for (Amoeba<Value> citizen : colony) {
if (citizen.equals(nominate)) {
return citizen.consume(nominate);
}
}
return colony.add(nominate);
}
static <Value> Collection<Value> produce(Set<Amoeba<Value>> colony) throws Exception {
Set<Value> values = new HashSet<Value>();
for (Amoeba<Value> citizen : colony) {
values.add(citizen.produce());
}
return values;
}
}
...
private final List<List<FinDate>> expiryDateByOptionAndLeg;
expiryDateByOptionAndLeg = new ArrayList<List<FinDate>>(size){
...
@Override
public List<
FinDate
> get(int index) {
List<
FinDate
> rez = null;
rez = super.get(index);
if(rez == null) {
rez = new ArrayList<
FinDate
>(2);
add(index, rez);
}
return rez;
}
};
...
expiryDateByOptionAndLeg.get(optionsIndex).set(legIndex, expiryDate);
Session | Key |
---|---|
Holds request specific data | Need to hold request specific data in api objects |
More agile approach, you can make you session active, have one master instance for actions or session-specific actors | Managing class and a collection of keys are needed for two way communication |
Visible list of services available | You should knew about service existence before use it |
It's complex to fake system | It's easy to confuse keys |