Objectives. Object Oriented Design and C++ Books C++ Lippman (good introduction) C++ Primer. Introduction to OOD. Objectives.

Similar documents
An Incomplete C++ Primer. University of Wyoming MA 5310

C++ INTERVIEW QUESTIONS

Object Oriented Software Design II

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

CEC225 COURSE COMPACT

Masters of Science in Software & Information Systems

Sample Syllabus (C++) CSCI 1301 Introduction to Programming Principles

BCS2B02: OOP Concepts and Data Structures Using C++

WORKSPACE WEB DEVELOPMENT & OUTSOURCING TRAINING CENTER

6.088 Intro to C/C++ Day 4: Object-oriented programming in C++ Eunsuk Kang and Jean Yang

Ch 7-1. Object-Oriented Programming and Classes

Comp151. Definitions & Declarations

Course MS10975A Introduction to Programming. Length: 5 Days

Code Refactoring and Defects

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas

Introduction to Programming Block Tutorial C/C++

How To Teach C++ Data Structure Programming

Laboratory Assignments of OBJECT ORIENTED METHODOLOGY & PROGRAMMING (USING C++) [IT 553]

Brent A. Perdue. July 15, 2009

Software Reuse. Software Engineering Course Given by: Arnon Netzer. To use parts of one product in another product with a different function.

Visual Studio 2008 Express Editions

Fundamentals of Java Programming

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

C++ Programming Language

Object-Oriented Programming

Curriculum Map. Discipline: Computer Science Course: C++

Konzepte objektorientierter Programmierung

Syllabus Introduction to C++ Programming and Numerical Analysis Spring 2016

Multichoice Quetions 1. Atributes a. are listed in the second part of the class box b. its time is preceded by a colon. c. its default value is

The C Programming Language course syllabus associate level

Parallelization: Binary Tree Traversal

5 CLASSES CHAPTER. 5.1 Object-Oriented and Procedural Programming. 5.2 Classes and Objects 5.3 Sample Application: A Clock Class

Simple C++ Programs. Engineering Problem Solving with C++, Etter/Ingber. Dev-C++ Dev-C++ Windows Friendly Exit. The C++ Programming Language

CS 103 Lab Linux and Virtual Machines

Software Engineering Techniques

Syllabus for CS 134 Java Programming

Mobile App Design Project #1 Java Boot Camp: Design Model for Chutes and Ladders Board Game

Chapter 1 Java Program Design and Development

by Pearson Education, Inc. All Rights Reserved.

Intro to GPU computing. Spring 2015 Mark Silberstein, , Technion 1

UNIX, C, C++ History, Philosophy, Patterns & Influences on modern Software Development. Alexander Schatten November

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Object Oriented Software Design II

Functions and Parameter Passing

OKLAHOMA SUBJECT AREA TESTS (OSAT )

CORBA Programming with TAOX11. The C++11 CORBA Implementation

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C

Visual C Tutorial

Sources: On the Web: Slides will be available on:

C++FA 5.1 PRACTICE MID-TERM EXAM

Department of Electrical and Computer Engineering. EEL 3160 Embedded C++ and Data Structures. Tuesday & Thursday 3:00 5:00 pm

Algorithm & Flowchart & Pseudo code. Staff Incharge: S.Sasirekha

The programming language C. sws1 1

A deeper look at Inline functions

Introduction to Object-Oriented Programming

1.00 Lecture 1. Course information Course staff (TA, instructor names on syllabus/faq): 2 instructors, 4 TAs, 2 Lab TAs, graders

Course Name: ADVANCE COURSE IN SOFTWARE DEVELOPMENT (Specialization:.Net Technologies)

Java SE 8 Programming

Software Development to Control the Scorbot ER VII Robot With a PC

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

PROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON

The University of Alabama in Huntsville Electrical and Computer Engineering CPE Test #4 November 20, True or False (2 points each)

Project 2: Bejeweled

Schedule. Structures and Classes in C++ Outline. Goals for This Topic. Another Example of a Structure. What is a Structure? Classes May 12-17, 2005

Masters in Information Technology

FLORIDA STATE COLLEGE AT JACKSONVILLE COLLEGE CREDIT COURSE OUTLINE. Introduction to Programming with Visual Basic.NET

El Dorado Union High School District Educational Services

CMPT 183 Foundations of Computer Science I

Member Functions of the istream Class

Lecture 7 Notes: Object-Oriented Programming (OOP) and Inheritance

How To Program A Computer

ALLIED PAPER : DISCRETE MATHEMATICS (for B.Sc. Computer Technology & B.Sc. Multimedia and Web Technology)

IS0020 Program Design and Software Tools Midterm, Feb 24, Instruction

Masters in Human Computer Interaction

Tutorial on C Language Programming

ADVANCED SCHOOL OF SYSTEMS AND DATA STUDIES (ASSDAS) PROGRAM: CTech in Computer Science

Course notes Standard C++ programming

Programming II. Cecotti, H. Seminars Tutorials. Independent study (including assessment)

Computer Science 1-3 (AP) Syllabus/Online Course Plan

Java (12 Weeks) Introduction to Java Programming Language

AP Computer Science A - Syllabus Overview of AP Computer Science A Computer Facilities

Basics of C++ and object orientation in OpenFOAM

Course plan. MSc on Bioinformatics for Health Sciences Academic Year Qualification Master's Degree

Constructor, Destructor, Accessibility and Virtual Functions

Facebook Twitter YouTube Google Plus Website

Android Application Development Course Program

Informatica e Sistemi in Tempo Reale

Introduction to Data Structures

Characteristics of Java (Optional) Y. Daniel Liang Supplement for Introduction to Java Programming

EP241 Computer Programming

Writing Reports BJECTIVES ONTENTS. By the end of this section you should be able to :

C++ Crash Kurs. C++ Object-Oriented Programming

Note: Syntactically, a ; is needed at the end of a struct definition.

CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues. Linda Shapiro Spring 2016

Operating System Structure

Chapter 5 Functions. Introducing Functions

School of Psychology PSYC 332: Behaviour Analysis 2013-Trimester 1. Lecturers: N Buist M Hunt A Macaskill

Computer Science III Advanced Placement G/T [AP Computer Science A] Syllabus

Transcription:

Objectives Object Oriented Design and C++ Richard Bowden CVSSP http://www.ee.surrey.ac.uk/personal/r.bowden r.bowden@surrey.ac.uk Objectives Understand object-oriented program design techniques Implementation of OOD in C++ Prerequisites C Programming Experience of UNIX environment Course Structure Introduction to Object-Oriented Programming Revision of C OOD in C++ Assessment C++ Assignment (30%) Design, Implementation and Documentation Set in week 5 Design due week 8-4pm Mon 24/11/2014 Final submission week 11-4pm Mon 15/12/2014 Tutorials 5-6pm weeks 7-10 Examination (70%) Section A - 20 Compulsory Multiple Choice Questions Section B - Choose 2 out of 3 questions Lectures Tues 11-1 22AA04 Lab Sessions Friday 2-4 Starting week 2 32BB03 34BB04 34aBB04 34BB03 Webpage http://www.ee.surrey.ac.uk/personal/r.bowden/cpp All notes, supplementary material and details of laboratory exercises are on the web page Books C++ Lippman (good introduction) C++ Primer Stroustrup (good reference) The C++ Programming Language OOD Booch (background reading) Object-Oriented Design Sams Teach yourself C++ in 21 days Plenty of them cheap on ebay Webpage http://www.ee.surrey.ac.uk/personal/r.bowden/cpp Online resources: http://www.cplusplus.com/ Introduction to OOD Object Oriented Design (OOD) Does not rely on any particular programming language Object Orientated Programming Uses OOD to develop a program OOD OOP abstraction implementation 1

OOD - Object Oriented Design Example of OOD: Shapes Aims to produce a direct representation of programmers ideas design program as a set of interacting objects rather than a bunch of structures with functions to process Why OOD? Better management of large software projects Development of software by multiple people Reuse of code (efficient development and fewer bugs) Feature of OOD Objects containing both and Object is accessed via a simple interface Hierarchical structure which inherit common properties Base Object Derived Objects Shape: common centre colour common location translation Triangle (shape): 3 points Square (shape): 4 points circle (shape): radius Thinking about programming 3 stages 1. Analysis: Clear understanding of the problem 2. Design: Identify key concepts involved in solution 3. Programming: Express the solution in a program Problem and concepts are often not clearly understood before programming Results in badly structured code which is difficult to modify, maintain and use. Critical for large programs with multiple users Thinking about programming Key to writing good programs: Design objects (classes) that clearly represent a single concept Focus on questions: How are objects created? Can objects be copied/destroyed? What are applied to an object? How does the object interface to other objects? Generates a clear concept of the object Simple Example of OOD Problem: Generation of exam marks for each student on the OOD course (exam mark + project mark) Analysis: How many students? Unknown Input? User supplies marks + n of students Output? Table of final marks Simple Example of OOD Design: Storage of exam marks for each student Option 1: Allocate a big array that is always bigger than the number of students make sure I don t access outside the array Option 2: Dynamically allocate an array to size remember to delete make sure I don t access outside the array Option 3: Design an object which is a dynamic array & manages creation/deletion/access Simple user interface for array safe memory management Program: Use simple dynamic array object + input and output 2

Programming Paradigms Procedural separate and Modular Organise into modules Data Abstraction Modules with associated Object Oriented encapsulation of and hierarchical Generic Common between different Procedural Programming original programming paradigm focus on the best algorithm to perform an operation program based on performing a set of (functions) on the pass to function and return result typical of programs written in C/Fortran/Pascal Procedural Programming double square(double x) return x*x; double sqr=square(2.0); Modular Programming hiding focus on organising group procedures with related module user code is insulated from representation necessary for large programs typical of programs in Modula2 Modular Programming stack : set of items on stack : stack_push(stack,double x) double stack_pop(stack) stack_push(10); double x=stack_pop(); Data Abstraction modules not sufficient to express complex systems focus on user-defined types use modules to define types with associated provide a user interface for user interface should be independent of internal representation 3

Data Abstraction stack : set of items on stack : construct(int size) destruct() push(double x) double pop() stack globalstack.construct(10); stack localstack.construct(5); localstack.push(3); double x=localstack.pop(); globalstack.push(x); localstack.destruct(); abstraction + object hierarchy focus on common relationships between sets of objects structured programs which reuse code for common between a set of objects object oriented languages support object hierarchies supported by C++/Java => classes/inheritance Design 1 Identify objects with and 2 Identify commonality between / for sets of objects 3 Define base objects with common / 4 Define derived objects for specific / Example class baseshapec point centre; colour col; baseshapec(point p, colour c);// Constructor centre & colour ~baseshapec(); point getlocation(); colour getcolour(); void translate(vector t); ; class trianglec : public baseshapec point vertex1,vertex2,vertex3; trianglec(point v1, point v2, point v3, point p, colour c); void rotate(double angle); // Rotate by angle void draw(); ; class circlec: public baseshapec double radius; circlec(double r, point p, colour c); void draw(); ; Example of OOD: Shapes Generic Programming Base Object Derived Objects Shape: common centre colour common location translation Triangle (shape): 3 points Square (shape): 4 points circle (shape): radius Objects which work for multiple types of focus on expressing algorithm independent of type used for containers, i.e. stack of char/int/double require common access functions. Supported by C++ as templates 4

Generic Programming Elements of Object-Oriented Programming Example template<class > class stackc * stack; stackc(int size); void push(); pop(); ; stackc<int> istack(5); stackc<double> dtsack(10); stackc<trianglec> tstack(100); istack.push(5); dstack.push(5.5); // stack of integers // stack of doubles // stack of triangles Modularity: Identify objects; with and Data Abstraction: Define a user-interface for object independent of internal representation Hierarchy: Identify common / between objects Create hierarchy of base and derived objects Base objects define common / Derived objects inherit base object / and add new Generic Identify common /structures for objects with different Define templates for structures The Standardisation of C++ Although developed in the early 1980 s Standardised in 1998 2003 saw some fixes 2005 recommended extensions to STL published in 2007 2011 latest major release 2014 some bug fixes Next major release planned for 2017 Year C++ Standard Informal name 1998 ISO/IEC 14882:1998 C++98 2003 ISO/IEC 14882:2003 C++03 2007 ISO/IEC TR 19768:2007 C++TR1 2011 ISO/IEC 14882:2011 C++11 2014 N3690 (working draft C++14) C++14 C++03 vs C++11 In mid-2011, the new C++ standard (dubbed C++11) was finished. The Boost library project made a considerable impact on the new standard New features included regular expression support a comprehensive randomization library a new C++ time library a standard threading library a new for loop syntax (like foreach loops) the auto keyword new container classes We couldn t finish the lecture without a hello world example Lets design a car base In C++ hello world looks something like this #include <iostream> using namespace std; int main(int argc, char *argv[]) cout << Hello world!! << endl; NOTE, cout is your new best friend. If I catch you using printf, Ill break your fingers :-) 5