Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Android Aspect Oriented Programming

Android Aspect Oriented Programming

This is an introduction to aspect oriented programming in Android. It also introduces Frodo Android Library based on AOP for logging RxJava Observables and Subscribers.

Fernando Cejas

July 15, 2015
Tweet

More Decks by Fernando Cejas

Other Decks in Programming

Transcript

  1. Aspect Oriented
    Programming
    Frodo Android Library
    +
    @fernando_cejas
    http://www.fernandocejas.com

    View Slide

  2. Aspect Oriented Programming
    title, date, 01 of 10
    In computing, aspect-oriented programming
    (AOP) is a patented programming paradigm
    that aims to increase modularity by allowing the
    separation of cross-cutting concerns.
    https://github.com/android10/frodo

    View Slide

  3. AOP Terminology
    title, date, 01 of 10
    ● Cross-cutting concerns: Cohesive areas of functionality
    across an application.
    ● Advice: The code that is injected to a class file.
    ● Joint point: A particular point in a program that might be the
    target of code injection.
    ● Pointcut: An expression which tells a code injection tool
    where to inject a particular piece of code.
    ● Aspect: The combination of the pointcut and the advice is
    termed an aspect.
    ● Weaving: The process of injecting code – advices – into the
    target places – joint points.

    View Slide

  4. AOP Terminology
    title, date, 01 of 10

    View Slide

  5. Where can we apply AOP?
    title, date, 01 of 10
    ● Logging
    ● Persistence
    ● Performance monitoring
    ● Data Validation
    ● Caching
    ● Etc...
    https://github.com/android10/frodo

    View Slide

  6. Where does the magic happen?
    title, date, 01 of 10
    ● Run-time
    ● Load-time
    ● Build-time
    https://github.com/android10/frodo

    View Slide

  7. Tools and Libraries
    title, date, 01 of 10
    ● AspectJ: A seamless aspect-oriented extension to the
    Javatm programming language (works with Android).
    ● Javassist for Android: An android porting of the very well
    known java library Javassist for bytecode manipulation.
    ● DexMaker: A Java-language API for doing compile time or
    runtime code generation targeting the Dalvik VM.
    ● ASMDEX: A bytecode manipulation library as ASM but it
    handles the DEX bytecode used by Android executables.

    View Slide

  8. Why AspectJ?
    title, date, 01 of 10
    ● Very powerful.
    ● Supports build time and
    load time code injection.
    ● Easy to use.
    https://github.com/android10/frodo

    View Slide

  9. title, date, 01 of 10
    Frodo

    View Slide

  10. Frodo
    title, date, 01 of 10
    It is an aspect oriented library for logging/tracing
    based on Annotations:
    ● @RxLogObservable
    ● @RxLogSubscriber
    https://github.com/android10/frodo

    View Slide

  11. Frodo
    title, date, 01 of 10
    https://github.com/android10/frodo

    View Slide

  12. Frodo
    title, date, 01 of 10

    View Slide

  13. Frodo
    title, date, 01 of 10
    ● Annotations Module
    ● Library Runtime
    ● Gradle Plugin

    View Slide

  14. How to use Frodo?
    title, date, 01 of 10
    https://github.com/android10/frodo

    View Slide

  15. How to use Frodo?
    title, date, 01 of 10

    View Slide

  16. Frodo
    title, date, 01 of 10
    ● Generated code?
    ● Performance?

    View Slide

  17. Thanks!
    title, date, 01 of 10
    http://www.fernandocejas.com/

    View Slide