Professional Documents
Culture Documents
PROGRAMMING
MID-SEMESTER EXAM REVISION
LEARNING OUTCOMES
5
STRUCTURED DESIGN
6
TOP-DOWN PROGRAMMING
8
OBJECT-ORIENTED PROGRAMMING
9
OBJECT-ORIENTED ANALYSIS
The process of identify and defining the use cases and set
of objects(classes) in the new system.
10
OBJECT-ORIENTED DESIGN
11
OBJECT-ORIENTED APPROACH
12
UNIFIED MODELING LANGUAGE (UML)
Developed in 1990
13
UML DIAGRAMS
Class Diagram
UML diagram that models a class as a rectangle with three
compartments
14
CLASS DIAGRAM COMPARTMENTS
Top compartment
Contains the name of the class centered horizontally in
boldface type.
Middle compartment
Contains the class's attributes, which corresponds to instance
variables and properties in C#.
15
CLASS DIAGRAM COMPARTMENTS, CONT.
Bottom compartment
Contains the class's operations, which corresponds to
methods in C#.
16
NOTATION
17
CLASSES AND OBJECTS
18
CLASS
Instance of a class
Variable of a class
Memory space is allocated when it is created.
Created many time as required
20
PROPERTY
set accessor
Store the values of data members or the properties
21
CONSTRUCTOR
22
CONSTRUCTOR
No argument constructor
Constructor with zero argument
24
TYPES OF CONSTRUCTORS, CONT.
25
INHERITANCE
26
INHERITANCE
Core principle or concept in object-oriented programming
Allows programmers to write new classes that inherit properties,
fields and methods of an already existing class.
Allows programmers to write much less code.
Allows for software reusability.
Allows for creation of a first class and then creating another class
which inherits properties, fields and methods of the first class.
27
SUPER CLASS
Parent class
Hold the properties, fields and methods that a sub class
wants
to extend and use appropriately in the sub class.
Base class
28
SUB CLASS
Child class
Extents properties, fields and methods of the super class.
It can have its own properties, fields and methods or modify
the super classes properties, methods and fields.
Derived class
29
RELATIONSHIPS
is-a relationship
Example: A reptile is-a creature
has-a relationship
Example: A reptile has-a face
30
POLYMORPHISM
31
POLYMORPHISM
32
POLYMORPHISM, CONT.
33
TYPES OF POLYMORPHISM
34
TYPES OF POLYMORPHISM
35
METHOD OVERLOADING
Creating a multiple methods in a class with same name but different
parameters and types.
Example of compile time polymorphism which is done at
compile time.
Can be achieved by
By changing the number of parameters used.
By changing the order of parameters.
By using different data types for the parameters
36
METHOD OVERRIDING
Can be achieved by
Using inheritance
Using virtual and override keywords in the respective methods.
Virtual keyword in parent class method.
Override keyword in derived class method
37
ENCAPSULATION
38
ENCAPSULATION
39
WHY ENCAPSULATION?
Encapsulation is used:
To protect data
To make classes easy to maintain
40
PRIVATE DATA MEMBERS
42
PUBLIC ACCESSORS AND MUTATORS
Mutators
Example: setID
43
CONTROLLING ACCESS TO MEMBERS
The Public and Private access modifiers control access to a classs
variables, methods and properties.
Public any class is able to view the data.
Private no other class, except the class where the variable is
held, is able to see the contents of the variable.
If a class member is not declared with an access modifier, it has
Private access by default.
44
CONTROLLING ACCESS TO MEMBERS, CONT.
The outside class can be able to access the private data members
through the public method.
This way data can only be accessed by public methods thus making
the private fields and their implementation hidden for outside
classes.
45
SUMMARY
Structured programming
Object-oriented programming
Classes and objects
Constructor
Inheritance
Polymorphism
Encapsulation
46
EXERCISES
47