Design – Layered architectures and modular software

designlayers

I have built a server-side Java application of about 10k lines of code and on a code review a colleague made me notice that when developing a new business feature , I have to touch several files. My explanation is the following:

  1. In a well-layered architecture, delivering an additional business functionality might require small changes/additions to all the layers. For example in a classical three layer application which has a REST API/business logic/ data access layer, adding a new feature might require to touch these three layers.

  2. When developing a new feature you will easily get presented with the chance of refactoring existing code in order to keep the code in good quality(cyclomatic complexity, dependency tree length, etc) and DRY. Given that I have a test coverage between 70% and 80% I do that aggressively.

  3. Due to the small changes of point 2, I might have to slightly touch the tests for those features

  4. Because I touch N layers, I will have to update each unit test for each layer + at least one integration test

A different approach would obviously be to develop a more "componentized" application, where each business functionality is achieved through an independent module. Am I right in considering a layered architecture better, at least in containing the total cost of ownership and development of the application?

Best Answer

A different approach would obviously be to develop a more "componentized" application, where each business functionality is achieved through an independent module. Am I right in considering a layered architecture better, at least in containing the total cost of ownership and development of the application?

If your "independent modules" or vertical slices each have their layers (i.e. for data, business, gui) you get the benefit of independence without loosing the advantages of a layered architekture.

In an online shop you may have slices for customer, product, product-availability, pricecalculation, orderprocess, payment, permissions, ....

However it might be difficuilt to make the slices independant of each other: Example: the pricecalculation needs infos about customer, product, product-availability

Related Topic