Difference between revisions of "Project A3 20141 - OOP344"

From CDOT Wiki
Jump to: navigation, search
(WIP)
 
(Introduction: More intro information)
Line 9: Line 9:
 
# It makes debugging '''much much easier''' both for yourself and for '''anyone helping you'''
 
# It makes debugging '''much much easier''' both for yourself and for '''anyone helping you'''
 
; So how do I keep my code sane?
 
; So how do I keep my code sane?
: By following these 2 simple steps:
+
: By following these simple steps:
 
# Keep the code nicely '''formatted''' at '''all times'''. This makes it easy to see the logical structure of your program at a glance and to follow the logic of it. Experienced programmers do '''NOT''' look for lines of code, they look for '''blocks''' denoted by '''indents'''. Train yourself to do the same.<br/>'''NOTE:''' If you are using an editor or environment that makes this hard for you, '''start by getting a better environment!'''<br/>Windows and visual studio are an excellent combination and provided for free by Seneca. On Linux, your options are netbeans and sublime. The debugging experience is simpler on Windows for our assignments however.<br/>Also note, on visual studio, you can have the editor '''automatically''' format your code nicely by pressing the following combinations in sequence:<br/>'''CTRL-K, CTRL-D'''
 
# Keep the code nicely '''formatted''' at '''all times'''. This makes it easy to see the logical structure of your program at a glance and to follow the logic of it. Experienced programmers do '''NOT''' look for lines of code, they look for '''blocks''' denoted by '''indents'''. Train yourself to do the same.<br/>'''NOTE:''' If you are using an editor or environment that makes this hard for you, '''start by getting a better environment!'''<br/>Windows and visual studio are an excellent combination and provided for free by Seneca. On Linux, your options are netbeans and sublime. The debugging experience is simpler on Windows for our assignments however.<br/>Also note, on visual studio, you can have the editor '''automatically''' format your code nicely by pressing the following combinations in sequence:<br/>'''CTRL-K, CTRL-D'''
 
# Do not begin writing the next feature before the '''last feature''' is working! This is of '''paramount importance'''! By ensuring that your code is working ('''use the tests, specs, and your common sense!'''), you can save versions of your assignment at specific points in time and '''know''' that if a problem arises, '''it must be caused by your latest set of changes!'''
 
# Do not begin writing the next feature before the '''last feature''' is working! This is of '''paramount importance'''! By ensuring that your code is working ('''use the tests, specs, and your common sense!'''), you can save versions of your assignment at specific points in time and '''know''' that if a problem arises, '''it must be caused by your latest set of changes!'''
 +
# Use a '''consistent''' naming convention for all member variables and '''another''' convention for local variables.<br/>This makes it easy for you and for '''anyone helping you''' to tell at a glance (ie '''WITHOUT''' looking at your header) which variables are local, member, etc...<br/>Too often I see conventions either not used, not used consistently, or '''mixed'''. Of the three cases, '''the third is the worst'''.<br/>Aim to '''ALWAYS''' use consistent naming conventions, whatever they may be.<br/>An easy set of conventions is as follows:
 +
#; Private/Protected Member Variable/Function: _underscoreCamelCase
 +
#; Public Member Variable/Function: regularCamelCase
 +
#; Local Variable/Function Parameter/Global Function: regularCamelCase
 +
#; Public #Define (ie should be used by external code): SCREAMING_CAPS
 +
#; Private #Define (ie should only be internally used): _UNDERSCORE_SCREAMING_CAPS
  
 
When you are finished the assignment, you will have created the following files:
 
When you are finished the assignment, you will have created the following files:
Line 19: Line 25:
  
 
== Part 1: Integer Linked List ==
 
== Part 1: Integer Linked List ==
For this part, you will build the classes '''IntList''' and '''IntListNode''' in the file '''intlist.h'''. These two classes compose a basic implementation of an integer linked list. Please see the following sections on the exact specifications of these classes.
+
For this part, you will build the classes '''IntList''' and '''IntListNode''' in the files '''intlist.h''' and '''intlist.cpp'''. These two classes compose a basic implementation of an integer linked list. Please see the following sections on the exact specifications of these classes.
  
 
=== Class: IntListNode, Files: [intlist.h, intlist.cpp], Test: 0 ===
 
=== Class: IntListNode, Files: [intlist.h, intlist.cpp], Test: 0 ===

Revision as of 02:38, 23 March 2014

Introduction

Our third assignment will have you construct an integer holding linked list, adapt it into a templated linked list, then create an object editor utilizing the list. You will use the testing package linked here to test your assignment. The linked lists have automated tests; the rest of the assignment has some automated tests and some visual tests. Please note the filename and test number conveniently provided in the section headers for each required class/function.

SANITY NOTE
You will be writing a number of classes and functions. Please remember to sanitize your code as you go along.
What is code sanity?
The idea behind code sanity is to keep the code clean and the logic strong at all times. This has 2 main advantages.
  1. If your code is logically correct at all times then you can be sure that if there is a problem, it has been caused by the latest set of alterations.
  2. It makes debugging much much easier both for yourself and for anyone helping you
So how do I keep my code sane?
By following these simple steps:
  1. Keep the code nicely formatted at all times. This makes it easy to see the logical structure of your program at a glance and to follow the logic of it. Experienced programmers do NOT look for lines of code, they look for blocks denoted by indents. Train yourself to do the same.
    NOTE: If you are using an editor or environment that makes this hard for you, start by getting a better environment!
    Windows and visual studio are an excellent combination and provided for free by Seneca. On Linux, your options are netbeans and sublime. The debugging experience is simpler on Windows for our assignments however.
    Also note, on visual studio, you can have the editor automatically format your code nicely by pressing the following combinations in sequence:
    CTRL-K, CTRL-D
  2. Do not begin writing the next feature before the last feature is working! This is of paramount importance! By ensuring that your code is working (use the tests, specs, and your common sense!), you can save versions of your assignment at specific points in time and know that if a problem arises, it must be caused by your latest set of changes!
  3. Use a consistent naming convention for all member variables and another convention for local variables.
    This makes it easy for you and for anyone helping you to tell at a glance (ie WITHOUT looking at your header) which variables are local, member, etc...
    Too often I see conventions either not used, not used consistently, or mixed. Of the three cases, the third is the worst.
    Aim to ALWAYS use consistent naming conventions, whatever they may be.
    An easy set of conventions is as follows:
    Private/Protected Member Variable/Function
    _underscoreCamelCase
    Public Member Variable/Function
    regularCamelCase
    Local Variable/Function Parameter/Global Function
    regularCamelCase
    Public #Define (ie should be used by external code)
    SCREAMING_CAPS
    Private #Define (ie should only be internally used)
    _UNDERSCORE_SCREAMING_CAPS

When you are finished the assignment, you will have created the following files:

  • intlist.h
  • intlist.cpp
  • list.h

Part 1: Integer Linked List

For this part, you will build the classes IntList and IntListNode in the files intlist.h and intlist.cpp. These two classes compose a basic implementation of an integer linked list. Please see the following sections on the exact specifications of these classes.

Class: IntListNode, Files: [intlist.h, intlist.cpp], Test: 0

An IntListNode is a linked list node, as such it holds an integer value and a pointer to an IntListNode that is the next node in the list. If the next link is NULL then the current node is considered the last node in the list. While this class is only used by IntList, it is expected to have a set of its own functionality. The exact specs follow:

Protected Functions

void next(IntListNode*)
Setter function for the next property. Sets the internal next pointer held by this node to the incoming value.

Public Functions