Escolar Documentos
Profissional Documentos
Cultura Documentos
ThePOJOantipatternanddatacentricdesign|Antonyh
ANTONYH
Development & stuff
About Me
Adobe AEM & CQ5
Development
The POJO
antipattern and
data-centric design
DEVELOPMENT
0 COMMENTS
The POJO antipattern is established when developers create plain java objects
that have no behaviour, only getters and setters. Its an insidious misuse of object
orientation and causes application code to be too data-centric in the name of datahttp://antonyh.co.uk/2014/01/thepojoantipattern/
1/4
29/12/2014
ThePOJOantipatternanddatacentricdesign|Antonyh
orientation and causes application
code to be too data-centric in the name of data-
modelling, abstraction, and persistence when there are many reasons to avoid this
style of coding.
Carcar=newCar()
car.setDriver(driver)
car.setPassengers(setOfPassengers)
car.setDirection(Compass.NORTH)
car.setSpeedMph(88)
All this is very well and good, expect it isnt. By error, its possible to set a speed
without a driver or a direction. It also doesnt actually do anything once its set,
theres no logic. Its like a car without an engine.
The worst part about POJOs is that its utterly pointless writing unit tests for them,
making them an antagonist in the world of TDD. They artificially change coverage
percentages purely by their presence, and help hide other code that should be
tested.
Carcar=newCar(location)
car.drive(destination,driver,passengers)
Less code, more validation, better logic, and its still can be persisted using
serialisable variables if needed.
http://antonyh.co.uk/2014/01/thepojoantipattern/
2/4
29/12/2014
ThePOJOantipatternanddatacentricdesign|Antonyh
PREVIOUS POST
NEXT POST
A reason to calibrate
colours on OS X
0Comments
antonyh.co.uk
Login
Share Favorite
SortbyBest
Startthediscussion
Bethefirsttocomment.
WHAT'STHIS?
ALSOONANTONYH.CO.UK
AnIntroductiontoCQ5forArchitects
JavaCMSRoundup
3comments10monthsago
4comments10monthsago
http://antonyh.co.uk/2014/01/thepojoantipattern/
3/4
29/12/2014
ThePOJOantipatternanddatacentricdesign|Antonyh
NitinShingneAnthonyAppreciate
AntonyHutchisonGoodpoint,Liferay
thepost.Veryhelpful.
ismissingfromthisroundup.AtthetimeI
classifieditasaportalwhenIwasmore
interestedinpureCMSproducts.This
VagrantVMsforTomcatorMongoDB
Developers
AvoidcreatingMicrosites
2comments10monthsago
2comments7monthsago
AntonyThankyou,yoursupportis
appreciated.
AntonyHutchisonIhaveanditseems
toworkwell.ThekeyistomaketheVM
disposable,sodon'tputCQ/AEMinthe
VMfilesystem(putitinthelocal
Subscribe
AddDisqustoyoursite
Privacy
http://antonyh.co.uk/2014/01/thepojoantipattern/
4/4