2. Principles of OOP
Abstraction Inheritance
Encapsulation Polymorphism
2
3. Inheritance
Staff
Member Gold
Loyalty
Non
Regular
Member
3
4. Classes and Interfaces
Classes Interfaces
methods and
Methods contain
Fields, properties, properties, left to
code for
methods be implemented 4
execution
later
9. Accessibility Levels
protected internal - limited Private -
to the current assembly or types derived from restricted to the
the containing class containing type
Protected - Public –
limited to the
Internal -
containing type and limited to the current access is not
assembly 9
types derived from it restricted
10. Important Aspects
Instance and static constructors No multiple
are not inherited inheritance
Multiple Transitive relation
Structures cannot
interfaces can be C < - B , B < -A
be inherited
implemented then C <-A 10
12. Abstraction – Reducing the
complexity
Classes defined with the Class +
keyword abstract Interface
Not implemented
Implemented or
methods are Cannot be
fully
declared instantiated
unimplemented 12
abstract
14. Encapsulation
Hides the implementation Public
details interface
No interface
All data members Accessed via
members should
should be hidden properties
be hidden 14
15. Encapsulation ..
Constructors
Private data fields
and Assessors
Reduces
Changing the complexity
Change fields
class internals
validation Easier
does not affect 15
maintenance
16. Polymorphism Extensibility
Cohesion and Coupling
Reusability
Having many forms Provides
abstraction
Virtual Override Eliminates
Keyword Keyword redundant
code 16