Download presentation
Presentation is loading. Please wait.
Published byIsaak Tetterton Modified over 10 years ago
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.: 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 private Entire solution Assembly only Derived classes Class only More …
13
Inheritance and casting Casting = converting between types implicit explicit 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 Abstract ClassesInterfaces Inherit from one parent One or more interfaces can be implemented on one or more classes Abstract and non-abstract membersMembers have no implementation Members can be public, private, protected, internal, protected internal Only public members
16
Composition One class composed of another MapLayerFeatureLayerRasterLayer * No direct access to Udder via Cow Composition can be setup to allow access to members of dependent classes. Composition in ArcGIS
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.