Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

José Eduardo Eguiguren
José Eduardo Eguiguren
17,555 Points

How to define the Package Structure and where to put things - Spring MVC

Let's say I'm developing a web application using Spring MVC using a layered architecure. Also using a package by layer structure. After taking the spring courses I've come to expect to have the classes that access my DAO objects as Service classes. That being said here are my questions:

1. Where should I place my business logic

I've read that my business logic classes should go on my service package, but I think it would start to get confusing the more classes I start adding to the package, what are some good ways to classify my classes within a package layer.

2. How much logic should go on my controller classes

Controllers are supposed to just handle requests coming to the server right? but sometimes I get hesitant as to how much logic should be included in a request mapper. If there is a complex business logic behaviour should I use a service to implement it and call it from the controller?

1 Answer