1 / 19

OOP

OOP. Abstraction Classes Class Members: Properties & Methods Instance (object ) Encapsulation Interfaces Inheritance Composition Polymorphism Using Inheritance Using Interfaces. Abstraction.

cwen
Download Presentation

OOP

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OOP • Abstraction • Classes • Class Members: Properties & Methods • Instance (object) • Encapsulation • Interfaces • Inheritance • Composition • Polymorphism • Using Inheritance • Using Interfaces

  2. Abstraction A model of the properties, actions, and interactions of real world objects that are required for a software application.

  3. Classes A class is a template for an object. The class defines the properties (data attributes) and methods (functions in a class) that will be common to all instances of that class (objects) created from it.

  4. Encapsulation Functional details (how a member is implemented) of one object are hidden from objects that interact with it.

  5. Classes & Interfaces An Interface is a logical group of properties & methods that can be implemented by a class • All Interface members are implicitly public • There is no code inside interface members. • Can’t be static, virtual, abstract, or sealed

  6. Interfaces & ArcGIS Once published, Interfaces should not be modified (add/remove members) (e.g. IBasicMap, IBasicMap2)

  7. Inheritance • Some classes have some things in common • The common things can be promoted to a base class • The specific things can remain in the derived classes

  8. Inheritance syntax and keywords • MyClass : BaseClass • MyClass inherits from BaseClass, e.g.:<none | internal | public> class Cow : Animal • abstract keyword • Class cannot be instantiated only derived from, e.g.:public abstract class Animal • sealed keyword • Class cannot be derived from, e.g.:public sealed class Cow

  9. Inheritance syntax and keywords virtual & override keywords • Base class virtual members can be overridden in derived classes

  10. Inheritance syntax and keywords protected keyword • Member is accessible to base class and derived classes NOT to external classes

  11. Inheritance syntax and keywords base keyword • Call members on base class

  12. Scope Review public internal (default) protected Entire solution private More … Assembly only More … Derived classes More … Class only More …

  13. Inheritance and casting Casting = converting between types explicit implicit • Can also cast between interfaces on • Same class • Base and derived classes

  14. Abstract Classes vs Interfaces Similarities • Can be • Inherited • SomeClass : BaseClass • ISomeInterface : ISomeOtherInterface • Declared as variable types • BaseClass bc; • ISomeInterface si; • Cannot be instantiated • new BaseClass() • new ISomeInterface()

  15. Abstract Classes vs Interfaces Differences

  16. Layer FeatureLayer RasterLayer Map Composition One class composed of another No direct access to Udder via Cow Composition in ArcGIS * Composition can be setup to allow access to members of dependent classes.

  17. Polymorphism (Using Inheritance) Polymorphism: Members that have the same name but different implementations in different objects Polymorphism using inheritance: Members in derived classes have same name but different implementations than the base class.

  18. Polymorphism (Using Interfaces) Implementation of interface can be different in classes that implement it

  19. OOP • Abstraction • Classes • Class Members: Properties & Methods • Instance (object) • Encapsulation • Interfaces • Inheritance • Composition • Polymorphism • Using Inheritance • Using Interfaces

More Related