24 07 2008
Some points about services layer
Some time ago I introduced here book titled as "Domain Driven Design". One concept this book described was Services Layer. Okay, there were some other layers too but I want to stop at services layer this time 🙂
In one of our projects we created services layer for different tasks taht can be handled as services – searching, user registering and some other types of registration tasks. At first it seems like the additional layer has no deeper point and it will be something that adds additional overhead to system (testing, documenting, deploying). But when the project was lasted some time it was clear to me that services layer was correct decision.
- Defining separate layer for services keeps repositories clean. I believe that repositories are not the place where complex operations should be performed. Services layer can be also separate library and if all communication goes through repositories then services layer should only know repositories interfaces to manipulate data.
- One thing that is maybe hard to notice in projects where one client application is written is services functionality behind pages and user controls. It is not hard to forget yourself writing and not to notice that current functionality may be useful also in multiple applications situation. When all service related code is moved to services library then forms and user controls will be clearer and deal only with functionality they have to – move data between user and server.
These were two cool points I wanted to introduce this time about using services layer. Of course, there will also other benefits and if some of them is cool I will introduce it here.