Design pattern used in AEM | Community
Skip to main content
Level 7
Jul 10, 2023 3:26 PM UTC
Solved

Design pattern used in AEM

Hello All,

 

Is there any design pattern/s, that AEM is built on top of it? i.e: List of design patterns that most of the AEM features follows. example: Services in AEM are singleton

 

Can someone explain the design patterns that they have used to do do some operations in your AEM applications.  Thanks in advance.

 

 

aanchal-sikka
aanchal-sikkaAccepted solution
New Participant
Jul 10, 2023 4:23 PM UTC

Hello @mahesh_gunaje 

 

1. Model-View-Controller (MVC) Pattern:
AEM uses the MVC pattern to separate the data models (Java classes or Sling models), the views (JSP or HTL templates), and the controllers (Java classes or Sling servlets) for rendering web pages.

2. Singleton Pattern:
Example: AEM uses the Singleton pattern to ensure that there is only one instance of critical objects like the OSGi service component or the AEM service.

3. Factory Pattern:
AEM employs the Factory pattern to create objects based on a common interface or abstract class. For instance, the OSGi service component factory provides multiple instances of the same service implementation.

4. Adapter Pattern:
AEM uses the Adapter pattern to convert one interface into another. For example, the Sling Adapter Factory enables adapting a resource to various adaptable types. Example: Resource -> Page

5. Composite Pattern:
AEM leverages the Composite pattern to treat a group of objects as a single object. For instance, AEM's component-based architecture allows creating composite components with child components.

6. Observer Pattern:
AEM utilizes the Observer pattern to establish a one-to-many dependency between objects. For instance, AEM's Event Listeners and Event Handlers follow the Observer pattern to react to specific events.

Aanchal Sikka

5 replies

Sid_Gour
Level 3
Jul 11, 2023 5:29 AM UTC

Hi @mahesh_gunaje ,

Please refer to this video - https://www.youtube.com/watch?v=flHjyzSJhrI

which talks about following design patterns which can be used in AEM 

1. OSGi Declarative Services
2. Service Locator Design Pattern
3. Command Design Pattern
4. Events Sourcing Design Pattern
5. Singleton Design Pattern
6. Adapter Design Pattern
7. Factory Design Pattern
8. Proxy Design Pattern
9. Decorator Design Pattern
10. Observer Design Pattern
11. Chain of Responsibility Design Pattern

 

Thanks,

Translate
Level 7
Jul 12, 2023 9:54 AM UTC

Thanks @sid_gour  for the explanation

Translate
aanchal-sikka
aanchal-sikkaAccepted solution
New Participant
Jul 10, 2023 4:23 PM UTC

Hello @mahesh_gunaje 

 

1. Model-View-Controller (MVC) Pattern:
AEM uses the MVC pattern to separate the data models (Java classes or Sling models), the views (JSP or HTL templates), and the controllers (Java classes or Sling servlets) for rendering web pages.

2. Singleton Pattern:
Example: AEM uses the Singleton pattern to ensure that there is only one instance of critical objects like the OSGi service component or the AEM service.

3. Factory Pattern:
AEM employs the Factory pattern to create objects based on a common interface or abstract class. For instance, the OSGi service component factory provides multiple instances of the same service implementation.

4. Adapter Pattern:
AEM uses the Adapter pattern to convert one interface into another. For example, the Sling Adapter Factory enables adapting a resource to various adaptable types. Example: Resource -> Page

5. Composite Pattern:
AEM leverages the Composite pattern to treat a group of objects as a single object. For instance, AEM's component-based architecture allows creating composite components with child components.

6. Observer Pattern:
AEM utilizes the Observer pattern to establish a one-to-many dependency between objects. For instance, AEM's Event Listeners and Event Handlers follow the Observer pattern to react to specific events.

Translate
Aanchal Sikka
Level 7
Jul 12, 2023 9:53 AM UTC

Thanks a lot @aanchal-sikka  for the detailed explanation. 

 

Regards

Mahesh

Translate
Ravi_Pampana
New Participant
Jul 10, 2023 3:59 PM UTC

Hi,

 

You can refer https://computepatterns.com/osgi-design-patterns/ for OSGI design patterns with sample implementations. 

Translate