0% found this document useful (0 votes)
127 views9 pages

M1-Lesson 1

This document provides an introduction to object-oriented programming. It discusses the history of OOP, how OOP is different from procedural programming by encapsulating functions and data together in objects. The key advantages of OOP include objects having complete control over their responsibilities and data. Some disadvantages are also mentioned. The learning plan outlines the objectives and activities for students to understand the foundations of OOP through readings, videos and exercises.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
127 views9 pages

M1-Lesson 1

This document provides an introduction to object-oriented programming. It discusses the history of OOP, how OOP is different from procedural programming by encapsulating functions and data together in objects. The key advantages of OOP include objects having complete control over their responsibilities and data. Some disadvantages are also mentioned. The learning plan outlines the objectives and activities for students to understand the foundations of OOP through readings, videos and exercises.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

IT 203 : OBJECT-ORIENTED

PROGRAMMING 1
Module 1

ERVIN L. RODRIGUEZ, Ph.D.


Assistant Professor I

College of Computing and Information Sciences


Bachelor of Science in Information Technology

2021
Object-oriented Programming 1

Table of Contents

Module 1 .....................................................................................................................................
Lesson 1 – Introduction to Object-oriented Programming....................................................
History ......................................................................................................................................
What’s different? ......................................................................................................................
What does object orientation mean? ........................................................................................
Objects and their interactions ...................................................................................................
Advantages of OOP .................................................................................................................
Disadvantages of OOP ..............................................................................................................
Object-oriented Programming 1

Rationale
The purpose of the module is to allow the student to gain knowledge on conceptualizing
and designing a web system/information system and the different applications used for the
concept or design implementation. The module also provides learning awareness that will help
the students produce a timely and fit web information systems. It expects that the students
should have at least a 95% passing result at the end of the module. To be able to achieve the
result, the student should be able to read the provided theories and concepts through the reading
materials, view video clips, participate in essential topics in forums, demonstrate activity output
if necessary, and pass the quizzes or tests. Additional reading materials are provided for the
student to gain a piece of advance information aside from the expected learning outcomes.
Lastly, the module requires the student to submit all requirements in a specific period.

The Learning Plan provides a guide to the student in achieving the desired learning
outcomes. Specifically, the learning plan may contain the following sections:

o Let's hit these. This section defines the learning objectives of the students expect to
achieve at the end of the lesson. It describes the knowledge and skills that will be
acquired by a student after completing each lesson.

o Let's get started. This section contains enabling activity, which includes pretest to
determine a baseline knowledge of the topic/s that is about to be learned. The pretest
may be in the form of a case study, video clip, quiz, or any related material that directs
the learner to the topics/s of the lesson.

o Let's find out. This section provides an analysis of the previously given enabling
activity. The said analysis will prepare the learner in moving to the next part of the
module.

o Let's read. This section covers text/readings and other related materials as inputs of the
lesson. This section also provides the student with the opportunity to study and review
the necessary information to understand the topic.

o Let's remember. This section serves as a summary of the lesson. It contains essential
information only that includes the key ideas and main points that are worth noting and
remembering by the students.

o Let's do this. This section allows the instructor to assess the learning of the students
based on the provided lesson or information necessary in achieving the objectives of
the module.
Object-oriented Programming 1

Module 1
Module title: Object-oriented Programming

Module description:
This course focuses on understanding Object-Oriented Programming fundamentals and
concepts. The course will demonstrate the theory and lecture discussion using Hypertext
Preprocessor (PHP) OOP and MySQL OOP. At the end of the course, the students should be
able to demonstrate the different procedural or functional approach of OOP. In addition, the
students should be able to explain the functionalities of OOP regardless of the programming
language utilized. Lastly, students should be able to implement OOP concepts using PHP and
MySQL.

Purpose of the Module:


This module lets the students learn the importance of understanding and performing
object-oriented programming in PHP.

Module Guide:
The students are required to participate in forums, answer the quizzes, case studies if
available, submit the output in individual/group activity, and take the pretest and post-test if
available. The provided reading materials (Let's Read Section & Suggested Readings) are the
necessary information to accomplish the said requirements.

Module Outcomes: Compare and contrast procedural/functional approach to object-oriented


programming approach.

Module Requirements:
At the end of this module, the students should have at least 75% passing grade in overall
quiz results, individual/group activities, forum/class participation, case study analysis, major
output, and major exams.

Key Terms:
OOP, PHP, Programming, HTML, CSS, JavaScript, Object-oriented

IT 203 : Object-oriented Programming 1 Page 1 of 9


Object-oriented Programming 1

Learning Plan
Lesson No: 1

Lesson Title: Introduction to Object-oriented programming

Let's hit these:


At the end of this lesson, students should be able to:
▪ Understand how OOP works
▪ Understand the building blocks of OOP
▪ Determine the Advantages of OOP
▪ Determine the Disadvantages of OOP

Let's get started:

Try to view this youtube video about "Object-oriented programming in 7 Minutes"


through this link: https://www.youtube.com/watch?v=pTB0EiLXUC8

Let's find out:

• List down the four foundations of OOP. Explain each based on your understanding
through adding real-world situation samples.

Let's read:

INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING

History
The principles of object-oriented programming1 were formulated during the 1960s and 1970s.
This new approach to programming emerged as a result of failed software developments during the
mid-1960s. This was the first time that software costs had exceeded hardware costs, a situation that
triggered the so-called “software crisis”.
But OOP did not gain in popularity until the mid-1980s and has become a widely accepted
computer programming concept during the intervening years.
Most modern programs for personal computers are written in the language C++. These
programs would be inconceivable today without object-oriented program ming. When it was time to
switch from C to C++, programmers were faced with the same paradigm shift as they are today in
automation engineering.
With the Internet age came new programming languages. Java is generally the most popular of
these because it was integrated very early on as a programming tool in WEB browsers. Java as well as
C# both fundamentally support object-oriented programming.

What’s different?
Object-oriented programming encapsulates functions and data in a single object. This means
that data are tightly coupled with the object and the programmer is free to decide the means by which
data may be accessed. Furthermore, in the event of a legal data access operation, it is possible to check
whether the data have been changed to meaningful values. These check mechanisms are capable of
preventing illegal changes to data and eliminating other error sources. The object has complete control
over all its responsibilities at all times.
In Figure 1 you can see two objects in human form communicating with one another. Let’s call
our objects Michael and Manfred. Michael asks Manfred whether he’s got a euro to spare. Manfred is

IT 203 : Object-oriented Programming 1 Page 2 of 9


Object-oriented Programming 1

not willing to give away a euro. Since Manfred always retains control over his responsibilities and data,
Michael is not going to get a euro.

Figure 1. Communication between objects – object-oriented

The old procedural programming method that comprises programs, subprograms, functions and
data breaks a task down into individual components. It thus uses a series of commands to define
algorithms which ultimately solve the task. However, a basic principal feature of procedural
programming is that data are not necessarily directly coupled with programs, subprograms or functions.
In other words, data are defined by the programmer and made public for use by programs and functions.
They can thus be globally accessed by any program. When the software is extended or modified,
however, the overall contexts within the data mesh are often not documented, creating an error source
which can lead to malfunctions in the processing plant.
In the example of communication between objects in human form, Manfred has now disclosed
his data in accordance with the procedural method (note: the term “objects” is not strictly correct when
referring to procedural programming). He has disclosed where he keeps his money. Anyone now has
access to it and can change the data (Figure 2). No communication takes place and Manfred is no longer
fully in control. He’s likely to have difficulties – the next time he goes shopping at the very latest.

Figure 2. Communication between objects – procedural

This example illustrates a fundamental problem with procedural programming. Since there is
no means of limiting or channeling access to data, changes to data can give rise to sporadic and often
inexplicable errors that can be very difficult to locate.
With object-oriented programming, data and operations are uniquely assigned to the object.
The programmer has the option of specifying how data can be accessed and can therefore protect the
data. If data need to be changed for the purpose of the object function, this can only be done by
specifically programmed methods. These methods can include a mechanism for checking whether data
changes are mean ingful. Erroneous transfer of data that can cause processing errors is prevented. An
explanation (including examples) of how methods are programmed and used can be found in later
chapters. First of all, however, we are going to lay the foundation for helping you to understand the
basic principles of object-oriented programming.

IT 203 : Object-oriented Programming 1 Page 3 of 9


Object-oriented Programming 1

What does object orientation mean?


The whole concept is actually pretty simple. The term “object orientation” is used because the
language is entirely based on the concept of “objects”. As human beings, we generally regard the world
as a collection of objects. Everything that we perceive is an object. Houses, cars, people, plants and
animals, in other words, all tangible things, are objects to us. At the same time, we can certainly view
some of these things as complex objects which may each comprise a collection of different objects. For
example, a car consists of other objects such as wheels, seats, engine, bodywork, etc.
We also define more abstract groupings such as vehicles, for example, to which we then assign
specialized derivations. A car is a vehicle, but a particular specializa tion of vehicle. A bicycle is not
a car, but it is a vehicle. Since everybody knows the difference between a car and a bicycle, but both
these objects can be assigned to the grouping “vehicle”, we need to ask ourselves: How do we
differentiate between these objects?
To a vehicle we attribute certain universal properties and potential functions that all vehicles
must possess. Every vehicle has a number of wheels and some form of drive mechanism that renders it
capable of movement (acceleration, braking and driving are all operations). There are of course other
properties that can be used to describe a vehicle. These are attributable to cars, bicycles, motor bikes or
even horse-drawn carriages.
It is therefore certainly true to say that when we consider properties, we describe vehicles in
more generalized terms than specialized forms of vehicle such as cars, bicycles or HGVs.
Specializations thus inherit the properties (attributes) and the behavior of the original abstract
object and tend to refine or expand these attributes.
Let’s take a vehicle registration certificate as a useful example of how vehicle properties are
described. This certificate defines all the properties of a vehicle that is authorized for road use according
to road traffic regulations. These properties “include” specific values for the relevant vehicle such as
length, width, engine type and capacity as well as registration number, owner and so on. The vehicle
registration certificate therefore describes a particular vehicle, i.e. the specific object, for example, a car
with all the defined attributes.

Objects and their interactions


Objects possess properties (attributes) and potential operations (functionalities). It therefore
follows that objects of the same kind must have the same kind of functional scope. Individual vehicles
are capable of movement, i.e. are capable of being driven. A vehicle can accelerate or brake in order to
move or come to a stop. We need to remember that a car cannot move on its own, but simply has the
potential to do so.
A car is generally controlled by another complex object, i.e. by its driver. The object “car
driver” is completely different from the object “car” and there is no comparison between the two. For
the car driver to be able to drive the car, some way needs to be found to coordinate the two objects.
The driver has hands, feet and eyes (and a brain as well of course, but we can ignore that for
the moment). The car has a driver’s seat, steering wheel, ignition lock, accelerator pedal and other
control equipment. These have in turn been coordinated with the limbs of the human driver. When we
consider this on a more abstract level, the object car and the object driver have mutually compatible
interfaces and it is precisely these that allow the two objects to communicate.
To accelerate the car, the driver needs to press down the accelerator pedal. The car then
accelerates at the rate determined by the position of the pedal. It is important to understand, however,
that acceleration is effected by the engine, gearbox and wheels and not by the accelerator pedal.
In other words, the car has a function (method) for accelerating and a method for commanding
acceleration. Thus it can be said that objects of this kind possess not only methods to implement
potential operations, but also methods to communicate.
The speedometer likewise displays the current traveling speed of the vehicle. The driver can
therefore release the pressure on the accelerator pedal until the vehicle is moving at the desired speed.
The speedometer is thus also a method possessed by the car to feed information back to the driver, i.e.
a method of communication.
In our modern, technologically advanced world, we have a vast number of complex objects that
possess executable operations (methods) as well as further methods for communicating with other
objects. Objects always retain control over their own responsibilities and attributes. This encapsulation

IT 203 : Object-oriented Programming 1 Page 4 of 9


Object-oriented Programming 1

means that changes in the behavior or the attributes of an object can only be effected in response to
requests (methods). The object itself decides according to existing (implemented) capabilities whether
or not it can fulfill the request. Pressing the accelerator pedal for our object car will not directly cause
it to accelerate if, for example, the engine is not running and/or the car is not in gear. To be able to drive
a car, the driver needs to understand its fundamental behavior but does not need to know exactly how
the car starts its own engine or accelerates. The only thing the driver needs to grasp is what has to be
done to get the car to start its engine.
We can therefore deduce that a car possesses externally accessible (public) methods and internal
methods that are not externally visible. A core principal of the object orientation concept is that access
to the internal data or functions of objects is not permitted. Data can be changed only by the methods
provided expressly for this purpose.
We have assimilated this view of the world as a series of objects and we find it easy to describe
and categorize them. We learn to handle and interact with objects from an early age. Based on this
insight, it is simply a question of logic when technical functions exploit this view of the world for their
own benefit. By applying this model to software, it becomes easier for us to understand many aspects
of software operation. This precisely was the driving force behind development of the object-oriented
programming concept.

Advantages of OOP
Object-oriented programming is a well-adopted programming style that uses interacting objects
to model and solve complex programming tasks. Two examples of popular object-oriented
programming languages are Java and C++. Some other well-known object-oriented programming
languages include Objective C, Perl, Python, Javascript, Simula, Modula, Ada, Smalltalk, and the
Common Lisp Object Standard.
Some of the advantages of object-oriented programming include:
1. Improved software-development productivity
Object-oriented programming is modular, as it provides separation of duties in object-
based program development. It is also extensible, as objects can be extended to include
new attributes and behaviors. Objects can also be reused within an across applications.
Because of these three factors – modularity, extensibility, and reusability – object-
oriented programming provides improved software-development productivity over
traditional procedure-based programming techniques.
2. Improved software maintainability
For the reasons mentioned above, objectoriented software is also easier to maintain.
Since the design is modular, part of the system can be updated in case of issues without
a need to make large-scale changes.
3. Faster development
Reuse enables faster development. Object-oriented programming languages come with
rich libraries of objects, and code developed during projects is also reusable in future
projects.
4. Lower cost of development
The reuse of software also lowers the cost of development. Typically, more effort is put
into the object-oriented analysis and design, which lowers the overall cost of
development.
5. Higher-quality software
Faster development of software and lower cost of development allows more time and
resources to be used in the verification of the software. Although quality is dependent
upon the experience of the teams, object-oriented programming tends to result in
higher-quality software.

IT 203 : Object-oriented Programming 1 Page 5 of 9


Object-oriented Programming 1

Disadvantages of OOP
Some of the disadvantages of object-oriented programming include:
1. Steep learning curve
The thought process involved in object-oriented programming may not be natural for
some people, and it can take time to get used to it. It is complex to create programs
based on interaction of objects. Some of the key programming techniques, such as
inheritance and polymorphism, can be challenging to comprehend initially.
2. Larger program size
Object-oriented programs typically involve more lines of code than procedural
programs.
3. Slower programs
Object-oriented programs are typically slower than procedure-based programs, as they
typically require more instructions to be executed.
4. Not suitable for all types of problems
There are problems that lend themselves well to functional-programming style, logic-
programming style, or procedure-based programming style, and applying object-
oriented programming in those situations will not result in efficient programs.

References/Sources:
Online Videos:
• Object-oriented Programming in PHP. Retrieved from
https://www.youtube.com/watch?v=Anz0ArcQ5kI&list=PL0eyrZgxdwhypQiZnYXM
7z7-OTkcMgGPh
• What is Object-oriented programming? Retrieved from
https://www.youtube.com/watch?v=xoL6WvCARJY
• Object-oriented programming in 7 Minutes. Retrieved from
https://www.youtube.com/watch?v=pTB0EiLXUC8
Online Reading Materials
• Advantages and Disadvantages of OOP. Retrieved from
https://learn.saylor.org/mod/page/view.php?id=22041
E-Book:
• Braun, M., and Horn, W., (2017). Object-Oriented Programming with SIMOTION:
Fundamentals, Program Examples and Software Concepts According to IEC 61131-3.
Retrieved on July 29, 2021. Retrieved from https://book4you.org/book/3364782/e31ffb

IT 203 : Object-oriented Programming 1 Page 6 of 9

You might also like