Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Object-oriented Programming CSIS 3701: Advanced Object Oriented Programming.

Similar presentations


Presentation on theme: "Introduction to Object-oriented Programming CSIS 3701: Advanced Object Oriented Programming."— Presentation transcript:

1 Introduction to Object-oriented Programming CSIS 3701: Advanced Object Oriented Programming

2 The “Software Crisis” Most “real world” programs 10,000 – 10,000,000 lines long Take months or years to develop Created by dozens or hundreds of programmers –Many are added to or leave the project throughout development Modified over time as customer needs change

3 Abstracton Ability to use tool without having to understand how it works –Example: can drive car without understanding physics of internal combustion, electronics, etc. Functional abstraction: y = sqrt(x); –Do you know how C computes square root? –Do you need to?

4 Large-Scale Programming Abstraction key to large scale programming –No individual can understand entire system –Just need to understand your subsystem –Need to know how to use methods in other modules it interacts with Your module Other module methods Other module methods Other module methods

5 Data Access 3-Tier Architecture User InterfaceBusiness Logic Order Database Product Database UI developers just need to know UI design and how to call business logic methods Business logic developers just need to know business model, how will be called by UI, and how to call data access methods Data access developers just need to know SQL and database design and how will be called by business logic

6 Objects Object-oriented classes are abstractions “Client programmer”: Programmer who uses class in their own code Methods to access state of object Current state of object Object Only has to understand how to call methods, not how they work Does not have to understand internal representation of object state

7 Abstract Data Types as Objects Example: Stack abstract data type Programmer who uses Stack class void push(int) int pop() boolean isEmpty() Stack Only has to understand how these affect abstract concept of a “stack” Internal representation could be array, linked list, etc. top contents

8 Examples of Objects GUI components: –Attributes: width, font, text, location, etc. –Methods: setText, getText, show, hide, etc. –Can use without knowing how drawn by OS “Problem domain” classes: –Example: Order class for financial system –Attributes: order#, item, quantity, totalCost, … –Methods: getNewOrderNumber, setItem, setQuantity…

9 Objects vs. Classes Class defines: –Attribute types ( int top, String[] contents ) –Code for methods ( push, pop, isEmpty ) –Created by developer and added to “library” Object is an instance of a class –Constructed from class by “client programmer” –Each may have different attribute values top: 3 contents: [“Larry”, “Curley”, “Moe”] top: 2 contents: [“Fred”, “Barney”] stoogesStackbedrockStack

10 Constructors and Abstraction Other programmers should not have to understand internal representation to create an object Constructor: code executed automatically at object startup to define initial state –Default values –Parameters passed to constructors –Values read from file

11 Reuse Should never have to rewrite code from scratch Reuse in maintenance –Must be able to add abilities to new version without causing faults in existing code –Otherwise, will have to redesign/retest entire program for each modification! Existing code from previous version New code to add new abilities and features New code affects existing code

12 Reuse Reuse in version design –Multiple products may share common features –If those features changed, must propagate to all products –Ideally do with single change Common features of Office products (file handling, etc.) WordExcelPowerPoint Change to file handling

13 Java Programming Language specifically designed for object- oriented programming Abstraction: –Everything is an object –Encapsulation of internal state –Polymorphism/interfaces for abstract containers Reuse: –Inheritance of properties between classes

14 Abstraction in Design UML: Universal Modeling Language –Common representation for design at abstract level –Class types and relationships

15 Reuse in Design Abstract design ideas reused in different systems Design patterns: –Classes used to solve common problems –Example: Adaptor pattern to map to another protocol

16 Reuse in Design Class design level: –Typical types of classes –Typical methods within those classes Methods to set values of member variables (with validation) Methods to access (without changing) member variable values Methods to display state of object as a string …


Download ppt "Introduction to Object-oriented Programming CSIS 3701: Advanced Object Oriented Programming."

Similar presentations


Ads by Google