CSI33 Data Structures

Similar documents
Outline. Outline. 1 Chapter 2: Data Abstraction

CSI33 Data Structures

Chapter 4 Defining Classes I

What is an algorithm?

CMPT 117: Tutorial 1. Craig Thompson. 12 January 2009

Object-Oriented Programming (OOP) Basics. CSCI 161 Introduction to Programming I

Abstract Data Types. CS 234, Fall Types, Data Types Abstraction Abstract Data Types Preconditions, Postconditions ADT Examples

What is an algorithm?

Lecture 7: Data Abstractions

Outline. Computer Science 331. Information Hiding. What This Lecture is About. Data Structures, Abstract Data Types, and Their Implementations

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

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107

Programming II (CS300)

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

CSI32 Object-Oriented Programming

Data Structures and Algorithms for Engineers

CSE 214 Computer Science II Java Classes and Information Hiding

Defining Classes and Methods

Abstract Data Types (ADT) and C++ Classes

Defining Classes and Methods. Objectives. Objectives 6/27/2014. Chapter 5

JAVA MOCK TEST JAVA MOCK TEST II

What is a class? Responding to messages. Short answer 7/19/2017. Code Listing 11.1 First Class. chapter 11. Introduction to Classes

Objectives. Defining Classes and Methods. Objectives. Class and Method Definitions: Outline 7/13/09

Abstract Data Types Chapter 1

Chapter 1: Programming Principles

CMSC 132: Object-Oriented Programming II

Glossary. For Introduction to Programming Using Python By Y. Daniel Liang

TeenCoder : Java Programming (ISBN )

Inheritance and Polymorphism

Defining Classes and Methods

Inheritance and Polymorphism

Programming II (CS300)

Object Orientated Analysis and Design. Benjamin Kenwright

Data Structures and Algorithms. Chapter 1

5. Defining Classes and Methods

Programmazione. Prof. Marco Bertini

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

Lecture Chapter 2 Software Development

Chapter 1: Principles of Programming and Software Engineering

CLASSES AND OBJECTS IN JAVA

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

Lecture 7. Log into Linux New documents posted to course webpage

CompuScholar, Inc. 9th - 12th grades

CSI33 Data Structures

EECS168 Exam 3 Review

Object Oriented Programming

Dot and Scope Resolution Operator

AP Computer Science Chapter 10 Implementing and Using Classes Study Guide

CSI33 Data Structures

Chapter 10 Classes Continued. Fundamentals of Java

IMACS: AP Computer Science A

Welcome to CSC148! Introduction to Computer Science

CSC Advanced Object Oriented Programming, Spring Specification

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

Object-Oriented Programming Concepts

C++ Quick Guide. Advertisements

OOPs Concepts. 1. Data Hiding 2. Encapsulation 3. Abstraction 4. Is-A Relationship 5. Method Signature 6. Polymorphism 7. Constructors 8.

OBJECT ORIENTED PROGRAMMING

Java Object Oriented Design. CSC207 Fall 2014

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

Chief Reader Report on Student Responses:

An OBJECT contains VARIABLES = PROPERTIES and METHODS = BEHAVIORS. Outline the general nature of an object.

Objects and Classes. Amirishetty Anjan Kumar. November 27, Computer Science and Engineering Indian Institue of Technology Bombay

Day 3. COMP 1006/1406A Summer M. Jason Hinek Carleton University

Textbook. Topic 6: Functions. Motivation. What is a Function? What s a function? How can we use functions to write better software?

Chapter 1: Key Concepts of Programming and Software Engineering

CS304 Object Oriented Programming Final Term

ICT Object Oriented Design Standards

CSE 331 Software Design & Implementation

Programming I. Course 9 Introduction to programming

Type Hierarchy. Lecture 6: OOP, autumn 2003

Introduction to OOP. Procedural Programming sequence of statements to solve a problem.

CSc 110, Autumn Lecture 30: Methods. Adapted from slides by Marty Stepp and Stuart Reges

CSC 1052 Algorithms & Data Structures II: Interfaces

Chapter 4. Defining Classes I

CSC207H: Software Design. Java + OOP. CSC207 Winter 2018

Designing data types. Overview. Object Oriented Programming. Alan Kay. Object Oriented Programming (OOP) Data encapsulation. Checking for equality

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

M.C.A DEGREE EXAMINATION,NOVEMBER/DECEMBER 2010 Second Semester MC 9222-OBJECT ORIENTED PROGRAMMING (Regulation 2009)

Java. Classes 3/3/2014. Summary: Chapters 1 to 10. Java (2)

Data Structures and Programming with C++

Defining Classes and Methods

Designing data types. Fundamentals of Computer Science I

Classes, interfaces, & documentation. Review of basic building blocks

UNDERSTANDING CLASS DEFINITIONS CITS1001

COMP 250 Winter 2011 Reading: Java background January 5, 2011

Object Oriented Paradigm

CSI33 Data Structures

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value

6.170 Lecture 7 Abstract Data Types MIT EECS

Chapter 7. Inheritance

CS 112 Intro to Programming Basic OO Concepts

Object Model. Object Orientated Analysis and Design. Benjamin Kenwright

CPS 506 Comparative Programming Languages. Programming Language

Top Down Design vs. Modularization

Abstract Data Types. Stack. January 26, 2018 Cinda Heeren / Geoffrey Tien 1

Introduction to Object- Oriented Programming

Inheritance CSC 123 Fall 2018 Howard Rosenthal

Object oriented programming. Encapsulation. Polymorphism. Inheritance OOP

Chapter 8: Creating Your Own Type Classes

Transcription:

Outline Department of Mathematics and Computer Science Bronx Community College August 29, 2018

Outline Outline 1 Chapter 2: Data Abstraction

Outline Chapter 2: Data Abstraction 1 Chapter 2: Data Abstraction

From Data Type to ADT Values A value is a unit of information used in a program. It can be associated with a constant or variable (a name) by an assignment statement: person = George n = 4 All primitive type values (integer, float, string) are represented internally in the computer program s memory as a series of zeros and ones. More complex types have values which are combinations of more primitive types.

From Data Type to ADT Data Types A Data Type is the set of possible values which all represent the same type of information and share the same behavior. In Python, most data types are classes, and a value of some data type is an object in that class. int str float list dict file

Defining an ADT = Specification Data Abstraction The data is represented using abstract attributes. Example: a card has attributes suit and rank. The behavior is given by specifying functions, with the signature, preconditions, and postconditions of procedural abstraction. Data Abstraction is the hiding of the primitive components comprising the values of some type, and hiding the implementation of the operations using that type.

Implementation of an ADT Concrete Representation The abtract attributes are represented using types from the programming language or previously defined classes. Example: a suit is now a member of the Python string class str, and is allowed to have the values c, d, h or s.

Class Specification Python Classes ADTs become Python classes, and their behaviors become methods for those classes.

Class Specification Data Abstraction In the class definition, a comment will tell how the concrete representation corresponds to the abstract attributes (for example, the letter c corresponds to the suit clubs ).

Class Specification Functional Abstraction Each method specification includes a comment listing all preconditions and postconditions.

Class Implementation Data Representation In the class definition, the constructor init will take parameters to set the attributes of new objects (or use default values).

Class Implementation Method Implementation The actual Python code to implement the behavior of each method follows the comments listing preconditions and postconditions. Typical methods are mutators, which change attribute values, and accessors which return attribute values without changing them.

Changing the Representation The Abstraction Barrier By keeping the specification and implementation separate, it is possible to change the implementation say, to use a more efficient algorithm without having to change any program that uses the ADT respectful of its specification.

Changing the Representation The Abstraction Barrier The program which uses the ADT only has access to it through its methods, which are written to obey the specification what types of parameters are passed and what types of values are returned. The concrete representation can change, but as long as the methods have the same signatures, and honors the same contracts (preconditions and postconditions), the program which calls them will still work.

Object Oriented Design (OOD) and Object Oriented Programming (OOP) OOD extends ADTs Data Abstraction is only one of several ideas that have helped to advance software engineering. Object Oriented Design and programming uses ADTs as well as other principles.

Object Oriented Design (OOD) and Object Oriented Programming (OOP) Encapsulation Also known as information hiding, this separates the issues of what to do from issues of how to do it.

Object Oriented Design (OOD) and Object Oriented Programming (OOP) Polymorphism This is the principle that sending the same message (that is, calling the same method) to objects in different classes should make the objects behave the same.

Object Oriented Design (OOD) and Object Oriented Programming (OOP) Inheritance Classes which share behaviors should not have to reimplement these behavior if they can be inherited from a base class which implements that same behavior. This principle promotes reuse of code, which in turn makes software more reliable, since bugs are more localized.