vendredi 18 septembre 2015

Application start up code design

We have a class and method for application start up. Initially it had very less code.

Over the course of time this method was highly abused and everyone started putting their requirements/domain specific requirement into the method. Lot of code and delegated methods which would execute were added to this method.

I think this method method must only execute application start up lifecycle code any common code which is required by the application like (creation of db, starting of logging etc. ) not any domain/requirement specific code .

Couple of ways i can think of is:

Observer pattern/event based/OSGI extension point like model: Application startup event is fired by this application method. All domain specific listeners must execute their code. But here the ordering and dependencies between the listeners code is important.

Delegated methods to domain specific code Again this one would increase lot of direct calling of domain specific code sequentially (maintains the order) from the startup code (which is kind of happening in my code )

Would like to know if there is any other way i can solve this design problem ?

cheers,

Saurav

Aucun commentaire:

Enregistrer un commentaire