Questions tagged [aggregation]

Aggregation is a relationship between two classes that is best described as a "has-a" and "whole/part" relationship.

Aggregation is a relationship between two classes that is best described as a "has-a" and "whole/part" relationship. It is a more specialized version of the association relationship. The aggregate class contains a reference to another class and is said to have ownership of that class. Each class referenced is considered to be part-of the aggregate class

3383 questions
1962
votes
35 answers

Prefer composition over inheritance?

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?
readonly
  • 343,444
  • 107
  • 203
  • 205
563
votes
21 answers

What is the difference between association, aggregation and composition?

What is the difference between association, aggregation, and composition? Please explain in terms of implementation.
None
231
votes
4 answers

Show all Elasticsearch aggregation results/buckets and not just 10

I'm trying to list all buckets on an aggregation, but it seems to be showing only the first 10. My search: curl -XPOST "http://localhost:9200/imoveis/_search?pretty=1" -d' { "size": 0, "aggregations": { "bairro_count": { …
Samuel Rizzo
  • 2,811
  • 2
  • 20
  • 18
202
votes
10 answers

MySQL - Using COUNT(*) in the WHERE clause

I am trying to accomplish the following in MySQL (see pseudo code) SELECT DISTINCT gid FROM `gd` WHERE COUNT(*) > 10 ORDER BY lastupdated DESC Is there a way to do this without using a (SELECT...) in the WHERE clause because that would seem like a…
Ice
155
votes
12 answers

Inheritance vs. Aggregation

There are two schools of thought on how to best extend, enhance, and reuse code in an object-oriented system: Inheritance: extend the functionality of a class by creating a subclass. Override superclass members in the subclasses to provide new…
Craig Walker
  • 49,871
  • 54
  • 152
  • 212
115
votes
9 answers

Implementation difference between Aggregation and Composition in Java

I'm aware of the conceptual differences between Aggregation and Composition. Can someone tell me the implementation difference in Java between them with examples?
Rajath
  • 2,178
  • 6
  • 32
  • 38
90
votes
2 answers

Aggregation in Pandas

How can I perform aggregation with Pandas? No DataFrame after aggregation! What happened? How can I aggregate mainly strings columns (to lists, tuples, strings with separator)? How can I aggregate counts? How can I create a new column filled by…
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252
79
votes
2 answers

ElasticSearch multi level parent-child aggregation

I have a parent/child structure in 3 levels. Let's say: Company -> Employee -> Availability Since Availability (and also Employee) is frequently updated here, I choose using parent/child structure against nested. And search function works fine…
Pete Minus
  • 906
  • 6
  • 6
64
votes
5 answers

Distinguishing between delegation, composition and aggregation (Java OO Design)

I am facing a continuing problem distinguishing delegation, composition and aggregation from each other, and identifying the cases where it's the best to use one over the other. I have consulted a Java OO Analysis and Design book, but my confusion…
denchr
  • 4,142
  • 13
  • 48
  • 51
60
votes
4 answers

Aggregation vs Composition vs Association vs Direct Association

I am reviewing my knowledge in object-oriented programming. Under the relationship between classes topic, I have encountered some relationships which are a bit ambiguous to me. I know dependency "uses-a" and inheritance "is-a" but I'm a bit…
steven0529
  • 1,513
  • 1
  • 18
  • 28
53
votes
3 answers

Count Number of Consecutive Occurrence of values in Table

I have below table create table #t (Id int, Name char) insert into #t values (1, 'A'), (2, 'A'), (3, 'B'), (4, 'B'), (5, 'B'), (6, 'B'), (7, 'C'), (8, 'B'), (9, 'B') I want to count consecutive values in name column +------+------------+ | Name |…
FLICKER
  • 6,439
  • 4
  • 45
  • 75
51
votes
8 answers

UML aggregation vs association

From Martin Fowler's UML Distilled: In the pre-UML days, people were usually rather vague on what was aggregation and what was association. Whether vague or not, they were always inconsistent with everyone else. As a result, many modelers think…
Andna
  • 6,539
  • 13
  • 71
  • 120
43
votes
1 answer

Transform vs. aggregate in Pandas

When grouping a Pandas DataFrame, when should I use transform and when should I use aggregate? How do they differ with respect to their application in practice and which one do you consider more important?
Sylvi0202
  • 901
  • 2
  • 9
  • 13
40
votes
6 answers

Django Aggregation: Sum return value only?

I have a list of values paid and want to display the total paid. I have used aggregation and Sum to calculate the values together. The problem is,I just want the total value printed out, but aggregation prints out: {'amount__sum': 480.0} (480.0…
Stephen
  • 527
  • 2
  • 7
  • 19
38
votes
5 answers

calling constructor of a class member in constructor

Can I call constructor of a member in my Class's constructor? let say If I have a member bar of class type foo in my class MClass. Can I call constructor of bar in MClass's constructor? If not, then how can I initialize my member bar? It is a…
shampa
  • 1,350
  • 3
  • 13
  • 22
1
2 3
99 100