User Tools

Site Tools


principles:keep_it_simple_stupid

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
principles:keep_it_simple_stupid [2021-09-02 17:54]
65.21.179.175 old revision restored (2021-09-02 10:43)
principles:keep_it_simple_stupid [2021-10-20 21:09]
christian +++ restored and merged +++
Line 6: Line 6:
   * KISS may also mean "Keep it short and simple", "keep it simple and straightforward", "keep it smart and simple", etc. A large amount of variations exists.   * KISS may also mean "Keep it short and simple", "keep it simple and straightforward", "keep it smart and simple", etc. A large amount of variations exists.
  
-**Remarks**: "Stupid" may be interpreted as an adjective or a noun. Compare the two variants "keep it simple and stupid" vs. "keep it simple, stupid!". Despite all these alternative names the general idea of the KISS principle is always the same.+**Remarks**: "Stupid" may be interpreted as an adjective or a noun. Compare the two variants "keep it simple and stupid" vs. "keep it simple, stupid!". Despite all these alternative namesthe general idea of the KISS principle is always the same.
  
  
Line 15: Line 15:
   * [[contexts:User Interface Design]]   * [[contexts:User Interface Design]]
   * [[contexts:Implementation]]   * [[contexts:Implementation]]
-===== Principle Statement =====l+ 
 +===== Principle Statement =====
  
 A simple solution is better than a complex one, even if the solution looks stupid.  A simple solution is better than a complex one, even if the solution looks stupid. 
Line 24: Line 25:
 The KISS principle is about striving for simplicity. Modern programming languages, frameworks and APIs have powerful means to create sophisticated solutions for various kinds of problems. Sometimes developers might feel tempted to write "clever" solutions that use all these complex features. The KISS principle states that a solution is better when it uses less inheritance, less polymorphism, fewer classes, etc. The KISS principle is about striving for simplicity. Modern programming languages, frameworks and APIs have powerful means to create sophisticated solutions for various kinds of problems. Sometimes developers might feel tempted to write "clever" solutions that use all these complex features. The KISS principle states that a solution is better when it uses less inheritance, less polymorphism, fewer classes, etc.
  
-A solution that follows the KISS principle might look boring or even "stupid" but simple and understandable. The KISS principle states that there is no value in a solution being "clever" but in one being easily understandable.+A solution that follows the KISS principle might look boring or even "stupid" but simple and understandable. The KISS principle states that there is no value in a solution being "clever" but being easily understandable
 + 
 +This does not mean that features like inheritance and polymorphism should not be used at all. Rather they should only be used when they are necessary or there is some substantial advantage.
  
-This does not mean that features like inheritance and polymorphism should not be used at all. Rather they should only be used when they are necessary or there is some substantial advantage 
 ===== Rationale ===== ===== Rationale =====
  
-A simpler solution is better than a complex one because simple solutions are easier to maintain. This includes increased readability, understandability, and changeability. Furthermore writing simple code is less error prone.+A simpler solution is better than a complex one because simple solutions are easier to maintain. This includes increased readability, understandability, and changeability. Furthermorewriting simple code is less error-prone.
  
-The advantage of simplicity is even bigger when the person who maintains the software is not the one who once wrote it. The maintainer might also be less familiar with sophisticated programming language features. So simple and stupid programs are easier to maintain because the maintainer needs less time to understand them and is less likely to introduce further defects.+The advantage of simplicity is even more significant when the person who maintains the software is not the one who once wrote it. The maintainer might also be less familiar with sophisticated programming language features. So simple and stupid programs are easier to maintain because the maintainer needs less time to understand them and is less likely to introduce further defects.
  
-One reason to create more complex code is to make it more flexible to accommodate further requirements. But one cannot know in what way to make it flexible or if that flexibility will be ever needed.+One reason to create more complex code is to make it more flexible to accommodate further requirements. But one cannot know how to make it flexible or if that flexibility will be ever needed.
  
-"When you make your code more flexible or sophisticated than it needs to be, you over-engineer it. Some do this because they believe they know their systems future requirements. They reason that its best to make a design more flexible or sophisticated today, so it can accommodate the needs of tomorrow. That sounds reasonable, if you happen to be a psychic." - Refactoring To Patterns - Joshua Kerievsky.+"When you make your code more flexible or sophisticated than it needs to be, you over-engineer it. Some do this because they believe they know their system's future requirements. The reason that it's best to make a design more flexible or sophisticated today is to accommodate the needs of tomorrow. That sounds reasonable, if you happen to be a psychic." - Refactoring To Patterns - Joshua Kerievsky.
  
-Another reason to create more complex code is to make optimizations. An optimized code is a more complex code. Pareto principle applies also in code: a program spend most of the time in a small portion of the code, so it will be wise to concentrate the effort to optimize only that part of the code. Another best practice is to follow the +Another reason to create more complex code is to make optimizations. An optimized code is a more complex code. Pareto principle applies also in code: a program spends most of the time in a small portion of the code, so it will be wise to concentrate the effort to optimize only that part of the code. Another best practice is to follow the 
 "Three rules of optimization": (1. Don't, 2. Don't... Yet, 3. Profile before optimizing), which make sense: to optimize only the code with performance problems. (First author: Michael A. Jackson) "Three rules of optimization": (1. Don't, 2. Don't... Yet, 3. Profile before optimizing), which make sense: to optimize only the code with performance problems. (First author: Michael A. Jackson)
  
Line 43: Line 45:
 ===== Strategies ===== ===== Strategies =====
  
-This is a very general principle so there is a large variety of possible strategies to adhere more to this principle largely depending on the given design problem:+This is a very general principleso there is a large variety of possible strategies to adhere more to this principle largely depending on the given design problem:
  
   * Avoid inheritance, polymorphism, dynamic binding and other complicated OOP concepts. Use delegation and simple if-constructs instead.   * Avoid inheritance, polymorphism, dynamic binding and other complicated OOP concepts. Use delegation and simple if-constructs instead.
-  * Avoid low-level optimization of algorithms especially when involving Assembler, bit-operations, and pointers. Slower implementations will work just fine.+  * Avoid low-level optimization of algorithmsespecially when involving Assembler, bit-operations, and pointers. Slower implementations will work just fine.
   * Use simple brute-force solutions instead of complicated algorithms. Slower algorithms will work in the first place.   * Use simple brute-force solutions instead of complicated algorithms. Slower algorithms will work in the first place.
   * Avoid numerous classes and methods as well as large code blocks (see [[More Is More Complex]])   * Avoid numerous classes and methods as well as large code blocks (see [[More Is More Complex]])
Line 86: Line 88:
 Hypothesis 1 is true by definition. If the solution cannot be implemented quickly, it is not simple.  Hypothesis 1 is true by definition. If the solution cannot be implemented quickly, it is not simple. 
  
-Though hypotheses 2 and 3 are not true by definition but they can be regarded intuitively clear. Nevertheless there is some research. In ((Virginia R. Gibson and James A. Senn: //[[http://dl.acm.org/citation.cfm?id=62073|System Structure and Software Maintenance Performance]]//)) a system was improved in two steps resulting in three variants of the same system. Several metrics show that the improvements reduced complexity. 36 programmers with varying experience conducted three different maintenance tasks and their performance was measured. The results indicate that the improvements also improved maintainability. Several other studies support the correlation between complexity and maintainability((Chris F. Kemerer: //[[http://link.springer.com/article/10.1007%2FBF02249043?LI=true|Software complexity and software maintenance: A survey of empirical research]]//)).+Though hypotheses 2 and 3 are not true by definition but they can be regarded intuitively clear. Neverthelessthere is some research. In ((Virginia R. Gibson and James A. Senn: //[[http://dl.acm.org/citation.cfm?id=62073|System Structure and Software Maintenance Performance]]//)) a system was improved in two steps resulting in three variants of the same system. Several metrics show that the improvements reduced complexity. 36 programmers with varying experience conducted three different maintenance tasks and their performance was measured. The results indicate that the improvements also improved maintainability. Several other studies support the correlation between complexity and maintainability((Chris F. Kemerer: //[[http://link.springer.com/article/10.1007%2FBF02249043?LI=true|Software complexity and software maintenance: A survey of empirical research]]//)).
  
-Furthermore software cost estimation techniques are partly based on complexity judgments((Barry W. Boehm: //Software Engineering Economics//, IEEE)). So complexity---although this normally relates the complexity of the problem and not to the complexity of the solution---is a known cost factor which may be accounted to maintenance.+Furthermoresoftware cost estimation techniques are partly based on complexity judgments((Barry W. Boehm: //Software Engineering Economics//, IEEE)). So complexity---although this normally relates the complexity of the problem and not to the complexity of the solution---is a known cost factor which may be accounted to maintenance.
  
-Lastly hypothesis 4 is likely to be false. Several studies relating complexity metrics and post-release reliability show that module size in lines of code predicts reliability at least as good as the McCabe metric (also called cyclomatic complexity) ((see Albert Endres, Dieter Rombach: //A Handbook of Software and Systems Engineering//, p. 168ff.)). Assuming cyclomatic complexity correctly depicts the complexity of a module, reliability should not the reason for applying KISS.+Lastlyhypothesis 4 is likely to be false. Several studies relating complexity metrics and post-release reliability show that module size in lines of code predicts reliability at least as good as the McCabe metric (also called cyclomatic complexity) ((see Albert Endres, Dieter Rombach: //A Handbook of Software and Systems Engineering//, p. 168ff.)). Assuming cyclomatic complexity correctly depicts the complexity of a module, reliability should not the reason for applying KISS.
  
  
Line 108: Line 110:
 Note that many principles are contrary to KISS. This means that it is worthwhile to consider KISS when considering one of those. Nevertheless this does not mean that this is true the other way around. When considering KISS, one wouldn't want to consider all principles that have complexity as a disadvantage. So here are those needing consideration: Note that many principles are contrary to KISS. This means that it is worthwhile to consider KISS when considering one of those. Nevertheless this does not mean that this is true the other way around. When considering KISS, one wouldn't want to consider all principles that have complexity as a disadvantage. So here are those needing consideration:
  
-  * **[[Generalization Principle]] (GP)**: This is the directly converse principle. A solution that is generally applicable typically is not simple anymore.+  * **[[Generalization Principle]] (GP)**: This is the directly converse principle. A generally applicable solution typically is not simple anymore.
   * **[[Murphy's Law]] (ML)**: The ultimate reason behind KISS is to increase maintainability and reduce the introduction of defects. But following KISS blindly by always using the simplest solution may also lead to //reduced// maintainability when Murphy's Law is not considered.   * **[[Murphy's Law]] (ML)**: The ultimate reason behind KISS is to increase maintainability and reduce the introduction of defects. But following KISS blindly by always using the simplest solution may also lead to //reduced// maintainability when Murphy's Law is not considered.
-  * [[Model Principle]] (MP): There are often simpler ways to build a software system than to model and mirror the real world behavior, which frequently means having more objects and more complicated structures. Nevertheless it is advisable to do so anyway.+  * [[Model Principle]] (MP): There are often simpler ways to build a software system than to model and mirror the real-world behavior, which frequently means having more objects and more complicated structures. Neverthelessit is advisable to do so anyway.
  
 ==== Complementary Principles ==== ==== Complementary Principles ====
principles/keep_it_simple_stupid.txt · Last modified: 2021-10-20 21:09 by christian