Questions tagged [composition]

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

1737 questions
0
votes
0 answers

Splitting a Hibernate entity class into a class hierarchy

I have a table called Product and the respective Hibernate entity class called Product.java. There are different types and subtypes of Products that are distinguished by two columns in the table called "type" and "subtype". In the application,…
0
votes
2 answers

Java composition constructor

I create some kind of a basic rpg. I use composition (Character and Fighter) and there's a problem in CharacterCreator class. It says that there're incompatible types, Game.Fighter (and rest of the character classes I created) and Game.Character.…
Niminim
  • 668
  • 1
  • 7
  • 16
0
votes
2 answers

Shared componentDidMount() function

I have several function having the exact same componentDidMount function. Is there a way to share it ? I'am using ES6 and apparently there is not way to use Mixin. Thanks for any help
bokzor
  • 413
  • 7
  • 19
0
votes
1 answer

COM ownership with composition in interfaces

Does a COM interface have to override AddRef and Release if it owns other interfaces? At interface creation, members are created that maintain a refcount, so I have to override Release to not leak the owned interfaces when the own refcount reaches…
typ1232
  • 5,535
  • 6
  • 35
  • 51
0
votes
1 answer

Inheritance, composition with interface

As per my understanding, there can be both class inheritance and interface inheritance. And interface is one of the ways to provide encapsulation. Q1: Then why "Inheritance will always have weak encapsulation"? Q2: composition with interface is…
sumit
  • 133
  • 2
  • 10
0
votes
1 answer

Representing Associations when object state is initialized using Spring Dependency injection

I am trying to draw a class diagram and am confused regarding the association relationship to be used in the scenario similar to the one below. Interface SampleInterface{ void sampleMethod(); } class SampleInterfaceImpl implements…
sujith
  • 665
  • 2
  • 9
  • 22
0
votes
4 answers

Does the Derived class need diamond link?

If, for example, I have the following requirements: 1. Dog is an Animal 2. Zoo has Animal(s) Do I still need the 2nd diamond connector (the lower one) as shown here:
The_Void
  • 1
  • 1
0
votes
2 answers

Object composition vs Nested class in C++.Which shall I use when?

C++ provides two similar provisions to perform the same task.While object composition seems more convenient as the declared class can be used for some other class as well. Eg. An 'Address' class can contain some properties and functions and then be…
0
votes
1 answer

Application of Aggregation and Composition

Ok, I understand Composition and Aggregation. An aggregation is any object that can exist outside of the "parent" class. Composition means that when the parent dies, the objects it is composed of dies. Ok, I have a testing application. A Category…
Jacob Pressures
  • 1,391
  • 2
  • 12
  • 15
0
votes
1 answer

Model Login System: Implement Interface or Composition?

I'm developing a administrative application (in PHP), where the Administrator can register customers. There are 2 types of customers: Companies and Individuals. A Company 'has-many' ContactPersons, which can login to the application. A Individual…
Jan-Paul Kleemans
  • 818
  • 1
  • 12
  • 22
0
votes
1 answer

How to override a method of a member object?

In python 3.4 I have a member object through composition. I would like to override one of it's member functions. def class Foo: def __init__(self, value): self.value = value def member_obj.baz(baz_self, arg): print("my new…
mvbentes
  • 1,022
  • 12
  • 24
0
votes
2 answers

Is there a correct way of composing moore machines?

A mealy machine is just a stateful function. Hence, two mealy machines can be composed using simple function composition. A moore machine is a restricted mealy machine with an initial output value. Is there a way to compose two moore machines? This…
0
votes
1 answer

UML composition with bidirectional association (composing object has back-pointer)

I can't seem to find a decent answer on the interwebs, though I'm sure it's been asked before. Basically, I have an object that is composed of another object - so black diamond and line. When the parent dies, the object it composes dies. However,…
friartuck
  • 2,954
  • 4
  • 33
  • 67
0
votes
1 answer

Refactoring inheritance to composition using Vbex2005

I have a class that I wrote fairly early on in my vb.net programming experience which inherited from another class it really should have composed. The base class is a relatively generic nested dictionary-based collection; let's call the descendant…
supercat
  • 77,689
  • 9
  • 166
  • 211
0
votes
1 answer

How to do decorator with composition pattern in Autofac and Ninject

I want to make a 'decorator' for the IRepository. This decorator is also a 'composition' of multiple IRepository's. In code: public interface IRepository { } public class RepositoryFoo : IRepository { } public class RepositoryBar : IRepository {…