Changes for page Code Example: Data Structure Style vs. Object Style
Last modified by chrisby on 2024/03/03 17:01
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -1,3 +1,10 @@ 1 +### Use Cases 2 + 3 +This example is intended to demonstrate the extensibility differences between data structures and objects by extending them with 4 + 5 +1. an Area() function (extending behavior) 6 +1. a rectangle type (extending data type) 7 + 1 1 ### Data Structure Style 2 2 3 3 type Square struct { ... ... @@ -16,8 +16,10 @@ 16 16 return 2 * PI * g.radius 17 17 } 18 18 19 - *26 +1. 20 20 28 +#### 29 + 21 21 #### Object-Oriented Style 22 22 23 23 interface GeometricObject {