oop concepts

18
OOP Programming Melick R. Baranasooriya melick-rajee.blogspot.com

Upload: melick-baranasooriya

Post on 10-Jun-2015

1.902 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Oop concepts

OOP ProgrammingMelick R. Baranasooriyamelick-rajee.blogspot.com

Page 2: Oop concepts

Principles of OOP

Abstraction

Encapsulation Polymorphism

Inheritance

2

Page 3: Oop concepts

3

Inheritance

Loyalty

Member

Staff

Gold

RegularNon Member

Page 4: Oop concepts

4

Classes and Interfaces

Classes

Fields, properties, methods

Methods contain code for

execution

Interfaces

methods and properties, left to be implemented

later

Page 5: Oop concepts

5

Page 6: Oop concepts

Inheritance

characteristics of existing parent class

extend the parent class

Add new fields and methods

AttributesOperations

Redefine methods 6

Page 7: Oop concepts

Inheritance

inherits

implements Extends

Extensibility

Reusability

Provides abstraction

Eliminates redundant code 7

Page 8: Oop concepts

8

Page 9: Oop concepts

Accessibility Levels

protected internal - limited to the current assembly or types

derived from the containing class

Protected - limited to the containing type and types derived from it

Internal - limited to the current assembly

Private -restricted to the containing type

Public –access is not

restricted 9

Page 10: Oop concepts

Important Aspects

Instance and static constructors are not inherited

Multiple interfaces can be implemented

Structures cannot be inherited

No multiple inheritance

Transitive relationC < - B , B < -A

then C <-A 10

Page 11: Oop concepts

Demo

Sealed

Methods + New Multiple Interfaces

Virtual + Override

Access Modifiers11

Page 12: Oop concepts

Abstraction – Reducing the complexity

Classes defined with the keyword abstract

Implemented or fully unimplemented

Not implemented methods are

declared abstract

Class + Interface

Cannot be instantiated 12

Page 13: Oop concepts

13

Page 14: Oop concepts

Encapsulation

Hides the implementation details

All data members should be hidden

Accessed via properties

Public interface

No interface members should

be hidden 14

Page 15: Oop concepts

Encapsulation ..

Private data fields

Changing the class internals does not affect

Change fields validation

Constructors and Assessors

Reduces complexity

Easier maintenance

15

Page 16: Oop concepts

Polymorphism Cohesion and Coupling

Having many forms

Virtual Keyword

Override Keyword

Extensibility

Reusability

Provides abstraction

Eliminates redundant code 16

Page 17: Oop concepts

17

Page 18: Oop concepts

THANK YOU! 18