27
OBJECT-TO-OBJECT MAPPING © OLEKSII DUKHNO @ LOHIKA SYSTEMS

O 2-o

Embed Size (px)

Citation preview

Page 1: O 2-o

OBJECT-T

O-OBJE

CT

MAPPIN

G

© O L E K S I I D U K H N O @ L O H I K A S Y S T E M S

Page 2: O 2-o

COMPLEXITY OF SOFTWARE

Page 3: O 2-o

ABSTRACTIONS AND MODEL

Page 4: O 2-o

ABSTRACTIONS AND MODEL

Модель представ ляет собой специально отобранный и сознательно упрощенный запас знаний (набор данных) Представленный в структу рированной форме.

Page 5: O 2-o

DDD AS THE TOOL

Page 6: O 2-o

DTO AND VIEW MODEL

DTO• Model data only

View Model• Model data and behavioral

aspects

Page 7: O 2-o

WHY USING O-2-O WITH DDD?

Layers are independent

Code aligning

Flattening logic encapsulation

Page 8: O 2-o

RESULTS USING DDD WITH O-2-O ?

Neater code

Simpler support

Better understanding

Page 9: O 2-o

SAMPLES - DATA LAYER

Page 10: O 2-o

SAMPLES – SERVICE LAYER

Page 11: O 2-o

SAMPLES – APPLICATION LAYER

Page 12: O 2-o

MODELS, DATA TRANSFER OBJECTS AND VIEW MODELS

Page 13: O 2-o

HOME-GROWN OVER “OPERATOR” KEYWORD

Code template:• public static implicit operator DTO_Type ( Entity_Type

entity)

Open sample

Page 14: O 2-o

HOME-GROWN OVER EXTENSION METHODS

Code template:• public static DTO_Type ToDTO ( this Entity_Type photo

)

Open sample

Page 15: O 2-o

HOME-GROWN OVER SEPARATE CLASS

Instructions:• Define static or singleton class• Implement conversion methods explicitly

Open sample

Page 16: O 2-o

EMIT MAPPER KEY SUFFICIENCIES

Fast (close to hand written code)

Supports mono

Pretty extensible

Page 17: O 2-o

EMIT OBJECT MAPPERS

Page 18: O 2-o

EMIT MAPPERS FACTORY

Page 19: O 2-o

EMIT MAPPER CONFIGURATION

Page 20: O 2-o

EMIT MAPPER

Standard

Custom converter

Post processing

Custom configurator

Page 21: O 2-o

OTIS

Metadata 

Configuration file

Custom mapping providers

Page 22: O 2-o

OTIS

Metadata 

Configuration file

Custom mapping providers

No DateTime and nullable value types support!

Page 23: O 2-o

AUTOMAPPER

Mapping Through

Convention

Source/Destination Properties Names Convention

Mapping Through

Configuration

Projection

Type Converter

Value Resolver

Ignore

Test Mapping

Validate Configurati

on

Page 24: O 2-o

USING AUTOMAPPER IN THE ALLOCINE-CMS

Page 25: O 2-o

USING AUTOMAPPER IN THE ALLOCINE-CMS

Page 26: O 2-o

THE OTHERS OPTIONS

Entities to DTOs

T4 templates – To be continued

Page 27: O 2-o

MAPPERS SUMMARY TABLE

/// Style Facade

Speed

Open Source

Reliability

Silverlight

Manuals

Cost

Emit Mapp

er

Procedural

No The Best

Yes Low Yes Poor Mid

Auto Mapp

er

Object Oriented

Yes Good Yes High Yes Good Low

Home-

grown

Any Depends

Depends

Could be

Depends Yes Depends High