Karumi is the beauty of ordinary things spoken of in a simple way.
Offline first
Adam Tornhill
“Offline is not an error, Offline is a fact of mobile life.”Alex Feyerke
Adam Tornhill
“Once out of bed, internet and apps are used almost constantly, peakin during the
daily commute with 70 percent usage.”Ericsson.
Traffic and Market Report, june 2012
Mem Cache
Mem CacheBe careful with OutOfMemories.
Mem Cachecache2k DANGER!!!!!
Mem Cache“There are only two hard things in
Computer Science: cache invalidation and naming things.”
Phil Karlton
Shared Preferences
Mem CacheA Key value xml file.
Mem Cachecommit vs apply.
Mem CacheAre not thread save.
Mem CacheShared preferences has cache. Be careful with StringSets.
Databases
Mem CacheDon’t Use a sledgehammer to crack a nut.
Mem CacheSerialize JSON to disk can be an option if you don’t need queries.
Mem CacheORMs as ORMLite is a good solution.
I like ORMLite over GreenDAO and SugarORM.
Mem CacheRealm is not an ORM. Not SQL. Fast. Good
choice. Be careful sharing info between threads.
Network
Mem CacheNetwork is other kind of persistence.
Mem CacheUse Retrofit only if your api is REST.
Content Providers
Mem CacheThe way to share information between apps and processes.
Mem CacheIt’s not mandatory use a database behind
the content provider. You can use a MatrixCursor.
Repository pattern
Mem CachePersistence and network invasion.
Mem Cache Minimize duplicate query logic.
Mem Cache
“Use a repository to separate the logic that retrieves the data and maps it to the entity model from the business logic that
acts on the model. The business logic should be agnostic to the type of data that
comprises the data source layer. For example, the data source layer can be a
database, a SharePoint list, or a Web service.”
Msdn.
Client Business Logic
Data Mapper
Data Source
Query Object
Business Entity
Persist
Query
Business Entity Data
SourceData Mapper
Repository
Data Mapper
UsersRealmStorage
IQuery
UserApiModel
Persist
Query
User
UsersApiData Mapper
Repository
User
findById(id)
BibliographyThey’re the cracks!
Offline first. Alex Feyerke. May 2014. Webdirections Patterns of Enterprise Application Architecture. Martin Fowler Domain driven design. Eric J. Evans The Repository Pattern. Msdn Software design patterns. Pedro Vicente Gomez. Droidcon Spain 2013