0% found this document useful (0 votes)
25 views29 pages

CST06105 - Fundamentals of OOP Introductory Lecture Dr. Msury Mahunnah E-Mail: Msury - Mahunnah@ifm - Ac.tz

This document provides information about a course on fundamentals of object-oriented programming (OOP). It introduces the course instructor, learning outcomes, course materials, textbooks, assessment details, student responsibilities, and an overview of OOP concepts including classes, objects, encapsulation, and inheritance.

Uploaded by

steward materu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views29 pages

CST06105 - Fundamentals of OOP Introductory Lecture Dr. Msury Mahunnah E-Mail: Msury - Mahunnah@ifm - Ac.tz

This document provides information about a course on fundamentals of object-oriented programming (OOP). It introduces the course instructor, learning outcomes, course materials, textbooks, assessment details, student responsibilities, and an overview of OOP concepts including classes, objects, encapsulation, and inheritance.

Uploaded by

steward materu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 29

CST06105 – Fundamentals of OOP

Lecture 1
Introductory Lecture

Dr. Msury Mahunnah


e-mail: [email protected]
Contacts
• Dr. Mahunnah, M
• Head, Department of CS and Maths
• Block E, Room # 305
• Email Address: [email protected]

2
Sub-Enabling Outcomes
• 3.3.1 Explain basic concepts of imperative programming.
• 3.3.2 Demonstrate knowledge on basics concepts of Object-
Oriented Programming.
• 3.3.3 Relate Procedural Programming and Object-Oriented
Programming.
• 3.3.4 Apply object-oriented programming skills to create
computer programs.
• 3.3.5 Use simple tools to write, compile, execute and
documenting programs.

3
Course Materials
• Lecture notes
• Workshops
• Homework
• Assignments

- ALL these course materials can be downloaded from


IFM e-learning system

4
Required Textbooks
1. Weisfeld, M. (2013). The Object-Oriented Thought Process, 4th
Edition. Addison-Wesley Professional.
2. Farell, J. (2012). An Object-Oriented Approach to Programming
Logic and Design, 4th Edition. Cengage Learning.
3. Wu, C. (2009). An Introduction to Object-Oriented Programming
with Java, 5th Edition. McGraw-Hill Science/Engineering/Math.
4. John Lewis , William Loftus (2017). JAVA Software Solutions, 9th
Edition. Pearson Prentice Hall.
5. Weiss, M (2011). Data Structures and Algorithm Analysis in Java,
3rd Edition. Pearson Prentice Hall.

5
Recommended Textbooks
1. Darwin, I (2020). Java Cookbook: Problems and Solutions for
Java Developers, 9th Edition. O’Reilly.
2. Main, M (2013). Data Structures and Other Objects Using Java,
4th Edition. Pearson Prentice Hall.
3. Zakas, N (2014). The Principles of Object-Oriented JavaScript, 1st
Edition. No Starch Press.

6
Assessment

• Midterm Test : 20 %
• Assignment : 20 %
• Final Exam : 60 %

7
Student Responsibilities
regarding Lectures
• Minimize noise
• Do not talk in lectures
• Do not pack up early
• Minimize distractions
• Turn off your mobile phone
• Lecture attendance
• Bring ID card, and wear it during the lecture session

8
Overview
• Principles of Object Oriented Programming
• What is OOP? Why is it important?
• Basic principles and advantages
• The Unified Modelling Language
• UML Class Diagrams
Object Oriented Programming
• Understanding OOP is fundamental to writing good Java applications
• Improves design of your code
• Improves understanding of the Java APIs
• There are several concepts underlying OOP:
• Abstract Types (Classes)
• Encapsulation (or Information Hiding)
• Association (Aggregation and Composition)
• Inheritance
• Polymorphism
What is Object Oriented Programming?

• Modelling real-world objects in software.


• Why design applications in this way?
• We naturally classify objects into different types.
• By attempting to do this with software aim to make it more maintainable,
understandable and easier to reuse.
• In a conventional application we typically:
• decompose it into a series of functions,
• define data structures that those functions act upon.
• there is no relationship between the two other than the functions act on the
data.
What is Object Oriented Programming?
• How is OOP different to conventional programming?
• Decompose the application into abstract data types by identifying some
useful entities/abstractions
• An abstract type is made up of a series of behaviours and the data that those
behaviours use.
What is Object Oriented Programming?
• Identifying abstract types is part of the modelling/design process
• The types that are useful to model may vary according to the individual
application
• For example a payroll system might need to know about Departments,
Employees, Managers, Salaries, etc
• An E-Commerce application may need to know about Users, Shopping Carts,
Products, etc
What is Object Oriented Programming?
• Object-oriented languages provide a way to define abstract data
types, and then create objects from them
• It’s a template from which we can create new objects
• For example, a Car class might have attributes of speed, colour, and
behaviours of accelerate, brake, etc
• An individual Car object will have the same behaviours but its own values
assigned to the attributes (e.g. 30mph, Red, etc)
What is Object Oriented Programming?
Encapsulation

• The data (state) of an object is


private –it cannot be accessed
directly.
• The state can only be changed
through its behaviour,
otherwise known as its public
interface or contract
• This is called encapsulation.
Encapsulation
• Main benefit of encapsulation
• Wrapping of data in a construct such that it hides its internal data.
• Provide behaviour methods to control access of data in desired fashion
What is an Object-Oriented Program?
• What does an OO program consist of?
• A series of objects that use each others behaviours in order to carry out some
desired functionality
• When one object invokes some behaviour of another it sends it a message
• In Java terms it invokes a method of the other object
• A method is the implementation of a given behaviour.
• OO programs are intrinsically modular
• Objects are only related by their public behaviour (methods)
Association
• Association is the ability to create new classes out of existing classes
• Treating them as building blocks or components
• Association allows reuse of existing code
• Reduce costs of developing software
• Two forms of Association
• Composition (Whole-Part relationships)
• Car is made of Engine, Chassis, Wheels
• House is made of Rooms
• Aggregation (Containment relationships)
• A Shopping Cart contains several Products
• A List contains several Items
Aggregation /Composition Example

Person Brain
Composition

Aggregation

Car
UML Association
• A line between two classes indicates a
relationship
• Extra information can be added to describe
the relationship
• Including
• Its name
• The roles that the classes play
• The cardinality of the relationship (how many
objects are involved)
• E.g. a Person works For a Company, which
has many employees
Inheritance
• Inheritance is the ability to define a new class in terms of an
existing class
• The existing class is the parent, base or superclass
• The new class is the child, derived or subclass
• The child class inherits all of the attributes and behaviour of
its parent class
• It can then add new attributes or behaviour
• Or even alter the implementation of existing behaviour
• Inheritance is therefore another form of code reuse
Summary
• In OO programming we
• Define classes
• Create objects from them
• Combine those objects together to create an application
• Benefits of OO programming
• Easier to understand (closer to how we view the world)
• Easier to maintain (localised changes)
• Modular (classes and objects)
• Good level of code reuse (aggregation and inheritance)
Unified Modelling Language
• UML is a diagramming tool for describing and documenting object
oriented applications
• Programming language independent
• Used for modelling an application before its engineered
• Twelve different diagrams in all, with many complex details
• Generally though only two of these are used regularly
• Class diagrams
• Sequence diagrams
Unified Modelling Language
• Class Diagrams
• Describe classes and interfaces
• …their properties
• …their public interface
• …and their relationships (e.g. inheritance, aggregation, composition)
• Sequence Diagrams
• Describe how objects send messages to one another
• Useful for describing how a particular part of an application works
• We’ll be covering just class diagrams
• Very useful for describing APIs and discussing OO applications
UML Classes

• Box with 3 sections


• The top contains the class name
• The middle lists the classes
attributes
• The bottom lists the classes
methods
• Can indicate parameters and
return types to methods, as well
as their visibility
UML comments

• Useful for adding text


for the readers of your
diagram
• The symbol looks like a
little note, with a
dotted line joining it to
the class or relationship
that its describing
UML Inheritance

• Inheritance is shown by a
solid arrow from the sub-
class to the super-class
• The sub-class doesn’t list its
super-class attributes or
methods,
• Unless its providing its own
alternate version (i.e. is
extending the behaviour of
the base class)
Example #1

You might also like