User Tools

Site Tools


principles:single_level_of_abstraction

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
principles:single_level_of_abstraction [2020-10-12 12:36] – old revision restored (2014-07-02 21:07) 159.69.186.191principles:single_level_of_abstraction [2020-10-12 14:25] – old revision restored (2014-07-01 11:12) 159.69.186.191
Line 36: Line 36:
  
 ===== Caveats ===== ===== Caveats =====
-See section [[#contrary principles]].+An exception where it may be helpful not to adhere to the principle are certain algorithms. When implementing for instance a sorting algorithm, keeping the algorithm together can be considered more readable than splitting it up into several small functions. This is because certain algorithms are well known and splitting them up may disguise them. A suitable compromise has to be found in such a case. 
 + 
 +See section [[#contrary principles]] for further aspects.
  
  
Line 115: Line 117:
 Now there are two smaller methods each of which is written in terms of a single level of abstraction. This is better readable as no mental grouping is necessary. Furthermore the two methods are still separately understandable ([[Principle of Separate Understandability|PSU]]) so no mental inlining is necessary and if you don't care about the details of the ''toDto'' method, you can just read and understand ''buildResult'' without being distracted by unnecessary detail. Now there are two smaller methods each of which is written in terms of a single level of abstraction. This is better readable as no mental grouping is necessary. Furthermore the two methods are still separately understandable ([[Principle of Separate Understandability|PSU]]) so no mental inlining is necessary and if you don't care about the details of the ''toDto'' method, you can just read and understand ''buildResult'' without being distracted by unnecessary detail.
  
-==== Example2: Comment Plus Code Block ====+==== Example2: Commented Code Blocks ====
  
-==== Example3: Parameter Checking ====+==== Example3: Algorithms ====
  
-==== Example4: Extracting Classes ==== 
  
 ===== Description Status ===== ===== Description Status =====
principles/single_level_of_abstraction.txt · Last modified: 2021-10-18 22:03 by christian