Aspect Oriented Programming (AOP) - A case study in Android

Preview:

Citation preview

AOP

A case-study in Android

by

Carlos Anjos

anjosc@imeshine.com

Why ?

Developing for Android

● The 5 stages of grief● Denial

– “This can't be that bad, I must be missing something ...”● Anger

– “WTF did they have to reinvent the wheel … for the worse ?!”● Bargaining

– “Maybe I can find a port of my favorite framework for android … Err.... Maybe I can patch it to make it work ...”

● Depression– “Nothing works … nothing will ever work … :'-( Maybe I should stick to

doing HTML and Javascript ...“● Acceptance

– “Oh well … let's start coding !” - «Resistance is futile»

Real men don't eat honey, they chew bees !

What is AOP ?

AspectJ

AspectJ – Java AOP

● Cross-cutting concerns

AOP - Weaving

Source: AspectJ in Action

AOP – Like Themes

Concepts

•Jointpoint

•Pointcut

•Advice

•Aspect

How AspectJ implements AOP

Source code weavingBinary weaving

Load Time weaving

How it works

How it works

How it works (with Android)

The case study

AspectJ FTW!

}

AspectJ - Level 2

AspectJ – Level 3

AspectJ - Level 4

AspectJ – Level 5

AspectJ – Level 6

AspectJ – Level 7

AspectJ – Level 8

AspectJ – Level 100

AspectJ – Over 9000 !

Paradigm Shift !

Careful …

don't try to solve everything with aspects !

OOP is still good ! :-)

“Perfection is achieved, not when there is nothing more to add,

but when there is nothing left to take away.”

Antoine de Saint-Exupéry

Resources

● AspectJ in Action, Ramnivas Laddad● http://www.eclipse.org/aspectj/● http://www.eclipse.org/ajdt/● http://android.imeshine.com/

● stackoverflow.com

● commonsware.com● apps.sapo.pt● developer.android.com

Questions ?

Recommended