SlideShare a Scribd company logo
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Object-­‐Oriented	
  Design	
  
	
  
Inheritance	
  	
  
vs.	
  	
  
ComposiAon:	
  
Part	
  II	
  
	
  
	
  Inheritance for Interface: Multiple Inheritance
Design	
  QuesAons	
  
•  How	
  to	
  implement	
  mulAple	
  inheritance?	
  
•  What	
  type	
  is	
  most	
  important?	
  	
  	
  
– DisAnguish	
  between	
  potenAal	
  base	
  classes	
  
– Decide	
  which	
  type(s)	
  to	
  subordinate	
  
Copyright@2015	
  	
  	
  	
  	
  	
  	
  	
  Adair	
  Dingle	
  
Key	
  ObservaAons	
  
•  Inheritance	
  and	
  composiAon	
  BOTH	
  provide	
  
reuse	
  
•  Interface	
  inheritance	
  is	
  not	
  true	
  inheritance	
  
– but	
  can	
  serve	
  to	
  fulfill	
  client	
  needs	
  
•  Design	
  impacts	
  soSware	
  maintainability	
  
Copyright@2015	
  	
  	
  	
  	
  	
  	
  	
  Adair	
  Dingle	
  
Chapter	
  8:	
  	
  
Design	
  AlternaAves	
  &	
  PerspecAves	
  
	
  
ComparaAve	
  Design	
  
	
  	
  Design	
  types	
  and	
  alterna/ves	
  for	
  client	
  use	
  	
  	
  
	
  
•  Class	
  design	
  types	
  
•  Design	
  for	
  Inheritance	
  
•  Inheritance	
  vs.	
  ComposiAon	
  
•  MulAple	
  Inheritance	
  
•  Design	
  Principles	
  
	
  	
  
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Why	
  consider	
  SoSware	
  Design?	
  
•  Design	
  impacts	
  soSware	
  use	
  	
  
–  Efficiency,	
  OpAmizaAon	
  (Inlining),	
  Maintainability,	
  …	
  
–  Ease	
  of	
  subtype	
  manipulaAon,	
  heterogeneous	
  collecAons,	
  ...	
  
–  Interface	
  adaptaAon,	
  type	
  subordinaAon,	
  …	
  
•  Design	
  impacts	
  soSware	
  reuse	
  
–  Type	
  extensibility	
  
–  Type	
  checking,	
  type	
  extracAon	
  
•  Class	
  designers	
  should	
  carefully	
  consider	
  design	
  alternaAves	
  
•  Different	
  costs	
  and	
  benefits	
  
–  Inheritance	
  vs	
  composiAon	
  
–  Exposed/echoed/wrapped	
  interfaces	
  
–  Type	
  definiAon/idenAficaAon/extracAon	
  
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Class	
  Design	
  Types	
  
•  Concrete	
  –	
  immediately	
  usable	
  
–  Simple,	
  efficient,	
  standalone	
  type	
  
–  Inheritance	
  NOT	
  intended	
  
•  Abstract	
  –	
  not	
  instanAable	
  
–  Defines	
  common	
  interface	
  for	
  class	
  hierarchy	
  
–  Inheritance	
  REQUIRED	
  
•  Node	
  -­‐-­‐	
  Intermediate	
  class	
  in	
  class	
  hierarchy	
  
–  Inherits	
  interface	
  
–  provides	
  resoluAon	
  or	
  refined	
  behavior	
  
–  Inheritance	
  anAcipated	
  
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Class	
  Design	
  Types	
  -­‐-­‐	
  conAnued	
  
•  Wrapper	
  
–  Isolates	
  client	
  from	
  instable	
  or	
  proprietary	
  interface	
  
–  May	
  echo	
  porAon	
  of	
  wrapped	
  interface	
  
–  May	
  augment/coalesce/modified	
  wrapped	
  behavior	
  
–  Wrapped	
  object	
  replaceable	
  without	
  impact	
  
•  Delegate	
  
–  Wrapped	
  subObject	
  	
  
–  Replaceable,	
  possibly	
  polymorphic	
  
–  ResponsibiliAes	
  delegated	
  to	
  wrapped	
  subObject	
  
•  Handle	
  
–  Transparent	
  resource	
  manager	
  
–  Tracks	
  wrapped	
  subObject	
  
–  No	
  alteraAon	
  in	
  wrapped	
  behavior	
  
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Encapsulated	
  SubObjects	
  
•  Wrappers	
  encapsulate	
  exisAng	
  types	
  
–  reusing	
  (and	
  possibly	
  augmenAng	
  or	
  modifying)	
  funcAonality	
  	
  
–  frequently	
  isolate	
  applicaAon	
  programmer	
  from	
  unstable	
  interfaces	
  	
  
–  wrapped	
  subObject	
  may	
  be	
  replaced	
  without	
  any	
  impact	
  
–  subObject’s	
  interface,	
  if	
  echoed,	
  	
  oSen	
  echoed	
  in	
  a	
  modified	
  fashion.	
  	
  	
  
•  Delegate	
  is	
  (wrapped)	
  subObject	
  
–  provides	
  key	
  funcAonality	
  to	
  the	
  wrapper	
  class	
  
–  may	
  be	
  exchanged,	
  replaced,	
  stubbed	
  out,	
  and/or	
  polymorphic.	
  
•  Handle	
  promotes	
  transparency	
  	
  
–  provides	
  external	
  access	
  to	
  internal	
  funcAonality	
  of	
  wrapped	
  subObject	
  	
  
–  e.g.	
  smart	
  pointer	
  
–  Unlike	
  wrappers,	
  handles	
  do	
  not	
  augment	
  or	
  modify	
  subObject	
  
funcAonality.	
  	
  	
  
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Abstract	
  Classes	
  
•  Define	
  interface	
  for	
  class	
  hierarchy	
  
–  Determine	
  funcAonality	
  accessible	
  via	
  heterogeneous	
  
collecAon	
  
•  May	
  or	
  may	
  not	
  provide	
  default	
  behavior	
  
•  Require	
  inheritance	
  
•  EffecAve	
  design	
  with	
  polymorphism	
  
–  May	
  dilute	
  cohesion	
  if	
  designed	
  but	
  unnecessary	
  
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Abstract	
  Classes	
  
•  A	
  class	
  is	
  DESIGNED	
  as	
  abstract	
  when	
  
•  At	
  least	
  one	
  method	
  is	
  undefined	
  
•  only	
  protected	
  constructors	
  provided	
  
=>	
  Client	
  cannot	
  instanAate	
  instance	
  of	
  class	
  
•  C#/Java	
  provide	
  keyword	
  abstract	
  
•  code	
  more	
  readable	
  and	
  thus	
  maintainable	
  
•  C++	
  does	
  not	
  provide	
  keyword	
  abstract	
  
•  UAlity	
  of	
  abstract	
  classes	
  remains	
  the	
  same	
  
–  regardless	
  of	
  syntacAcal	
  differences	
  across	
  languages	
  	
  	
  
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Example	
  8.4	
  	
  Abstract	
  Classes	
  
//C++: no keyword abstract C#/Java: just use keyword abstract
// C++ => at least one method must be pure virtual
class Toy
{ public:
virtual bool safe() = 0;
…
};
//Abstract BY DESIGN (C++, C#, Java,…)
// => protected constructor, no public constructor
class Vehicle
{ protected:
Vehicle();
public:
…
};
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Example	
  8.5	
  	
  Delegate	
  Use	
  
class seminarAttendee // delegate could be object or pointer
{ // indirection supports postponed instantiation
idVerifier delegate;
…
void replaceDelegate(…)
{ idVerifier newImproved(…);
delegate = newImproved;
}
public:
…
// pass requests to delegate
bool registerD() { return delegate.isSet() }
bool isValid() { return delegate.verify(); }
bool renew()
{ if (!registerD() || !isValid()) return false;
return (delegate.getAge() > 18)
}
};
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Example	
  8.6	
  	
  Polymorpic	
  Delegate	
  
class HasADelegate
{ idVerifier delegate;
BaseType* polyD;
void replaceDelegate()
{ delete polyD;
if (…) polyD = new MinType(…);
else if (…) polyD = new MaxType(…);
else if (…) polyD = new MeanType(…);
}
public:
// simple echo
int getAge() [ return delegate.getAge(); }
// additional layer of indirection supports polymorphism
void dynamicProcess()
{ return polyD->process(); }
…
};
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Table	
  8.4	
  	
  Inheritance	
  Effects	
  
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Motivation Characteristics Benefits Costs
Code reuse
Inheritance of
Implementation
Reuse existing class
May suppress/NOP
interface
Reduce :
--development time
--cut & paste design
--maintenance
Code complexity
Increased coupling
Decreased cohesion
Unavoidable overhead
Fixed cardinality
Dependency on parent
Lifetime association
Type extension
Inheritance of
Interface
Is-a relationship
Subtype relevant
Type familiarity
Substitutability
Polymorphism
Heterogeneity
Extensibility
Inheritance	
  vs.	
  ComposiAon	
  
Both	
  support	
  Code	
  Reuse	
  
Inheritance	
  supports	
  	
  
	
  type	
  extensibility	
  
	
  polymorphism	
  
	
  heterogeneous	
  collecAons	
  
	
  
Inheritance	
  provides	
  	
  
	
  built-­‐in	
  and	
  efficient	
  mechanism	
  for	
  type-­‐checking	
  
	
  promotes	
  design	
  clarity	
  and	
  maintainability	
  	
  
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Inheritance	
  vs.	
  ComposiAon	
  
ComposiAon	
  affords	
  the	
  class	
  designer	
  more	
  control	
  
•  subObject	
  may	
  be	
  manipulated	
  in	
  ways	
  that	
  a	
  parent	
  cannot	
  
	
  
•  InstanAaAon	
  may	
  be	
  postponed	
  
•  subObjects	
  may	
  be	
  replaced	
  
•  Cardinality,	
  lifeAme,	
  associaAon	
  and	
  ownership	
  may	
  vary	
  
–  All	
  fixed	
  design	
  for	
  inheritance	
  	
  	
  
•  Interfaces	
  may	
  be	
  selecAvely	
  echoed	
  	
  	
  
•  Overhead	
  can	
  be	
  avoided	
  	
  	
  
•  Unstable	
  types	
  may	
  be	
  wrapped	
  	
  	
  	
  
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Example	
  8.8	
  	
  Inheritance	
  vs	
  ComposiAon	
  
class B
{ protected:
virtual void filter();
public:
…
virtual void store();
};
class QueenInheritB: public B
{ public:
// keyword used for documentation
// once virtual always virtual!!
virtual void store()
{ B::store();
filter();
…
}
…
};
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Example	
  8.8	
  	
  conAnued	
  
class QueenComposeB
{
B subObject;
public:
// cannot access protected B::filter()
// virtual nature of B::store() not relevant
void store()
{ subObject.store();
…
}
…
};
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Example	
  8.9	
  ComposiAon	
  with	
  Exposed	
  Interface	
  
class Be: public B
{ public:
… // make inherited protected method public
void filter() { B::filter(); }
};
class QueenComposeB2
{ Be subObject;
public:
// can filter by using intermediary class
void store()
{ subObject.store();
subObject.filter();
}
};
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Example	
  8.10	
  	
  Inheritance	
  vs	
  Polymorphic	
  Subobjects	
  
class flexQueen
{ B* subObjP;
public:
// constructor can instantiate any B (sub)type object
// subObjP = 0 or subObjP = new Be or subObjP = Bee …
flexQueen()
{ subObjP = new B;
… // other choices
}
virtual void store()
{ subObjP->store(); // dynamic behavior }
void replaceB(B*& worker)
{ delete subObjP; subObjP = worker;
worker = 0;
}
…
};
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
MulAple	
  Inheritance	
  
•  Like	
  single	
  inheritance,	
  mulAple	
  inheritance	
  	
  
–  promotes	
  type	
  extensibility	
  	
  
–  supports	
  polymorphism.	
  	
  	
  
•  MulAple	
  inheritance	
  increases	
  design	
  complexity	
  	
  	
  
–  two	
  divergent	
  ancestral	
  paths	
  needed	
  to	
  understand	
  	
  class	
  	
  
–  Two-­‐degree	
  variance	
  may	
  compromise	
  maintainability	
  	
  	
  
•  Two	
  classic	
  design	
  difficulAes	
  
–  AMBUGUITY:	
   	
  parental	
  interfaces	
  overlap	
  
–  REDUNDANCY: 	
  common	
  grandparent	
  component	
  
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
MulAple	
  Inheritance	
  
•  Ambiguity	
  easily	
  resolved	
  
–  Two	
  parents	
  define	
  same	
  funcAon	
  signature	
  
=>	
  	
  COMPILER	
  ERROR	
  
–  Child	
  class	
  must	
  override	
  doubly	
  inherited	
  funcAon	
  
•  redefine	
  or	
  direct	
  call	
  to	
  specific	
  parent	
  
=>	
  Descendant	
  class	
  definiAons	
  compile	
  
•  Redundancy	
  NOT	
  easily	
  resolved	
  
–  Two	
  parents	
  share	
  same	
  ancestor	
  
–  Child	
  class	
  inherits	
  two	
  copies	
  of	
  common	
  ancestor	
  	
  
–  Duplicate	
  copy	
  cannot	
  be	
  suppressed	
  easily	
  
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Example	
  8.12	
  Resolving	
  Ambiguity:	
  	
  
C++	
  MulAple	
  Inheritance	
  
class StudentEmployee: public Employee, public Student
{ …
public:
…
int getAge()
{ return Student::getAge(); }
int getSeniority()
{ return Employee::getAge(); }
};
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Type	
  SubordinaAon	
  
•  Inheritance	
  simulated	
  via	
  ComposiAon	
  
–  One	
  (or	
  both)	
  parent	
  is	
  defined	
  as	
  a	
  subObject	
  
–  Necessary	
  when	
  mulAple	
  inheritance	
  NOT	
  supported	
  (C#/Java)	
  	
  
•  Class	
  designer	
  selects	
  subObject	
  &	
  thus	
  subordinates	
  a	
  type	
  	
  
•  subObject	
  does	
  not	
  have	
  visibility	
  of	
  a	
  parent	
  component	
  
–  its	
  interface	
  is	
  not	
  assumed	
  	
  
–  Its	
  interface	
  must	
  be	
  echoed	
  if	
  needed	
  
•  No	
  is-­‐a	
  relaAonship	
  to	
  support	
  type	
  interchange	
  in	
  client	
  	
  code	
  	
  
–  Design	
  changes	
  not	
  ‘automaAcally’	
  passed	
  with	
  compilaAon	
  
–  No	
  external	
  subsAtutability	
  for	
  subObject	
  
–  No	
  heterogeneous	
  collecAons	
  typed	
  to	
  subObject	
  	
  	
  
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Type	
  SubordinaAon	
  
	
  
EffecAve	
  design	
  technique	
  
•  Permits	
  simulaAon	
  of	
  inheritance	
  	
  
•  adds	
  flexibility	
  and	
  control	
  over	
  	
  
–  InstanAaAon	
  
–  Cardinality	
  
–  AssociaAon	
  
–  LifeAme	
  
–  Ownership	
  
–  Interface	
  	
  	
  
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Example	
  8.17	
  	
  C#	
  StudentEmployee:	
  	
  Student	
  parent	
  
interface EmployeeI
{ … }
public class StudentEmployee3: Student, EmployeeI
{ // contain zero or more Employee components
private Employee e;
// interface forces echo of Employee functionality
…
}
// why ‘Employee’ subordinated to ‘Student’?
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Table	
  8.5	
  	
  Simulate	
  MulAple	
  Inheritance	
  
using	
  ComposiAon	
  	
  
Motivation Benefits Costs
No provision for multiple
inheritance in implementation
language
Clear subordinate parent type
Efficiency
Type depends on one parent
for utility not interface
Variable cardinality
Replaceable subobject
Insulating layer
Shield from parent
Polymorphic subobject
Inconvenient loss of:
-- Protected interface
Design constrained by
loss of:
--Type familiarity
--Substitutability
--Polymorphism
--Heterogeneity
--Extensibility
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Interface	
  SegregaAon	
  Principle	
  
Interfaces	
  should	
  be	
  small	
  and	
  contain	
  only	
  a	
  few,	
  
related	
  methods	
  	
  	
  
•  Exalts	
  interfaces	
  as	
  key	
  design	
  component	
  	
  
•  Promotes	
  high	
  cohesion	
  and	
  low	
  coupling	
  	
  
•  Confines	
  breadth	
  of	
  interface	
  
–  Narrow	
  interfaces	
  focus	
  design	
  and	
  imply	
  specific	
  uAlity.	
  	
  	
  
–  Wide	
  interfaces	
  undermine	
  cohesion	
  and	
  maintainability	
  
•  Targets	
  interacAng	
  class	
  design	
  
–  whether	
  for	
  inheritance	
  or	
  composiAon.	
  
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Program	
  to	
  Interface	
  	
  
Not	
  to	
  ImplementaAon	
  
Model	
  func/onality,	
  decoupled	
  from	
  implementa/on,	
  by	
  
using	
  abstract	
  classes	
  and	
  interfaces.	
  
=>	
  	
  Implementa/on	
  can	
  then	
  vary	
  independently.	
  	
  	
  
•  Exalts	
  interfaces	
  as	
  key	
  design	
  component	
  	
  
•  Upholds	
  OOD	
  abstracAon	
  and	
  encapsulaAon	
  	
  
–  Isolate	
  client	
  from	
  volaAle/arbitrary	
  implementaAon	
  	
  
•  Drives	
  complementary	
  class	
  design	
  
–  whether	
  for	
  inheritance	
  or	
  composiAon.	
  
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  
Dependency	
  Inversion	
  Principle	
  
High-­‐level	
  abstrac/ons	
  are	
  more	
  stable.	
  	
  
If	
  dependencies	
  exist,	
  preferable	
  that	
  low-­‐level	
  
abstrac/ons	
  depend	
  on	
  high-­‐level	
  abstrac/ons	
  	
  	
  
•  reinforces	
  value	
  of	
  an	
  extensible,	
  possibly	
  abstract,	
  
interface	
  at	
  the	
  base	
  of	
  a	
  class	
  hierarchy.	
  	
  	
  
•  suggests	
  choice	
  when	
  determining	
  subordinate	
  class	
  	
  
–  Client	
  should	
  be	
  isolated	
  from	
  the	
  least	
  abstract	
  type.	
  	
  	
  
–  if	
  any	
  lower-­‐level	
  details	
  change,	
  client	
  code	
  is	
  shielded.	
  
Copyright@2014	
  	
  	
  	
  	
  	
  	
  	
  Taylor	
  &	
  Francis	
  	
  	
  	
  	
  	
  	
  
Adair	
  Dingle	
  	
  	
  All	
  Rights	
  Reserved	
  

More Related Content

What's hot

Introducing Domain Driven Design - codemash
Introducing Domain Driven Design - codemashIntroducing Domain Driven Design - codemash
Introducing Domain Driven Design - codemash
Steven Smith
 
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)
Jay Patel
 
Cs8392 u1-1-oop intro
Cs8392 u1-1-oop introCs8392 u1-1-oop intro
Cs8392 u1-1-oop intro
Rajasekaran S
 
Refactoring Applications using SOLID Principles
Refactoring Applications using SOLID PrinciplesRefactoring Applications using SOLID Principles
Refactoring Applications using SOLID Principles
Steven Smith
 
OOP Unit 1 - Foundation of Object- Oriented Programming
OOP Unit 1 - Foundation of Object- Oriented ProgrammingOOP Unit 1 - Foundation of Object- Oriented Programming
OOP Unit 1 - Foundation of Object- Oriented Programming
dkpawar
 
Object oriented programming
Object oriented programmingObject oriented programming
C sharp
C sharpC sharp
C sharp
Ahmed Vic
 
Linq To The Enterprise
Linq To The EnterpriseLinq To The Enterprise
Linq To The Enterprise
Daniel Egan
 
Java for C++ programers
Java for C++ programersJava for C++ programers
Java for C++ programers
Salahaddin University-Erbil
 
1 Intro Object Oriented Programming
1  Intro Object Oriented Programming1  Intro Object Oriented Programming
1 Intro Object Oriented Programming
Docent Education
 
Class Members Access/Visibility Guide (Checklist)
Class Members Access/Visibility Guide (Checklist)Class Members Access/Visibility Guide (Checklist)
Class Members Access/Visibility Guide (Checklist)
Jayasree Perilakkalam
 
Core java part1
Core java  part1Core java  part1
Core java part1
VenkataBolagani
 
Object Oriented Programming Principles
Object Oriented Programming PrinciplesObject Oriented Programming Principles
Object Oriented Programming Principles
Andrew Ferlitsch
 
Introduction to c_sharp
Introduction to c_sharpIntroduction to c_sharp
Introduction to c_sharp
HEM Sothon
 
Presentation on java
Presentation  on  javaPresentation  on  java
Presentation on java
shashi shekhar
 
Short notes of oop with java
Short notes of oop with javaShort notes of oop with java
Short notes of oop with java
Mohamed Fathy
 
Introduction to object oriented language
Introduction to object oriented languageIntroduction to object oriented language
Introduction to object oriented language
farhan amjad
 
Itinerary Website (Web Development Document)
Itinerary Website (Web Development Document)Itinerary Website (Web Development Document)
Itinerary Website (Web Development Document)
Traitet Thepbandansuk
 
Domain specific languages and Scala
Domain specific languages and ScalaDomain specific languages and Scala
Domain specific languages and Scala
Filip Krikava
 

What's hot (19)

Introducing Domain Driven Design - codemash
Introducing Domain Driven Design - codemashIntroducing Domain Driven Design - codemash
Introducing Domain Driven Design - codemash
 
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)
 
Cs8392 u1-1-oop intro
Cs8392 u1-1-oop introCs8392 u1-1-oop intro
Cs8392 u1-1-oop intro
 
Refactoring Applications using SOLID Principles
Refactoring Applications using SOLID PrinciplesRefactoring Applications using SOLID Principles
Refactoring Applications using SOLID Principles
 
OOP Unit 1 - Foundation of Object- Oriented Programming
OOP Unit 1 - Foundation of Object- Oriented ProgrammingOOP Unit 1 - Foundation of Object- Oriented Programming
OOP Unit 1 - Foundation of Object- Oriented Programming
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
C sharp
C sharpC sharp
C sharp
 
Linq To The Enterprise
Linq To The EnterpriseLinq To The Enterprise
Linq To The Enterprise
 
Java for C++ programers
Java for C++ programersJava for C++ programers
Java for C++ programers
 
1 Intro Object Oriented Programming
1  Intro Object Oriented Programming1  Intro Object Oriented Programming
1 Intro Object Oriented Programming
 
Class Members Access/Visibility Guide (Checklist)
Class Members Access/Visibility Guide (Checklist)Class Members Access/Visibility Guide (Checklist)
Class Members Access/Visibility Guide (Checklist)
 
Core java part1
Core java  part1Core java  part1
Core java part1
 
Object Oriented Programming Principles
Object Oriented Programming PrinciplesObject Oriented Programming Principles
Object Oriented Programming Principles
 
Introduction to c_sharp
Introduction to c_sharpIntroduction to c_sharp
Introduction to c_sharp
 
Presentation on java
Presentation  on  javaPresentation  on  java
Presentation on java
 
Short notes of oop with java
Short notes of oop with javaShort notes of oop with java
Short notes of oop with java
 
Introduction to object oriented language
Introduction to object oriented languageIntroduction to object oriented language
Introduction to object oriented language
 
Itinerary Website (Web Development Document)
Itinerary Website (Web Development Document)Itinerary Website (Web Development Document)
Itinerary Website (Web Development Document)
 
Domain specific languages and Scala
Domain specific languages and ScalaDomain specific languages and Scala
Domain specific languages and Scala
 

Viewers also liked

Introduction to Embedded System
Introduction to Embedded SystemIntroduction to Embedded System
Introduction to Embedded System
Emertxe Information Technologies Pvt Ltd
 
I2C programming with C and Arduino
I2C programming with C and ArduinoI2C programming with C and Arduino
I2C programming with C and Arduino
sato262
 
Protols used in bluetooth
Protols used in bluetoothProtols used in bluetooth
Protols used in bluetooth
Sonali Parab
 
Multiple Inheritance
Multiple InheritanceMultiple Inheritance
Multiple Inheritance
adil raja
 
Embedded C - Optimization techniques
Embedded C - Optimization techniquesEmbedded C - Optimization techniques
Embedded C - Optimization techniques
Emertxe Information Technologies Pvt Ltd
 
Arm processor
Arm processorArm processor
Arm processor
SHREEHARI WADAWADAGI
 
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
Ronak Chhajed
 
Arm developement
Arm developementArm developement
Arm developement
hirokiht
 
Serial Peripheral Interface
Serial Peripheral InterfaceSerial Peripheral Interface
Serial Peripheral Interface
Anurag Tomar
 
Compiler in System Programming/Code Optimization techniques in System Program...
Compiler in System Programming/Code Optimization techniques in System Program...Compiler in System Programming/Code Optimization techniques in System Program...
Compiler in System Programming/Code Optimization techniques in System Program...
Janki Shah
 
SPI Protocol
SPI ProtocolSPI Protocol
SPI Protocol
Anurag Tomar
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
Abhijeet kapse
 
Embedded C
Embedded CEmbedded C
Embedded C - Lecture 1
Embedded C - Lecture 1Embedded C - Lecture 1
Embedded C - Lecture 1
Mohamed Abdallah
 
I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)
Varun Mahajan
 
Serial peripheral interface
Serial peripheral interfaceSerial peripheral interface
Serial peripheral interface
Abhijeet kapse
 
Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)
Dhaval Kaneria
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
guest9f8315
 
Iot
IotIot

Viewers also liked (19)

Introduction to Embedded System
Introduction to Embedded SystemIntroduction to Embedded System
Introduction to Embedded System
 
I2C programming with C and Arduino
I2C programming with C and ArduinoI2C programming with C and Arduino
I2C programming with C and Arduino
 
Protols used in bluetooth
Protols used in bluetoothProtols used in bluetooth
Protols used in bluetooth
 
Multiple Inheritance
Multiple InheritanceMultiple Inheritance
Multiple Inheritance
 
Embedded C - Optimization techniques
Embedded C - Optimization techniquesEmbedded C - Optimization techniques
Embedded C - Optimization techniques
 
Arm processor
Arm processorArm processor
Arm processor
 
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
 
Arm developement
Arm developementArm developement
Arm developement
 
Serial Peripheral Interface
Serial Peripheral InterfaceSerial Peripheral Interface
Serial Peripheral Interface
 
Compiler in System Programming/Code Optimization techniques in System Program...
Compiler in System Programming/Code Optimization techniques in System Program...Compiler in System Programming/Code Optimization techniques in System Program...
Compiler in System Programming/Code Optimization techniques in System Program...
 
SPI Protocol
SPI ProtocolSPI Protocol
SPI Protocol
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
Embedded C
Embedded CEmbedded C
Embedded C
 
Embedded C - Lecture 1
Embedded C - Lecture 1Embedded C - Lecture 1
Embedded C - Lecture 1
 
I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)
 
Serial peripheral interface
Serial peripheral interfaceSerial peripheral interface
Serial peripheral interface
 
Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Iot
IotIot
Iot
 

Similar to Object-Oriented Design: Multiple inheritance (C++ and C#)

C# - Igor Ralić
C# - Igor RalićC# - Igor Ralić
Better Understanding OOP using C#
Better Understanding OOP using C#Better Understanding OOP using C#
Better Understanding OOP using C#
Chandan Gupta Bhagat
 
L03 Software Design
L03 Software DesignL03 Software Design
L03 Software Design
Ólafur Andri Ragnarsson
 
Writing Readable Code
Writing Readable CodeWriting Readable Code
Writing Readable Code
eddiehaber
 
Code like a ninja session 1 object-oriented principles
Code like a ninja  session 1   object-oriented principlesCode like a ninja  session 1   object-oriented principles
Code like a ninja session 1 object-oriented principles
Deon Meyer
 
ITKonekt 2023: The Busy Platform Engineers Guide to API Gateways
ITKonekt 2023: The Busy Platform Engineers Guide to API GatewaysITKonekt 2023: The Busy Platform Engineers Guide to API Gateways
ITKonekt 2023: The Busy Platform Engineers Guide to API Gateways
Daniel Bryant
 
Ej Chpt#4 Final
Ej Chpt#4 FinalEj Chpt#4 Final
Ej Chpt#4 Final
Chandan Benjaram
 
Some Cool Design Patterns, Practices, and Principles
Some Cool Design Patterns, Practices, and PrinciplesSome Cool Design Patterns, Practices, and Principles
Some Cool Design Patterns, Practices, and Principles
itsarsalan
 
9 crucial Java Design Principles you cannot miss
9 crucial Java Design Principles you cannot miss9 crucial Java Design Principles you cannot miss
9 crucial Java Design Principles you cannot miss
Mark Papis
 
What is Interface in Java | How to implement Multiple Inheritance Using Inter...
What is Interface in Java | How to implement Multiple Inheritance Using Inter...What is Interface in Java | How to implement Multiple Inheritance Using Inter...
What is Interface in Java | How to implement Multiple Inheritance Using Inter...
Edureka!
 
Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)
stanbridge
 
ePortfolio and Platform Selection
ePortfolio and Platform SelectionePortfolio and Platform Selection
ePortfolio and Platform Selection
Jiyeon Lee
 
Building Large Sustainable Apps
Building Large Sustainable AppsBuilding Large Sustainable Apps
Building Large Sustainable Apps
Buğra Oral
 
Domain driven design
Domain driven designDomain driven design
Domain driven design
Amit Mukherjee
 
Creating Responsive eLearning With FRED
Creating Responsive eLearning With FREDCreating Responsive eLearning With FRED
Creating Responsive eLearning With FRED
Upside Learning Solutions
 
Traits composition
Traits compositionTraits composition
Traits composition
Marielle Lange
 
UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptx
anguraju1
 
Software Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural PatternsSoftware Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural Patterns
Sergey Aganezov
 
Technical interview questions
Technical interview questionsTechnical interview questions
Technical interview questions
Soba Arjun
 
Drupalcon cph
Drupalcon cphDrupalcon cph
Drupalcon cph
cyberswat
 

Similar to Object-Oriented Design: Multiple inheritance (C++ and C#) (20)

C# - Igor Ralić
C# - Igor RalićC# - Igor Ralić
C# - Igor Ralić
 
Better Understanding OOP using C#
Better Understanding OOP using C#Better Understanding OOP using C#
Better Understanding OOP using C#
 
L03 Software Design
L03 Software DesignL03 Software Design
L03 Software Design
 
Writing Readable Code
Writing Readable CodeWriting Readable Code
Writing Readable Code
 
Code like a ninja session 1 object-oriented principles
Code like a ninja  session 1   object-oriented principlesCode like a ninja  session 1   object-oriented principles
Code like a ninja session 1 object-oriented principles
 
ITKonekt 2023: The Busy Platform Engineers Guide to API Gateways
ITKonekt 2023: The Busy Platform Engineers Guide to API GatewaysITKonekt 2023: The Busy Platform Engineers Guide to API Gateways
ITKonekt 2023: The Busy Platform Engineers Guide to API Gateways
 
Ej Chpt#4 Final
Ej Chpt#4 FinalEj Chpt#4 Final
Ej Chpt#4 Final
 
Some Cool Design Patterns, Practices, and Principles
Some Cool Design Patterns, Practices, and PrinciplesSome Cool Design Patterns, Practices, and Principles
Some Cool Design Patterns, Practices, and Principles
 
9 crucial Java Design Principles you cannot miss
9 crucial Java Design Principles you cannot miss9 crucial Java Design Principles you cannot miss
9 crucial Java Design Principles you cannot miss
 
What is Interface in Java | How to implement Multiple Inheritance Using Inter...
What is Interface in Java | How to implement Multiple Inheritance Using Inter...What is Interface in Java | How to implement Multiple Inheritance Using Inter...
What is Interface in Java | How to implement Multiple Inheritance Using Inter...
 
Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)
 
ePortfolio and Platform Selection
ePortfolio and Platform SelectionePortfolio and Platform Selection
ePortfolio and Platform Selection
 
Building Large Sustainable Apps
Building Large Sustainable AppsBuilding Large Sustainable Apps
Building Large Sustainable Apps
 
Domain driven design
Domain driven designDomain driven design
Domain driven design
 
Creating Responsive eLearning With FRED
Creating Responsive eLearning With FREDCreating Responsive eLearning With FRED
Creating Responsive eLearning With FRED
 
Traits composition
Traits compositionTraits composition
Traits composition
 
UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptx
 
Software Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural PatternsSoftware Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural Patterns
 
Technical interview questions
Technical interview questionsTechnical interview questions
Technical interview questions
 
Drupalcon cph
Drupalcon cphDrupalcon cph
Drupalcon cph
 

Recently uploaded

June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
fredae14
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 

Recently uploaded (20)

June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 

Object-Oriented Design: Multiple inheritance (C++ and C#)

  • 1. Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved   Object-­‐Oriented  Design     Inheritance     vs.     ComposiAon:   Part  II      Inheritance for Interface: Multiple Inheritance
  • 2. Design  QuesAons   •  How  to  implement  mulAple  inheritance?   •  What  type  is  most  important?       – DisAnguish  between  potenAal  base  classes   – Decide  which  type(s)  to  subordinate   Copyright@2015                Adair  Dingle  
  • 3. Key  ObservaAons   •  Inheritance  and  composiAon  BOTH  provide   reuse   •  Interface  inheritance  is  not  true  inheritance   – but  can  serve  to  fulfill  client  needs   •  Design  impacts  soSware  maintainability   Copyright@2015                Adair  Dingle  
  • 4. Chapter  8:     Design  AlternaAves  &  PerspecAves     ComparaAve  Design      Design  types  and  alterna/ves  for  client  use         •  Class  design  types   •  Design  for  Inheritance   •  Inheritance  vs.  ComposiAon   •  MulAple  Inheritance   •  Design  Principles       Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 5. Why  consider  SoSware  Design?   •  Design  impacts  soSware  use     –  Efficiency,  OpAmizaAon  (Inlining),  Maintainability,  …   –  Ease  of  subtype  manipulaAon,  heterogeneous  collecAons,  ...   –  Interface  adaptaAon,  type  subordinaAon,  …   •  Design  impacts  soSware  reuse   –  Type  extensibility   –  Type  checking,  type  extracAon   •  Class  designers  should  carefully  consider  design  alternaAves   •  Different  costs  and  benefits   –  Inheritance  vs  composiAon   –  Exposed/echoed/wrapped  interfaces   –  Type  definiAon/idenAficaAon/extracAon   Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 6. Class  Design  Types   •  Concrete  –  immediately  usable   –  Simple,  efficient,  standalone  type   –  Inheritance  NOT  intended   •  Abstract  –  not  instanAable   –  Defines  common  interface  for  class  hierarchy   –  Inheritance  REQUIRED   •  Node  -­‐-­‐  Intermediate  class  in  class  hierarchy   –  Inherits  interface   –  provides  resoluAon  or  refined  behavior   –  Inheritance  anAcipated   Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 7. Class  Design  Types  -­‐-­‐  conAnued   •  Wrapper   –  Isolates  client  from  instable  or  proprietary  interface   –  May  echo  porAon  of  wrapped  interface   –  May  augment/coalesce/modified  wrapped  behavior   –  Wrapped  object  replaceable  without  impact   •  Delegate   –  Wrapped  subObject     –  Replaceable,  possibly  polymorphic   –  ResponsibiliAes  delegated  to  wrapped  subObject   •  Handle   –  Transparent  resource  manager   –  Tracks  wrapped  subObject   –  No  alteraAon  in  wrapped  behavior   Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 8. Encapsulated  SubObjects   •  Wrappers  encapsulate  exisAng  types   –  reusing  (and  possibly  augmenAng  or  modifying)  funcAonality     –  frequently  isolate  applicaAon  programmer  from  unstable  interfaces     –  wrapped  subObject  may  be  replaced  without  any  impact   –  subObject’s  interface,  if  echoed,    oSen  echoed  in  a  modified  fashion.       •  Delegate  is  (wrapped)  subObject   –  provides  key  funcAonality  to  the  wrapper  class   –  may  be  exchanged,  replaced,  stubbed  out,  and/or  polymorphic.   •  Handle  promotes  transparency     –  provides  external  access  to  internal  funcAonality  of  wrapped  subObject     –  e.g.  smart  pointer   –  Unlike  wrappers,  handles  do  not  augment  or  modify  subObject   funcAonality.       Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 9. Abstract  Classes   •  Define  interface  for  class  hierarchy   –  Determine  funcAonality  accessible  via  heterogeneous   collecAon   •  May  or  may  not  provide  default  behavior   •  Require  inheritance   •  EffecAve  design  with  polymorphism   –  May  dilute  cohesion  if  designed  but  unnecessary   Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 10. Abstract  Classes   •  A  class  is  DESIGNED  as  abstract  when   •  At  least  one  method  is  undefined   •  only  protected  constructors  provided   =>  Client  cannot  instanAate  instance  of  class   •  C#/Java  provide  keyword  abstract   •  code  more  readable  and  thus  maintainable   •  C++  does  not  provide  keyword  abstract   •  UAlity  of  abstract  classes  remains  the  same   –  regardless  of  syntacAcal  differences  across  languages       Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 11. Example  8.4    Abstract  Classes   //C++: no keyword abstract C#/Java: just use keyword abstract // C++ => at least one method must be pure virtual class Toy { public: virtual bool safe() = 0; … }; //Abstract BY DESIGN (C++, C#, Java,…) // => protected constructor, no public constructor class Vehicle { protected: Vehicle(); public: … }; Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 12. Example  8.5    Delegate  Use   class seminarAttendee // delegate could be object or pointer { // indirection supports postponed instantiation idVerifier delegate; … void replaceDelegate(…) { idVerifier newImproved(…); delegate = newImproved; } public: … // pass requests to delegate bool registerD() { return delegate.isSet() } bool isValid() { return delegate.verify(); } bool renew() { if (!registerD() || !isValid()) return false; return (delegate.getAge() > 18) } }; Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 13. Example  8.6    Polymorpic  Delegate   class HasADelegate { idVerifier delegate; BaseType* polyD; void replaceDelegate() { delete polyD; if (…) polyD = new MinType(…); else if (…) polyD = new MaxType(…); else if (…) polyD = new MeanType(…); } public: // simple echo int getAge() [ return delegate.getAge(); } // additional layer of indirection supports polymorphism void dynamicProcess() { return polyD->process(); } … }; Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 14. Table  8.4    Inheritance  Effects   Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved   Motivation Characteristics Benefits Costs Code reuse Inheritance of Implementation Reuse existing class May suppress/NOP interface Reduce : --development time --cut & paste design --maintenance Code complexity Increased coupling Decreased cohesion Unavoidable overhead Fixed cardinality Dependency on parent Lifetime association Type extension Inheritance of Interface Is-a relationship Subtype relevant Type familiarity Substitutability Polymorphism Heterogeneity Extensibility
  • 15. Inheritance  vs.  ComposiAon   Both  support  Code  Reuse   Inheritance  supports      type  extensibility    polymorphism    heterogeneous  collecAons     Inheritance  provides      built-­‐in  and  efficient  mechanism  for  type-­‐checking    promotes  design  clarity  and  maintainability     Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 16. Inheritance  vs.  ComposiAon   ComposiAon  affords  the  class  designer  more  control   •  subObject  may  be  manipulated  in  ways  that  a  parent  cannot     •  InstanAaAon  may  be  postponed   •  subObjects  may  be  replaced   •  Cardinality,  lifeAme,  associaAon  and  ownership  may  vary   –  All  fixed  design  for  inheritance       •  Interfaces  may  be  selecAvely  echoed       •  Overhead  can  be  avoided       •  Unstable  types  may  be  wrapped         Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 17. Example  8.8    Inheritance  vs  ComposiAon   class B { protected: virtual void filter(); public: … virtual void store(); }; class QueenInheritB: public B { public: // keyword used for documentation // once virtual always virtual!! virtual void store() { B::store(); filter(); … } … }; Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 18. Example  8.8    conAnued   class QueenComposeB { B subObject; public: // cannot access protected B::filter() // virtual nature of B::store() not relevant void store() { subObject.store(); … } … }; Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 19. Example  8.9  ComposiAon  with  Exposed  Interface   class Be: public B { public: … // make inherited protected method public void filter() { B::filter(); } }; class QueenComposeB2 { Be subObject; public: // can filter by using intermediary class void store() { subObject.store(); subObject.filter(); } }; Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 20. Example  8.10    Inheritance  vs  Polymorphic  Subobjects   class flexQueen { B* subObjP; public: // constructor can instantiate any B (sub)type object // subObjP = 0 or subObjP = new Be or subObjP = Bee … flexQueen() { subObjP = new B; … // other choices } virtual void store() { subObjP->store(); // dynamic behavior } void replaceB(B*& worker) { delete subObjP; subObjP = worker; worker = 0; } … }; Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 21. MulAple  Inheritance   •  Like  single  inheritance,  mulAple  inheritance     –  promotes  type  extensibility     –  supports  polymorphism.       •  MulAple  inheritance  increases  design  complexity       –  two  divergent  ancestral  paths  needed  to  understand    class     –  Two-­‐degree  variance  may  compromise  maintainability       •  Two  classic  design  difficulAes   –  AMBUGUITY:    parental  interfaces  overlap   –  REDUNDANCY:  common  grandparent  component   Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 22. MulAple  Inheritance   •  Ambiguity  easily  resolved   –  Two  parents  define  same  funcAon  signature   =>    COMPILER  ERROR   –  Child  class  must  override  doubly  inherited  funcAon   •  redefine  or  direct  call  to  specific  parent   =>  Descendant  class  definiAons  compile   •  Redundancy  NOT  easily  resolved   –  Two  parents  share  same  ancestor   –  Child  class  inherits  two  copies  of  common  ancestor     –  Duplicate  copy  cannot  be  suppressed  easily   Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 23. Example  8.12  Resolving  Ambiguity:     C++  MulAple  Inheritance   class StudentEmployee: public Employee, public Student { … public: … int getAge() { return Student::getAge(); } int getSeniority() { return Employee::getAge(); } }; Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 24. Type  SubordinaAon   •  Inheritance  simulated  via  ComposiAon   –  One  (or  both)  parent  is  defined  as  a  subObject   –  Necessary  when  mulAple  inheritance  NOT  supported  (C#/Java)     •  Class  designer  selects  subObject  &  thus  subordinates  a  type     •  subObject  does  not  have  visibility  of  a  parent  component   –  its  interface  is  not  assumed     –  Its  interface  must  be  echoed  if  needed   •  No  is-­‐a  relaAonship  to  support  type  interchange  in  client    code     –  Design  changes  not  ‘automaAcally’  passed  with  compilaAon   –  No  external  subsAtutability  for  subObject   –  No  heterogeneous  collecAons  typed  to  subObject       Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 25. Type  SubordinaAon     EffecAve  design  technique   •  Permits  simulaAon  of  inheritance     •  adds  flexibility  and  control  over     –  InstanAaAon   –  Cardinality   –  AssociaAon   –  LifeAme   –  Ownership   –  Interface       Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 26. Example  8.17    C#  StudentEmployee:    Student  parent   interface EmployeeI { … } public class StudentEmployee3: Student, EmployeeI { // contain zero or more Employee components private Employee e; // interface forces echo of Employee functionality … } // why ‘Employee’ subordinated to ‘Student’? Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 27. Table  8.5    Simulate  MulAple  Inheritance   using  ComposiAon     Motivation Benefits Costs No provision for multiple inheritance in implementation language Clear subordinate parent type Efficiency Type depends on one parent for utility not interface Variable cardinality Replaceable subobject Insulating layer Shield from parent Polymorphic subobject Inconvenient loss of: -- Protected interface Design constrained by loss of: --Type familiarity --Substitutability --Polymorphism --Heterogeneity --Extensibility Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 28. Interface  SegregaAon  Principle   Interfaces  should  be  small  and  contain  only  a  few,   related  methods       •  Exalts  interfaces  as  key  design  component     •  Promotes  high  cohesion  and  low  coupling     •  Confines  breadth  of  interface   –  Narrow  interfaces  focus  design  and  imply  specific  uAlity.       –  Wide  interfaces  undermine  cohesion  and  maintainability   •  Targets  interacAng  class  design   –  whether  for  inheritance  or  composiAon.   Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 29. Program  to  Interface     Not  to  ImplementaAon   Model  func/onality,  decoupled  from  implementa/on,  by   using  abstract  classes  and  interfaces.   =>    Implementa/on  can  then  vary  independently.       •  Exalts  interfaces  as  key  design  component     •  Upholds  OOD  abstracAon  and  encapsulaAon     –  Isolate  client  from  volaAle/arbitrary  implementaAon     •  Drives  complementary  class  design   –  whether  for  inheritance  or  composiAon.   Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved  
  • 30. Dependency  Inversion  Principle   High-­‐level  abstrac/ons  are  more  stable.     If  dependencies  exist,  preferable  that  low-­‐level   abstrac/ons  depend  on  high-­‐level  abstrac/ons       •  reinforces  value  of  an  extensible,  possibly  abstract,   interface  at  the  base  of  a  class  hierarchy.       •  suggests  choice  when  determining  subordinate  class     –  Client  should  be  isolated  from  the  least  abstract  type.       –  if  any  lower-­‐level  details  change,  client  code  is  shielded.   Copyright@2014                Taylor  &  Francis               Adair  Dingle      All  Rights  Reserved