Difference between revisions of "OOP Reassigned"
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | [[Category: | + | [[Category:IAM Classes]] |
Duck Study | Duck Study | ||
Line 25: | Line 25: | ||
Object ---> | Object ---> | ||
[http://iam.colum.edu/quickstart/util/classbrowser.aspx?assembly=System.Web,%20Version=2.0.0.0,%20Culture=neutral,%20PublicKeyToken=b03f5f7f11d50a3a&namespace=System.Web.UI&class=Control Control]---> [http://iam.colum.edu/quickstart/util/classbrowser.aspx?assembly=System.Web,%20Version=2.0.0.0,%20Culture=neutral,%20PublicKeyToken=b03f5f7f11d50a3a&namespace=System.Web.UI.WebControls&class=WebControl WebControl]---> BaseDataBoundControl ---> DataBoundControl --->[http://iam.colum.edu/quickstart/util/classbrowser.aspx?assembly=System.Web,%20Version=2.0.0.0,%20Culture=neutral,%20PublicKeyToken=b03f5f7f11d50a3a&namespace=System.Web.UI.WebControls&class=ListControl ListControl] ---> [http://iam.colum.edu/quickstart/util/classbrowser.aspx?assembly=System.Web,%20Version=2.0.0.0,%20Culture=neutral,%20PublicKeyToken=b03f5f7f11d50a3a&namespace=System.Web.UI.WebControls&class=DropDownList DropDownList] | [http://iam.colum.edu/quickstart/util/classbrowser.aspx?assembly=System.Web,%20Version=2.0.0.0,%20Culture=neutral,%20PublicKeyToken=b03f5f7f11d50a3a&namespace=System.Web.UI&class=Control Control]---> [http://iam.colum.edu/quickstart/util/classbrowser.aspx?assembly=System.Web,%20Version=2.0.0.0,%20Culture=neutral,%20PublicKeyToken=b03f5f7f11d50a3a&namespace=System.Web.UI.WebControls&class=WebControl WebControl]---> BaseDataBoundControl ---> DataBoundControl --->[http://iam.colum.edu/quickstart/util/classbrowser.aspx?assembly=System.Web,%20Version=2.0.0.0,%20Culture=neutral,%20PublicKeyToken=b03f5f7f11d50a3a&namespace=System.Web.UI.WebControls&class=ListControl ListControl] ---> [http://iam.colum.edu/quickstart/util/classbrowser.aspx?assembly=System.Web,%20Version=2.0.0.0,%20Culture=neutral,%20PublicKeyToken=b03f5f7f11d50a3a&namespace=System.Web.UI.WebControls&class=DropDownList DropDownList] | ||
+ | |||
+ | ==Interfaces== | ||
+ | |||
+ | 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== | ||
Line 41: | Line 54: | ||
Pretty good example of the strategey method in action. | Pretty good example of the strategey method in action. | ||
− | [http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class11/Characters/ | + | [http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class11/Characters/Characters/Characters/Program.cs Characters] |
==Homework== | ==Homework== | ||
Create Characters class and weapons class that uses the strategy pattern | Create Characters class and weapons class that uses the strategy pattern |
Latest revision as of 16:37, 10 June 2019
Duck Study
Problems with inheritance
The super class Duck has a swim method.
Duck.swim()
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
http://iam.colum.edu/oop/classsource/class11/controls.aspx
see
Hierarchy
Object ---> Control---> WebControl---> BaseDataBoundControl ---> DataBoundControl --->ListControl ---> DropDownList
Interfaces
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
http://www.dofactory.com/Patterns/PatternStrategy.aspx
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
http://iam.colum.edu/oop/browser/browser.aspx?f=/classsource/class11/Duck
http://www.dofactory.com/Patterns/PatternStrategy.aspx
Pretty good example of the strategey method in action.
Homework
Create Characters class and weapons class that uses the strategy pattern