Single responsibility principle

Simply put, a module or class should have the following characteristics only:

  • It should do one single thing and only have a single reason to change
  • It should do its one single thing well
  • The functionality provided needs to be entirely encapsulated by that class or module

What is meant when saying that a module must be responsible for a single thing? The Google definition of a module is:

"Each of a set of standardized parts or independent units that can be used to construct a more complex structure, such as an item of furniture or a building."

From this, we can understand that a module is a simple building block. It can be used or reused to create something bigger and more complex when used with other modules. ...

Get C# 7 and .NET Core 2.0 Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.