Questions tagged [composition]

Composition is the process of combining, or composing, parts of a program into a larger program.

1737 questions
0
votes
1 answer

Would Statement st=con.CreateStatement() be an example of composition?

Would this be considered composition? Statement st=con.CreateStatement(); I believe this is correct. The con.CreateStatement() I think is an example of Factory methods which returns an object. I guess this would be somewhat similar to a…
Rubiks
  • 461
  • 1
  • 6
  • 21
0
votes
1 answer

Is my approach to composability idiomatic for Go?

I created this in the playground: https://play.golang.org/p/Jj4UhA8Yn7 I'll paste the code below as well. The question revolves around whether my approach on composability is something I should consider as viable, good Go code, or if I'm thinking…
Jerry Saravia
  • 3,737
  • 3
  • 24
  • 39
0
votes
1 answer

Classes Relationships with JPA

I have a set of Java classes with the following UML diagram: public class Invoice { @Id private long id; ... } public class InvoiceDetail { @Id private long id; ... private…
julianfperez
  • 1,726
  • 5
  • 38
  • 69
0
votes
3 answers

Design Pattern: Inheritance or Composition

I have 2 classes A and B, both of which have properties X and Y; but class B also has another property, Z. Classes A and B are completely unrelated to one another, they just share properties X and Y. Inheritance class A { public int X; …
0
votes
0 answers

Moq'ing IHttpControllerActivator in test project to use my actual CompositionRoot

This is mostly a Mocking question. I am attempting to write an automated Web API test and am having trouble activating my controllers inside the test environment using an externally defined IHttpControllerActivator. I can activate the controllers…
K. Alan Bates
  • 3,104
  • 5
  • 30
  • 54
0
votes
1 answer

calling __init__ method in composition

I am trying to use composition in python but I wasn’t sure how to do it if I needed the __init__ method from the other class. In other words, how do I do this super(childClass, self).__init__(…) with composition? for example: class Class*(object):…
W.A
  • 7
  • 2
0
votes
2 answers

Representing relationship between "Repotee" class and "Manager" class

I am trying to understand the relationship between classes. For example I am trying to understand the relationship between "Manager" class and (his) "Reportee" class, as in below diagram: To my understanding, "Manager" and "Reportee" can exists…
CuriousMind
  • 8,301
  • 22
  • 65
  • 134
0
votes
2 answers

Correct way of applying OOP concept of Aggregation

I'm fixing the OOP design of my system because I think the architecture is flawed. I've to rewrite the classes for correct Object Orientation application such as its inheritance, interfaces and aggregation / composition for proper code re-use and…
heisenberg
  • 1,784
  • 4
  • 33
  • 62
0
votes
4 answers

Does a class with has-a relationship with a Collection object have a relationship with the Collection's elements?

I am studying for the Java 8 Programmer II certification, and I'm going over the relationships classes can have. I understand composition, but I wondered if there is relationship considered between the elements of a collection that is a class…
Shoikana
  • 595
  • 4
  • 8
0
votes
1 answer

Implementing a simple text adventure game in java (working with interfaces)

I was doing some reading on ECS/Composition over inheritance and decided to modify a text adventure game that I'm currently working on to better understand the concept. I decided to try it using a specific weapon in my game. Now, in my game the…
user6287396
0
votes
1 answer

Application Composition in Software-Defined Networking (SDN)

I have seen that many current SDN controller platforms like OpenDaylight, Floodlight or the HP VAN SDN controller allow to write SDN applications as independent modules. It seems like you can run multiple applications side by side. With the HP SDN…
Matthias
  • 1
  • 2
0
votes
0 answers

Composition error

I'm trying to run "loadProgram" located in the motherboard class through the "Room" class. I typed theRoom.getTheComputer().getMotherboard().loadProgram("Windows"); But I get Exception in thread "main" java.lang.NullPointerException at…
PrQ
  • 43
  • 1
  • 7
0
votes
0 answers

Java: Subclass instances referencing the same Superclass instance

Before marking duplicate please read: I did read the following article and found the potential 'solutions' not to be what I was looking for as most of them address using an equals() method. Classes sharing the same super class instance What I am…
0
votes
1 answer

Mixin pattern in Backbone - how does it differ from Backbone's extend implementation?

Recently I have been reading up on JavaScript patterns and architecture in general. One tip I often encountered was to favor composition over inheritance, so I spent the day digging a bit deeper into this. Having understood the advantages of a…
Sven
  • 12,997
  • 27
  • 90
  • 148
0
votes
2 answers

Should i use class inheritance or not?

I have to manage dues for customers. I made a class named Due. It stores dues for two types of customers X,Y. It goes like this. public abstract class Due { private CustomerType customerType; //can be either X or Y protected DueType dueType; …
zodi91
  • 150
  • 1
  • 11