Timeline for JavaScript: Parking lot simplified OOD
Current License: CC BY-SA 4.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 3, 2021 at 19:01 | vote | accept | Joji | ||
Jan 27, 2021 at 7:00 | comment | added | Scotty Jamison | Composition can still be done with es6 classes - you can find plenty of examples online of this pattern. As I think about it some more, I might have been wrong to use that phrase in this scenario - you were mostly using inheritance to enforce a common interface and self-document a relationship, not to share behavior, meaning there was no behavior to compose, so normal composition solutions would not help there. I can't think of a good (and normal) way to remove this kind of inheritance with es6 classes, but it can be done with factory functions. | |
Jan 27, 2021 at 6:04 | history | bounty ended | CommunityBot | ||
Jan 26, 2021 at 19:33 | comment | added | Joji | Hi thank you for the answer! I am curious about "Composition vs Inheritance". I have some knowledge of it but I wonder what benefits you think a factory function brings that a class doesn't? Or in other words, what are some pros and cons for choosing factory functions over class? | |
Jan 22, 2021 at 3:45 | comment | added | Scotty Jamison | @konijn - Thanks, I've updated my answer to include the hasVehicle() function. | |
Jan 22, 2021 at 3:45 | history | edited | Scotty Jamison | CC BY-SA 4.0 |
Edit in response to comment about missing feature
|
Jan 21, 2021 at 11:04 | comment | added | konijn | NIce answer. You did drop the feature of checking whether a car is already checked in. | |
Jan 21, 2021 at 4:00 | history | answered | Scotty Jamison | CC BY-SA 4.0 |