at runtime, classes java concentration extend bottom class
i wish something this:
list<animal> animals = new arraylist<animal>();
for( category c: list_of_all_classes_available_to_my_app() )
(c animal)
animals.add( new c() );
so, i wish feeling during classes application's universe, i descends animal, i wish emanate new vigilant form supplement list. allows me supplement functionality but carrying transform list things. i prevaricate following:
list<animal> animals = new arraylist<animal>();
animals.add( new dog() );
animals.add( new cat() );
animals.add( new donkey() );
...
with above approach, i simply emanate new category extends animal it'll picked adult automatically.
update: 10/16/2008 9:00 a.m. mild customary time:
this doubt generated lot good responses -- conclude you. from responses research, i've found i unequivocally wish only illusory underneath java. there approaches, such ddimitrov's serviceloader apparatus work -- nonetheless unequivocally complicated i want, i trust i simply pierce problem java formula an outmost settlement file. update 5/10/19 (11 years later!) there several libraries assistance according @ivannik's looks good. also @luke hutchison's looks interesting. there several some-more possibilities answers well.
another proceed state i want: stationary duty animal category finds instantiates classes get animal -- but any offer configuration/coding. i have configure, i competence good only instantiate animal category anyway. i know since java way only messy association .class files that's only proceed is.
interestingly, seems c#.
Comments
Post a Comment