As I have been learning about software development the last 2 years the more I learn, it seems the more gray areas I am running into. One gray area I have issues with right now is trying to decide how many layers an application should have. For example, in a WPF MVVM application what fashion of layering is ok? Is the following too separated? When I mention layering I mean creating a new class library for each layer.
Or for a non MVVM application is this too separated?
Is acceptable to run layers together and just create folders for each layer? Any coloring of this gray area would be appreciated.
If you're wearing so many layers that you lose some flexibility or range of motion, it could seriously hinder you if you're doing any technical climbing.
There is no set amount of layers you should have in one song, it really depends on the needs of the song you're working on. If you are struggling to get a clean mix, don't be afraid to get rid of layers! When I'm mixing, I like to take my layered tracks and mute all but one layer.
Six layers will give you a solid, efficient home This is the standard in terms of building a wall system more efficiently and we have gotten it down to a science. Generally a six layer home will give you a solid, energy efficient, comfortable home.
A general architectural design of a layered web application consists of three layers: A presentation layer, a business layer, and a data layer.
The answer is, it depends. First off, a separate class library doesn't always mean a separate "layer." A layer is a conceptual grouping of related functionality, that may or may not manifest itself in a single assembly.
How many layers you create is really dependent on your problem at hand. Traditionally, a WPF MVVM application will contain at least the 3 layers (Model, View, View Model) but it can really be varied. Often times I see the Views and ViewModels in the same assembly and the models in their own assembly (usually because the Model objects are POCO's that are used in other contexts)
There is really no silver bullet that answers your question, it is entirely dependent on your problem. The advantage of "layering" and separation is to increase maintainability, promote code re-use, and increase overall clarity (to name a few).
I would argue that if you are not reaching these goals with your current layering solution then you have room to improve. If increasing the layers is decreasing the clarity or maintainability then you have gone too far. If you have only a single "layer" and it is becoming bloated then you have an opportunity to add a layer.
The bottom line is don't over engineer something for the sake of following a strict "pattern." If the pattern has clear advantages to you and your problem at hand then implement it, but understand why you are doing so and what the goal of each "layer" is.
Consider the following areas:
...then adjust your architecture based on which of these you value. I'm probably missing some other important parts, but you get the idea. There's really no right or wrong answer to this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With