- easier to write
- easier to maintain
- easier to test
- easier to reuse
When we separate concerns we create distinct layers in our architecture.
Each of these layers expose an interface (API) through which the layers can communicate with each other.
An interface that many of us have experience with is a T.V. control. A T.V. control is an interface that we can use to interact with a T.V.
Layered architecture gives us a place for all of our code taking away some of the organizational cognitive load.
It makes writing code easier because each piece of code has limited responsibility. As a developer we only need to keep this limited responsibility in mind while developing.
Let's start trying to find layers in the systems that we build and clearly define these layers in the code that we write.
Models manage our data. They are responsible for the shape of our data and retrieving that data from a data store.
The model will then expose an interface to the rest of the application. Any other file doesn't need to concern itself with how the data is managed.
Controllers take incoming input and forward the information to the appropriate model or service
Services contain our domain logic. They contain the code that makes our application unique.
Services are not responsible for talking to the database, and they are not responsible for handling incoming input. They are responsible for solving real problems
Utility functions to make life easier.