SlideShare a Scribd company logo
The	
  Open	
  Closed	
  Principle	
  
	
  
Part	
  I	
  
The	
  Original	
  Version	
  
	
  
©	
  2014	
  Philip	
  Schwarz	
  
h>ps://twi>er.com/philip_schwarz	
  
philip.johann.schwarz@gmail.com	
  
	
  
	
  
	
  
This	
  work	
  is	
  licensed	
  under	
  a	
  
CreaHve	
  Commons	
  A>ribuHon-­‐NonCommercial-­‐NoDerivs	
  3.0	
  Unported	
  License.	
  
Tension	
  Between	
  
known	
  	
  
needs	
  	
  
of	
  today	
  
changes	
  that	
  
will	
  arrive	
  in	
  
the	
  future	
  
Sandi	
  Metz	
  
The	
  Fundamental	
  Target	
  of	
  
Design	
  
Code	
  needs	
  to	
  
work	
  today	
  just	
  
once,	
  
and	
  it	
  needs	
  to	
  be	
  easy	
  to	
  change	
  forever	
  
It	
  is	
  at	
  this	
  point	
  of	
  tension	
  
where	
  design	
  ma2ers	
  
today’s	
  
needs	
  	
  
future	
  
changes	
  
its	
  purpose,	
  its	
  enHre	
  reason	
  
for	
  being,	
  is	
  to	
  reduce	
  the	
  
cost	
  of	
  change.	
  
	
  
1999	
  
3rd	
  Apr	
  2014	
  	
  
@KentBeck	
  design	
  is	
  irrelevant	
  for	
  today.	
  it	
  only	
  ma2ers	
  when	
  we	
  want	
  to	
  change	
  the	
  
so9ware...	
  
@KentBeck	
  change	
  is	
  the	
  only	
  reason	
  to	
  organize	
  so9ware	
  at	
  all…	
  
adopted	
  by	
  agile	
  
community	
  as	
  a	
  truth	
  
about	
  soZware	
  
development	
  
Henrik	
  	
  
Christensen	
   2010	
  
“soZware	
  must	
  be	
  designed	
  and	
  developed	
  to	
  
make	
  it	
  easy	
  to	
  change”	
  
Let’s	
  examine	
  soZware	
  qualiHes	
  that	
  enable	
  
ease	
  of	
  change	
  	
  
Look	
  for	
  definiHons	
  in	
  ISO	
  9126	
  
Projects	
  someHmes	
  fail	
  due	
  to	
  not	
  having	
  any	
  clear	
  	
  
defini=ons	
  of	
  "success”	
  
This	
  standard	
  tries	
  to	
  develop	
  a	
  common	
  understanding	
  of	
  
project	
  objec=ves	
  and	
  goals,	
  e.g.	
  soZware	
  qualiHes	
  
SoZware	
  is	
  Reliabile	
  if	
  it	
  can	
  maintain	
  a	
  
specific	
  level	
  of	
  performance	
  under	
  specific	
  
usage	
  condiHons	
  
in	
  our	
  secng…	
  
In	
  parHcular,	
  we	
  are	
  interested	
  in	
  
preserving	
  reliability	
  in	
  the	
  face	
  of	
  change	
  	
  
SoZware	
  is	
  Reliabile	
  if	
  it	
  can	
  perform	
  the	
  
required	
  func=ons	
  without	
  failing	
  	
  
“maintainability	
  is	
  composed	
  of	
  
several,	
  finer	
  grained,	
  qualiHes”	
  
Analysability	
  
Maintainability	
  
Changeability	
   Stability	
   Testability	
  
SoZware	
  is	
  Analysable	
  if	
  you	
  can	
  
•  diagnose	
  it	
  for	
  	
  
§  deficiencies	
  
§  causes	
  of	
  failure	
  
•  idenHfy	
  the	
  parts	
  to	
  be	
  modified	
  
“Analysability	
  is	
  basically	
  the	
  ability	
  to	
  understand	
  
soZware”	
  
Analysability	
  
Maintainability	
  
Changeability	
   Stability	
   Testability	
  
SoZware	
  is	
  changeable	
  if	
  it	
  allows	
  you	
  to	
  
•  implement	
  a	
  specific	
  modificaHon	
  
•  add,	
  modify,	
  or	
  enhance	
  a	
  feature	
  	
  
	
  	
  	
  	
  at	
  a	
  reasonable	
  cost	
  
“almost	
  all	
  Design	
  Pa2erns	
  are	
  	
  
geared	
  towards	
  increasing	
  	
  
design’s	
  changeability”	
  
Analysability	
  
Maintainability	
  
Changeability	
   Stability	
   Testability	
  
“SoZware	
  is	
  flexible	
  if	
  you	
  can	
  add/enhance	
  	
  
func=onality	
  purely	
  by	
  adding	
  so9ware	
  units	
  
and	
  specifically	
  not	
  by	
  modifying	
  exis=ng	
  
so9ware	
  units”	
  
Flexibility	
   a	
  special	
  case	
  of	
  
changeability	
  
Changeability	
  
Behavioural	
  changes	
  that	
  are	
  introduced	
  
by	
  modifying	
  exisHng	
  producHon	
  code	
  
Changeability	
  is	
  a	
  desirable	
  quality,	
  	
  
but	
  it	
  relies	
  on	
  
Change	
  by	
  Modifica=on	
  
Change	
  by	
  	
  
ModificaHon	
  
“The	
  less	
  I	
  ever	
  modify	
  a	
  class,	
  the	
  higher	
  the	
  probability	
  that	
  
it	
  will	
  remain	
  free	
  of	
  defects”	
  
ModificaHons	
  carry	
  the	
  risk	
  of	
  introducing	
  defects,	
  and	
  the	
  
necessary	
  cost	
  of	
  avoiding	
  them:	
  tesHng,	
  code	
  reviewing,	
  etc.	
  
Behavioural	
  changes	
  that	
  are	
  introduced	
  
by	
  modifying	
  exisHng	
  producHon	
  code	
  
Change	
  by	
  	
  
ModificaHon	
  
Change	
  by	
  	
  
AddiHon	
  
Behavioural	
  changes	
  that	
  are	
  introduced	
  by	
  
adding	
  new	
  producHon	
  code	
  instead	
  of	
  
modifying	
  exisHng	
  code	
  
Contrast	
  	
  
Change	
  by	
  Addi=on	
  avoids	
  (risky)	
  modifica=ons	
  altogether	
  
with	
  
Changeability	
  
Change	
  by	
  	
  
AddiHon	
  
Change	
  by	
  	
  
ModificaHon	
  
Changeability	
  does	
  not	
  take	
  a	
  stand	
  point	
  with	
  regards	
  	
  
to	
  the	
  way	
  a	
  specified	
  modificaHon	
  is	
  implemented	
  
Flexibility	
  
In	
  contrast,	
  Flexibility	
  does	
  take	
  this	
  stand	
  point	
  	
  
and	
  requires	
  that	
  no	
  modifica=ons	
  are	
  made	
  
Analysability	
  
Maintainability	
  
Changeability	
   Stability	
   Testability	
  
SoZware	
  is	
  Stable	
  if	
  it	
  avoids	
  unexpected	
  effects	
  when	
  
modified	
  
“I	
  advocate	
  the	
  pracHce	
  to	
  avoid	
  modifying	
  exis=ng	
  code	
  but	
  
preferably	
  add	
  features	
  or	
  modify	
  exis=ng	
  ones	
  by	
  other	
  
means”	
  
“any	
  change	
  to	
  exisHng	
  soZware	
  carries	
  a	
  risk	
  of	
  introducing	
  
defects”	
  
Changeability	
  
Stability	
  
Flexibility	
  
Reliability	
  
Change	
  by	
  	
  
ModificaHon	
  
Change	
  by	
  	
  
AddiHon	
  
-­‐
+ -­‐
+	
  
Summary	
  
+ supports	
  
-­‐ risks	
  undermining	
  
relies	
  on	
  
Ques=on:	
  how	
  do	
  we	
  promote	
  flexibility,	
  	
  
reliability	
  and	
  stability	
  in	
  our	
  soZware?	
  
Analysability	
  
Maintainability	
  
Changeability	
   Stability	
   Testability	
  
Flexibility	
  
Reliability	
  
Answer:	
  we	
  favour	
  ‘Change	
  by	
  Addi=on’	
  over	
  	
  
‘Change	
  by	
  Modifica=on’	
  
Changeability	
  
Stability	
  
Flexibility	
  
Reliability	
  
Change	
  by	
  	
  
ModificaHon	
  
Change	
  by	
  	
  
AddiHon	
  
-­‐
+ -­‐
+	
  
I	
  cover	
  techniques	
  that	
  
focus	
  on	
  flexibility	
  	
  
Christensen	
  
if	
  you	
  require	
  
that	
  s/w	
  can	
  
adapt	
  to	
  
changing	
  
requirements	
  
without	
  
modifying	
  
the	
  
produc=on	
  
code	
  
then	
  you	
  need	
  to	
  
employ	
  a	
  SPECIAL	
  
set	
  of	
  design	
  and	
  
programming	
  
techniques	
  as	
  well	
  
as	
  adopt	
  a	
  
SPECIAL	
  mindset	
  
“Another	
  way	
  of	
  characterising	
  
Change	
  by	
  Addi=on	
  that	
  you	
  
may	
  come	
  across	
  is	
  the	
  Open	
  
Closed	
  Principle”	
  
How	
  do	
  we	
  achieve	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  ?	
  Change	
  by	
  	
  
AddiHon	
  
The	
  Open-­‐Closed	
  Principle	
  
Modules	
  should	
  be	
  both	
  open	
  and	
  closed	
  
Bertrand	
  Meyer	
  
Object	
  Oriented	
  
SoZware	
  ConstrucHon	
  
The	
  most	
  comprehensive,	
  definiHve	
  
OO	
  reference	
  ever	
  published	
  1988	
  
Isn’t	
  there	
  a	
  contradic=on	
  	
  
between	
  the	
  two	
  terms?	
  
Modules	
  should	
  be	
  both	
  
OPEN	
  and	
  CLOSED	
  
	
  
¬(p	
  ∧	
  ¬p)	
  	
  
The	
  contradic=on	
  is	
  only	
  apparent	
  
The	
  two	
  terms	
  
correspond	
  to	
  
goals	
  of	
  a	
  
different	
  nature	
  
e.g.	
  a	
  Dutch	
  door	
  can	
  be	
  	
  
both	
  OPEN	
  and	
  CLOSED	
  
It	
  is	
  a	
  	
  
So	
  let’s	
  look	
  at	
  the	
  goals	
  of	
  the	
  OCP	
  
OCP
A	
  module	
  is	
  	
  
said	
  to	
  be	
  	
  
OPEN	
  
if	
  it	
  is	
  sHll	
  
available	
  for	
  
extension	
  
or	
  add	
  fields	
  to	
  its	
  data	
  
structures	
   Data	
  Structures	
  
fields	
  
+
operations
e.g.	
  it	
  should	
  be	
  possible	
  to	
  
expand	
  its	
  set	
  of	
  opera=ons	
  	
  
A	
  module	
  is	
  
said	
  to	
  be	
  
CLOSED	
  
If	
  it	
  is	
  available	
  
for	
  use	
  by	
  
other	
  modules	
  
Has	
  a	
  well-­‐defined,	
  stable	
  descripHon	
  	
  
(its	
  interface	
  –	
  in	
  informaHon	
  hiding	
  sense)	
  
public	
  part	
  
secret	
  part	
  
interface	
  
1	
  
can	
  be	
  compiled,	
  stored	
  in	
  a	
  library,	
  and	
  made	
  
available	
  for	
  clients	
  to	
  use	
  2	
  
in	
  the	
  case	
  of	
  a	
  design	
  or	
  specificaHon	
  module:	
  
•  approved	
  
•  baselined	
  in	
  version	
  control	
  
•  its	
  interface	
  published	
  	
  for	
  benefit	
  of	
  other	
  module	
  authors	
  
3	
  
OPEN	
  
if	
  it	
  is	
  sHll	
  
available	
  for	
  
extension	
  
CLOSED	
  
If	
  it	
  is	
  available	
  
for	
  use	
  by	
  
other	
  modules	
  
Recap	
  –	
  A	
  module	
  is…	
  
It	
  is	
  impossible	
  to	
  foresee	
  all	
  the	
  elements	
  	
  
that	
  a	
  module	
  will	
  need	
  in	
  its	
  lifeHme	
   X
The	
  need	
  for	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  ness	
  
so	
  developers	
  wish	
  to	
  keep	
  the	
  module	
  open	
  for	
  as	
  long	
  as	
  possible	
  
	
  
so	
  that	
  they	
  can	
  address	
  changes,	
  	
  
and	
  extensions	
  	
  
by	
  changing	
  elements	
  or	
  
adding	
  new	
  elements	
  
The	
  need	
  for	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  ness	
  
if	
  a	
  module	
  is	
  never	
  closed	
  unHl	
  it	
  is	
  certain	
  
that	
  it	
  contains	
  all	
  the	
  needed	
  features	
  	
  
x	
  
every	
  developer	
  would	
  always	
  be	
  waiHng	
  for	
  
compleHon	
  of	
  another	
  developer's	
  job	
  
then	
  mulH-­‐module	
  s/w	
  can	
  
never	
  reach	
  compleHon	
  x	
  
in	
  a	
  system	
  consisHng	
  of	
  many	
  modules,	
  most	
  
modules	
  will	
  depend	
  on	
  some	
  others	
  
but	
  it	
  is	
  also	
  necessary	
  to	
  close	
  modules	
  
Modules	
  should	
  be	
  both	
  open	
  and	
  closed	
  
We	
  want	
  modules	
  to	
  be	
  both	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  for	
  extension	
  and	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  for	
  modificaHon	
  
the	
  two	
  goals	
  of	
  	
  
openness	
  and	
  closedness	
  
	
  
with	
  tradi=onal	
  
techniques	
  
are	
  incompa=ble	
  
either	
  you	
  keep	
  a	
  module	
  open	
  	
  
and	
  others	
  cannot	
  use	
  it	
  yet	
  
and	
  any	
  change	
  or	
  
extension	
  can	
  trigger	
  a	
  
painful	
  chain	
  reac=on	
  of	
  
changes	
  
or	
  you	
  close	
  it	
  	
  
in	
  many	
  other	
  modules	
  
which	
  relied	
  on	
  the	
  
original	
  module	
  directly	
  
or	
  indirectly	
  
A	
  B	
   C	
  
D	
  
E	
  
A	
  module	
  and	
  its	
  clients	
  
A’	
  F	
  
G	
   H	
   I	
  
New	
  clients	
  which	
  need	
  A’,	
  an	
  adapted	
  or	
  extended	
  version	
  of	
  A	
  
Typical	
  situaHon	
  where	
  the	
  needs	
  for	
  Open	
  and	
  Closed	
  
modules	
  are	
  hard	
  to	
  reconcile	
  
=	
  	
  client	
  of	
  
With	
  non-­‐OO	
  methods,	
  	
  
there	
  seem	
  to	
  be	
  only	
  2	
  solu=ons,	
  	
  
equally	
  unsa=sfactory	
  
A	
  B	
   C	
  
D	
  
E	
  
A	
  F	
  
G	
   H	
   I	
  
SoluHon	
  1	
  
A	
  B	
   C	
  
D	
  
E	
  
A	
  F	
  
G	
   H	
   I	
  
SoluHon	
  1	
  
A	
  B	
   C	
  
D	
  
E	
  
A’	
  F	
  
G	
   H	
   I	
  
	
  	
  	
  	
  	
  	
  	
  SoluHon	
  
We	
  have	
  taken	
  a	
  copy	
  of	
  A	
  and	
  modified	
  it,	
  turning	
  it	
  into	
  the	
  desired	
  A’	
  
 	
  	
  	
  	
  	
  	
  SoluHon	
  
Meyer’s	
  Assessment	
  
the	
  consequences	
  are	
  appalling	
  
an	
  explosion	
  of	
  variants	
  	
  
of	
  the	
  original	
  module,	
  	
  
many	
  of	
  them	
  very	
  similar,	
  
but	
  never	
  quite	
  iden=cal	
  
if	
  you	
  extrapolate	
  its	
  effects	
  to	
  	
  
•  many	
  modules	
  	
  
•  many	
  modificaHon	
  requests	
  	
  
•  a	
  long	
  period	
  of	
  Hme	
  
	
  
 	
  	
  	
  	
  	
  	
  SoluHon	
  (Source	
  tree	
  copy)	
  
Christensen’s	
  Assessment	
  
Probably	
  the	
  main	
  reason	
  it	
  is	
  encountered	
  so	
  o9en	
  in	
  prac=ce	
  	
  	
  
	
  
Easy	
  to	
  explain	
  to	
  colleagues	
  &	
  new	
  developers	
  	
  
No	
  implementa=on	
  interference	
  X	
  
 	
  	
  	
  	
  	
  	
  SoluHon	
  (Source	
  tree	
  copy)	
  
Christensen’s	
  Assessment	
  
Quick	
  but	
  very	
  dangerous	
  
In	
  the	
  long	
  run	
  it	
  is	
  	
  
oZen	
  a	
  real	
  disaster…	
  
The	
  soluHon	
  has	
  severe	
  
limita=ons.	
  	
  
because	
  it	
  leads	
  to	
  the	
  	
  
mul=ple	
  maintenance	
  problem	
  	
  
 	
  	
  	
  	
  	
  	
  SoluHon	
  (Source	
  tree	
  copy)	
  
Christensen’s	
  Assessment	
  
when	
  you	
  want	
  to	
  add/modify	
  logic	
  	
  
you	
  have	
  to:	
  
•  Do	
  it	
  for	
  each	
  source	
  tree	
  
•  Write	
  the	
  same	
  test	
  cases	
  for	
  each	
  
source	
  tree	
  
you	
  have	
  to	
  do	
  it	
  in	
  	
  
each	
  source	
  tree	
  
when	
  you	
  need	
  to	
  	
  
remove	
  a	
  defect	
  	
  
DRIFT	
  
PracHce	
  shows	
  that	
  over	
  Hme	
  the	
  
source	
  trees	
  evolve	
  into	
  completely	
  
different	
  direcHons:	
  they	
  dri9	
  apart.	
  
AZer	
  a	
  while	
  it	
  is	
  more	
  or	
  
less	
  like	
  maintaining	
  a	
  set	
  
of	
  completely	
  different	
  
applica=ons	
  
At	
  that	
  point,	
  before	
  you	
  do	
  any	
  of	
  
the	
  operaHons,	
  you	
  have	
  to	
  first	
  
analyse	
  each	
  source	
  tree!!	
  
Used	
  in	
  airports	
  to	
  generate	
  reports	
  of	
  local	
  weather	
  
one	
  variant	
  for	
  each	
  airport	
  in	
  Denmark	
  
init	
  and	
  config	
  code	
  
Example	
  
SAWOS	
  -­‐	
  Semi	
  AutomaHc	
  Weather	
  ObservaHon	
  System	
  
	
  
8	
  copies!!!	
  
Analysability	
   Stability	
   Reliability	
  
soluHon	
  
-­‐ -­‐ -­‐
Summary	
  
mul=ple	
  maintenance	
  problem	
  
That	
  was	
  Meyer’s	
  first	
  unsa=sfactory	
  
soluHon	
  
to	
  the	
  problem	
  of	
  making	
  modules	
  	
  
both	
  OPEN	
  and	
  CLOSED	
  
Let’s	
  turn	
  to	
  the	
  second	
  one	
  
	
  
A	
  B	
   C	
  
D	
  
E	
  
A’	
  F	
  
G	
   H	
   I	
  
A	
  module	
  and	
  its	
  clients	
  
New	
  clients	
  which	
  need	
  A’,	
  an	
  adapted	
  or	
  extended	
  version	
  of	
  A	
  
=	
  	
  client	
  of	
  
Problem	
  
SoluHon	
  2	
  
A	
  B	
   C	
  
D	
  
E	
  
A’	
  F	
  
G	
   H	
   I	
  
Change	
  by	
  	
  
ModificaHon	
  
A+	
  B	
   C	
  
D	
  
E	
  
A’	
  F	
  
G	
   H	
   I	
  
We	
  have	
  modified	
  A	
  into	
  A+,	
  which	
  can	
  switch	
  between	
  two	
  modes	
  of	
  execuHon	
  
In	
  one	
  mode	
  it	
  behaves	
  like	
  A,	
  and	
  in	
  the	
  other	
  it	
  behaves	
  as	
  expected	
  of	
  A’	
  	
  
	
  	
  	
  	
  	
  	
  SoluHon	
  
A+	
  B	
   C	
  
D	
  
E	
  
A’	
  F	
  
G	
   H	
   I	
  
We	
  have	
  modified	
  A	
  into	
  A+,	
  which	
  can	
  switch	
  between	
  two	
  modes	
  of	
  execuHon	
  
In	
  one	
  mode	
  it	
  behaves	
  like	
  A,	
  and	
  in	
  the	
  other	
  it	
  behaves	
  as	
  expected	
  of	
  A’	
  	
  
	
  	
  	
  	
  	
  	
  SoluHon	
  
A+	
  B	
   C	
  
D	
  
E	
  
A’	
  F	
  
G	
   H	
   I	
  
If	
  (variant	
  ==	
  VARIANT_1)	
  
then	
  {	
  
	
  	
  	
  	
  ….	
  	
  
}	
  else	
  {	
  
	
  	
  	
  	
  ….	
  
}	
  	
  
At	
  points	
  of	
  varia=on,	
  A+	
  looks	
  like	
  this:	
  
We	
  have	
  modified	
  A	
  into	
  A+,	
  which	
  can	
  switch	
  between	
  two	
  modes	
  of	
  execuHon	
  
In	
  one	
  mode	
  it	
  behaves	
  like	
  A,	
  and	
  in	
  the	
  other	
  it	
  behaves	
  as	
  expected	
  of	
  A’	
  	
  
AlternaHvely,	
  this	
  can	
  	
  
be	
  a	
  switch	
  
	
  	
  	
  	
  	
  	
  SoluHon	
  
A+	
  B	
   C	
  
D	
  
E	
  
A’	
  F	
  
G	
   H	
   I	
  
	
  	
  	
  	
  	
  	
  SoluHon	
  –	
  Meyer’s	
  Assessment	
  
A+	
  B	
   C	
  
D	
  
E	
  
A’	
  F	
  
G	
   H	
   I	
  
The	
  poten=al	
  for	
  disaster	
  is	
  obvious:	
  changes	
  to	
  A	
  may	
  invalidate	
  the	
  assumpHons	
  on	
  the	
  	
  
basis	
  of	
  which	
  the	
  old	
  clients	
  used	
  A.	
  
So	
  the	
  changes	
  may	
  start	
  a	
  dramaHc	
  series	
  of	
  changes	
  in	
  clients,	
  client	
  of	
  clients....etc	
  
	
  	
  	
  	
  	
  	
  SoluHon	
  –	
  Meyer’s	
  Assessment	
  
A+	
  
A’	
  F	
  
G	
   H	
   I	
  
	
  	
  	
  	
  	
  	
  SoluHon	
  –	
  Meyer’s	
  Assessment	
  
The	
  poten=al	
  for	
  disaster	
  is	
  obvious:	
  changes	
  to	
  A	
  may	
  invalidate	
  the	
  assumpHons	
  on	
  the	
  	
  
basis	
  of	
  which	
  the	
  old	
  clients	
  used	
  A.	
  
So	
  the	
  changes	
  may	
  start	
  a	
  dramaHc	
  series	
  of	
  changes	
  in	
  clients,	
  client	
  of	
  clients....etc	
  
B	
   C	
   E	
  
D	
  
this	
  is	
  a	
  nightmare	
  for	
  the	
  proj.	
  mgr.	
  
the	
  system	
  regresses	
  
and	
  several	
  modules	
  have	
  to	
  be	
  re-­‐
opened	
  for	
  dev/test/debug/
documentaHon	
  
Even	
  though	
  the	
  Change	
  soluHon	
  has	
  this	
  problema=c	
  ripple	
  effect,	
  it	
  is	
  sHll	
  be2er	
  than	
  	
  
the	
  Copy	
  solu=on.	
  
On	
  the	
  surface,	
  the	
  copy	
  solu=on	
  seems	
  be2er	
  because	
  it	
  avoids	
  the	
  ripple	
  effect	
  of	
  change	
  
but	
  in	
  fact	
  it	
  may	
  even	
  be	
  more	
  catastrophic…it	
  only	
  postpones	
  the	
  day	
  of	
  reckoning	
  
We	
  saw	
  earlier	
  the	
  risks	
  of	
  an	
  explosion	
  of	
  variants,	
  many	
  of	
  them	
  very	
  similar,	
  	
  
but	
  never	
  quite	
  iden=cal:	
  
	
  	
  	
  	
  	
  	
  SoluHon	
  –	
  Meyer’s	
  Assessment	
  
soluHon	
  soluHon	
  
 	
  	
  	
  	
  	
  SoluHon	
  (Parametric	
  soluHon)	
  
Christensen’s	
  Assessment	
  
CondiHonals	
  are	
  easy	
  to	
  understand.	
  So	
  approach	
  is	
  easy	
  to	
  
describe	
  to	
  other	
  developers.	
  
Avoids	
  Mul=ple	
  Maintenance	
  Problem	
  	
  
Only	
  one	
  code	
  base	
  to	
  maintain	
  
soluHon	
  soluHon	
  
LiabiliHes,	
  most	
  of	
  which	
  deal	
  with	
  long	
  term	
  maintainability	
  
	
  
Change	
  by	
  	
  
ModificaHon	
  
Reliability	
  Concerns	
  –	
  soluHon	
  relies	
  on	
  	
  	
  
with	
  risk	
  of	
  
introducing	
  
new	
  defects	
  
	
  
Analysability	
  concerns	
  –	
  as	
  more	
  and	
  more	
  
requirements	
  are	
  handled	
  by	
  parameter	
  
switching,	
  the	
  code	
  becomes	
  less	
  easy	
  to	
  
analyse	
  
	
  
…	
  
Responsibility	
  erosion	
  –	
  the	
  soZware	
  has,	
  
without	
  much	
  noHce,	
  been	
  given	
  an	
  extra	
  
responsibility	
  
drives	
  
towards	
  
Procedural	
  
Design	
  
Blob	
  aka	
  
God	
  Class	
  
	
  	
  	
  	
  	
  	
  SoluHon	
  (Parametric	
  soluHon)	
  
Christensen’s	
  Assessment	
  
A	
  reasonable	
  approach	
  at	
  first,	
  but	
  one	
  with	
  serious	
  problems	
  
for	
  applicaHons	
  that	
  need	
  to	
  grow	
  over	
  Hme	
  
	
  	
  	
  	
  	
  	
  SoluHon	
  (Switches)	
  
Shalloway’s	
  Assessment	
  
Not	
  too	
  bad	
  as	
  long	
  as	
  you	
  just	
  keep	
  adding	
  cases…	
   2004	
  
but	
  soon	
  you	
  need	
  to	
  introduce	
  fall-­‐throughs…	
  
…and	
  then	
  the	
  switches	
  are	
  not	
  as	
  nice	
  as	
  they	
  used	
  to	
  be	
  
Eventually	
  you	
  need	
  to	
  start	
  adding	
  varia=ons	
  within	
  a	
  case.	
  	
  
	
  
I	
  like	
  to	
  call	
  this	
  	
   switch!
The	
  flow	
  of	
  the	
  switches	
  themselves	
  becomes	
  confusing,	
  hard	
  to	
  read,	
  hard	
  to	
  	
  
decipher.	
  
When	
  a	
  new	
  case	
  comes	
  in	
  the	
  programmer	
  must	
  find	
  every	
  place	
  it	
  can	
  	
  
be	
  involved	
  (o9en	
  finding	
  all	
  but	
  one	
  of	
  them).	
  
Suddenly	
  things	
  get	
  bad	
  in	
  a	
  hurry.	
  	
  
Analysability	
   Stability	
   Reliability	
  
solu=on	
  
-­‐ -­‐ -­‐
Summary	
  
Analysability	
   Stability	
   Reliability	
  
solu=on	
  
-­‐	
   -­‐	
   -­‐	
  
With	
  non-­‐OO	
  methods,	
  there	
  are	
  only	
  only	
  2	
  solu=ons	
  available	
  to	
  us,	
  	
  
BOTH	
  UNSATISFACTORY	
  
mul=ple	
  maintenance	
  problem	
  
Change	
  by	
  	
  
ModificaHon	
  
CHANGE	
  
COPY	
  
If	
  non-­‐OO	
  methods	
  are	
  all	
  we	
  have,	
  then	
  
Meyer	
  says	
  we	
  face	
  a	
  change	
  or	
  copy	
  
dilemma	
  
CHANGE	
   COPY	
  
A	
  B	
   C	
  
D	
  
E	
  
A’	
  F	
  
G	
   H	
   I	
  
So	
  how	
  can	
  we	
  have	
  modules	
  that	
  are	
  both	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  and	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  ?	
  
How	
  can	
  we	
  keep	
  A	
  and	
  everything	
  in	
  the	
  top	
  part	
  of	
  the	
  figure	
  unchanged,	
  …	
  
…while	
  providing	
  A’	
  to	
  the	
  bo>om	
  clients,	
  and	
  avoiding	
  duplica=on	
  of	
  so9ware?	
  	
  
A	
  B	
   C	
  
D	
  
E	
  
A’	
  F	
  
G	
   H	
   I	
  
With	
  the	
  OO	
  concept	
  of	
  inheritance	
  
Inheritance	
  allows	
  us	
  to	
  get	
  out	
  of	
  the	
  CHANGE	
  OR	
  COPY	
  dilemma…	
  
…because	
  inheritance	
  allows	
  us	
  to	
  define	
  a	
  new	
  module	
  A'	
  in	
  terms	
  of	
  an	
  exis=ng	
  
module	
  A,	
  …by	
  sta=ng	
  only	
  the	
  differences	
  between	
  the	
  two	
  	
  
A’	
  defines	
  new	
  features,	
  and	
  redefines	
  (i.e.	
  modifies)	
  
one	
  or	
  more	
  of	
  A’s	
  features	
  
inherits	
  from	
  
Change	
  by	
  	
  
AddiHon	
  
Thanks	
  to	
  inheritance,	
  OO	
  developers	
  can	
  adopt	
  a	
  much	
  more	
  
incremental	
  approach	
  to	
  soZware	
  development	
  than	
  used	
  to	
  be	
  
possible	
  with	
  earlier	
  methods	
  
OO	
  inheritance	
  
Hacking = Slipshod approach to building and
modifying code
Slipshod = Done poorly or too quickly; careless.
The	
  Hacker	
  	
  
may	
  seem	
  	
  
bad	
  
but	
  oZen	
  his	
  	
  
heart	
  is	
  pure.	
  
He	
  sees	
  a	
  useful	
  piece	
  of	
  soZware,	
  which	
  is	
  almost	
  able	
  to	
  address	
  the	
  needs	
  of	
  the	
  	
  
moment,	
  more	
  general	
  than	
  the	
  soZware’s	
  original	
  purpose.	
  	
  
Hacker	
  	
  
Spurred	
  by	
  a	
  laudable	
  desire	
  not	
  to	
  redo	
  what	
  can	
  be	
  reused,	
  our	
  hacker	
  starts	
  	
  
modifying	
  the	
  original	
  to	
  add	
  provisions	
  for	
  new	
  cases	
  
solu=on	
  
The	
  impulse	
  is	
  good	
  but	
  the	
  effect	
  
is	
  oZen	
  to	
  pollute	
  the	
  soZware	
  
with	
  many	
  clauses	
  of	
  the	
  form	
  	
  
if	
  that_special_case	
  then…	
  
if	
  (<special	
  case	
  D>)	
  
then …	
  
if	
  (<special	
  case	
  C>)	
  
then …	
  
if	
  (<special	
  case	
  B>)	
  
then …	
  
if	
  (<special	
  case	
  A>)	
  
then …	
  
switch!
so	
  that	
  aZer	
  a	
  few	
  rounds	
  of	
  hacking,	
  perhaps	
  by	
  different	
  hackers,	
  	
  
the	
  soZware	
  starts	
  resembling	
  a	
  chunk	
  of	
  Swiss	
  cheese	
  that	
  
has	
  been	
  leZ	
  outside	
  for	
  too	
  long	
  in	
  August	
  –	
  it	
  has	
  both	
  holes	
  
and	
  growth	
  
Hacking	
  
Open-Closed Principle = 	
  
One	
  way	
  to	
  describe	
  the	
  OCP	
  and	
  the	
  consequent	
  OO	
  techniques	
  is	
  to	
  think	
  of	
  them	
  
as	
  organised	
  hacking	
  
Hacking	
  
The	
  organised	
  form	
  of	
  hacking	
  will	
  enable	
  us	
  to	
  cater	
  to	
  the	
  variants	
  	
  
without	
  affec=ng	
  the	
  consistency	
  of	
  the	
  original	
  version.	
  
Inheritance	
  
Change	
  by	
  	
  
ModificaHon	
  
Change	
  by	
  	
  
AddiHon	
  
if	
  you	
  have	
  control	
  over	
  	
  
original	
  s/w	
  and	
  	
  
can	
  rewrite	
  it	
  
	
  	
  
so	
  that	
  it	
  will	
  address	
  the	
  needs	
  
	
  of	
  several	
  kinds	
  of	
  clients	
  
…you	
  should	
  do	
  so	
  
Caveats	
  
at	
  no	
  extra	
  complicaHon	
  
 	
  The	
  OCP	
  principle	
  and	
  associated	
  techniques	
  are	
  intended	
  for	
  the	
  	
  
adapta=on	
  of	
  healthy	
  modules	
  
	
  If	
  there	
  is	
  something	
  wrong	
  
with	
  a	
  module	
  you	
  should	
  fix	
  
it…	
  
	
  	
  
	
  
	
  
…not	
  leave	
  the	
  original	
  alone	
  and	
  
try	
  to	
  correct	
  the	
  problem	
  in	
  the	
  
derived	
  module	
  
Derived	
  
Base	
  
neither	
  OCP	
  nor	
  redefiniHon	
  in	
  
inheritance	
  is	
  a	
  way	
  to	
  address	
  
design	
  flaws,	
  let	
  alone	
  bugs	
   Design	
  	
  
Flaw	
  
its	
  purpose,	
  its	
  enHre	
  reason	
  
for	
  being,	
  is	
  to	
  reduce	
  the	
  
cost	
  of	
  change.	
  
	
  
Ques=on:	
  how	
  do	
  we	
  promote	
  flexibility,	
  	
  
reliability	
  and	
  stability	
  in	
  our	
  soZware?	
  
Analysability	
  
Maintainability	
  
Changeability	
   Stability	
   Testability	
  
Flexibility	
  
Reliability	
  
Answer:	
  we	
  favour	
  ‘Change	
  by	
  Addi=on’	
  over	
  	
  
‘Change	
  by	
  Modifica=on’	
  
Changeability	
  
Stability	
  
Flexibility	
  
Reliability	
  
Change	
  by	
  	
  
ModificaHon	
  
Change	
  by	
  	
  
AddiHon	
  
-­‐
+ -­‐
+	
  
How	
  do	
  we	
  achieve	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  ?	
  Change	
  by	
  	
  
AddiHon	
  
which	
  uses	
  OO	
  inheritance	
  
Inheritance	
  
We	
  apply	
  the	
  Open-­‐Closed	
  Principle	
  
extends	
  is	
  evil!!!!!	
  
Yes,	
  we’ll	
  cover	
  that	
  in	
  the	
  next	
  presentaHon:	
  Part	
  II	
  
But,	
  using	
  inheritance	
  is	
  no	
  longer	
  the	
  main	
  approach	
  	
  
to	
  saHsfying	
  the	
  OCP	
  
Allen	
  Holub	
   2004	
  
2003	
  
in	
  which	
  we	
  look	
  at	
  the	
  modern,	
  	
  
contemporary	
  version	
  of	
  the	
  OCP	
  	
  
again,	
  we’ll	
  cover	
  this	
  in	
  the	
  next	
  presentaHon:	
  Part	
  II	
  
Using	
  inheritance	
  is	
  sHll	
  one	
  of	
  the	
  ways	
  of	
  saHsfying	
  the	
  OCP,	
  	
  
and	
  was	
  considered	
  THE	
  approach	
  for	
  a	
  long	
  while	
  
Why	
  extends	
  is	
  evil	
  
1988	
  -­‐	
  1st	
  ed.	
  	
   1997	
  –	
  2nd	
  ed.	
  	
  
1995	
  	
  
That	
  started	
  changing	
  with	
  the	
  	
  emergence	
  of	
  the	
  	
  
design	
  techniques	
  presented	
  in	
  Design	
  Pa2erns	
  
2003	
  
References	
  
All	
  images	
  sourced	
  from	
  h>p://www.google.co.uk/advanced_image_search,	
  so	
  see	
  there	
  for	
  details	
  of	
  
which	
  are	
  	
  subject	
  to	
  copyright	
  
	
  
Object-­‐Oriented	
  So9ware	
  Construc=on	
  –	
  by	
  Bertrand	
  Meyer;	
  PublicaHon	
  Date:	
  3	
  April	
  1997	
  |	
  ISBN-­‐10:	
  
0136291554	
  |	
  ISBN-­‐13:	
  978-­‐0136291558	
  |	
  EdiHon:	
  2	
  
	
  
Flexible,	
  Reliable	
  So9ware:	
  Using	
  Pa2erns	
  and	
  Agile	
  Development	
  –	
  by	
  Henrik	
  B.	
  Christensen;	
  
PublicaHon	
  Date:	
  11	
  May	
  2010	
  |	
  ISBN-­‐10:	
  1420093622	
  |	
  ISBN-­‐13:	
  978-­‐1420093629	
  
	
  
Design	
  Pa2erns	
  Explained:	
  A	
  New	
  Perspec=ve	
  on	
  Object-­‐Oriented	
  Design;	
  by	
  Alan	
  Shalloway;	
  
PublicaHon	
  Date:	
  12	
  Oct	
  2004	
  |	
  ISBN-­‐10:	
  0321247140	
  |	
  ISBN-­‐13:	
  978-­‐0321247148	
  |	
  EdiHon:	
  2	
  
	
  
Less	
  -­‐	
  The	
  Path	
  to	
  Be2er	
  Design;	
  by	
  Sandi	
  Metz	
  at	
  GoRuCo	
  2011	
  	
  
goruco_2011_-­‐_sandi_metz_-­‐_less_-­‐_the_path_to_be>er_design_1280x720.mp4	
  
	
  
Why	
  Extends	
  is	
  Evil	
  -­‐	
  Improve	
  your	
  code	
  by	
  replacing	
  concrete	
  base	
  classes	
  with	
  interfaces;	
  by	
  
Allen	
  Holub;	
  	
  h>p://www.javaworld.com/arHcle/2073649/core-­‐java/why-­‐extends-­‐is-­‐evil.html	
  

More Related Content

What's hot

SOLID design principles applied in Java
SOLID design principles applied in JavaSOLID design principles applied in Java
SOLID design principles applied in Java
Bucharest Java User Group
 
Implementing The Open/Closed Principle
Implementing The Open/Closed PrincipleImplementing The Open/Closed Principle
Implementing The Open/Closed PrincipleSam Hennessy
 
Object Oriented Design Principles
Object Oriented Design PrinciplesObject Oriented Design Principles
Object Oriented Design Principles
Thang Tran Duc
 
OO design principles & heuristics
OO design principles & heuristicsOO design principles & heuristics
OO design principles & heuristics
Dhaval Shah
 
principles of object oriented class design
principles of object oriented class designprinciples of object oriented class design
principles of object oriented class design
Neetu Mishra
 
Learning solid principles using c#
Learning solid principles using c#Learning solid principles using c#
Learning solid principles using c#
Aditya Kumar Rajan
 
Geecon09: SOLID Design Principles
Geecon09: SOLID Design PrinciplesGeecon09: SOLID Design Principles
Geecon09: SOLID Design Principles
Bruno Bossola
 
Binding android piece by piece
Binding android piece by pieceBinding android piece by piece
Binding android piece by piece
Bucharest Java User Group
 
Design Patterns: From STUPID to SOLID code
Design Patterns: From STUPID to SOLID codeDesign Patterns: From STUPID to SOLID code
Design Patterns: From STUPID to SOLID code
Paulo Gandra de Sousa
 
S.O.L.I.D. Principles for Software Architects
S.O.L.I.D. Principles for Software ArchitectsS.O.L.I.D. Principles for Software Architects
S.O.L.I.D. Principles for Software Architects
Ricardo Wilkins
 
Are You a SOLID Coder?
Are You a SOLID Coder?Are You a SOLID Coder?
Are You a SOLID Coder?
Steve Green
 
Solid principles
Solid principlesSolid principles
Solid principles
Toan Nguyen
 
Soild principles
Soild principlesSoild principles
Soild principles
Avidnyat Chiddarwar
 
Refactoring - An Introduction
Refactoring - An IntroductionRefactoring - An Introduction
Refactoring - An Introduction
Giorgio Vespucci
 
Refactoring Tips by Martin Fowler
Refactoring Tips by Martin FowlerRefactoring Tips by Martin Fowler
Refactoring Tips by Martin Fowler
Igor Crvenov
 
Refactoring: Improve the design of existing code
Refactoring: Improve the design of existing codeRefactoring: Improve the design of existing code
Refactoring: Improve the design of existing code
Valerio Maggio
 
Solid principles
Solid principlesSolid principles
Solid principles
Monica Rodrigues
 
Refactoring to SOLID Code
Refactoring to SOLID CodeRefactoring to SOLID Code
Refactoring to SOLID Code
Adil Mughal
 
TDD And Refactoring
TDD And RefactoringTDD And Refactoring
TDD And Refactoring
Naresh Jain
 

What's hot (20)

SOLID design principles applied in Java
SOLID design principles applied in JavaSOLID design principles applied in Java
SOLID design principles applied in Java
 
Implementing The Open/Closed Principle
Implementing The Open/Closed PrincipleImplementing The Open/Closed Principle
Implementing The Open/Closed Principle
 
Object Oriented Design Principles
Object Oriented Design PrinciplesObject Oriented Design Principles
Object Oriented Design Principles
 
OO design principles & heuristics
OO design principles & heuristicsOO design principles & heuristics
OO design principles & heuristics
 
SOLID Design principles
SOLID Design principlesSOLID Design principles
SOLID Design principles
 
principles of object oriented class design
principles of object oriented class designprinciples of object oriented class design
principles of object oriented class design
 
Learning solid principles using c#
Learning solid principles using c#Learning solid principles using c#
Learning solid principles using c#
 
Geecon09: SOLID Design Principles
Geecon09: SOLID Design PrinciplesGeecon09: SOLID Design Principles
Geecon09: SOLID Design Principles
 
Binding android piece by piece
Binding android piece by pieceBinding android piece by piece
Binding android piece by piece
 
Design Patterns: From STUPID to SOLID code
Design Patterns: From STUPID to SOLID codeDesign Patterns: From STUPID to SOLID code
Design Patterns: From STUPID to SOLID code
 
S.O.L.I.D. Principles for Software Architects
S.O.L.I.D. Principles for Software ArchitectsS.O.L.I.D. Principles for Software Architects
S.O.L.I.D. Principles for Software Architects
 
Are You a SOLID Coder?
Are You a SOLID Coder?Are You a SOLID Coder?
Are You a SOLID Coder?
 
Solid principles
Solid principlesSolid principles
Solid principles
 
Soild principles
Soild principlesSoild principles
Soild principles
 
Refactoring - An Introduction
Refactoring - An IntroductionRefactoring - An Introduction
Refactoring - An Introduction
 
Refactoring Tips by Martin Fowler
Refactoring Tips by Martin FowlerRefactoring Tips by Martin Fowler
Refactoring Tips by Martin Fowler
 
Refactoring: Improve the design of existing code
Refactoring: Improve the design of existing codeRefactoring: Improve the design of existing code
Refactoring: Improve the design of existing code
 
Solid principles
Solid principlesSolid principles
Solid principles
 
Refactoring to SOLID Code
Refactoring to SOLID CodeRefactoring to SOLID Code
Refactoring to SOLID Code
 
TDD And Refactoring
TDD And RefactoringTDD And Refactoring
TDD And Refactoring
 

Similar to The Open Closed Principle - Part 1 - The Original Version

SOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionSOLID Design Principles for Test Automaion
SOLID Design Principles for Test Automaion
Knoldus Inc.
 
DevOps in 2014
DevOps in 2014DevOps in 2014
DevOps in 2014
David Thompson
 
What is DevOps?
What is DevOps?What is DevOps?
What is DevOps?
jeckels
 
An introduction to DevOps
An introduction to DevOpsAn introduction to DevOps
An introduction to DevOps
Andrea Tino
 
DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatterns
Basavaraj Patil
 
DevOps and Tools
DevOps and ToolsDevOps and Tools
DevOps and Tools
Mohammed Fazuluddin
 
DevOps.pptx
DevOps.pptxDevOps.pptx
DevOps.pptx
EswarVineet
 
JavaOne 2015 - Swimming upstream in the container revolution
JavaOne 2015 - Swimming upstream in the container revolutionJavaOne 2015 - Swimming upstream in the container revolution
JavaOne 2015 - Swimming upstream in the container revolution
Bert Jan Schrijver
 
Object Oriented Design SOLID Principles
Object Oriented Design SOLID PrinciplesObject Oriented Design SOLID Principles
Object Oriented Design SOLID Principles
rainynovember12
 
Best practices for implementing CI/CD on Salesforce
Best practices for implementing CI/CD on SalesforceBest practices for implementing CI/CD on Salesforce
Best practices for implementing CI/CD on Salesforce
AIMDek Technologies
 
Software design principles - jinal desai
Software design principles - jinal desaiSoftware design principles - jinal desai
Software design principles - jinal desai
jinaldesailive
 
Practical Enterprise Application Development
Practical Enterprise Application DevelopmentPractical Enterprise Application Development
Practical Enterprise Application Development
Adil Mughal
 
DevOps Lifecycle: Definition, Phases and Key Components.pdf
DevOps Lifecycle: Definition, Phases and Key Components.pdfDevOps Lifecycle: Definition, Phases and Key Components.pdf
DevOps Lifecycle: Definition, Phases and Key Components.pdf
EcosmobTechnologies1
 
Devoxx BE 2015 - Swimming upstream in the container revolution
Devoxx BE 2015 - Swimming upstream in the container revolutionDevoxx BE 2015 - Swimming upstream in the container revolution
Devoxx BE 2015 - Swimming upstream in the container revolution
Bert Jan Schrijver
 
EuregJUG 2016-01-07 - Swimming upstream in the container revolution
EuregJUG 2016-01-07 - Swimming upstream in the container revolutionEuregJUG 2016-01-07 - Swimming upstream in the container revolution
EuregJUG 2016-01-07 - Swimming upstream in the container revolution
Bert Jan Schrijver
 
Devops On Cloud Powerpoint Template Slides Powerpoint Presentation Slides
Devops On Cloud Powerpoint Template Slides Powerpoint Presentation SlidesDevops On Cloud Powerpoint Template Slides Powerpoint Presentation Slides
Devops On Cloud Powerpoint Template Slides Powerpoint Presentation Slides
SlideTeam
 
Dev ops interview questions &amp; answers
Dev ops interview questions &amp; answersDev ops interview questions &amp; answers
Dev ops interview questions &amp; answers
KrishnaMildain
 
What is DevOps? What is DevOps CoE?
What is DevOps? What is DevOps CoE? What is DevOps? What is DevOps CoE?
What is DevOps? What is DevOps CoE?
7Targets AI Sales Assistants
 
Java Forum Nord 2015 - Swimming upstream in the container revolution
Java Forum Nord 2015 - Swimming upstream in the container revolutionJava Forum Nord 2015 - Swimming upstream in the container revolution
Java Forum Nord 2015 - Swimming upstream in the container revolution
Bert Jan Schrijver
 

Similar to The Open Closed Principle - Part 1 - The Original Version (20)

SOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionSOLID Design Principles for Test Automaion
SOLID Design Principles for Test Automaion
 
DevOps in 2014
DevOps in 2014DevOps in 2014
DevOps in 2014
 
What is DevOps?
What is DevOps?What is DevOps?
What is DevOps?
 
Solid
SolidSolid
Solid
 
An introduction to DevOps
An introduction to DevOpsAn introduction to DevOps
An introduction to DevOps
 
DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatterns
 
DevOps and Tools
DevOps and ToolsDevOps and Tools
DevOps and Tools
 
DevOps.pptx
DevOps.pptxDevOps.pptx
DevOps.pptx
 
JavaOne 2015 - Swimming upstream in the container revolution
JavaOne 2015 - Swimming upstream in the container revolutionJavaOne 2015 - Swimming upstream in the container revolution
JavaOne 2015 - Swimming upstream in the container revolution
 
Object Oriented Design SOLID Principles
Object Oriented Design SOLID PrinciplesObject Oriented Design SOLID Principles
Object Oriented Design SOLID Principles
 
Best practices for implementing CI/CD on Salesforce
Best practices for implementing CI/CD on SalesforceBest practices for implementing CI/CD on Salesforce
Best practices for implementing CI/CD on Salesforce
 
Software design principles - jinal desai
Software design principles - jinal desaiSoftware design principles - jinal desai
Software design principles - jinal desai
 
Practical Enterprise Application Development
Practical Enterprise Application DevelopmentPractical Enterprise Application Development
Practical Enterprise Application Development
 
DevOps Lifecycle: Definition, Phases and Key Components.pdf
DevOps Lifecycle: Definition, Phases and Key Components.pdfDevOps Lifecycle: Definition, Phases and Key Components.pdf
DevOps Lifecycle: Definition, Phases and Key Components.pdf
 
Devoxx BE 2015 - Swimming upstream in the container revolution
Devoxx BE 2015 - Swimming upstream in the container revolutionDevoxx BE 2015 - Swimming upstream in the container revolution
Devoxx BE 2015 - Swimming upstream in the container revolution
 
EuregJUG 2016-01-07 - Swimming upstream in the container revolution
EuregJUG 2016-01-07 - Swimming upstream in the container revolutionEuregJUG 2016-01-07 - Swimming upstream in the container revolution
EuregJUG 2016-01-07 - Swimming upstream in the container revolution
 
Devops On Cloud Powerpoint Template Slides Powerpoint Presentation Slides
Devops On Cloud Powerpoint Template Slides Powerpoint Presentation SlidesDevops On Cloud Powerpoint Template Slides Powerpoint Presentation Slides
Devops On Cloud Powerpoint Template Slides Powerpoint Presentation Slides
 
Dev ops interview questions &amp; answers
Dev ops interview questions &amp; answersDev ops interview questions &amp; answers
Dev ops interview questions &amp; answers
 
What is DevOps? What is DevOps CoE?
What is DevOps? What is DevOps CoE? What is DevOps? What is DevOps CoE?
What is DevOps? What is DevOps CoE?
 
Java Forum Nord 2015 - Swimming upstream in the container revolution
Java Forum Nord 2015 - Swimming upstream in the container revolutionJava Forum Nord 2015 - Swimming upstream in the container revolution
Java Forum Nord 2015 - Swimming upstream in the container revolution
 

More from Philip Schwarz

A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Philip Schwarz
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
Philip Schwarz
 
Folding Cheat Sheet #3 - third in a series
Folding Cheat Sheet #3 - third in a seriesFolding Cheat Sheet #3 - third in a series
Folding Cheat Sheet #3 - third in a series
Philip Schwarz
 
Folding Cheat Sheet #2 - second in a series
Folding Cheat Sheet #2 - second in a seriesFolding Cheat Sheet #2 - second in a series
Folding Cheat Sheet #2 - second in a series
Philip Schwarz
 
Folding Cheat Sheet #1 - first in a series
Folding Cheat Sheet #1 - first in a seriesFolding Cheat Sheet #1 - first in a series
Folding Cheat Sheet #1 - first in a series
Philip Schwarz
 
Scala Left Fold Parallelisation - Three Approaches
Scala Left Fold Parallelisation- Three ApproachesScala Left Fold Parallelisation- Three Approaches
Scala Left Fold Parallelisation - Three Approaches
Philip Schwarz
 
Tagless Final Encoding - Algebras and Interpreters and also Programs
Tagless Final Encoding - Algebras and Interpreters and also ProgramsTagless Final Encoding - Algebras and Interpreters and also Programs
Tagless Final Encoding - Algebras and Interpreters and also Programs
Philip Schwarz
 
Fusing Transformations of Strict Scala Collections with Views
Fusing Transformations of Strict Scala Collections with ViewsFusing Transformations of Strict Scala Collections with Views
Fusing Transformations of Strict Scala Collections with Views
Philip Schwarz
 
A sighting of traverse_ function in Practical FP in Scala
A sighting of traverse_ function in Practical FP in ScalaA sighting of traverse_ function in Practical FP in Scala
A sighting of traverse_ function in Practical FP in Scala
Philip Schwarz
 
A sighting of traverseFilter and foldMap in Practical FP in Scala
A sighting of traverseFilter and foldMap in Practical FP in ScalaA sighting of traverseFilter and foldMap in Practical FP in Scala
A sighting of traverseFilter and foldMap in Practical FP in Scala
Philip Schwarz
 
A sighting of sequence function in Practical FP in Scala
A sighting of sequence function in Practical FP in ScalaA sighting of sequence function in Practical FP in Scala
A sighting of sequence function in Practical FP in Scala
Philip Schwarz
 
N-Queens Combinatorial Puzzle meets Cats
N-Queens Combinatorial Puzzle meets CatsN-Queens Combinatorial Puzzle meets Cats
N-Queens Combinatorial Puzzle meets Cats
Philip Schwarz
 
Kleisli composition, flatMap, join, map, unit - implementation and interrelat...
Kleisli composition, flatMap, join, map, unit - implementation and interrelat...Kleisli composition, flatMap, join, map, unit - implementation and interrelat...
Kleisli composition, flatMap, join, map, unit - implementation and interrelat...
Philip Schwarz
 
The aggregate function - from sequential and parallel folds to parallel aggre...
The aggregate function - from sequential and parallel folds to parallel aggre...The aggregate function - from sequential and parallel folds to parallel aggre...
The aggregate function - from sequential and parallel folds to parallel aggre...
Philip Schwarz
 
Nat, List and Option Monoids - from scratch - Combining and Folding - an example
Nat, List and Option Monoids -from scratch -Combining and Folding -an exampleNat, List and Option Monoids -from scratch -Combining and Folding -an example
Nat, List and Option Monoids - from scratch - Combining and Folding - an example
Philip Schwarz
 
Nat, List and Option Monoids - from scratch - Combining and Folding - an example
Nat, List and Option Monoids -from scratch -Combining and Folding -an exampleNat, List and Option Monoids -from scratch -Combining and Folding -an example
Nat, List and Option Monoids - from scratch - Combining and Folding - an example
Philip Schwarz
 
The Sieve of Eratosthenes - Part II - Genuine versus Unfaithful Sieve - Haske...
The Sieve of Eratosthenes - Part II - Genuine versus Unfaithful Sieve - Haske...The Sieve of Eratosthenes - Part II - Genuine versus Unfaithful Sieve - Haske...
The Sieve of Eratosthenes - Part II - Genuine versus Unfaithful Sieve - Haske...
Philip Schwarz
 
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
Philip Schwarz
 
Algebraic Data Types for Data Oriented Programming - From Haskell and Scala t...
Algebraic Data Types forData Oriented Programming - From Haskell and Scala t...Algebraic Data Types forData Oriented Programming - From Haskell and Scala t...
Algebraic Data Types for Data Oriented Programming - From Haskell and Scala t...
Philip Schwarz
 

More from Philip Schwarz (20)

A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Folding Cheat Sheet #3 - third in a series
Folding Cheat Sheet #3 - third in a seriesFolding Cheat Sheet #3 - third in a series
Folding Cheat Sheet #3 - third in a series
 
Folding Cheat Sheet #2 - second in a series
Folding Cheat Sheet #2 - second in a seriesFolding Cheat Sheet #2 - second in a series
Folding Cheat Sheet #2 - second in a series
 
Folding Cheat Sheet #1 - first in a series
Folding Cheat Sheet #1 - first in a seriesFolding Cheat Sheet #1 - first in a series
Folding Cheat Sheet #1 - first in a series
 
Scala Left Fold Parallelisation - Three Approaches
Scala Left Fold Parallelisation- Three ApproachesScala Left Fold Parallelisation- Three Approaches
Scala Left Fold Parallelisation - Three Approaches
 
Tagless Final Encoding - Algebras and Interpreters and also Programs
Tagless Final Encoding - Algebras and Interpreters and also ProgramsTagless Final Encoding - Algebras and Interpreters and also Programs
Tagless Final Encoding - Algebras and Interpreters and also Programs
 
Fusing Transformations of Strict Scala Collections with Views
Fusing Transformations of Strict Scala Collections with ViewsFusing Transformations of Strict Scala Collections with Views
Fusing Transformations of Strict Scala Collections with Views
 
A sighting of traverse_ function in Practical FP in Scala
A sighting of traverse_ function in Practical FP in ScalaA sighting of traverse_ function in Practical FP in Scala
A sighting of traverse_ function in Practical FP in Scala
 
A sighting of traverseFilter and foldMap in Practical FP in Scala
A sighting of traverseFilter and foldMap in Practical FP in ScalaA sighting of traverseFilter and foldMap in Practical FP in Scala
A sighting of traverseFilter and foldMap in Practical FP in Scala
 
A sighting of sequence function in Practical FP in Scala
A sighting of sequence function in Practical FP in ScalaA sighting of sequence function in Practical FP in Scala
A sighting of sequence function in Practical FP in Scala
 
N-Queens Combinatorial Puzzle meets Cats
N-Queens Combinatorial Puzzle meets CatsN-Queens Combinatorial Puzzle meets Cats
N-Queens Combinatorial Puzzle meets Cats
 
Kleisli composition, flatMap, join, map, unit - implementation and interrelat...
Kleisli composition, flatMap, join, map, unit - implementation and interrelat...Kleisli composition, flatMap, join, map, unit - implementation and interrelat...
Kleisli composition, flatMap, join, map, unit - implementation and interrelat...
 
The aggregate function - from sequential and parallel folds to parallel aggre...
The aggregate function - from sequential and parallel folds to parallel aggre...The aggregate function - from sequential and parallel folds to parallel aggre...
The aggregate function - from sequential and parallel folds to parallel aggre...
 
Nat, List and Option Monoids - from scratch - Combining and Folding - an example
Nat, List and Option Monoids -from scratch -Combining and Folding -an exampleNat, List and Option Monoids -from scratch -Combining and Folding -an example
Nat, List and Option Monoids - from scratch - Combining and Folding - an example
 
Nat, List and Option Monoids - from scratch - Combining and Folding - an example
Nat, List and Option Monoids -from scratch -Combining and Folding -an exampleNat, List and Option Monoids -from scratch -Combining and Folding -an example
Nat, List and Option Monoids - from scratch - Combining and Folding - an example
 
The Sieve of Eratosthenes - Part II - Genuine versus Unfaithful Sieve - Haske...
The Sieve of Eratosthenes - Part II - Genuine versus Unfaithful Sieve - Haske...The Sieve of Eratosthenes - Part II - Genuine versus Unfaithful Sieve - Haske...
The Sieve of Eratosthenes - Part II - Genuine versus Unfaithful Sieve - Haske...
 
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
 
Algebraic Data Types for Data Oriented Programming - From Haskell and Scala t...
Algebraic Data Types forData Oriented Programming - From Haskell and Scala t...Algebraic Data Types forData Oriented Programming - From Haskell and Scala t...
Algebraic Data Types for Data Oriented Programming - From Haskell and Scala t...
 

Recently uploaded

Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 

Recently uploaded (20)

Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 

The Open Closed Principle - Part 1 - The Original Version

  • 1. The  Open  Closed  Principle     Part  I   The  Original  Version     ©  2014  Philip  Schwarz   h>ps://twi>er.com/philip_schwarz   philip.johann.schwarz@gmail.com         This  work  is  licensed  under  a   CreaHve  Commons  A>ribuHon-­‐NonCommercial-­‐NoDerivs  3.0  Unported  License.  
  • 2. Tension  Between   known     needs     of  today   changes  that   will  arrive  in   the  future   Sandi  Metz   The  Fundamental  Target  of   Design  
  • 3. Code  needs  to   work  today  just   once,   and  it  needs  to  be  easy  to  change  forever  
  • 4. It  is  at  this  point  of  tension   where  design  ma2ers   today’s   needs     future   changes  
  • 5. its  purpose,  its  enHre  reason   for  being,  is  to  reduce  the   cost  of  change.    
  • 6. 1999   3rd  Apr  2014     @KentBeck  design  is  irrelevant  for  today.  it  only  ma2ers  when  we  want  to  change  the   so9ware...   @KentBeck  change  is  the  only  reason  to  organize  so9ware  at  all…  
  • 7. adopted  by  agile   community  as  a  truth   about  soZware   development   Henrik     Christensen   2010  
  • 8. “soZware  must  be  designed  and  developed  to   make  it  easy  to  change”  
  • 9. Let’s  examine  soZware  qualiHes  that  enable   ease  of  change     Look  for  definiHons  in  ISO  9126   Projects  someHmes  fail  due  to  not  having  any  clear     defini=ons  of  "success”   This  standard  tries  to  develop  a  common  understanding  of   project  objec=ves  and  goals,  e.g.  soZware  qualiHes  
  • 10. SoZware  is  Reliabile  if  it  can  maintain  a   specific  level  of  performance  under  specific   usage  condiHons  
  • 11. in  our  secng…   In  parHcular,  we  are  interested  in   preserving  reliability  in  the  face  of  change     SoZware  is  Reliabile  if  it  can  perform  the   required  func=ons  without  failing    
  • 12. “maintainability  is  composed  of   several,  finer  grained,  qualiHes”  
  • 13. Analysability   Maintainability   Changeability   Stability   Testability   SoZware  is  Analysable  if  you  can   •  diagnose  it  for     §  deficiencies   §  causes  of  failure   •  idenHfy  the  parts  to  be  modified   “Analysability  is  basically  the  ability  to  understand   soZware”  
  • 14. Analysability   Maintainability   Changeability   Stability   Testability   SoZware  is  changeable  if  it  allows  you  to   •  implement  a  specific  modificaHon   •  add,  modify,  or  enhance  a  feature            at  a  reasonable  cost   “almost  all  Design  Pa2erns  are     geared  towards  increasing     design’s  changeability”  
  • 15. Analysability   Maintainability   Changeability   Stability   Testability   “SoZware  is  flexible  if  you  can  add/enhance     func=onality  purely  by  adding  so9ware  units   and  specifically  not  by  modifying  exis=ng   so9ware  units”   Flexibility   a  special  case  of   changeability  
  • 16. Changeability   Behavioural  changes  that  are  introduced   by  modifying  exisHng  producHon  code   Changeability  is  a  desirable  quality,     but  it  relies  on   Change  by  Modifica=on   Change  by     ModificaHon   “The  less  I  ever  modify  a  class,  the  higher  the  probability  that   it  will  remain  free  of  defects”   ModificaHons  carry  the  risk  of  introducing  defects,  and  the   necessary  cost  of  avoiding  them:  tesHng,  code  reviewing,  etc.  
  • 17. Behavioural  changes  that  are  introduced   by  modifying  exisHng  producHon  code   Change  by     ModificaHon   Change  by     AddiHon   Behavioural  changes  that  are  introduced  by   adding  new  producHon  code  instead  of   modifying  exisHng  code   Contrast     Change  by  Addi=on  avoids  (risky)  modifica=ons  altogether   with  
  • 18. Changeability   Change  by     AddiHon   Change  by     ModificaHon   Changeability  does  not  take  a  stand  point  with  regards     to  the  way  a  specified  modificaHon  is  implemented   Flexibility   In  contrast,  Flexibility  does  take  this  stand  point     and  requires  that  no  modifica=ons  are  made  
  • 19. Analysability   Maintainability   Changeability   Stability   Testability   SoZware  is  Stable  if  it  avoids  unexpected  effects  when   modified   “I  advocate  the  pracHce  to  avoid  modifying  exis=ng  code  but   preferably  add  features  or  modify  exis=ng  ones  by  other   means”   “any  change  to  exisHng  soZware  carries  a  risk  of  introducing   defects”  
  • 20. Changeability   Stability   Flexibility   Reliability   Change  by     ModificaHon   Change  by     AddiHon   -­‐ + -­‐ +   Summary   + supports   -­‐ risks  undermining   relies  on  
  • 21. Ques=on:  how  do  we  promote  flexibility,     reliability  and  stability  in  our  soZware?   Analysability   Maintainability   Changeability   Stability   Testability   Flexibility   Reliability  
  • 22. Answer:  we  favour  ‘Change  by  Addi=on’  over     ‘Change  by  Modifica=on’   Changeability   Stability   Flexibility   Reliability   Change  by     ModificaHon   Change  by     AddiHon   -­‐ + -­‐ +  
  • 23. I  cover  techniques  that   focus  on  flexibility     Christensen   if  you  require   that  s/w  can   adapt  to   changing   requirements   without   modifying   the   produc=on   code   then  you  need  to   employ  a  SPECIAL   set  of  design  and   programming   techniques  as  well   as  adopt  a   SPECIAL  mindset  
  • 24. “Another  way  of  characterising   Change  by  Addi=on  that  you   may  come  across  is  the  Open   Closed  Principle”   How  do  we  achieve                                                                    ?  Change  by     AddiHon  
  • 25. The  Open-­‐Closed  Principle   Modules  should  be  both  open  and  closed   Bertrand  Meyer   Object  Oriented   SoZware  ConstrucHon   The  most  comprehensive,  definiHve   OO  reference  ever  published  1988  
  • 26. Isn’t  there  a  contradic=on     between  the  two  terms?   Modules  should  be  both   OPEN  and  CLOSED     ¬(p  ∧  ¬p)    
  • 27. The  contradic=on  is  only  apparent   The  two  terms   correspond  to   goals  of  a   different  nature   e.g.  a  Dutch  door  can  be     both  OPEN  and  CLOSED   It  is  a    
  • 28. So  let’s  look  at  the  goals  of  the  OCP   OCP
  • 29. A  module  is     said  to  be     OPEN   if  it  is  sHll   available  for   extension   or  add  fields  to  its  data   structures   Data  Structures   fields   + operations e.g.  it  should  be  possible  to   expand  its  set  of  opera=ons    
  • 30. A  module  is   said  to  be   CLOSED   If  it  is  available   for  use  by   other  modules   Has  a  well-­‐defined,  stable  descripHon     (its  interface  –  in  informaHon  hiding  sense)   public  part   secret  part   interface   1   can  be  compiled,  stored  in  a  library,  and  made   available  for  clients  to  use  2   in  the  case  of  a  design  or  specificaHon  module:   •  approved   •  baselined  in  version  control   •  its  interface  published    for  benefit  of  other  module  authors   3  
  • 31. OPEN   if  it  is  sHll   available  for   extension   CLOSED   If  it  is  available   for  use  by   other  modules   Recap  –  A  module  is…  
  • 32. It  is  impossible  to  foresee  all  the  elements     that  a  module  will  need  in  its  lifeHme   X The  need  for                          ness   so  developers  wish  to  keep  the  module  open  for  as  long  as  possible     so  that  they  can  address  changes,     and  extensions     by  changing  elements  or   adding  new  elements  
  • 33. The  need  for                            ness   if  a  module  is  never  closed  unHl  it  is  certain   that  it  contains  all  the  needed  features     x   every  developer  would  always  be  waiHng  for   compleHon  of  another  developer's  job   then  mulH-­‐module  s/w  can   never  reach  compleHon  x   in  a  system  consisHng  of  many  modules,  most   modules  will  depend  on  some  others   but  it  is  also  necessary  to  close  modules  
  • 34. Modules  should  be  both  open  and  closed   We  want  modules  to  be  both                                  for  extension  and                              for  modificaHon  
  • 35. the  two  goals  of     openness  and  closedness     with  tradi=onal   techniques   are  incompa=ble  
  • 36. either  you  keep  a  module  open     and  others  cannot  use  it  yet   and  any  change  or   extension  can  trigger  a   painful  chain  reac=on  of   changes   or  you  close  it     in  many  other  modules   which  relied  on  the   original  module  directly   or  indirectly  
  • 37. A  B   C   D   E   A  module  and  its  clients   A’  F   G   H   I   New  clients  which  need  A’,  an  adapted  or  extended  version  of  A   Typical  situaHon  where  the  needs  for  Open  and  Closed   modules  are  hard  to  reconcile   =    client  of  
  • 38. With  non-­‐OO  methods,     there  seem  to  be  only  2  solu=ons,     equally  unsa=sfactory  
  • 39. A  B   C   D   E   A  F   G   H   I   SoluHon  1  
  • 40. A  B   C   D   E   A  F   G   H   I   SoluHon  1  
  • 41. A  B   C   D   E   A’  F   G   H   I                SoluHon   We  have  taken  a  copy  of  A  and  modified  it,  turning  it  into  the  desired  A’  
  • 42.              SoluHon   Meyer’s  Assessment   the  consequences  are  appalling   an  explosion  of  variants     of  the  original  module,     many  of  them  very  similar,   but  never  quite  iden=cal   if  you  extrapolate  its  effects  to     •  many  modules     •  many  modificaHon  requests     •  a  long  period  of  Hme    
  • 43.              SoluHon  (Source  tree  copy)   Christensen’s  Assessment   Probably  the  main  reason  it  is  encountered  so  o9en  in  prac=ce         Easy  to  explain  to  colleagues  &  new  developers     No  implementa=on  interference  X  
  • 44.              SoluHon  (Source  tree  copy)   Christensen’s  Assessment   Quick  but  very  dangerous   In  the  long  run  it  is     oZen  a  real  disaster…   The  soluHon  has  severe   limita=ons.    
  • 45. because  it  leads  to  the     mul=ple  maintenance  problem    
  • 46.              SoluHon  (Source  tree  copy)   Christensen’s  Assessment   when  you  want  to  add/modify  logic     you  have  to:   •  Do  it  for  each  source  tree   •  Write  the  same  test  cases  for  each   source  tree   you  have  to  do  it  in     each  source  tree   when  you  need  to     remove  a  defect    
  • 47. DRIFT   PracHce  shows  that  over  Hme  the   source  trees  evolve  into  completely   different  direcHons:  they  dri9  apart.   AZer  a  while  it  is  more  or   less  like  maintaining  a  set   of  completely  different   applica=ons   At  that  point,  before  you  do  any  of   the  operaHons,  you  have  to  first   analyse  each  source  tree!!  
  • 48. Used  in  airports  to  generate  reports  of  local  weather   one  variant  for  each  airport  in  Denmark   init  and  config  code   Example   SAWOS  -­‐  Semi  AutomaHc  Weather  ObservaHon  System     8  copies!!!  
  • 49. Analysability   Stability   Reliability   soluHon   -­‐ -­‐ -­‐ Summary   mul=ple  maintenance  problem  
  • 50. That  was  Meyer’s  first  unsa=sfactory   soluHon   to  the  problem  of  making  modules     both  OPEN  and  CLOSED   Let’s  turn  to  the  second  one    
  • 51. A  B   C   D   E   A’  F   G   H   I   A  module  and  its  clients   New  clients  which  need  A’,  an  adapted  or  extended  version  of  A   =    client  of   Problem  
  • 52. SoluHon  2   A  B   C   D   E   A’  F   G   H   I   Change  by     ModificaHon  
  • 53. A+  B   C   D   E   A’  F   G   H   I   We  have  modified  A  into  A+,  which  can  switch  between  two  modes  of  execuHon   In  one  mode  it  behaves  like  A,  and  in  the  other  it  behaves  as  expected  of  A’                SoluHon  
  • 54. A+  B   C   D   E   A’  F   G   H   I   We  have  modified  A  into  A+,  which  can  switch  between  two  modes  of  execuHon   In  one  mode  it  behaves  like  A,  and  in  the  other  it  behaves  as  expected  of  A’                SoluHon  
  • 55. A+  B   C   D   E   A’  F   G   H   I   If  (variant  ==  VARIANT_1)   then  {          ….     }  else  {          ….   }     At  points  of  varia=on,  A+  looks  like  this:   We  have  modified  A  into  A+,  which  can  switch  between  two  modes  of  execuHon   In  one  mode  it  behaves  like  A,  and  in  the  other  it  behaves  as  expected  of  A’     AlternaHvely,  this  can     be  a  switch              SoluHon  
  • 56. A+  B   C   D   E   A’  F   G   H   I              SoluHon  –  Meyer’s  Assessment  
  • 57. A+  B   C   D   E   A’  F   G   H   I   The  poten=al  for  disaster  is  obvious:  changes  to  A  may  invalidate  the  assumpHons  on  the     basis  of  which  the  old  clients  used  A.   So  the  changes  may  start  a  dramaHc  series  of  changes  in  clients,  client  of  clients....etc              SoluHon  –  Meyer’s  Assessment  
  • 58. A+   A’  F   G   H   I              SoluHon  –  Meyer’s  Assessment   The  poten=al  for  disaster  is  obvious:  changes  to  A  may  invalidate  the  assumpHons  on  the     basis  of  which  the  old  clients  used  A.   So  the  changes  may  start  a  dramaHc  series  of  changes  in  clients,  client  of  clients....etc   B   C   E   D   this  is  a  nightmare  for  the  proj.  mgr.   the  system  regresses   and  several  modules  have  to  be  re-­‐ opened  for  dev/test/debug/ documentaHon  
  • 59. Even  though  the  Change  soluHon  has  this  problema=c  ripple  effect,  it  is  sHll  be2er  than     the  Copy  solu=on.   On  the  surface,  the  copy  solu=on  seems  be2er  because  it  avoids  the  ripple  effect  of  change   but  in  fact  it  may  even  be  more  catastrophic…it  only  postpones  the  day  of  reckoning   We  saw  earlier  the  risks  of  an  explosion  of  variants,  many  of  them  very  similar,     but  never  quite  iden=cal:              SoluHon  –  Meyer’s  Assessment   soluHon  soluHon  
  • 60.            SoluHon  (Parametric  soluHon)   Christensen’s  Assessment   CondiHonals  are  easy  to  understand.  So  approach  is  easy  to   describe  to  other  developers.   Avoids  Mul=ple  Maintenance  Problem     Only  one  code  base  to  maintain   soluHon  soluHon  
  • 61. LiabiliHes,  most  of  which  deal  with  long  term  maintainability     Change  by     ModificaHon   Reliability  Concerns  –  soluHon  relies  on       with  risk  of   introducing   new  defects     Analysability  concerns  –  as  more  and  more   requirements  are  handled  by  parameter   switching,  the  code  becomes  less  easy  to   analyse     …   Responsibility  erosion  –  the  soZware  has,   without  much  noHce,  been  given  an  extra   responsibility   drives   towards   Procedural   Design   Blob  aka   God  Class              SoluHon  (Parametric  soluHon)   Christensen’s  Assessment  
  • 62. A  reasonable  approach  at  first,  but  one  with  serious  problems   for  applicaHons  that  need  to  grow  over  Hme              SoluHon  (Switches)   Shalloway’s  Assessment   Not  too  bad  as  long  as  you  just  keep  adding  cases…   2004  
  • 63. but  soon  you  need  to  introduce  fall-­‐throughs…   …and  then  the  switches  are  not  as  nice  as  they  used  to  be  
  • 64. Eventually  you  need  to  start  adding  varia=ons  within  a  case.       I  like  to  call  this     switch! The  flow  of  the  switches  themselves  becomes  confusing,  hard  to  read,  hard  to     decipher.   When  a  new  case  comes  in  the  programmer  must  find  every  place  it  can     be  involved  (o9en  finding  all  but  one  of  them).   Suddenly  things  get  bad  in  a  hurry.    
  • 65. Analysability   Stability   Reliability   solu=on   -­‐ -­‐ -­‐ Summary   Analysability   Stability   Reliability   solu=on   -­‐   -­‐   -­‐   With  non-­‐OO  methods,  there  are  only  only  2  solu=ons  available  to  us,     BOTH  UNSATISFACTORY   mul=ple  maintenance  problem   Change  by     ModificaHon   CHANGE   COPY  
  • 66. If  non-­‐OO  methods  are  all  we  have,  then   Meyer  says  we  face  a  change  or  copy   dilemma   CHANGE   COPY  
  • 67. A  B   C   D   E   A’  F   G   H   I   So  how  can  we  have  modules  that  are  both                                and                                    ?   How  can  we  keep  A  and  everything  in  the  top  part  of  the  figure  unchanged,  …   …while  providing  A’  to  the  bo>om  clients,  and  avoiding  duplica=on  of  so9ware?    
  • 68. A  B   C   D   E   A’  F   G   H   I   With  the  OO  concept  of  inheritance   Inheritance  allows  us  to  get  out  of  the  CHANGE  OR  COPY  dilemma…   …because  inheritance  allows  us  to  define  a  new  module  A'  in  terms  of  an  exis=ng   module  A,  …by  sta=ng  only  the  differences  between  the  two     A’  defines  new  features,  and  redefines  (i.e.  modifies)   one  or  more  of  A’s  features   inherits  from   Change  by     AddiHon  
  • 69. Thanks  to  inheritance,  OO  developers  can  adopt  a  much  more   incremental  approach  to  soZware  development  than  used  to  be   possible  with  earlier  methods   OO  inheritance  
  • 70. Hacking = Slipshod approach to building and modifying code Slipshod = Done poorly or too quickly; careless. The  Hacker     may  seem     bad   but  oZen  his     heart  is  pure.  
  • 71. He  sees  a  useful  piece  of  soZware,  which  is  almost  able  to  address  the  needs  of  the     moment,  more  general  than  the  soZware’s  original  purpose.     Hacker     Spurred  by  a  laudable  desire  not  to  redo  what  can  be  reused,  our  hacker  starts     modifying  the  original  to  add  provisions  for  new  cases   solu=on  
  • 72. The  impulse  is  good  but  the  effect   is  oZen  to  pollute  the  soZware   with  many  clauses  of  the  form     if  that_special_case  then…   if  (<special  case  D>)   then …   if  (<special  case  C>)   then …   if  (<special  case  B>)   then …   if  (<special  case  A>)   then …   switch!
  • 73. so  that  aZer  a  few  rounds  of  hacking,  perhaps  by  different  hackers,     the  soZware  starts  resembling  a  chunk  of  Swiss  cheese  that   has  been  leZ  outside  for  too  long  in  August  –  it  has  both  holes   and  growth   Hacking  
  • 74. Open-Closed Principle =   One  way  to  describe  the  OCP  and  the  consequent  OO  techniques  is  to  think  of  them   as  organised  hacking   Hacking   The  organised  form  of  hacking  will  enable  us  to  cater  to  the  variants     without  affec=ng  the  consistency  of  the  original  version.   Inheritance   Change  by     ModificaHon   Change  by     AddiHon  
  • 75. if  you  have  control  over     original  s/w  and     can  rewrite  it       so  that  it  will  address  the  needs    of  several  kinds  of  clients   …you  should  do  so   Caveats   at  no  extra  complicaHon  
  • 76.    The  OCP  principle  and  associated  techniques  are  intended  for  the     adapta=on  of  healthy  modules    If  there  is  something  wrong   with  a  module  you  should  fix   it…           …not  leave  the  original  alone  and   try  to  correct  the  problem  in  the   derived  module   Derived   Base   neither  OCP  nor  redefiniHon  in   inheritance  is  a  way  to  address   design  flaws,  let  alone  bugs   Design     Flaw  
  • 77.
  • 78. its  purpose,  its  enHre  reason   for  being,  is  to  reduce  the   cost  of  change.    
  • 79. Ques=on:  how  do  we  promote  flexibility,     reliability  and  stability  in  our  soZware?   Analysability   Maintainability   Changeability   Stability   Testability   Flexibility   Reliability  
  • 80. Answer:  we  favour  ‘Change  by  Addi=on’  over     ‘Change  by  Modifica=on’   Changeability   Stability   Flexibility   Reliability   Change  by     ModificaHon   Change  by     AddiHon   -­‐ + -­‐ +  
  • 81. How  do  we  achieve                                                                    ?  Change  by     AddiHon   which  uses  OO  inheritance   Inheritance   We  apply  the  Open-­‐Closed  Principle  
  • 82. extends  is  evil!!!!!   Yes,  we’ll  cover  that  in  the  next  presentaHon:  Part  II   But,  using  inheritance  is  no  longer  the  main  approach     to  saHsfying  the  OCP   Allen  Holub   2004   2003  
  • 83. in  which  we  look  at  the  modern,     contemporary  version  of  the  OCP     again,  we’ll  cover  this  in  the  next  presentaHon:  Part  II   Using  inheritance  is  sHll  one  of  the  ways  of  saHsfying  the  OCP,     and  was  considered  THE  approach  for  a  long  while   Why  extends  is  evil   1988  -­‐  1st  ed.     1997  –  2nd  ed.     1995     That  started  changing  with  the    emergence  of  the     design  techniques  presented  in  Design  Pa2erns   2003  
  • 84.
  • 85. References   All  images  sourced  from  h>p://www.google.co.uk/advanced_image_search,  so  see  there  for  details  of   which  are    subject  to  copyright     Object-­‐Oriented  So9ware  Construc=on  –  by  Bertrand  Meyer;  PublicaHon  Date:  3  April  1997  |  ISBN-­‐10:   0136291554  |  ISBN-­‐13:  978-­‐0136291558  |  EdiHon:  2     Flexible,  Reliable  So9ware:  Using  Pa2erns  and  Agile  Development  –  by  Henrik  B.  Christensen;   PublicaHon  Date:  11  May  2010  |  ISBN-­‐10:  1420093622  |  ISBN-­‐13:  978-­‐1420093629     Design  Pa2erns  Explained:  A  New  Perspec=ve  on  Object-­‐Oriented  Design;  by  Alan  Shalloway;   PublicaHon  Date:  12  Oct  2004  |  ISBN-­‐10:  0321247140  |  ISBN-­‐13:  978-­‐0321247148  |  EdiHon:  2     Less  -­‐  The  Path  to  Be2er  Design;  by  Sandi  Metz  at  GoRuCo  2011     goruco_2011_-­‐_sandi_metz_-­‐_less_-­‐_the_path_to_be>er_design_1280x720.mp4     Why  Extends  is  Evil  -­‐  Improve  your  code  by  replacing  concrete  base  classes  with  interfaces;  by   Allen  Holub;    h>p://www.javaworld.com/arHcle/2073649/core-­‐java/why-­‐extends-­‐is-­‐evil.html