Post on 04-Jul-2015
transcript
Developing Social Network using ORM
By N.S.Devaraj
Good Afternoon!!
Agenda
ORM Introduction
Why ORM ?
How to use ORM ?
Why Generic DAO / Persistent Collections ?
Social Networking Application
Demo
Questions ?
OMG WTF ORM ?
Object-Relational Mapping
maps objects to relational databases maps relational databases to objects
a programming technique for converting data between incompatible type systems in object-oriented programming languages - WikiPedia
Why ORM ?
The ORM World
Full on Objects of objects
Beans Not much else
Classic Procedural with DAO’s
Less DB Work
More DB Work
Procedural Object-Oriented
How to use ORM
to achieve, we need DI / IoC framework (Swiz)
a GenericDAO to be created to manage Business Logic
a Persistent Data collection to reduce server calls
supported with a Push Mechanism to be Sync with Data Source & for Conflict Management
ORM have to allow the DB swap "on the fly"
Data Access Object
DAO is used to do CRUD
operations and access with
Database tables, used to achieve encapsulation
Each DAO instance is
responsible for one primary
domain object or entity.
an object that provides an abstract interface to some types of database or persistence mechanism. - WikiPedia
Why we need GenericDAO?
Mostly we deal with
multiple VO’s to be queried from service
layer.
Using MVC Framework, while dealing with n x VO, we end up with
n x Delegates
n x Commands
n x Events
With GenericDAO, the business logic will be in generic
code.
Unit testing is damn easy
as we can inject values
Advantages
Increases productivity
Apply DRY (Don’t Repeat Yourself)
Principle
Reduces errors
Easy for Unit Testing
Server DAO Model
Data Source
Data Access Object
Business Object
Client
Value Object
Abstract Real World Example
Create, Read, Update, Delete
Delegates CRUD Operations to
calls
creates
receives
SQL Table: Notes
Notes DAO
Library Service
Flex RIA
NoteVO
receives
Perform SQL Queries
Communicates with
Maps SQL Records to
Delegates CRUD Operations to
Client DAO Model
Business Object
DAO
Events
View
VO
Abstract
Create, Read, Update, Delete
Delegates CRUD Operations to
dispatches
creates
receives
PC
Push
Delegate Update Notes Beans
Generic DAO
Signals
Skinnable Component
NoteVO
Real World Example
Service Results to
receives
Perform functions
Delegates CRUD Operations to
dispatches
PC
Push
Delegate Update
Why Persistent Collections?
Social Network App
Persons
Notes(updates) – files, replies
Connections
Value Objects Required
DEMO
Questions ?
Thanks For
Twitter @nsdevaraj
GTalk nsdevaraj
Blog http://nsdevaraj.wordpress.com
Code https://github.com/nsdevaraj/SwizDAO
Web http://www.adamstudio.in