1
I’m starting to develop with java (Jsp). And I would like to know the correct structure of working (only with java "pure").
Would that be:
model (Classes with get and set) dao (classes that extend the connection class) (for each class of the model package I have a DAO that accesses the database)
need to have another package to have the business rules? or should I implement in the model?
Hi @Teuassuri, how are you? It is a little difficult to answer such a broad question of architecture because there is more than "a correct way" to draw the layers of an application in java, it all depends on your project. On one side we have Martin Fowler talking about the dangers of anemic models, on the other, years and years of "procedural" culture and service layer design (whether in EJB projects, Spring projects, etc). I don’t know if this helps, but what I can say is, get information on rich domain and business layers, use what’s best for your project (which can be both ;).
– Anthony Accioly
Another relevant comment... If you’re going to work with "pure" web java (whatever that is), don’t forget the
Servlets
. They play an important role: to interact with the business model and/or layer, to control navigation, etc jsps may be limited to the layer of view. Avoid scriptlets and things like that; leave your layer of view clean; the Servlets "Frontals" should take care of all this and do forward for the jsps, the latter must be "donkeys" (show only results).– Anthony Accioly