What is the use of Association, Aggregation and Composition?

I have gone through lots of theories about what is encapsulation and the three techniques of implementing it, which are Association, Aggregation and Composition.

What I found is:


Encapsulation is the technique of making the fields in a class private and providing access to the fields via public methods. If a field is declared private, it cannot be accessed by anyone outside the class, thereby hiding the fields within the class. For this reason, encapsulation is also referred to as data hiding.

Encapsulation can be described as a protective barrier that prevents the code and data being randomly accessed by other code defined outside the class. Access to the data and code is tightly controlled by an interface.

The main benefit of encapsulation is the ability to modify our implemented code without breaking the code of others who use our code. With this feature Encapsulation gives maintainability, flexibility and extensibility to our code.


Association is a relationship where all object have their own lifecycle and there is no owner. Let’s take an example of Teacher and Student. Multiple students can associate with a single teacher and a single student can associate with multiple teachers, but there is no ownership between the objects and both have their own lifecycle. Both can create and delete independently.


Aggregation is a specialized form of Association where all objects have their own lifecycle, but there is ownership and a child object cannot belong to another parent object. Let’s take an example of a Department and teacher. A single teacher cannot belong to multiple departments, but if we delete the department the teacher object will not be destroyed. We can think of it as a “has-a” relationship.


Composition is again a specialized form of Aggregation and we can call this as a “death” relationship. It is a strong type of Aggregation. Child object does not have their lifecycle and if parent object deletes all child object will also be deleted. Let’s take again an example of relationship between House and rooms. House can contain multiple rooms but there is no independent life of a room and any room cannot belong to two different houses. If we delete the house, the room will automatically be deleted.

The question is:

Now these all are real world examples. I am looking for some description about how to use these techniques in actual class code. I mean what is the point for using three different techniques for encapsulation, How these techniques could be implemented and How to choose which technique is applicable at time.

Show that the composition of a sub-invariant measure with a sub-Markov kernel is a contraction on $L^p$


  • $ (\Omega,\mathcal A)$ be a measurable space
  • $ \mu$ be a finite measure on $ (\Omega,\mathcal A)$
  • $ \kappa$ be a sub-Markov kernel on $ (\Omega,\mathcal A)$
  • $ p\ge1$

I’ll denote the composition of $ \mu$ and $ \kappa$ by $ \mu\kappa$ . Moreover, $ $ \kappa f:=\int\kappa(x,{\rm d}y)f(y)$ $ and $ $ \mu f:=\int f\:{\rm d}\mu$ $ whenever the integrals are well-defined. It’s easy to see that if $ f:\Omega\to\overline{\mathbb R}$ is $ \mathcal A$ -measurable and either nonnegative or bounded, then $ \kappa f$ is $ \mathcal A$ -measurable.

Now, assume $ $ \mu\kappa\le\mu\tag1$ $ and let $ g\in\mathcal L^p(\mu)$ . I want to show that $ \kappa g\in L^p(\mu)$ and $ $ \left\|\kappa g\right\|_{L^p(\mu)}\le\left\|g\right\|_{L^p(\mu)}\tag2.$ $

By the aforementioned property, $ \kappa|g|$ is well-defined and $ \mathcal A$ -measurable. Moreover, by a Fubini like result $ $ \mu(\kappa f)=(\mu\kappa)f\tag3$ $ for all $ \mathcal A$ -measurable $ f:\Omega\to[0,\infty]$ and hence $ $ \mu(\kappa|g|)=(\mu\kappa)|g|<\infty.$ $ Thus, $ $ \kappa|g|<\infty\;\;\;\mu\text{-almost everywhere}\tag4$ $ and hence $ \kappa g$ is $ \mu$ -almost everywhere well-defined. We can find a sequence $ (g_n)_{n\in\mathbb N}$ of (elementary, simple, step – call it however you like) $ \mathcal A$ -measurable functions with $ $ g_n\xrightarrow{n\to\infty}g\tag5$ $ and $ $ \left|g_n\right|\le\left|g\right|\;\;\;\text{for all }n\in\mathbb N\tag6.$ $ Thus, by dominated convergence, $ $ \kappa g_n\xrightarrow{n\to\infty}\kappa g\;\;\;\mu\text{-almost everywhere}\tag7.$ $ So, there is a $ \mathcal A$ -measurable $ f:\Omega\to\mathbb R$ (e.g. $ f:=\limsup_{n\to\infty}\kappa g_n$ ) with $ $ f=\kappa g\;\;\;\mu\text{-almost everywhere}\tag8.$ $ By Jensen’s inequality $ $ \left|\kappa g\right|^p\le\kappa|g|^p$ $ and hence $ $ \left\|f\right\|_{L^p(\mu)}^p\le\mu(\kappa|g|^p)=(\mu\kappa)|g|^p=\left\|g\right\|_{L^p(\mu)}^p\tag9.$ $

Did I overcomplicate anything? Please let me know. In any case, my actual question is: Is it correct that we’re not able to show that $ \kappa g$ is well-defined and $ \mathcal A$ -measurable on all of $ \Omega$ ? As shown in my proof, I guess that it’s only possible to show that there is a $ \mathcal A$ -measurable $ \mu$ -version of $ \kappa g$ . Or am I missing something?

Singular integral of the composition of the Hilbert transform and fractional Laplacian

Given $ 0<s<1$ , we can define the Fractional Laplacian by

$ $ \Lambda^{-s}f(x):=(-\Delta)^{-s/2}(x)=\int_{-\infty}^{+\infty}|x-y|^{-1+s}f(y)dy$ $ or by means of Fourier transform as $ $ \widehat{\Lambda^{-s}f}(\xi)=c_s|\xi|^{-s}\widehat{f}(\xi)\;\mbox{for all}\;\xi\neq0.$ $

The Hilbert transform is defined by $ $ Hf(x)=p.v. \int_{-\infty}^{+\infty}\frac{f(y)}{x-y}dy$ $ or by means of Fourier transform as $ $ \widehat{Hf}(\xi)=-isgn(\xi)\widehat{f}(\xi)\;\mbox{for all}\;\xi\neq0.$ $

Therefore, we can write \begin{equation}\label{eq1}\widehat{\Lambda^{-s}Hf}(\xi)=C_ssgn(\xi)|\xi|^{-s}\widehat{f}(\xi)\;\mbox{for all}\;\xi\neq0. \end{equation} My question is how can i define $ \Lambda^{-s}Hf$ by singular integrals.

Chain-of-responsibility pattern and composition

Sorry for my ignorance but I am little bit confused about Chain-of-responsibility pattern and composition. Below is my code,

class ValidatorChain {      private $  validators;     public function __construct(IValidator ...$  validators)     {         $  this->validators = $  validators;     }      public function isValid(Argument $  arg): bool     {         foreach ($  this->validators as $  validator) {             if (!$  validator->isValid($  arg)) {                 return false;             };         }         return true;     } } 

What I needed is to keep multiple validation in one class and loop all the validations? Can you please suggest to improve the above code(including class name)? Can we call it Chain-of-responsibility pattern or it has any separate design name?