Click here to load reader
Upload
bemyapp
View
573
Download
3
Embed Size (px)
DESCRIPTION
David Caroseli | Java Annotation Processors And Domain Model Objects Spiegherò brevemente cos'è un Annotation Processor e come può essere usato per farci risparmiare molto tempo ed avere del codice altamente efficiente. Gli oggetti del modello di dominio sono solitamente delle classi Java con funzionalità standard che sono semplici quanto noiose da scrivere e da tenere aggiornate. I processori di annotazioni possono esserci utili per automatizzare questo processo ed avere del codice sempre aggiornato e non dover rinunciare all'efficienza.
Citation preview
+
Davide Caroselli, CTO at Pubster [email protected]
Java Annotation Processors &
Domain Model Objects
+Domain Model Objects
Pub
Deal
PubsterLite Domain Model
• ID [long] • Name [String] • Address [String] • Latitude [double] • Longitude [double]
• ID [long] • Name [String] • Coins [int] • Type [long]
+Coding…
n Getter methods
n Setter methods
n JSON serialization and deserialization methods
n Parcelable serialization and deserialization methods
n …
FOR EACH DOMAIN MODEL CLASS !
+Java Reflection
n Easy to use
n Its behaviour can be customized
n It works!
n Bad performances
n Not ALL the code could be automatized (getter and setter)
n Could not be used for every task, or for very specific implementation logic
PRO CONS
+Java Annotation Processor CODENAME: Automagically!
+Java Annotation Processor CODENAME: Automagically!
n Annotations n “Mark” the code in a given point to attach a sort of meta-
data that the Java Compiler or Runtime Environment can parse and use.
n Java Annotation Processor n A processor that run at compile-time and could add brand
new source files to the build. It can “read” the Annotations in the code.
Demo
+Want more?
n Any model-level common logic methods (normalization, validation…)
n SQLite serialization and deserialization methods
n Maybe lazy load getter and setter ? n Fetch objects when you need to!
Want EVEN more ?
+iOS or Windows Phone Domain Model Class