Skip to content

Commit

Permalink
Update 2024-10-25-vsa.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhiyuan-Amos authored Oct 31, 2024
1 parent ed61c47 commit 428c42f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions _posts/2024-10-25-vsa.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,25 @@ void Foo(bool param1, bool param2, bool param3)
}
```

Modifying this code is also non-trivial because you have to know all the other use cases to be sure you don’t break them (or at least, you have to trust that the engineers before you working on this code have written sufficiently good tests).
Code generally changes over time because of changes in business requirements, so it's important that code is easily modifiable. However, modifying this code is non-trivial because you have to know all the other use cases to be sure you don’t break them (or at least, you have to trust that the engineers before you working on this code have written sufficiently good tests).

### Overbearing Cognitive Load

The above problems make it hard to understand how a complex endpoint works: Apart from having to navigate through many files, it is also hard to reason and trace through the functions called by the endpoint.
The above problems make it hard to understand how a complex endpoint works: Apart from having to navigate through many files, it is also hard to reason and trace through the functions called by the endpoint. This also makes it hard for code reviewers to catch errors.

### Summary

<figure>
<img src="../img/big-ball-of-mud.png" alt="Big Ball Of Mud" />
<figcaption>Unfortunately, the software typically ends up looking like this</figcaption>
</figure>

Wrapping up, the problems stated above aren't problems with Layered / Onion architectures per-se. However, using these architectures typically result in these problems because there's a greater emphasis (and in my opinion, over-emphasis) on these principles DRY (Don't Repeat Yourself) and SRP (Single Responsibility Principle).

Quoting from the book "A Philosophy Of Software Design" section 4.6:

> Unfortunately, the value of deep classes is not widely appreciated today. The conventional wisdom in programming is that classes should be small, not deep... developers are encouraged to minimize the amount of functionality in each new class: if you want more functionality, introduce more classes... result in classes that are individually simple, but it increases the complexity of the overall system. Small classes don't contribute much functionality, so there have to be a lot of them, each with its own interface. These interfaces accumulate to create tremendous complexity at the system level.
>
>
> ...
>
> The most important issue in designing classes and other modules is to make them deep, so that they have simple interfaces for the common use cases, yet still provide significant functionality.
Expand Down Expand Up @@ -102,3 +107,4 @@ VSA is really not a new idea, but an application of the KISS (Keep it Simple Sil
1. [Reddit post](https://www.reddit.com/r/dotnet/comments/lw13r2/choosing_between_using_cleanonion_or_vertical/)
2. [Blog post](https://phauer.com/2020/package-by-feature/)
3. [YouTube video](https://www.youtube.com/watch?v=1PAGtLwOH4Y)

0 comments on commit 428c42f

Please sign in to comment.