Questions tagged [composition]

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

1737 questions
0
votes
2 answers

Should I use inheritance or composition in my case?

I'm creating a class which shares common codes with another class and am not sure which pattern I should use. The class I've already have: public class TeamA{ private static final Logger LOGGER = Logger.getLogger(TeamA.class); @Autowired …
user959704
0
votes
2 answers

compose objects without initializing objects that are not in hash

I am trying to compose an object Transaction from objects TranFee and Rate. class Transaction attr_reader :tranfee, :rate def initialize(hash) @tranfee = PaymentType::TranFee.new(hash) @rate = PaymentType::Rate.new(hash) …
heinztomato
  • 795
  • 1
  • 7
  • 12
0
votes
1 answer

Object Oriented Modelling Advice

hoping for a bit of guidance with modelling decisions for an RoR app I’m planning to build. It’ll be a rental platform hosting with multiple rental vendors. I'm supposing the following classes and or modules and my question is about modelling,…
jbk
  • 1,911
  • 19
  • 36
0
votes
2 answers

Scala Play Action Composition : Declare ActionBuilder that produces Action by combining several ActionFunction

I'm trying to wrap my head around Play action composition. My primary reference is: https://www.playframework.com/documentation/2.3.6/ScalaActionsComposition Here's what I want to achieve (to be able to declare a function in my Controller this…
Cokorda Raka
  • 4,375
  • 6
  • 36
  • 54
0
votes
3 answers

Is it good design to explicitely distinguish immutable and mutable parts of an object?

Let's think about this class, where ImmutablePart is an immutable pure data Object : public class Clazz1 { private final ImmutablePart immu ; private String f1; private boolean f2; private int f3; /** some constructor…
Jules Sam. Randolph
  • 3,610
  • 2
  • 31
  • 50
0
votes
1 answer

Class composition - can't convert from 'int' to class

I'm learning about class composition but I'm having a hard time understanding how the syntax works. I have two classes, Time and Date, and Date is composed with a Time object. I can't get the Date constructor to work correctly - there is a…
Sabien
  • 219
  • 2
  • 16
0
votes
0 answers

How to represent forum's relationship in Class diagram

I'm trying to make class diagram for a simple forum and i don't understand how to represent it. Here's what i did: Firstly, I don't understand how to make relationship between users,posts and threads. Secondly, is inheritance right choice or…
ma1169
  • 659
  • 1
  • 8
  • 26
0
votes
1 answer

Does the delegate pattern break encapsulation?

Lets say I have a class that takes a delegate: public class DelegateContainer { private IDelegate delegate; public DelegateContainer(IDelegate delegate) { this.delegate = delegate; } public void doSomething() { …
Jonathan
  • 1,256
  • 4
  • 12
  • 18
0
votes
1 answer

Microsoft.Composition. What does the WithDefaultConventions method do?

Supposing I have a method GetAssemblies, which returns a list of assemblies, and a method called GetConventions, which returns a ConventionBuilder, I might compose my container like this: CompositionHost container = new ContainerConfiguration() …
bornfromanegg
  • 2,826
  • 5
  • 24
  • 40
0
votes
1 answer

How can I achieve this kind of relationship (inheritance, composition, something else)?

I would like to set up a foundation of classes for an application, two of which are person and student. A person may or may not be a student and a student is always a person. The fact that a student “is a” person led me to try inheritance, but I…
Tim
  • 97
  • 1
  • 7
0
votes
2 answers

Passing a string in where clause in Rails is always quoted

I'm trying to compose programmatically the .where() clause. It looks like Post.where("description ?", @composite) Where @composite is a string which is constructed before. It may be something like = 'ABCD' or maybe IS LIKE 'ABCD' etc. Problem is in…
valk
  • 9,363
  • 12
  • 59
  • 79
0
votes
1 answer

Rails 1.0 - Using composed_of gives me a wrong number of arguments (1 for 5) error

I am developing a Rails 1.0 application (I can't upgrade, it's a strange situation) for which I am trying to use the :composed_of functionality. I have a class called StreetAddress: class StreetAddress attr_reader :address, :address2, :city,…
Tristan Havelick
  • 67,400
  • 20
  • 54
  • 64
0
votes
1 answer

Verifying Composition Method algorthm for Random Variable generation

I´m working on implementing the composition method algorithm that states the following: Composition Approach Another method for generating rando variables is the composition approach. Suppose that X has CDF (Cumulative Distribution Function) Fx and…
Pablo Estrada
  • 3,182
  • 4
  • 30
  • 74
0
votes
0 answers

C++ Object Composition and Separate Compilation

When I write C++ code I often try to limit the amount of header files that I have to #include, because it keeps compilation time smaller and also prevent unnecessary recompilation of compilation units when part of my program changes. On the other…
skuld
  • 149
  • 1
  • 8
0
votes
1 answer

Prism region behaviours and MEF

I have a question on which, AFAIK information is scarce. In the StockTrader RI provided by Microsoft there is a definition for a AutoPopulateExportedViewsBehavior, the purpose of which I seem to grasp. However, this behaviour is declared with an MEF…
Kris
  • 2,100
  • 5
  • 31
  • 50
1 2 3
99
100