Last modified by chrisby on 2024/03/03 17:01

From version 3.7
edited by chrisby
on 2024/03/03 15:23
Change comment: There is no comment for this version
To version 3.11
edited by chrisby
on 2024/03/03 17:01
Change comment: Update document after refactoring.

Summary

Details

Page properties
Parent
... ... @@ -1,1 +1,1 @@
1 -Main.WebHome
1 +Software Engineering.Clean Code.Objects and Data Structures.WebHome
Content
... ... @@ -60,11 +60,10 @@
60 60   }
61 61   }
62 62  
63 -1. Adding a function Area() to GeometricObject Interface is hard since all classes implementing
64 -1. Adding a new datatype, Rectangle, is more difficult because it requires touching existing code, namely any functions like Circumference() or Area() that need to be enabled handle this datatype.
63 +1. Adding a function Area() to the GeometricObject interface is hard because it requires touching existing code, namely extending all Square and Circle classes with the new function.
64 +1. Adding a new datatype, Rectangle, is easy because only new code is added, namely a Rectangle class.
65 65  
66 66  ### Conclusion
67 67  
68 -asd
69 -
70 -
68 +* The lesson here is that data structures are easy to extend with functions and hard to extend with data type, and objects are easy to extend with other objects but hard to extend with functionality.
69 +* Although the difference between the two styles may seem insignificant in this simplified example, it has serious implications in complex production codebases with multiple data types and behaviors.