Upload
mozaic-works
View
54
Download
0
Embed Size (px)
Citation preview
Programmer@Ambientia
skype: @rinkkasatiainentwitter: @rinkkasatiainenemail: [email protected]
Wednesday, May 20, 15
Content
• Background• A way to solve• Discussion• Open Space: Mob Programming?
Wednesday, May 20, 15
/INDEX (1 of many actions)
ParamsService
“DAO”“or not DAO”
DAO-DAO-DAO
ServiceService
DomainServiceRender
Wednesday, May 20, 15
What did we see
• build parameters• build context (on 2 places)• build domain• render different data, differently, based
on the domain entity
Wednesday, May 20, 15
..sort of
• most of the bugs I introduced, were on this behavior of the system.• This class• Concepts introduced by this class• Integration with Confluence API
• especially ‘null’s
Wednesday, May 20, 15
What IF...C’s responsibility
• Given a set of parameters...• Build Model (service / repository) • Render Template with model given
• and let other’s to figure out which template to render
Wednesday, May 20, 15
Decorate / Exhibit
Controller
HTTP GET
Domain
View
Exhibit
1) build model
2) render
3) exhibit
View tmpl
4) render
Wednesday, May 20, 15
few design decision done by me
• avoid nulls • separate Read Model from Write Model• 1st class collections• Separated Query and Command
Controller (sort of CQRS)
Wednesday, May 20, 15
Domain Entity: Group
<if> ReadOrWriteModel
<if> ReadModel <if> WriteModel
GroupEntity GroupDescrGroupList
Wednesday, May 20, 15
Domain Entity: Group
<if> ReadOrWriteModel
<if> ReadModel <if> WriteModel
GroupEntity GroupDescrGroupList
Wednesday, May 20, 15
Domain Entity: Group
GroupEntity* immutable
* final private prop* behavior rich
GroupDescriptor* public properties
* tiny behavior
AGroupThatDoesNotExistYet
AGroup
Wednesday, May 20, 15
Domain Entity: Group
<if> ReadOrWriteModel
<if> ReadModel <if> WriteModel
GroupEntity GroupDescrGroupList
Wednesday, May 20, 15
Exhibit Characteristics
• Wraps a single model instance• Is a true Decorator• Brings together model and context• Encapsulates the decision about how to
render an object• May modify the behavior of an object
Wednesday, May 20, 15
Exhibits: Group
<if> Exhibit+ renderBody()
GroupListExh GroupList
GroupExhibit GroupEntity
EditGroupExh GroupDesc
GroupWPicture
Wednesday, May 20, 15
Exhibits: Group
GroupListExh ListView
GroupExhibit ShowGroup
EditGroupExh GroupDesc
GroupWPicture ShowGPicture
Wednesday, May 20, 15
REST viewHTTP PATH Contr#Action Domain Class
GET /foo(.:format) foos#index FooList
POST /foo(.:format) foos#create FooDescriptor
GET /foo/new foos#new FooDescriptor
GET /foo/:id/edit foos#edit FooDescriptor
GET /foo/:id foos#show FooEntry
PATCH/PUT /foo/:id foos#update FooDescriptor
DELETE /foo/:id foos#delete FooDescriptor
Wednesday, May 20, 15
Creating exhibits
public exhibit(ReadWriteModel model){for_each( exhibit: exhibit_classes ){
if( exhibit.applicableTo( model )// wrap model to exhibit and serve exhibit as new model
}}
Wednesday, May 20, 15
RemotePictureExhibit ||DefaultPictureExhibit
UserProfileExhibitCould be composite
Wednesday, May 20, 15
Did it work - in retrospect
• No issues in production with this code• It is not, by far, easy to grasp. Without
someone explaining
Wednesday, May 20, 15
What I did not show
• transformations of domain entities:• Request -> Write -> Persistence• Persistence -> Write (-> Read)
• Composite Exhibit - how to show 0, 1 or many concepts, dynamically, based on the ModelObject rendered
Wednesday, May 20, 15
What could I experiment
• Capabilities for exhibits• Capability.mobile• Capability.REST• Capability.json
Wednesday, May 20, 15
Thanks!Questions?
skype: @rinkkasatiainentwitter: @rinkkasatiainenemail: [email protected]
Wednesday, May 20, 15