Download presentation
Presentation is loading. Please wait.
Published byErik Turner Modified over 8 years ago
1
Unit 1 - Introducing Abstract Data Type (ADT) Part 1
2
Unit Objectives Solve a problem using a concrete data type (CDT) ◦ Apply 4 steps of software development process Side trip -> UML class diagram Solve same problem using an abstract data type ◦ Introduce abstract data type (ADT) ◦ Introduce our first ADT -> List Design ADT List First implementation: array-based List Side trip -> pointers and linked lists Second implementation: link-based List ◦ Compare both ADT List implementations Side trip -> efficiency analysis CMPT 225 - Anne Lavergne2
3
What is a Concrete Data Type (CDT)? Term used to contrast with Abstract Data Type (ADT) Definition ◦ Data structure, i.e., constructs, available as part of a programming language, in which we store data Examples: ◦ array ◦ linked list: classes and pointers CMPT 225 - Anne Lavergne3
4
Review: The 4 Steps of the Software Development Process Step 1: Problem statement Step 2: Design Step 3: Implementation Step 4: Testing CMPT 225 - Anne Lavergne4
5
Step 1 - Problem Statement FriendsBook Application ◦ Design and implement an application that maintains the data for a simple social network. ◦ Each person in the network must have a profile that contains the person’s name, optional image, current status and a list of friends. ◦ Your application must allow a user to join the network by creating a profile, leave the network modify the profile, search for other profiles, and add friends. Source: Textbook - Programming Problem 11 - Chapter 9 - Page 287 CMPT 225 - Anne Lavergne5
6
Step 1 - Question Is the problem statement clear and unambiguous? CMPT 225 - Anne Lavergne6
7
Why is Step 1 important! This quote demonstrates why problem statement must be clear and unambiguous before we move on to the other steps of software development process CMPT 225 - Anne Lavergne7
8
Step 2 - OO Design - 1 1. Model “entities” from problem statement Using: ◦ “Noun” technique to figure out what could be a classes and what could be its attributes ◦ OO Principles: Encapsulation Information hiding Single responsibility CMPT 225 - Anne Lavergne8
9
Step 2 - OO Design - 2 2. Choose appropriate ADT ◦ In this first implementation of our FriendsBook application, we shall choose a CDT instead 3. Record our design ◦ Use UML class diagram 4. Specify behaviour of our program ◦ Write algorithm (in pseudocode) CMPT 225 - Anne Lavergne9
10
Side Trip - UML
11
UML: Unified Modeling Language Object-Oriented Paradigm modelling notation Role: clear and effective way to represent (model) various aspects of software system Includes variety of techniques Programming language independent Flexible: allow models to evolve from one phase to another In this course, we will use UML Class Diagrams CMPT 225 - Anne Lavergne11
12
UML Class Diagram contains… Class ◦ Attributes ◦ Operations Relationship between classes ◦ Generalization (is-a) ◦ Aggregation (has-a) ◦ Dependency (uses) ◦ Multiplicity + other details CMPT 225 - Anne Lavergne12
13
CMPT 225 - Anne Lavergne13 Class Class Name Attributes Operations - account ID - customer - balance + deposit(…) + withdraw(…) Example: Exclude constructors, destructors, getters/setters. Why? Because we assume that we will develop these methods for our classes, if they are needed. Account How to represent a class in UML
14
UML class diagram for our FriendsBook Application CMPT 225 - Anne Lavergne14 FriendsBook - numberOfMembers : integer - members : Profile[0..*] + join( newProfile : Profile ) : void + leave( profile : Profile ) : void + modify( profile : Profile ) : void + search( target : String ) : Profile Profile - name : String - image : String - status : String - numberOfFriends : integer - friends : String[0..*] 0..* + addFriend( aFriend : String ) : void
15
Step 3 - Solution #1 – Code Posted on our course web site Week 2: ◦ Code demonstrating class testing with a Test Driver: FriendsBook version 1 Profile.h, Profile.cpp, FriendsBook.cpp (Test Driver), MakefileProfile.hProfile.cppFriendsBook.cppMakefile ◦ Code demonstrating Incremental Development + use of CDT: FriendsBook version 2 FriendsBook.cpp and version 3 FriendsBook.cppFriendsBook.cpp CMPT 225 - Anne Lavergne15
16
Documentation Header Comment Block Class description Class Invariant Method description Preconditions Postconditions CMPT 225 - Anne Lavergne16
17
Solution #1 – Disadvantages of having client code manipulating data directly 1. FriendsBook has many responsibilities: ◦ Interface with the user ◦ Manage data ( Profile objects) CMPT 225 - Anne Lavergne17
18
Observation: Client Code versus CDT Our FriendsBook (client code) manipulates the data, i.e., the array (CDT or data structure) containing Profile objects directly array Directly access data FriendsBook (client code) CMPT 225 - Anne Lavergne18
19
Solution #1 – Disadvantages of having client code manipulating data directly 2. Difficult to reuse the same data collection (array + functions to manipulate its data) in another application CMPT 225 - Anne Lavergne19
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.