bg287

CSC210 Notes

Posted in csc210 by bnmng on 2011 01/19

Two Homeworks handed out, due Monday and Wednesday.
Reading Assignment: Read 2 to end, and 3 to page 114.

Today: Finish Big O; Testing and debugging; Classes; Constructors; Namespaces (not testable); Classes and Parameters; Maybe overloading;

Important for defining functions: pre-conditions and post-conditions.

Assert: helpful tool. Tests conditions. Stops program, gives error message

In class exercise: writing pre and post conditions

//pre-condition: an integer array, which holds a list of numbers is provided along with an integer which represents the length of the list of numbers. This length is greater than zero and less than or equal to the max allowed length. Also provided is a target to search for.

//postcondition: The target value is added to the end of the list. The return value is the location of the first occurrence of the target value in the list.

Big O: All except n= a constant are increasing functions. They involve more steps when the amount of data gets larger.

for (i=1; i<=m; i++)
for (j=1; j<=s; j++)
for (k=1; k<=s; k++)
cout << k <<endl;
Big O notation: This is O(n3).

for (i=1; i<=m; i++)
for (j=1; j<=5; j++)
for (k=1; k<=s; k++)
cout << k <<endl;
Big O notation: This is O(n2). because one loop only runs for a constant amount of times.

i=1;
while (i =0)
{
i=i/2;
}
Big O: logarithmic

Test oracle: A set of inputs with predicted outputs.
Definitions of General Case, Boundary Conditions and Error conditions using an array of max length of 50 as an example:
General Case: length is 2 to 49
Boundary Conditions: length is 0, 1, or 50
Error Conditions: length is out bounds. (ie -5 or 75)

The amount of paths, depending on the amount of decisions, is 2 to the amount of decisions.
You should endeavor to test all paths, but that may not be practical.

Remember types of functions in a class: Constructors, destructors, iterators, transformers, observers

The throttle class (a class used in the book as an example)

macroguard: see page 50. Should surround the specification for the class. Ensures we don’t generate a comple time error if we have multiple copies of the dot.h file.

Don’t macroguard standard libraries.

Include classes after using namespaces.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: