May. 25th, 2007
Говорят, что если это слово, ru_пbр, попадается в тексте поста, посылаемого из России, то ни хрена не доходит до ЖЖ.
Теперь внимание, опыт. У меня и из Маунтин Вью не доходит.
Ну что делать будем?
update. greatestjournal.com окей.
Так что, где сервера? Что с ними? Пишем в тех суппорт.
Теперь внимание, опыт. У меня и из Маунтин Вью не доходит.
Ну что делать будем?
update. greatestjournal.com окей.
Так что, где сервера? Что с ними? Пишем в тех суппорт.
I wonder how obvious or how stupid or how ubiquitous is the following trick:
Say, I have an enum somewhere outside of my realm:
and my method takes an instance of that enum, and I really do not like switching based on the enum; of course I can have an
(PURPLE STUFF ADDED LATER)
Is not it a poetry? :)
Say, I have an enum somewhere outside of my realm:
enum DataType {
PERSONAL, COMMUNITY, PRISON, ARMY;
};
....
and my method takes an instance of that enum, and I really do not like switching based on the enum; of course I can have an
EnumMap
, but the funny trick is that my strategies are based on this enum type, so I can do just this:
enum Strategy {
PERSONAL {
public void process(Entity entity) {...};
},
COMMUNITY {
public void process(Entity entity) {...};
},
PRISON {
public void process(Entity entity) {...};
},
ARMY {
public void process(Entity entity) {...};
}
abstract public void process(Entity entity);
DEFAULT{
public void process(Entity entity) {...};
};
abstract public void process(Entity entity);
(and so on, add functionality here )
Strategy forDataType(DataType type) {
Strategy candidate = valueOf(type.name());
return candidate == null ? DEFAULT : candidate;
}
};
....
Strategy.forDataType(myType).process(myEntity);
(PURPLE STUFF ADDED LATER)
Is not it a poetry? :)