KYDronePilot
KYDronePilot

Reputation: 555

Reasons for a "Simple and Stupid" software design

I am currently studying for a software engineering test. One of the study points is to know why we should use a "Simple and Stupid" design principle.

I know this is helpful when reading through someone else's code, but are there any other important reasons for following this principle?

Upvotes: 0

Views: 125

Answers (1)

John Deters
John Deters

Reputation: 4391

All design principles work by influencing the designer to maximize desirable properties and minimize undesirable properties of the system being designed. In the case of software engineering, those include maximizing cohesion, minimizing coupling, and minimizing complexity.

Cohesion is the property that says related ideas belong together. If you have a point made up of Cartesian coordinates X, Y, and Z, it is desirable to put all three values into the same set or object. If you have points defined by Polar coordinates, they belong together as well - but maybe not in the same object as the Cartesian coordinates.

Coupling is the property by which unrelated things depend on each other. A line depends on two points, but it shouldn’t depend on colors or owners or anything else. Note that if you define a line with two points, it is still a line regardless of if those points were defined as Cartesian or Polar; or with one, two, three, or even more axes. Loose coupling ensures that lines are unchanged regardless of how you specify the individual points.

Complexity is a property of code that measures how many decisions it contains. The higher the complexity, the harder it is to test; the harder it is to test, the higher the chances it will contain a bug. Smaller modules have fewer decision paths to test.

“Simple and Stupid” is a way to think about these properties that drives desirable designs. Simple means “high cohesion” - don’t keep adding stuff to an object just because it might be related - make sure they actually belong together. Stupid means “low complexity” - don’t try to be clever and pack all your logic in a single function. Break your problem down into smaller methods, and describe it in testable details.

You will likely end up with higher quality code if you follow those principles. Readability (as you mentioned above) is only one aspect of quality (but an important one); proper functioning is another; as is testability.

Upvotes: 1

Related Questions