composition Questions

1

Solved

I am learning SOLID principle. While learning "Dependency Inversion Principle" found out that class should depend on interfaces rather than concrete classes. Does this mean composition is...

36

Why prefer composition instead of inheritance? What trade-offs are there for each approach? And the converse question: when should I choose inheritance instead of composition?

3

Solved

What are the differences and the similarities between composition and inner classes? I am trying to learn the principles of Java and try to figure out the whole image. For me is better to make ana...
Hartung asked 1/11, 2016 at 13:21

4

Solved

with combining characters one can use 2 unicode characters at single location, creating a composition of two graphics. I'm thinking about simple ascii art, I would need to first use, as wikipedia s...
Marlinmarline asked 23/6, 2018 at 15:25

3

Solved

In my project i have to implement one different color image on the other same size and pattern image using canvas and images are not in round or rectangle shapes. That all are in waves shape and it...
Kickback asked 22/8, 2013 at 11:59

3

Solved

I wish to extend Python socket.socket with a new attribute (in particular, a queue.Queue, but could be anything else). I am trying to decide whether I should use inheritance or composition, but at ...
Happen asked 20/7, 2017 at 6:58

4

Solved

Definitions taken from here Dependency Change in structure or behaviour of a class affects the other related class, then there is a dependency between those two classes. It need not be the sa...
Rolfe asked 9/1, 2014 at 13:47

21

What is the difference between association, aggregation, and composition? Please explain in terms of implementation.
Whoop asked 20/5, 2009 at 2:47

3

in the classfull-Style (c++) or in the traditional Design Patterns (GofPatterns) it is really clear, what is the difference between composition and inheritance and how it is implemented and when to...
Lynda asked 18/6, 2014 at 15:1

16

Solved

I have an array of functions and I'm trying to produce one function which consists of the composition of the elements in my array. My approach is: def compose(list): if len(list) == 1: return la...
Biogeography asked 24/5, 2013 at 16:10

4

Solved

Found in Apple doc, that Codable protocol is composed of Encodable and Decodable. Thus, Codable = Encodable & Decodable Now, let's say I implemented below classes, class X: Codable { var n...
Gopak asked 12/3, 2020 at 10:30

3

input: two functions f and g, represented as dictionaries, such that g ◦ f exists. output: dictionary that represents the function g ◦ f. example: given f = {0:’a’, 1:’b’} and g = {’a’:’apple’, ’b...
Lehmbruck asked 28/9, 2016 at 20:17

5

This question is NOT question like "inheritence vs composition". I understand completely how inheritance differs from composition, I know the Liskov substitution principle, the diamond problem, ad...

11

Solved

What are the differences between service orchestration and service choreography from an intra-organization point of view.
Gisela asked 8/11, 2010 at 19:26

1

Solved

Here's a 'compose' function which I need to improve: const compose = (fns) => (...args) => fns.reduceRight((args, fn) => [fn(...args)], args)[0]; Here's a practical implementation of one:...

2

Solved

I have this code snippet that creates an array of boxes, I want to make it generic so it can also, for example, store a triangle. I'm not quite sure what parameters I need to use or how I need to m...
Favianus asked 3/9, 2021 at 22:4

2

Solved

In main.js, I set axios as a global function. //main.js import { createApp } from 'vue'; import App from './App.vue'; import axios from 'axios'; const app = createApp(App); app.config.globalProper...
Shaunteshave asked 19/8, 2021 at 13:37

3

Solved

I have a module in Angular that is structured likes this: moduleName componentA componentB Now componentA and componentB are very similar, as they share some attributes and methods, e.g.: pro...
Laud asked 14/9, 2018 at 13:58

6

Solved

While designing my objects I find composition to be a better choice from the perspective of testability. The reason being, I can mock parts of the composition structure if I need to, while running ...
Carrero asked 17/4, 2009 at 13:41

1

Solved

If I have a Role R defined as: role R { method answer { 42 } } What is the difference (if any) between these two lines: my $a = 'question' does R; my $b = 'question' but R; They appear very simi...
Garnettgarnette asked 28/2, 2021 at 16:5

1

Solved

This title seems to receive a lot of criticism. However, I have found this notion to be difficult to search for. It is also relatively new in C++ land, where schools are still teaching C++11. Motiv...
Pussyfoot asked 2/2, 2021 at 14:29

3

Solved

I'm trying to make a function that compose a function f(x) by itself N times, something like that: function CompositionN(f,N) for i in 1:N f(x) = f(f(x)) end return f(x) I need that the functio...
Classmate asked 27/10, 2020 at 17:23

5

Solved

I am trying to implement a Stack in java (using the list interface: Interface List). I want to implement it two different ways: using composition and inheritance. For inheritance, so far I have:...
Datnow asked 13/9, 2009 at 23:32

1

Solved

I'm looking into how to apply functional programming in javascript, and I'm experimenting with trying to avoid using the class keyword. I'm not a fan of going to extreme measures just for the sake...
Futurity asked 5/4, 2020 at 17:5

4

Solved

I can't solve what seems to be a basic MEF problem: I have 2 "plugins" project (which we'll call P1 and P2), and a third project that is common to both plugins (which we'll call C). P1 and P2 both ...
Alcaide asked 13/9, 2012 at 8:16

© 2022 - 2024 — McMap. All rights reserved.