Axa Assurance Maroc - Insurer Innovation Award 2024
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
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
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
24. Th a n k yo u !
www.exoplatform.com
Copyright 2011 eXo Platform
Notas do Editor
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