Www.javacup.ir Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.

Slides:



Advertisements
Similar presentations
When is Orientated Programming NOT? Mike Fitzpatrick.
Advertisements

Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
Advanced Programming in Java Peyman Dodangeh Sharif University of Technology Fall 2013 Lecture 1: Introduction to OOP Slides adapted from Steven Roehrig.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Object Oriented Programming Chapter 7 Programming Languages by Ravi Sethi.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
What is an object? Your dog, your desk, your television set, your bicycle. Real-world objects share two characteristics: They all have state and behavior;
1 Introduction to C++ Programming Concept Basic C++ C++ Extension from C.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Object Oriented Programming
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Writing Classes (Chapter 4)
Sadegh Aliakbary Sharif University of Technology Fall 2011.
JAVA Introduction ● One of the main JAVA design goal is reducing complexity for programmer – Development time is half or less comparing to equivalent C++
Chapter 3 Introduction to Collections – Stacks Modified
SE-1010 Dr. Mark L. Hornick 1 Introduction to Object-Oriented Programming (OOP) Part 1.
Slide 1 UML Review Chapter 2: Introduction to Object-Oriented Systems Analysis and Design with the Unified Modeling Language, Version 2.0 Alan Dennis,
Sadegh Aliakbary Sharif University of Technology Fall 2012.
Chapter 6 Object-Oriented Java Script JavaScript, Third Edition.
Objected Oriented Programming & Design JAVA Shishir Gupta (704) (704)
Chapter 7 Objects and Classes 1 Fall 2012 CS2302: Programming Principles.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
SNPL1 Woochang Lim What (Variable) + How (Function) = Object Objects are the physical and conceptual things we find in the universe around us. Object-Oriented.
Object-Oriented Design Simple Program Design Third Edition A Step-by-Step Approach 11.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 4 Defining Your Own Classes.
1 Programming Paradigms Object Orientated Programming Paradigm (OOP)
S.Ducasse Stéphane Ducasse 1 Object-Oriented Programming.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Object-Oriented Programming with Java Lecture 1: Introduction Autumn, 2007.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
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”
CSCI 1100/1202 April 1-3, Program Development The creation of software involves four basic activities: –establishing the requirements –creating.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Basic Concepts of Object Orientation Object-Oriented Analysis CIM2566 Bavy LI.
Salman Marvasti Sharif University of Technology Winter 2015.
1 OOP - An Introduction ISQS 6337 John R. Durrett.
CSci 162 Lecture 10 Martin van Bommel. Procedures vs Objects Procedural Programming –Centered on the procedures or actions that take place in a program.
Inheritance CSI 1101 Nour El Kadri. OOP  We have seen that object-oriented programming (OOP) helps organizing and maintaining large software systems.
Introduction to OOP Mehdi Einali Advanced Programming in Java 1.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Copyright 2006 Oxford Consulting, Ltd1 January Introduction to C++ Programming is taking A problem Find the area of a rectangle A set of data.
1 CSE Programming in C++. 2 Overview Sign roster list Syllabus and Course Policies Introduction to C++ About Lab 1 Fill Questionnaire.
Object Oriented Programming. OOP  The fundamental idea behind object-oriented programming is:  The real world consists of objects. Computer programs.
Copyright 2005, The Ohio State University CSE – Introduction to C++ Name: Shirish Tatikonda Time: T 3:30 PM Room: BE 394
Introduction to OOP Mehdi Einali Advanced Programming in Java 1.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
CSCI 51 Introduction to Programming Dr. Joshua Stough February 26, 2009.
Objects and Memory Mehdi Einali Advanced Programming in Java 1.
Inheritance ITI1121 Nour El Kadri.
7.1 What Is An Object Object-oriented program - Description or simulation of application Object-oriented programming is done by adopting or extending an.
Object Oriented Programming F3031
Review: Two Programming Paradigms
JAVA Introduction ការណែនាំពី Java
Anatomy of a Class & Method
Chapter 4: Writing Classes
Advanced Programming in Java
Advanced Programming Behnam Hatami Fall 2017.
Road to Object Oriented Programming
Object Oriented Design & Analysis
Presentation transcript:

Sadegh Aliakbary

Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP is clearly noted as the source in the used case. JAVACUP shall not be liable for any errors in the content, or for any actions taken in reliance thereon. Please send your feedback to 2

Agenda Object Oriented Programming Characteristics of objects Interface Encapsulation 3

Abstraction Machine language Assembly: an abstraction of the machine language Many languages are abstraction of assembly language Fortran, Basic, C Big improvement But they still require you to think in terms of the structure of the computer Rather than the structure of the problem JAVACUP.ir Contents redistribution is allowed if JAVACUP is noted as the source4

Different Contexts Problem Space the place where the problem exists such as a business Solution Space the place where you’re implementing that solution such as a computer The effort required to perform this mapping JAVACUP.ir Contents redistribution is allowed if JAVACUP is noted as the source5

Library Problem Suppose you want to write a library program What are the elements of your program? We think about functions and variables… JAVACUP.ir Contents redistribution is allowed if JAVACUP is noted as the source6

Object Oriented Approach OO approach goes a step further Lets the programmer represent problem space elements This representation is general enough The programmer is not constrained to any particular type of problem. The elements in the problem space and their representations in the solution space are referred to as “objects” JAVACUP.ir Contents redistribution is allowed if JAVACUP is noted as the source7

OOP The program is allowed to adapt itself to the lingo of the problem by adding new types of objects when you read the code, you’re reading words that also express the problem. This is a more flexible and powerful language abstraction JAVACUP.ir Contents redistribution is allowed if JAVACUP is noted as the source8

Object Oriented Languages Smalltalk The first successful object-oriented language One of the languages upon which Java is based Java C++ C## JAVACUP.ir Contents redistribution is allowed if JAVACUP is noted as the source9

OOP vs. Procedural Approach Elements of OOP Objects Message passing between objects Elements of procedural programming Functions Variables Function invocation The way of thinking Thinking about objects and relations Thinking about functions and computer structure JAVACUP.ir Contents redistribution is allowed if JAVACUP is noted as the source10

OOP Characteristics Alan Kay summarized five basic characteristics of Smalltalk 1. Everything is an object 2. A program is a bunch of objects telling each other what to do by sending messages 3. Each object has its own memory made up of other objects 4. Every object has a type 5. All objects of a particular type can receive the same messages JAVACUP.ir Contents redistribution is allowed if JAVACUP is noted as the source11

Booch’s description of an Object An object has state, behavior and identity Booch added identity to the description An object (may) have internal data which gives it state An object (may) have methods to produce behavior And each object can be uniquely distinguished from every other object Each object has a unique address in memory JAVACUP.ir Contents redistribution is allowed if JAVACUP is noted as the source12

Interface Each object can satisfy only certain requests The requests you can make of an object are defined by its interface The type is what determines the interface JAVACUP.ir Contents redistribution is allowed if JAVACUP is noted as the source13

Representation of a light bulb: JAVACUP.ir Contents redistribution is allowed if JAVACUP is noted as the source14 UML Diagram

Person in an Education System JAVACUP.ir Contents redistribution is allowed if JAVACUP is noted as the source15

New names in OOP Function  Method, Service Variable  Property, State JAVACUP.ir Contents redistribution is allowed if JAVACUP is noted as the source16

Encapsulation Commercial products are encapsulated Remote control TV Cell phone They are Black Boxes Hidden Implementations Public interface JAVACUP.ir Contents redistribution is allowed if JAVACUP is noted as the source17

Why Encapsulation? Simplified use Even for the producer Open implementation  bad use Hiding the implementation reduces bugs It is more beautiful! JAVACUP.ir Contents redistribution is allowed if JAVACUP is noted as the source18

Object Encapsulation Encapsulation of a problem-space concept into a class of objects Define interface Hide the implementation Black box The client may see the implementation But can not use it directly This is better even for the producer (programmer) JAVACUP.ir Contents redistribution is allowed if JAVACUP is noted as the source19

Access Control Access to some parts of the class is restricted Public and Private area of the class The client of a class can use only public area Public area = class interface Public methods Public variables JAVACUP.ir Contents redistribution is allowed if JAVACUP is noted as the source20

Example: Rectangle Lets encapsulate a rectangle What is a rectangle? An object Which has length and width (properties) Lets you specify its length and width Can calculate its area and perimeter JAVACUP.ir Contents redistribution is allowed if JAVACUP is noted as the source21

public class Rectangle { private int width, length; public void setWidth(int w) { width = w; } public void setLength(int l) { length = l; } public int calculateArea(){ return width*length; } public int calculatePerimeter(){ return (width+length)*2; } JAVACUP.ir Contents redistribution is allowed if JAVACUP is noted as the source22 Private area: hidden implementation Public area : the interface Class Declaration

How to Use Rectangle? Rectangle rect = new Rectangle(); rect.setWidth(2); rect.setLength(7); System.out.println(rect.calculateArea()); System.out.println( rect.calculatePerimeter() ); JAVACUP.ir Contents redistribution is allowed if JAVACUP is noted as the source23 Object creation or instantiation

JAVACUP.ir Contents redistribution is allowed if JAVACUP is noted as the source24