tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,924
- Office Version
- 365
- 2019
- Platform
- Windows
I have a conundrum I hope someone can help me.
One of the merits of object oriented and classes is reusability.
From my understanding about OO, data and actions "gets packaged" into its own object.
Let's say every object in my program contains 1 property and 1 method.
Now object1 has data1 and method1.
But what if object2 has data2 but it uses its method in the same way as method1? Does that mean method1 needs to be copied and relabelled as method2, then "packaged" into object2?
If so, that defeats the whole purpose of not having to duplicate code.
On the other hand, if object2 can somehow use method1 (either directly or indirectly), that contradicts the "each object is self-contained" principle.
Thanks
One of the merits of object oriented and classes is reusability.
From my understanding about OO, data and actions "gets packaged" into its own object.
Let's say every object in my program contains 1 property and 1 method.
Now object1 has data1 and method1.
But what if object2 has data2 but it uses its method in the same way as method1? Does that mean method1 needs to be copied and relabelled as method2, then "packaged" into object2?
If so, that defeats the whole purpose of not having to duplicate code.
On the other hand, if object2 can somehow use method1 (either directly or indirectly), that contradicts the "each object is self-contained" principle.
Thanks