Kategori: Clean Code

  • The Common Reuse Principle

    What? The Common Reuse Principle (CRP) states: ”The classes in a component are reused together. If you reuse one of the classes in a component, you reuse them all.” In the last post I wrote about the Reuse/Release Equivalence Principle (REP). It says that reusable components must be releasable components, with everything that comes with […]

  • The Reuse/Release Equivalence Principle

    What? When we group classes into components we strive towards making some of them reusable so that we can potentially use them for other purposes and also other teams in the organization may use them if they want to. The Reuse/Release Equivalence Principle (REP) states that ”The granule of reuse is the granule of release”. […]

  • Principles of Package and Component Design

    One of the most known set of principles regarding software design is probably SOLID. But an important part of structuring software that SOLID does not cover is how to group classes into packages and components in a way that makes it scale, both when the application itself grows but also when the number of teams […]

  • SOLID – The Dependency-Inversion Principle

    We have now reached the grande finale of the blog series on SOLID, the big D, The Dependency-Inversion Principle. Let’s jump right into it. Definition The Dependency Inversion Principle (DIP) states: A: High-level modules should not depend on low-level modules. Both should depend on abstractions. B: Abstractions should not depend upon details. Details should depend […]

  • SOLID – The Interface Segregation Principle

    We are closing in on the final principle of SOLID. In the last post I wrote about the Liskov Substitution Principle, and now it is time to take a look at The Interface Segregation Principle (ISP). Definition The Interface Segregation Principle was coined by Robert C. Martin. It is explained in his book ”Agile Software […]

  • SOLID – The Liskov Substitution Principle

    In the previous post I wrote about the O in SOLID, The Open/Closed Principle. Now it is time for the L, The Liskov Substitution Principle (LSP). Definition In the year 1988, the American Computer Scientist Barbara Liskov, wrote What is wanted here is something like the following substitution property: If for each object o1 of […]

  • SOLID – The Open/Closed Principle

    In this third post on the SOLID principles we will look at the Open/Closed Principle (OCP). Definition Bertrand Mayer coined the Open/Closed Principle in 1988, and it states that ”A software entity (class, module, function) should be open for extension but closed for modification”. A software entity complies to OCP if its behavior can be […]

  • SOLID – The Single-Responsibility Principle

    You are now reading the second part of my blog series on the SOLID principles. In the first post I introduced the concept and gave some reasons to why you should learn about SOLID. In this part I will write about the first of the five SOLID principles, the Single-Responsibility Principle (SRP). Definition The Single-Responsibility […]

  • SOLID – Introduction

    If you have been working with object oriented programming (OOP) for some time you have probably heard of the SOLID principles. There is a lot of information available online on SOLID, of various quality. In this blog series, where you are currently reading the first part, I will cover the principles in detail and explain […]

  • Cleaner Code with Command Query Separation

    What is Command Query Separation? The Command Query Separation (CQS) concept is a way to structure your code and methods. The idea is that a method may either be a Command or a Query but not both. It was coined by Bertram Meyer in his book ”Object Oriented Software Construction” from 1994. What identifies a […]