A web application is often designed to be layered. Typically there would be a Repository (Dao) layer, a Service layer and a Control (web handling) layer. The Control layer uses the Service layer which in turn uses the Repository layer. Often you'll see the Control layer using the Repository layer directly.
Also quite prevalent is Services using other Services. Quite often all Services inherit from a base service class which will contain all references to all Repository components.
So my question is really how and why do you design your serverside application (in terms of layers) and what rules do you apply to them?
What are the generally accepted justifications for these layers and these rules?
What rules do you see that should be considered 'bad practice'?
What rules do you considered essential?
Have you tried anything new in this area that worked?
Best Answer
Warning long, rambling answer follows and I'm not really using 1/2 of the formal terminology that I should be (but that's OK, because someone will correct me!):
No Golden Bullet
I'll start by saying that I think each software architecture should be designed for the problem at hand. There is no golden bullet, silver hammer or one solution that fits all cases.
Overall strategy
Is to:
Why are there patterns?
Design patterns (and therefore frameworks around them) emerge because they solve certain common problems.
However, a mistake that I think many Java developers are guilty of is to over engineer architectures, applying patterns left right and centre. They think about all sorts of exotic "What If?" scenarios. My advice is that although there are common patterns out there, don't just blindly apply them, make sure you've got solid reasoning for doing so.
Examples
1.) People have used MVC for years because it gives you flexibility to change either the model, view or controller without impacting each other (unless you want them to). So for example if I want to:
2.) One of the reasons why Services have become popular because of the rise of multiple clients. So for example if I want to have a Java Swing client and a JSP client that both list the big Dogs in the system they can both call the same
DogShelterService
methodList<Dog> getBigDogs();
Conclusion
There are lots more examples of patterns and why they came about (I suspect someone will give better examples than I did). I find using a BDD, TDD/ATDD approach (at least in terms of your thinking) helps clarify the design and where you might want to go for a formal design patterns and where simple code will do just nicely.