Object-Oriented Programming Concepts: Week 1 - Objects and Principles, High school final essays of Computer science

An introduction to Object-Oriented Programming (OOP), focusing on the principles, characteristics, and benefits of objects. Topics include constructors, destructors, inheritance, polymorphism, encapsulation, classes, and software engineering concepts. It also covers the evolution of programming techniques and the differences between unstructured, procedural, and modular programming.

Typology: High school final essays

2017/2018

Uploaded on 03/03/2022

unknown user
unknown user 🇬🇧

8 documents

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
OB JECT ORIEN TED
PR OGRAMMING
CO NCEPTS
WEEK 1 OBJECT
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Object-Oriented Programming Concepts: Week 1 - Objects and Principles and more High school final essays Computer science in PDF only on Docsity!

OBJECT ORIENTED

PROGRAMMING

CONCEPTS

WEEK 1 – OBJECT

UNDERSTAND THE PRINCIPLES OF

OBJECT ORIENTED PROGRAMMING

Characteristics of objects : types eg constructors, destructors;

classification; features eg inheritance, polymorphism, encapsulation,

public classes, private classes, public methods, private methods,

message passing; interpreted, open source, common libraries

Variables : public instance variables; private instance variables;

static references

Software engineering : features eg modularity, encapsulation, reuse,

method overloading, instance variables, classes, abstract classes,

interfaces

Classes : characteristics eg identification attributes, control of scope

of attributes and methods, inheritance, aggregation, association,

polymorphism

PREREQUISITE & HOW TO SURVIVE

Basic knowledge of Programming required Read books and remember  Read the books, remember the language Think  Think in objects, think in classes Practice  Do as many coding as possible and make them running Ask in classes

DRAWBACKS

This programming technique can only be used in a very small program. For example, if the same statement sequence is needed at different locations within the program, the sequence must be copied. If an error needed to be modified, every copy needs to be modified. This has lead to the idea to extract these sequences(procedure), name them and offering a technique to call and return from these procedures.

PROCEDURAL

PROGRAMMING

With procedural programming, you are able to combine sequences of calling statements into one single place. A procedure call is used to invoke the procedure. After the sequence is processed, flow of control proceeds right after the position where the call was made. Main Program (^) Procedure

PROCEDURES

With parameters and sub-procedures (procedures of procedures) , programs can now be written more structured and error free. For example, if a procedure is correct, every time it is used it produces correct results. Consequently, in cases of errors you can narrow your search to those places which are not proven to be correct.

PROCEDURE PROGRAM VIEW

Now a program can be viewed as a sequence of procedure calls. The main program is responsible to pass data to the individual calls, the data is processed by the procedures and the resulting data is presented. Thus, the flow of data can be illustrated as a hierarchical graph, a tree.

Main Program(Also a module) Data Data Data 1 Module 2

Data Data 2 Module 1

Data Data 1 Procedure 1 Procedure 2 The main program coordinates calls to procedures in separate modules and hands over appropriate data as parameters. Procedure 3

Modular Programming

MODULAR PROGRAMMING

Each module can have its own data. This allows each module to manage an internal state which is modified by calls to procedures of this module. Each module has its own special functionalities that supports the implementation of the whole program.

STRUCTURED PROGRAMMING

Also structured programming A subset of procedural programming that enforces a logical structure on the program being written to make it more efficient and easier to understand and modify. Certain languages such as Ada, Pascal, and dBASE are designed with features that encourage or enforce a logical program

STRUCTURED PROGRAMMING

Three Types of Structures in a structured program

Statement sequence(s1,s2,…,sn)

Branch(if-then-else)

Loop(for,do, and while loops)

Goto (not often used)

How many basic structures for programming?

OBJECT ORIENTED PROGRAMMING

In OOP data and operations on data (data manipulation) are brought together into a single entity called an object. Our programs then consist of one or more objects interacting with each other to bring about a desired result. The object is responsible for its data and its data can only manipulated by a predefined list of acceptable operations. Object orientation aims to emulate the way humans interact with the world around them. In other words there is presumption that the object oriented approach to problem solving is somewhat akin to the natural approach. Consider a typical day, get out of bed, have a cup of coffee, catch a bus to work, go to a restaurant for lunch, go to your flat, eat your dinner with a knife and fork, watch television etc. It is possible to look on life as a series of interactions with things. These things we call objects. We can view all of these objects as consisting of data (called properties) and operations that can be performed on them (called methods). This is thought to closely resemble the way humans perceive the world, thus it is thought that object oriented system models are easier to understand.

SO WHAT IS AN OBJECT?

Tangible Things as a car, printer, ... Roles as employee, boss, ... Incidents as flight, overflow, ... Interactions as contract, sale, ... Specifications as colour, shape, … 20

SO, WHAT ARE OBJECTS?

An object represents an individual, identifiable item, unit, or entity, either real or abstract, with a well-defined role in the problem domain. Or An "object" is anything to which a concept applies. Etc. 21

WHY DO WE CARE ABOUT OBJECTS?

Modularity - large software projects can be split up in smaller pieces. Re-useability - Programs can be assembled from pre- written software components. Extensibility - New software components can be written or developed from existing ones. 22

WHAT IS AN OBJECT?

An object is an instance of a class Objects have the following qualities:  Identity: Objects are distinguishable from one another  Behavior: Objects can perform tasks  State: Objects store information that can vary over time 123 245 12 245 Object Object Class

OOP TERMINOLOGY

Objects -- packet containing data and procedures  methods -- deliver service  message -- request to execute a method Class -- template for creating objects Instance -- an object that belongs to a class Abstraction - emphasis on what rather than how Encapsulation -- information hiding by objects Inheritance -- allowing the reuse of class spec.s class  Hierarchy -- tree structure inheritance relations Polymorphism -- to hide different implementations