Most voted "composition" questions
18 questions
Sort by count of
-
66
votes3
answers2309
viewsIs it right to prefer composition to inheritance?
I’ve read several articles and books of Designer Patterns the expression Prefira composição em vez de herança. I believe it is a rather controversial subject due to the views discussed. In my view,…
-
5
votes0
answers75
viewsWhy should we prefer composition over inheritance?
Since the popularization of object orientation in the 90’s I hear that composition should be preferred before creating hierarchy of types. But perhaps the most important concept of object…
oop inheritance software-engineering composition liskov-principleasked 10 years, 5 months ago Maniero 444,682 -
5
votes2
answers177
viewsWhat is the name of the concept employed in this code?
If I create for example two classes and place the class Funcionario with a variable Empregado in class Empresa, what this means and what it serves? class Funcionario { String nome; String cpf; }…
-
4
votes1
answer261
viewsHeritage in object-oriented programming
I was reading that article today and I came across the following statement: "Inheritance refers to the ability of an object to access methods and other properties of another object." Inheritance…
-
3
votes2
answers148
viewsHow do you model a role in object orientation?
How one normally models a role (role) object-oriented? It is by means of a composition, correct? For example, to model that a Pessoa executes the paper of a Cliente or Fornecedor, it is modeled that…
-
3
votes2
answers174
viewsRequest and Pedidoitem establish a composition?
I took the test of the IFSULDESTE competition of Minas Gerais organized by the CEFET-MG Foundation and I have doubts about the following question: Note the following class diagram. About the…
-
2
votes2
answers973
viewsInheritance X Composition - Mysql C# Entity
There was a doubt of inheritance modeling in C# involving the entities Pessoa, Pessoafísica and Pessoalegal, but Gypsy Morrison Mendez helped a lot! Now I have another question in another type of…
c# asp.net-mvc entity-framework inheritance compositionasked 8 years, 8 months ago Felipe Bulle 387 -
2
votes1
answer183
viewsLINQ to SQL with entities that already exist, inheritance and composition
I’m starting to study LINQ to try to implement a project I’m working on. For examples both in articles as in videos, LINQ has an interface in visual Studio that generates the entity classes from the…
c# inheritance abstract-classes linq-to-sql compositionasked 8 years, 7 months ago Matheus Saraiva 2,157 -
2
votes1
answer154
viewsDoubts about class composition or inheritance
I’m having some doubts in that composition between the ClienteJuridico and Clientephysics with the NotaFiscal. I did some research and saw that the objetos of these classes within another, in case…
-
2
votes2
answers201
viewsAssociative class with double dependency
I was searching the internet and saw this way of making association between Java classes. Is it correct to make this type of association? 'Cause I did a lot of research on the Internet and I…
-
2
votes1
answer248
viewsAssociation, aggregation, etc. in practice?
I am studying POO and still can not see, in practice, the difference between them. Basically everything ends up in one class having as attribute the instance of another class. But if it is…
-
2
votes2
answers52
viewsCall and apply methods in functional composition
I wanted to know how the methods call and apply behave, especially when one is passed as argument from another, and understand some of the logic of this code, mainly in the line in which they were…
-
1
votes1
answer122
viewsHow to have an Arraylist by composition
I understand how to compose but I’ve never done with lists, although the principle should be the same, I don’t understand how to do. For starters I have a class CentroComercial who owns a ArrayList…
-
1
votes1
answer93
viewsHow to interpret the composition connector in a class diagram?
The teacher asked to make a relationship between parents, state and city. From what I understood of this relationship I made this diagram. Only he said that the diamond side is on the wrong side and…
-
1
votes1
answer229
viewsComposition of objects in javascript
I’m studying a little more javascript here and I’ve come to a problem: I have an object called player: let Player = function () { this.name = 'player'; } Player.prototype = new Sprite();…
-
0
votes2
answers425
viewsClass association or inheritance?
What better way to create an association or heritage where I have the class User and the class Academic whereas Academic is a User User-class: public class Usuario { public int Id { get; set; }…
-
0
votes1
answer83
viewscomposition and validation
Guys I have a struct called Contact with variables Std::string and a ready-to-use email validation class using regex. I am creating a program and not need to create another validation function for…
-
0
votes0
answers249
viewsHow to use Pdo in php by making inheritance via composition?
I can’t think of the right structure to create application in PHP. At first I have the Person and Student classes. The Student class instances the Person class in order to use its attributes and…