Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
58 Cards in this Set
- Front
- Back
Object-oriented analysis (OOA) |
What to do and what not to do. |
|
Object-oriented design (OOD) |
models of how it could be done |
|
Encapsulation |
Objects combine data and operations |
|
Inheritance |
Classes inherit properties from other classes |
|
Polymorphism |
Objects determine appropriate operations at execution. |
|
What is cohesive modules? |
Cohesive modules perform single well-defined tasks. Good for: 2)Easy to revise 3)Easy to reuse |
|
What is coupling? |
Coupling is a measure of depedence among modules. In other words: 1)Loosely coupled modules desired 2)Independence 3)If module fails, all dependent modules will fail 4)Objects should collaborate |
|
Operational contract |
1)Documentation 2)Specifies data flow 3)Does not need to specify the task 4)Remember pre and post conditions |
|
Unusal Conditions |
Failed? Garbage in, garbage out logic! |
|
Abstraction |
1)Seperates purpose of a module from its implementation 2)Use without concern about the implementation 3)What not how 4)Sort |
|
ADT - Bag (How to design?) |
1)What does the problem require? 2)What operations are required to be executed on the data? |
|
ADT- Bag (Behaviors, name 2!) |
1)Get size of bag 2)Check if bag is empty 3)Add object to bag 4)Remove an object etc... |
|
ADT- Specify at least two functions associated with Data and operations |
getCurrentSize() isEmpty() add(newEntry: ItemType): boolean remove(anEntry: ItemType): boolean clearn (): void getFrequencyOf(anEntry: itemType): integer contains(anEntry: ItemType): boolean toVector(): vector |
|
BREAK NEXT SLIDE |
Enter Interlude 1 classes |
|
UML |
Uniform Modelling Language |
|
Methods what is a get and set called? |
Accessor is a get, mutator is a set. |
|
Write the function prototype for a get and set |
ItemType getItem() const; void setItem(const ItemType& theItem); |
|
What do you add to the top of your file to prevent compling errors in terms of includes? |
#ifndef _CLASS #define _CLASS //code #endif |
|
Virtual Methods |
a member function that you expect to be redefined in derived classes. In other words, polymorphism. |
|
Abstract Classes always have what and cannot be what? |
Always have one or more virtual methods and cannot be instantiated. |
|
BREAK-- Not really that was lame af, but onward! |
RECURSION: The Mirrors |
|
What is the point of recursion? |
Breaking larger problems into smaller ones, such is life. |
|
Recursion will keep reducing in size until it encounters a _____ case; |
Base |
|
Memory Structure, when functions are invoked they are pushed onto the _________. Then they are _____ when execution finishes. Note: Global / static vars are stored in the static data section |
Stack, popped |
|
BREAK-- Onto the next nightmare |
WallsMirros CHP 3 PPT |
|
What is an ADT? |
A collection of data and a set of operations on that data |
|
Specifications of an ADT indictate... |
What an ADT does, but not how its implemented |
|
When using Fixed-Size Arrays you must... |
Track array elements used, figure out how methods are to be incorporated. |
|
Defining core methods from this point forward you will just write the functions out based off of the function prototype. |
bool roomtoadd = (itemCount<maxItems); if(roomtoadd){ items[itemCount]=newEntry; |
|
vector<ItemType> ArrayBag<ItemType>::toVector(){ |
vector<ItemType> bagContents; bagContents.push_back(items[i]); |
|
int ArrayBag<ItemType>::getCurrentSize() const{ //code |
1)return itemCount; 2)return itemCount==-0; |
|
int ArrayBag<ItemType>::getFrequencyOf(const ItemType& anEntry) const{ |
int freq=0; int curidx=0; if(items[curidx]==anEntry){ } |
|
bool ArrayBag<ItemType>::contains(const ItemType& anEntry) const{ |
bool isFound=false; |
|
int ArrayBag<ItemType>::getIndexOf(const ItemType& target) const{ |
bool isFound=false; int results=-1; result=searchIndex; else searchIndex++; |
|
bool ArrayBag<ItemTpye>::remove(const ItemType& anEntry){ |
int locatedIndex=getindexOf(anEntry); itemCount--; items[locatedIndex]=items[itemCount]; |
|
void ArrayBag<ItemType>::clear(){ |
itemCount=0; |
|
int ArrayBag<ItemType>::getIndexOf(const ItemType& taget, int searchIndex) const{ |
int result=-1; if(searchIndex<itemCount) { if(items[searchIndex]==target) result=searchIndex; else } |
|
int ArrayBag<ItemType>::countFrequency(const ItemType& target, int searchIndex) const{ |
if(searchIndex<itemCount) |
|
int ArrayBag<ItemType>::countFrequency(const ItemType& target, int searchIndex) const //code |
int frequency=0; |
|
Break -- No serious take a ten minute break |
MY MIND IS MELTING |
|
How do you avoid causing dangling pointers? |
Set a deleted pointer to null and making sure that declared pointers have a value |
|
How do you declare a virtual method? |
Declare methods in base class as virtual. |
|
How do you dynamically declare an array? |
int size=50; doublt *anArray=new double[size]; |
|
How do you delete that dynmaicllay declared array? |
delete [] anArray; |
|
Write an old array to a new array, dynamically! anArray= new double[2* arraySize]; |
for(int i=0;i<arraySize;i++) delete [] oldArray; |
|
Creating a resizable array to implement ADT BAG //code |
bool hasRoomToAdd = (itemCount < maxItems); items= new ItemType[2*max]; items[i]=oldArray[i]; delete [] oldArray; max=2*max; } itemCount++; return true; |
|
BREAK -- Last leg of it!! |
|
|
Nodes are usually placed into it... |
objects |
|
Class Node |
item =anItem; |
|
void Node<ItemType>::setNext(Node<ItemType>* nextNodePtr) |
next=nextNodePtr; |
|
ItemType Node<ItemType>::getItem() const |
return item; |
|
Node<ItemType>* Node<ItemType>::getNext() const |
return next; |
|
REFRESHER, give yourself a list of implementations of an ADT (Function list) |
getCurrentSize() |
|
Define a basic constructor of a LinkedBag... |
Nothing to see here... |
|
bool LinkedBag<ItemType>::add(const ItemType& newEntry) |
Node<ItemType>* newNodePtr= new Node<ItemType>();
|
|
What is a tranversion operation? |
Visits each node in a linked chain |
|
std::vector<ItemType> LinkedBag<ItemType>::toVector() const{ |
std::vector<ItemType> bagContents; |
|
a |
a |