Object-Oriented Programming

Slides:



Advertisements
Similar presentations
Programming Paradigms and languages
Advertisements

Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Topic 10 Java Memory Management. 1-2 Memory Allocation in Java When a program is being executed, separate areas of memory are allocated for each class.
1 OBJECT-ORIENTED CONCEPTS. 2 What is an object?  An object is a software entity that mirrors the real world in some way.  A software object in OOP.
1 Introduction. 2 Why? We need to deliver good programs Bugs: results may be catastrophic Long time to get something working Expensive to change: software.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
Object Oriented Software Development
Chapter 7 Designing Classes. Class Design When we are developing a piece of software, we want to design the software We don’t want to just sit down and.
Introduction to Object-oriented Programming CSIS 3701: Advanced Object Oriented Programming.
Copyright © 2002, Systems and Computer Engineering, Carleton University Intro.ppt * Object-Oriented Software Development Unit 1 Course.
CSS/417 Introduction to Database Management Systems Workshop 5.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved COS240 O-O Languages AUBG,
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Chapter 3 Introduction to Collections – Stacks Modified
1 Abstraction  Identify important aspects and ignore the details  Permeates software development programming languages are abstractions built on hardware.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Polymorphism, Inheritance Pt. 1 COMP 401, Fall 2014 Lecture 7 9/9/2014.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
CSE 303 – Software Design and Architecture LECTURE 4.
Florida A & M University Computer and Information Science e-learning Testing of Classes Copyright PCSA, Inc Cis4932 (Dr. Ed Jones)Page 1.
Abstraction ADTs, Information Hiding and Encapsulation.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
Lecture 2 Intro. To Software Engineering and Object-Oriented Programming (1/2)
Salman Marvasti Sharif University of Technology Winter 2015.
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
Written by: Dr. JJ Shepherd
Chapter 3 AS3 Programming. Introduction Algorithms + data structure =programs Why this formula relevant to application programs created in flash? The.
Welcome to Software Engineering. Lecture 1 Metaphysics of Software Engineering Alex
1 CS1120: Recursion. 2 What is Recursion? A method is said to be recursive if the method definition contains a call to itself A recursive method is a.
Lecture 2 Intro. To Software Engineering and Object-Oriented Programming (1/2)
Comp1004: Object Oriented Design I Abstract Classes and Interfaces.
Welcome to Software Engineering
Linked Data Structures
Lesson Objectives Aims You should be able to:
Basics of Computer A Computer is Electronic device that can
Programming paradigms
Object-Orientated Programming
Reference: COS240 Syllabus
A basic tutorial for fundamental concepts
MPCS – Advanced java Programming
Chapter 6: Structured Vs. Object Oriented Analysis and Design.
GENERAL OOPs CONCEPTS.
Object oriented system development life cycle
COMPUTER 2430 Object Oriented Programming and Data Structures I
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Java LESSON 7 Objects, Part 1
Subroutines Idea: useful code can be saved and re-used, with different data values Example: Our function to find the largest element of an array might.
Typescript Programming Languages
Foundations of Programming Languages – Course Overview
Foundations of Programming Languages – Course Overview
Object-Oriented Programming
CS1120: Recursion.
Object Oriented Design Patterns - Structural Patterns
Why Object-oriented Programming?
Object oriented vs procedural programming
Object Oriented Programming
Object oriented analysis and design
Programming Languages 2nd edition Tucker and Noonan
COP 3330 Object-oriented Programming in C++
ECE 352 Digital System Fundamentals
Introduction to Data Structure
Object-Oriented Programming
Programming Languages and Paradigms
What Is Good Software(Program)?
Review of Previous Lesson
Object-Oriented PHP (1)
Chapter 8 Inheritance Part 2.
Object Oriented Design & Analysis
Loops and Iteration CS 21a: Introduction to Computing I
(4 – 2) Introduction to Classes in C++
Presentation transcript:

Object-Oriented Programming In Pursuit of Absolute Simplicity

How Can We Learn A Language How to Learn A Natural Language Grammar, Culture How to Learn A PL Syntax/Grammar Algorithm A programming paradigm is presented. Hard!!! Hard!!! A programming paradigm is a pattern of problem-solving thought that underlies a particular genre of programs and languages.

Programming Paradigms Four Programming Paradigms: Imperative Object-oriented Functional Logic (declarative) What problem does OO paradigms solve? Software crisis: due to the rapid increases in computer power and the complexity of the problems that could be tackled. 

How Does Industry Do? Let us take a look at the automotive industry

What is the Goal/Principle of OOP? To address the problem in SW, OOP aims to develop a SW system like how automobile is made in the automotive industry. OOP has some of important principles: When new requirements for a component are considered, just replace it with a new one. Open for Extension and Close for Modification!

What Does OOP Provide Main concepts/features in OOP Class Interface Inheritance/polymorphism Message passing The key idea is how to use these main concepts in OOP?

Metaphor: Travel Adapter Computer Travel Adaptor: three pins to two pins adaptor

Travel Adaptor in Programming We assume a computer has turn_on feature which calls get power via three pins class Computer { private Boolean on; … public void turn_on() { on = get_power_via_3pins(); if(on) System.out.println(“Power is on”);} public boolean get_power_via_3pins(){ System.out.println(“Power is generated”); return true; }

Is the First Version a Good Program? No. Why? How to make it better? class Computer { private Boolean on; … public void turn_on() { on = get_power_via_3pins(); if(on) System.out.println(“Power is on);} } class Computer { private Boolean on; … public void turn_on() { on = p.get_power_via_3pins(); if(on) System.out.println(“Power is on);} } class PowerOutlet { } private PowerOutlet p; public Boolean get_power_via_3pins(){ System.our.println(“Power is generated”); return true; } public boolean get_power_via_3pins(){ System.our.println(“Power is generated”); return true; }

Why 2nd version is better? In Reality class PowerOutlet { } public Boolean get_power_via_3pins(){ System.out.println(“Power is generated”); return true; } class Computer { private Boolean on; … public void turn_on() { on = p.get_power_via_3pins(); if(on) System.out.println(“Power is on);} } private PowerOutlet p;

Don’t forget to Buy Objects Separately? Remember class is just a script and you need to buy these objects to get the real services for another complicated service class Application { } Why you cannot put the creation of object, i.e.main method in any of the previous two classes??? public static void main(…){ Computer c = new Computer(); PowerOutlet p = new PowerOutlet(); c.setPower(p); c.turn_on() }

What Happens When PowerOutlet Class Does not Work? In Reality: In OO Code X class Computer { private Boolean on; … public void turn_on() { on = p.get_power_via_3pins(); if(on) System.out.println(“Power is on);} } class PowerOutlet { } public Boolean get_power_via_3leg(){ System.out.println(“Power is generated”); return true; } private PowerOutlet p; class PowerOutletVia2Pins{ public Boolean get_powerVia2pins() {System.out.println(“Power is generated via 2 legs”); return true; } class Adaptor extends PowerOutlet{ private PowerOutletVia2Pins p2; public Boolean get_power_via_3leg(){ return p2.get_powerVia2leg(); }

Don’t forget to Buy Adaptor! For your Application Class: Class Application { } public static void main(…){ Computer c = new Computer(); PowerOutletVia2Pins p2 = new PowerOutletVia2Pins(); PowerOutlet p = new Adpator(); p.setPowerVia2Legs(p2); c.setPowerOutlet(p); c.turn_on() }

Importance of Interface There are two interfaces <<interface>> IComputer turnOn() <<interface>> IPowerOutlet get_power_via_3Pins() Computer PowerOutlet Adapter In scenario 1, you create a Computer and Power object and connect them together. In scenario 2, the Power object is not available, but your computer object can be still used.

DCG vs Interfaces Divide, Conquer, and Glue (DCG) is closely related to interfaces. Ex. Check whether a string consisting of ‘(‘ and ‘)’ is balanced or not. (()()): valid and (() invalid <<interface>> CheckBalanceString <<interface>> Stack <<interface>> StringTobeHandled getValidString();//only ‘(‘ and ‘)’ setStringTobeChecked(…) CheckBalancedParenthesis(); Push(….); Pop(); Console WebInt ArrayImpl DBLinkedList

Commercial Off The Shelf software(COTS) However, like all human-made artifacts, OO languages have advantage as well as disadvantage when developing a SW system!!!