Seperating concerns, reuse and maintainability are among the most essential principles in software engineering. These principles can be seen everywhere through the frameworks we use at work, such as MVC pattern and IOC. CSS is probably the everybody-know separation example.
When we decouple a monolithic problem space, we get better understand the domain of the given problem, what is the boundary and how the system communicate with outside world. As well, we get better understand what is the responsibility of each part that comprises the whole system.
CSS allows common style elments separted from html files and defined in an external file that can be "souced in" by several pages. When it comes to any change, we only need to change one file, rather than in each page individually. This reduces possible errors, inconsistencies and saves efforts. This is the essence of reuse.
CSS also comes with inheritance feature, we can reduce duplication by sharing style classes. We can also "source in" css with a css with @import as seen in W3C CSS2 Spec.
Another example is Struts Tiles. It is something similar to Master Page in ASP.Net. It provides a framework to support separation of JSP pages into "tiles" which are then used to assembly pages in a shared manner. A page can include certain number of tiles and a tile can be used in multiple pages. Even better, all these assembly information blueprint is defined in an xml configuration file - declarative decoupling.
No comments:
Post a Comment