Aggregation vs Composition vs Association vs Direct Association

Please note that there are different interpretations of the “association” definitions. My views below are heavily based on what you would read in Oracle Certification books and study guides. Temporary association A usage inside a method, its signature or as a return value. It’s not really a reference to a specific object. Example: I park … Read more

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

Delegation public class A { private B b = new B(); public void methodA() { b.methodB(); } } When clients of A call methodA, class A delegates the call to B‘s methodB. Rationale. Class A exposes behaviours that belong elsewhere. This can happen in single-inheritance languages where class A inherits from one class, but its … Read more

Why use inheritance at all? [closed]

[note: This question was originally tagged as being language-agnostic. Based on that, this answer was written to be fairly language agnostic, so it discusses inheritance as it’s used across a wide range of languages, such as Smalltalk, C++, and Object Pascal. It’s since been re-tagged as being specifically about Java. Java is different in defining … Read more

What is composition as it relates to object oriented design?

Composition refers to combining simple types to make more complex ones. In your example, composition could be: Animal: Skin animalSkin Organs animalOrgans Mammal::Animal: Hair/fur mammalFur warm-blooded-based_cirulation_system heartAndStuff Person::Mammal: string firstName string lastName If you wanted to go totally composition (and get rid of all inheritance) it would look like this: Animal: Skin animalSkin Organs animalOrgans … Read more

Application architecture/composition in F#

This is easy once you realize that Object-Oriented Constructor Injection corresponds very closely to Functional Partial Function Application. First, I’d write Dings as a record type: type Dings = { Lol : string; Rofl : string } In F#, the IGetStuff interface can be reduced to a single function with the signature Guid -> seq<Dings> … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)