Data Structures and Algorithms Design Goals Implementation Goals Design Principles Design Techniques. Version 03.s 2-1

Similar documents
Chapter 5 Object-Oriented Programming

Object-Oriented Programming

What are the characteristics of Object Oriented programming language?

Computer Science 210: Data Structures

Inheritance and object compatibility

Sorting. Sorting. Selection sort

Design issues for objectoriented. languages. Objects-only "pure" language vs mixed. Are subclasses subtypes of the superclass?

Goals of design. satisfies problem requirements, usable error free, resistant to incorrect input. readable, not purposefully cryptic.

Object-Oriented Concepts and Design Principles

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia

Java Object Oriented Design. CSC207 Fall 2014

Programming Language Concepts Object-Oriented Programming. Janyl Jumadinova 28 February, 2017

Part 7 - Object Oriented Concepts Classes, Objects, Properties and Methods

Inheritance. OOP components. Another Example. Is a Vs Has a. Virtual Destructor rule. Virtual Functions 4/13/2017

CPS 506 Comparative Programming Languages. Programming Language

VIRTUAL FUNCTIONS Chapter 10

Object-Oriented Design

Chapter 1: Object-Oriented Programming Using C++

C++ Important Questions with Answers

INHERITANCE & POLYMORPHISM. INTRODUCTION IB DP Computer science Standard Level ICS3U. INTRODUCTION IB DP Computer science Standard Level ICS3U

Object Oriented Programming. Java-Lecture 11 Polymorphism

CO Java SE 8: Fundamentals

Object-Oriented Concepts and Principles (Adapted from Dr. Osman Balci)

Object Model. Object Orientated Analysis and Design. Benjamin Kenwright

CH. 2 OBJECT-ORIENTED PROGRAMMING

PROGRAMMING LANGUAGE 2

Chapter 13 Object Oriented Programming. Copyright 2006 The McGraw-Hill Companies, Inc.

Object Oriented Design. Object-Oriented Design. Inheritance & Polymorphism. Class Hierarchy. Goals Robustness Adaptability Flexible code reuse

Concepts of Programming Languages

Object-Oriented Design. March 2005 Object Oriented Design 1

Software Paradigms (Lesson 3) Object-Oriented Paradigm (2)

Agenda. Objects and classes Encapsulation and information hiding Documentation Packages

Chapter 11. Categories of languages that support OOP: 1. OOP support is added to an existing language

CHAPTER 5 GENERAL OOP CONCEPTS

Object-Oriented Languages and Object-Oriented Design. Ghezzi&Jazayeri: OO Languages 1

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction

Java Class Design. Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding

Classes and Inheritance in Actor- Oriented Models

Programming II (CS300)

Software Development. Modular Design and Algorithm Analysis

CS200: Advanced OO in Java

Appendix A - Glossary(of OO software term s)

Exception Handling Introduction. Error-Prevention Tip 13.1 OBJECTIVES

CS111: PROGRAMMING LANGUAGE II

Object Oriented Concepts. Produced by. Introduction to the Java Programming Language. Eamonn de Leastar


Lecture Contents CS313D: ADVANCED PROGRAMMING LANGUAGE. What is Inheritance?

ECE 3574: Dynamic Polymorphism using Inheritance

IT101. Inheritance, Encapsulation, Polymorphism and Constructors

Inheritance -- Introduction

Practice for Chapter 11

Unit - IV CHAPTER - 13 INTRODUCTION TO OOP WITH C++ Part 1 Choose the best answer

STUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes

Compaq Interview Questions And Answers

The major elements of the object-oriented model

Inheritance, Polymorphism and the Object Memory Model

CS 445: Data Structures Final Examination: Study Guide

CS313D: ADVANCED PROGRAMMING LANGUAGE

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

Object Orientated Analysis and Design. Benjamin Kenwright

Programming II (CS300)

CT 229 Object-Oriented Programming Continued

Forth Meets Smalltalk. A Presentation to SVFIG October 23, 2010 by Douglas B. Hoffman

COURSE 2 DESIGN PATTERNS

Chapter 10 Classes Continued. Fundamentals of Java

Data Structures Lecture 2

CS-202 Introduction to Object Oriented Programming

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE

CompuScholar, Inc. Alignment to Nevada "Computer Science" Course Standards

MARS AREA SCHOOL DISTRICT Curriculum TECHNOLOGY EDUCATION

Introduction to Programming Using Java (98-388)

CREATED BY: Muhammad Bilal Arslan Ahmad Shaad. JAVA Chapter No 5. Instructor: Muhammad Naveed

1: Introduction to Object (1)

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

OBJECT ORİENTATİON ENCAPSULATİON

Programming Languages 2nd edition Tucker and Noonan"

CMPSCI 187: Programming With Data Structures. Lecture 6: The StringLog ADT David Mix Barrington 17 September 2012

Argument Passing All primitive data types (int etc.) are passed by value and all reference types (arrays, strings, objects) are used through refs.

Core Java - SCJP. Q2Technologies, Rajajinagar. Course content

CS558 Programming Languages Winter 2013 Lecture 8

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

CMSC131. Inheritance. Object. When we talked about Object, I mentioned that all Java classes are "built" on top of that.

Day 4. COMP1006/1406 Summer M. Jason Hinek Carleton University

Introduction to Object- Oriented Programming

Overview of Java s Support for Polymorphism

Data Structures (list, dictionary, tuples, sets, strings)

CS 251 Intermediate Programming Inheritance

HAS-A Relationship. Association is a relationship where all objects have their own lifecycle and there is no owner.

CompuScholar, Inc. 9th - 12th grades

Chapter 5: Procedural abstraction. Function procedures. Function procedures. Proper procedures and function procedures

Object. OutputStream write(int) write(byte[]) write(byte[], int, int) FilterOutputStream write(int) write(byte[]) write(byte[], int, int)

Overview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017

Java Software Solutions for AP Computer Science 3rd Edition, Lewis et al. 2011

Lesson 10. Work with Interfaces and Abstract Classes. Copyright all rights reserved

CSE 2011 Fundamentals of Data Structures

Compilation of Object Oriented Languages Tik Compilers Seminar

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

Component-based Architecture Buy, don t build Fred Broks

Self-review Questions

Object-Oriented Concept

Transcription:

Design Principles Data Structures and Algorithms Design Goals Implementation Goals Design Principles Design Techniques 2-1 Data Structures Data Structure - A systematic way of organizing and accessing data. In the most general sense, a data structure is a data container into which we can store data. However, to access the data in the container, we must follow certain rules 2-2

Abstract Data Types The rules that we follow to access data in a data structure is part of the abstract data type (ADT) for that data structure. In the object-oriented environment, the ADT also defines what messages the data structure must respond to. 2-3 Example - the Simplest Data Structure An array is the simplest data structure that almost all programming languages support. An array is a data container. Rules to access an array: An array has a pre-defined, non-changeable capacity N. Example: int a [] = new a [100]; Elements in the array are indexed by an integer from 0 to N-1. When putting data into the array, the index must be in range. Example: a[3] = 100; When access data from the array, the index must be in range. Example: int k = a[3]; 2-4

Algorithms Algorithm: A step-by-step procedure for performing some tasks in a finite amount of time. This implies that an algorithm should always terminate. Algorithms are used with data structures to ensure the rules for the ADT are enforced. 2-5 Design Goals Using Data Structures and Algorithms to achieve: Correctness: Data structures/algorithms are designed, at a high level, to always work correctly. Efficiency: Data structures/algorithms should be as fast as possible; use as little resources (e.g. memory) as possible. 2-6

Implementation Goal The code we write should have the following properties: Robustness Adaptability Reusability 2-7 Robustness The code should handle all possible inputs (i.e. never stall, crash or quit ). The code should recover gracefully from hardware or system failure (e.g. printer out-of-paper, file missing). The code should handle gracefully for system limitations (e.g. out-of-memory errors). 2-8

Adaptability Software should facilitate changes over time (in response to changing conditions). The code should be able to adapt to unexpected events. The Y2K problem was a very good counter example that how much it would cost us for lack of adaptability. 2-9 Reusability Software should facilitate reuse of components in other software systems. Example: the user interface code in every office suite can be reused for every component in the suite. 2-10

Design Principles Abstraction Encapsulation Modularity and Hierarchy 2-11 Abstraction Distill a complicated system down to its most fundamental parts. Describe these parts in simple and precise language. Specify interface but not implementation. Example: Abstract Data Types (ADT) Specify types of data stored. Specify operations and parameters. 2-12

Encapsulation Encapsulation = Information Hiding. Each software component should implement an abstraction without revealing the internal details of the implementation. Example: A stack can be implemented with either an array or a linked list, the user does not need to know about the details in order to use the stack. 2-13 Modularity and Hierarchy Modularity: Organizing the structures in which the different components are divided into separate functional units. Hierarchy: The relationship among the different modules. 2-14

Hierarchy Example Building Building Apartment Apartment House House Commerical Commerical Building Building Low-Rise Low-Rise Apartment Apartment High-Rise High-Rise Apartment Apartment Two-Story Two-Story House House Ranch Ranch Skyscraper Skyscraper 2-15 Design Techniques Interfaces and Typing Inheritance and Polymorphism Classes and Objects Design Patterns 2-16

Interfaces and Strong Typing All instances of one class have the same interface: a set of messages to which they respond in a prescribed way. This is called Application Programming Interface (API) or just short for Interface. Strong Typing: All types of parameters passed to methods MUST conform with the interface. Type checks of a strong typing language are done at compile time. To convert objects among different types, casting must be used. 2-17 Inheritance Subclass inherits all instance variables and methods from superclass. Object of Class S has instance variable x. Object of Class T has instance variables x and y. Object of Class S can respond to methods a, b and c. Object of Class T can respond to methods a, b, c, d and e. Message: o.a () means sending a() message to object o. Class: S Fields: x Methods: a () b () c () extends Class: T Fields: y Methods: d () e () 2-18

Method Overridden Subclass can also change (override) the way how it responds to a message. Object of Class T can still respond to methods a, b and c. However, the way it responds to the method a and b is different than its superclass. Class: S Fields: x Methods: a () b () c () extends Class: T Fields: y Methods: a () b () 2-19 Polymorphism Polymorphism - an object of Class T will respond to the a () message using the overridden implementation, whether it has been typecast to S or not. This is also called late binding or dynamic binding as the determination of which implementation to execute is deferred until runtime. In Java, methods are dynamically bound by default. Only final methods use static binding. Class: S Fields: x Methods: a () b () c () extends Class: T Fields: y Methods: a () b () 2-20

Classes and Objects Classes define the behavior of objects. What variables to hold data What messages to respond to Objects are the actual actors in application programs They actually hold variables (in memory) They actually respond to messages 2-21 Static methods and variables The definition of a class is held in a Class object. The Class object also holds the static variables and responds to the static methods. When we send a message to a static method, we are sending the message to the Class object of that class, not any instance object of that class. 2-22

Design Patterns A design pattern describes a solution to a typical software design problem. A pattern provides a general template for a solution that can be applied in many different situations. It describes the main elements of a solution in an abstract way that can be specialized for the specific problem at hand. Design patterns we will be studying in this course: Adapter (Chapter 4) Iterator (Chapter 5) Position (Chapter 5) Composition (Chapter 7) Comparator (Chapter 7) 2-23 Summary Design Goals Implementation Goals Design Principles Design Techniques Correctness Efficiency Robustness Adaptability Reusability Abstraction Encapsulation Modularity Interfaces and Typing Inheritance and Polymorphism Classes and Objects Design Patterns 2-24