Difference between revisions of "OOP Reassigned"

esse quam videri
Jump to: navigation, search
Line 1: Line 1:
[[Category:IAM Classes]][[Category:Object Oriented Programming]]
[[Category:IAM Classes]]
[[Category:Programming Language Concepts]]
[[Category:C Sharp]]
Duck Study
Duck Study

Latest revision as of 16:37, 10 June 2019

Duck Study

Problems with inheritance

The super class Duck has a swim method.


Any class that subclasses the duck class will inherit the swim() method. So far so good all ducks swim

The super class also has a fly() method sa all classes that inherit from duck will get the fly() method.

All ducks don't fly...

Controls is an example of good inhertance




Object ---> Control---> WebControl---> BaseDataBoundControl ---> DataBoundControl --->ListControl ---> DropDownList


Implements A

Interfaces are a alternative to inheritance that creates a polymorphic contract between classes. The classes the implements an interface all have the same properties and methods and can be used interchangeably.

Interfaces are often used to implement behaviors.

  • IRaceable
  • IWalkable
  • IDisposable
  • IPhone

Strategy Pattern


Strategy Pattern

Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.

Ducks From Book



Pretty good example of the strategey method in action.



Create Characters class and weapons class that uses the strategy pattern