Wednesday, January 4, 2012

Architectural Design

I was asked recently “how do you go about designing an application”? Let’s assume we know the problem domain and what the application needs to do. The next step is how we go about solving the problem.
Traditionally you have stacked “layers”
traditional ntier
The problem here is that you must assume one builds on top of the other and that all functionality must fall into a specific layer. You typically end up with Façade classes ending up as God classes. Anything that could ever be done to a user goes in the UserFacade class. Orders => OrderFacade… you get the idea. I find this happens because it lines up nice with the picture of n-tier you are imagining in your head.
Instead I like to think in vertical slices where each feature is a slice. Think of a slice as a specific context in which the user accesses the system. Search is a very common feature, so is placing an order. These features will most likely consist of components touching all the “layers” of n-tier, but they are only used in one specific context. (sorry can’t find an image to demonstrate what I’m writing.)
How does this impact the code. When designing by the slice you end up with many small context specific objects all designed to do one specific task. So you have many objects, but each object is only responsible for a small, one, aspect of the system. reading code becomes so much easier and managing the code becomes easier as well because you can keep all the components next to each other.

No comments:

Post a Comment