Timeline for Newbie: OOP working with different class-datatypes and loop through them
Current License: CC BY-SA 4.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 1, 2023 at 23:27 | vote | accept | SturmGhost | ||
Mar 9, 2023 at 0:30 | comment | added | Flater | @SturmGhost: When you want to reuse something (property, method) across multiple classes in a way that you can iterate over all of its usages, you need to declare it in a reusable component (abstract class, interface) and then have your classes implement the component. If you can then guarantee that your objects polymorphically adhere to this component, the compiler is satisfied that it will reliably be able to access the thing (method, property) that you wanted to reusably access. | |
Mar 8, 2023 at 22:44 | comment | added | candied_orange | Funny you should mention the word strategy. | |
Mar 8, 2023 at 22:33 | comment | added | SturmGhost |
Thank you. If I have variables that each class will need. I would make a base class/abstract class which declares this variables, like name and which will be inherited by the three object classes? Specific variables which only occurs in some of those three objects would be implemented with an interface or what's the strategy here?
|
|
Mar 8, 2023 at 22:32 | history | edited | candied_orange | CC BY-SA 4.0 |
added 11 characters in body
|
S Mar 8, 2023 at 13:43 | history | suggested | CommunityBot | CC BY-SA 4.0 |
improved spelling
|
Mar 8, 2023 at 8:52 | review | Suggested edits | |||
S Mar 8, 2023 at 13:43 | |||||
Mar 7, 2023 at 22:49 | history | edited | candied_orange | CC BY-SA 4.0 |
deleted 1 character in body
|
Mar 7, 2023 at 22:44 | history | answered | candied_orange | CC BY-SA 4.0 |