Composition vs. Inheritance [duplicate]
This question already has answers here: Designing a library that is easy to use: composition or inheritance (2 answers) Closed 11 years ago. Here’s what is given: public interface Request {} // there are 20 subclasses of Request public class CreateUserRequest implements Request { @NotEmpty public String userName; } // request processor is a thing […]
When Rob Pike says “Go is about composition”, what exactly does he mean? [closed]
Closed 10 years ago.
Inheritance using non-abstract base class
This post is based on the question https://stackoverflow.com/questions/49002/prefer-composition-over-inheritance/11758048#comment15634305_11758048.
How do inheritance and composition differ?
I’m wondering about the differences between inheritance and composition examined with concrete code relevant arguments.
Is this an example of a composition or aggregation? [duplicate]
This question already has answers here: Aggregation vs Composition (9 answers) Closed 7 years ago. Composition and aggregation both are confusion to me. Does my code sample below indicate composition or aggregation? class A { public static function getData($id) { //something } public static function checkUrl($url) { // something } class B { public function […]
Looking for a real-world example illustrating that composition can be superior to inheritance [closed]
Closed 9 years ago.
How do I avoid writing lots of pass-through functions in a wrapper?
I have a class, which wraps another class of a common base type. Because the base type interface is quite large this involves writing a lot of pass-through functions. I am looking for a way to avoid this.
What is the correct way of implementing state machine design pattern via composition?
I am trying to implement a VendingMachine
which has multiple states (Idle, ProductSelected, ReceivedMoney, ProductDispatched
). Each state implements method in VendingMachineState
(for simplicity consider just collectMoney(int amount)
). Methods like collectMoney()
do their job and then change the state to the next state as per the state machine.
Can you help me with this question? I’m wrote this code using AI and it’s not working. The errors it’s giving me are not giving me ideas of the issue
So the issue with my code is that I cannot figure out what is causing the issue here. The errors it gives me at runtime doesn’t make any sense to me and the internet isn’t helping either. Can any of you have a look and figure out what the exact issue is?
If an entity is composed, is it still a god object?
I am working on a system to configure hardware. Unfortunately, there is tons of variety in the hardware, which means there’s a wide variety of capabilities and configurations depending on what specific hardware the software connects to.