SlideShare une entreprise Scribd logo
1  sur  24
A O P & IO C




         V u Co n g T h a n h
         V i Qu o c Ha n h
         Social team

                             www.exoplatform.com
                       Copyright 2011 eXo Platform
Agenda

    W h a t is IO C ?

    IO C – Tim e o f In je c t o r

    IO C – P r o s & C o n s

    IO C - S c o p e

    De mo




                                           www.exoplatform.com
                                2
                                     Copyright 2011 eXo Platform
In v e r s io n O f
C o n t r o l ( IO C )


                           www.exoplatform.com
                     Copyright 2011 eXo Platform
WHAT IS “DEPENDENCY”?




                                  www.exoplatform.com
                        4
                            Copyright 2011 eXo Platform
Implementation with NOT IOC

» Construction by Hand.




» Factory Pattern.




                                        www.exoplatform.com
                              5
                                  Copyright 2011 eXo Platform
Dependencies Problems


» Code is tightly coupled
» Difficult to isolate when testing
» Difficult to maintain.




                                            www.exoplatform.com
                              6
                                      Copyright 2011 eXo Platform
What is IOC?


» Hollywood principle “Don't call us, we'll call you.”
» Creating, Assembling and Wiring the dependencies into
  Object graph.
» Type of Dependency Injector:
   – Constructor
   – Setter
   – Method
   – Field(Guice)


                                                        www.exoplatform.com
                              7
                                                  Copyright 2011 eXo Platform
IOC: Pros and Cons


» Pros:
   – Loosely Coupled
   – Increases Tesability
   – Separates component clearly.

   – Allows for use of Inversion of Control Container.

» Cons:
   – Increases code complexity
   – Difficult to understand at First
   – Complicate Debugging at First
   – Complicates following Code Flow.

                                                               www.exoplatform.com
                                        8
                                                         Copyright 2011 eXo Platform
Time for Injector - BoorStrapping the Injector


» Constructed and prepared before
  it can be used.
    – In the init lifecycle stage of a
      web application.
    – On startup of a desktop
      program




                                                       www.exoplatform.com
                                   9
                                                 Copyright 2011 eXo Platform
IOC - Metadata and Injector Configuration


» XML configuration file.
» Annotations(@Injector, @Singleton, …)
» Invoking into a programmatic API.




                                                  www.exoplatform.com
                                 10
                                            Copyright 2011 eXo Platform
Boorstrapping the Injector(Cont)


» Constructed and prepared before
  it can be used.
   – On demand, every time it is
     needed
   – Lazily, when it is first needed




                                              www.exoplatform.com
                                   11
                                        Copyright 2011 eXo Platform
IOC - What is Scope?


Fixed duration of time or method calls in which an object
 exist. General-purpose scopes: Singleton and No-scope.
» Web Application:
   – Request, Session and Conversation scope
   – Transaction scope




                                                     www.exoplatform.com
                            12
                                               Copyright 2011 eXo Platform
IOC - Benefit of Scope


» Lets injector manage the latent state of your objects
» Ensures that your services get new instances of
  dependencies as needed
» Implicitly separates state by context.




                                                       www.exoplatform.com
                             13
                                                 Copyright 2011 eXo Platform
DEMO



             www.exoplatform.com
       Copyright 2011 eXo Platform
Wha t?



               www.exoplatform.com
         Copyright 2011 eXo Platform
What?




                   www.exoplatform.com
        16
             Copyright 2011 eXo Platform
What?
AOP
 - Enables encapsulation of functionality that affects multiple
classes in separate
   units

 - Complements object oriented programming

  - Is not about “patching” pieces of code. About performing an
action
    systematically upon recognition of a behavior in the code.




                                                           www.exoplatform.com
                               17
                                                     Copyright 2011 eXo Platform
Why?

 Benefits:
   - Separates persistence and specific functionality (logging,
 security...)

  - Promotes code reuse and modularization

  - Decouples codes (the LogFactory from the DAO impl’s)




                                                          www.exoplatform.com
                              18
                                                    Copyright 2011 eXo Platform
AOP vs OOP

    Object Oriented               Aspect Oriented
    Class – code unit that        Aspect – code unit that
    encapsulates methods and      encapsulates pointcuts, advice,
    attributes.                   and attributes.
    Method signatures – define    Pointcut – define the set of
    the entry points for the      entry points (triggers) in which
    execution of method bodies.   advice is executed.

    Method bodies –               Advice – implementations of the
    implementations of the        cross cutting concerns.
    primary concerns.
    Compiler – converts source    Weaver – instruments code
    code into object code.        (source or object) with advice.



                                                                    www.exoplatform.com
                                  19
                                                             Copyright 2011 eXo Platform
Concepts

- Crosscutting Concerns
- Aspect: The merger of advice and pointcuts.
  All information about where, when and what
  job is to be done.
- Advice: The job of an aspect. Defines the what
  and when of an aspect.
- Pointcut: Pointcuts help narrow down the
  joinpoints advised by an aspect. Define the
  where of an aspect.
- Joinpoint: A point in the execution of an
  application where an aspect can be plugged
  in. All the opportunities for advice to be
  applied.




                                                         www.exoplatform.com
                                       20
                                                   Copyright 2011 eXo Platform
Concepts
- Target: Object being advised.
- Proxy: The object created after applying advice to the target object. To the client
making use of the target object the proxy looks the same.
- Weaving: Process of applying aspects to a target object to create a new, proxied
object.




                                                                         www.exoplatform.com
                                        21
                                                                   Copyright 2011 eXo Platform
How it works?




                           www.exoplatform.com
                22
                     Copyright 2011 eXo Platform
www.exoplatform.com
23
     Copyright 2011 eXo Platform
Th a n k yo u !




                        www.exoplatform.com
                  Copyright 2011 eXo Platform

Contenu connexe

En vedette

En vedette (7)

Ecological theory (Parra-Cardona, 2013)
Ecological theory (Parra-Cardona, 2013)Ecological theory (Parra-Cardona, 2013)
Ecological theory (Parra-Cardona, 2013)
 
Hypertension Prevention and Control
Hypertension Prevention and ControlHypertension Prevention and Control
Hypertension Prevention and Control
 
Microsoft office 2010 excel. unidad 1
Microsoft office 2010 excel. unidad 1 Microsoft office 2010 excel. unidad 1
Microsoft office 2010 excel. unidad 1
 
Year 5 English Unit 9 Preposition
Year 5 English Unit 9 PrepositionYear 5 English Unit 9 Preposition
Year 5 English Unit 9 Preposition
 
Motion ppt for class 9
Motion ppt for class 9Motion ppt for class 9
Motion ppt for class 9
 
Better Buildings by Design Vermont: Joslin Hill House
Better Buildings by Design Vermont: Joslin Hill HouseBetter Buildings by Design Vermont: Joslin Hill House
Better Buildings by Design Vermont: Joslin Hill House
 
Pyla ICF Ficha técnica
Pyla ICF Ficha técnicaPyla ICF Ficha técnica
Pyla ICF Ficha técnica
 

Similaire à IOC and AOP presentation

Scrum in Action
Scrum in ActionScrum in Action
Scrum in Action
Hoat Le
 
eXo Platform company overview 2012
eXo Platform company overview 2012eXo Platform company overview 2012
eXo Platform company overview 2012
Yann Aubry
 
Java application server in the cloud
Java application server in the cloudJava application server in the cloud
Java application server in the cloud
adm_exoplatform
 
Exo presented at OW2con11, Nov 24-25, 2011, Paris
Exo presented at OW2con11, Nov 24-25, 2011, ParisExo presented at OW2con11, Nov 24-25, 2011, Paris
Exo presented at OW2con11, Nov 24-25, 2011, Paris
OW2
 
Introduction to MonoTouch
Introduction to MonoTouchIntroduction to MonoTouch
Introduction to MonoTouch
Jonas Follesø
 
Next Generation Portals : How OpenSocial Standard Adds Social to the Mix?
Next Generation Portals : How OpenSocial Standard Adds Social to the Mix? Next Generation Portals : How OpenSocial Standard Adds Social to the Mix?
Next Generation Portals : How OpenSocial Standard Adds Social to the Mix?
Tugdual Grall
 
eXo Platform Company overview Oct 2012
eXo Platform Company overview Oct 2012eXo Platform Company overview Oct 2012
eXo Platform Company overview Oct 2012
Yann Aubry
 

Similaire à IOC and AOP presentation (20)

Scrum in Action
Scrum in ActionScrum in Action
Scrum in Action
 
Zero redeployment with JRebel
Zero redeployment with JRebelZero redeployment with JRebel
Zero redeployment with JRebel
 
eXo Platform company overview 2012
eXo Platform company overview 2012eXo Platform company overview 2012
eXo Platform company overview 2012
 
Java application server in the cloud
Java application server in the cloudJava application server in the cloud
Java application server in the cloud
 
AOP-IOC made by Vi Quoc Hanh and Vu Cong Thanh in SC Team
AOP-IOC made by Vi Quoc Hanh and Vu Cong Thanh in SC TeamAOP-IOC made by Vi Quoc Hanh and Vu Cong Thanh in SC Team
AOP-IOC made by Vi Quoc Hanh and Vu Cong Thanh in SC Team
 
Exo presented at OW2con11, Nov 24-25, 2011, Paris
Exo presented at OW2con11, Nov 24-25, 2011, ParisExo presented at OW2con11, Nov 24-25, 2011, Paris
Exo presented at OW2con11, Nov 24-25, 2011, Paris
 
Discovery the p2 API (updated to Indigo)
Discovery the p2 API (updated to Indigo)Discovery the p2 API (updated to Indigo)
Discovery the p2 API (updated to Indigo)
 
Jvm mbeans jmxtran
Jvm mbeans jmxtranJvm mbeans jmxtran
Jvm mbeans jmxtran
 
P2 Introduction
P2 IntroductionP2 Introduction
P2 Introduction
 
Ny symfony meetup may 2015
Ny symfony meetup may 2015Ny symfony meetup may 2015
Ny symfony meetup may 2015
 
Introduction to MonoTouch
Introduction to MonoTouchIntroduction to MonoTouch
Introduction to MonoTouch
 
Switch to alfresco with wasaaiq [compatibility mode]
Switch to alfresco with wasaaiq [compatibility mode]Switch to alfresco with wasaaiq [compatibility mode]
Switch to alfresco with wasaaiq [compatibility mode]
 
ICON Introduction and Roadmap
ICON Introduction and RoadmapICON Introduction and Roadmap
ICON Introduction and Roadmap
 
javagruppen.dk - e4, the next generation Eclipse platform
javagruppen.dk - e4, the next generation Eclipse platformjavagruppen.dk - e4, the next generation Eclipse platform
javagruppen.dk - e4, the next generation Eclipse platform
 
EMC World 2016 12 Factor Apps FTW
EMC World 2016 12 Factor Apps FTWEMC World 2016 12 Factor Apps FTW
EMC World 2016 12 Factor Apps FTW
 
Next Generation Portals : How OpenSocial Standard Adds Social to the Mix?
Next Generation Portals : How OpenSocial Standard Adds Social to the Mix? Next Generation Portals : How OpenSocial Standard Adds Social to the Mix?
Next Generation Portals : How OpenSocial Standard Adds Social to the Mix?
 
eXo Platform Company overview Oct 2012
eXo Platform Company overview Oct 2012eXo Platform Company overview Oct 2012
eXo Platform Company overview Oct 2012
 
Enabling IoT Devices’ Hardware and Software Interoperability, IPSO Alliance (...
Enabling IoT Devices’ Hardware and Software Interoperability, IPSO Alliance (...Enabling IoT Devices’ Hardware and Software Interoperability, IPSO Alliance (...
Enabling IoT Devices’ Hardware and Software Interoperability, IPSO Alliance (...
 
webOS App by Example: Sorting Thoughts
webOS App by Example: Sorting ThoughtswebOS App by Example: Sorting Thoughts
webOS App by Example: Sorting Thoughts
 
ECM and Open Source Software: A Disruptive Force in ECM Solutions
ECM and Open Source Software: A Disruptive Force in ECM SolutionsECM and Open Source Software: A Disruptive Force in ECM Solutions
ECM and Open Source Software: A Disruptive Force in ECM Solutions
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

IOC and AOP presentation

  • 1. A O P & IO C V u Co n g T h a n h V i Qu o c Ha n h Social team www.exoplatform.com Copyright 2011 eXo Platform
  • 2. Agenda  W h a t is IO C ?  IO C – Tim e o f In je c t o r  IO C – P r o s & C o n s  IO C - S c o p e  De mo www.exoplatform.com 2 Copyright 2011 eXo Platform
  • 3. In v e r s io n O f C o n t r o l ( IO C ) www.exoplatform.com Copyright 2011 eXo Platform
  • 4. WHAT IS “DEPENDENCY”? www.exoplatform.com 4 Copyright 2011 eXo Platform
  • 5. Implementation with NOT IOC » Construction by Hand. » Factory Pattern. www.exoplatform.com 5 Copyright 2011 eXo Platform
  • 6. Dependencies Problems » Code is tightly coupled » Difficult to isolate when testing » Difficult to maintain. www.exoplatform.com 6 Copyright 2011 eXo Platform
  • 7. What is IOC? » Hollywood principle “Don't call us, we'll call you.” » Creating, Assembling and Wiring the dependencies into Object graph. » Type of Dependency Injector: – Constructor – Setter – Method – Field(Guice) www.exoplatform.com 7 Copyright 2011 eXo Platform
  • 8. IOC: Pros and Cons » Pros: – Loosely Coupled – Increases Tesability – Separates component clearly. – Allows for use of Inversion of Control Container. » Cons: – Increases code complexity – Difficult to understand at First – Complicate Debugging at First – Complicates following Code Flow. www.exoplatform.com 8 Copyright 2011 eXo Platform
  • 9. Time for Injector - BoorStrapping the Injector » Constructed and prepared before it can be used. – In the init lifecycle stage of a web application. – On startup of a desktop program www.exoplatform.com 9 Copyright 2011 eXo Platform
  • 10. IOC - Metadata and Injector Configuration » XML configuration file. » Annotations(@Injector, @Singleton, …) » Invoking into a programmatic API. www.exoplatform.com 10 Copyright 2011 eXo Platform
  • 11. Boorstrapping the Injector(Cont) » Constructed and prepared before it can be used. – On demand, every time it is needed – Lazily, when it is first needed www.exoplatform.com 11 Copyright 2011 eXo Platform
  • 12. IOC - What is Scope? Fixed duration of time or method calls in which an object exist. General-purpose scopes: Singleton and No-scope. » Web Application: – Request, Session and Conversation scope – Transaction scope www.exoplatform.com 12 Copyright 2011 eXo Platform
  • 13. IOC - Benefit of Scope » Lets injector manage the latent state of your objects » Ensures that your services get new instances of dependencies as needed » Implicitly separates state by context. www.exoplatform.com 13 Copyright 2011 eXo Platform
  • 14. DEMO www.exoplatform.com Copyright 2011 eXo Platform
  • 15. Wha t? www.exoplatform.com Copyright 2011 eXo Platform
  • 16. What? www.exoplatform.com 16 Copyright 2011 eXo Platform
  • 17. What? AOP - Enables encapsulation of functionality that affects multiple classes in separate units - Complements object oriented programming - Is not about “patching” pieces of code. About performing an action systematically upon recognition of a behavior in the code. www.exoplatform.com 17 Copyright 2011 eXo Platform
  • 18. Why? Benefits: - Separates persistence and specific functionality (logging, security...) - Promotes code reuse and modularization - Decouples codes (the LogFactory from the DAO impl’s) www.exoplatform.com 18 Copyright 2011 eXo Platform
  • 19. AOP vs OOP Object Oriented Aspect Oriented Class – code unit that Aspect – code unit that encapsulates methods and encapsulates pointcuts, advice, attributes. and attributes. Method signatures – define Pointcut – define the set of the entry points for the entry points (triggers) in which execution of method bodies. advice is executed. Method bodies – Advice – implementations of the implementations of the cross cutting concerns. primary concerns. Compiler – converts source Weaver – instruments code code into object code. (source or object) with advice. www.exoplatform.com 19 Copyright 2011 eXo Platform
  • 20. Concepts - Crosscutting Concerns - Aspect: The merger of advice and pointcuts. All information about where, when and what job is to be done. - Advice: The job of an aspect. Defines the what and when of an aspect. - Pointcut: Pointcuts help narrow down the joinpoints advised by an aspect. Define the where of an aspect. - Joinpoint: A point in the execution of an application where an aspect can be plugged in. All the opportunities for advice to be applied. www.exoplatform.com 20 Copyright 2011 eXo Platform
  • 21. Concepts - Target: Object being advised. - Proxy: The object created after applying advice to the target object. To the client making use of the target object the proxy looks the same. - Weaving: Process of applying aspects to a target object to create a new, proxied object. www.exoplatform.com 21 Copyright 2011 eXo Platform
  • 22. How it works? www.exoplatform.com 22 Copyright 2011 eXo Platform
  • 23. www.exoplatform.com 23 Copyright 2011 eXo Platform
  • 24. Th a n k yo u ! www.exoplatform.com Copyright 2011 eXo Platform

Notes de l'éditeur

  1. SEO considers how search engines work, what people search for, the actual search terms typed into search engines and which search engines are preferred by their targeted audience. SEM: Search engine marketing, (SEM), is a form of Internet marketing that seeks to promote websites by increasing their visibility in search engine result pages (SERPs) through the use of paid placement, contextual advertising, and paid inclusion. The acronym "SEOs" can refer to "search engine optimizers," a term adopted by an industry of consultants who carry out optimization projects on behalf of clients, and by employees who perform SEO services in-house