Angular: Keeping it Fat, Dumb, and Happy

Click for: original source

Todd Palmer published this article about an architectural approach to better Angular applications. The article shows you how to keep your Templates declarative and dumb, your Components thin and smart, and your Services fat and happy.

The article will definitively answer your questions of how to structure your Angular application so the code is readable, testable, and maintainable. Specifically, this consistent approach makes our code more readable to others, especially those that are familiar with the approach. The code becomes more testable, because Services are easy to test.

A Template is Dumb when it doesn’t know anything about any other part of the application except for: Its Component and Its sub-component Templates. Services should be Fat and Happy. By Fat, I mean that business logic goes into your Services. When in doubt whether to put code into a Service or a Component, put it in the Service. Fatten up that Service and starve your Component.

The article is split into:

  • Core Principles
  • Templates should be Declarative and Dumb (Declarative, imperative, avoid complicated logic, small and simple)
  • Components should be should be Thin and Smart
  • Services should be Fat and Happy

A smart Component knows and controls exactly what the current state of the Template is. The Component determines exactly how to interact with the data model or Services based on user activity. Good explanation with examples of good and bac practice. All the code examples in the talk and article are in a GitHub repo. You will also get link to video resources. Nice one!

[Read More]

Tags web-development angular nodejs javascript