CS 305 -- Software Engineering

Architectural Design Document

Version: 1.7, Apr. 29, 1998

Maintained by: Tom Walcott

Other team members: Johan Raffin, Jennifer Wasserstrass

Changes from previous versions: Touchup of objects to ensure compliance to module design.

Non-standard Terminology: All nonstandard terminology is associated with methods. For an exhaustive enumeration of all methods, the reader is encouraged to finish the document.

Document purpose: This document defines the means by which the data structures for C++ Pointers shall be divided, as well as the objects with which these structures shall be associated. Methods will be detailed within this document, as well.

Object Index:

1: Node Object
2: Link Object
3: Line Object
4: Master Node Object
5: Master Link Object
6: Master Line Object
7: Command Object
8: Parser Object
9: Error Object
10: Loop Object
11: Command Line Object
12: Lesson Object
13: CPMenu Object
14: Undo Object

1. Node Objects

Associated Data:

Location locX, locY (int)
Next Node (Node)
Prev Node (Node)
Data (String[3])
static char node Type
static int height, breadth
bool isReachable

Object Overview:
A node object contains all information relevant to a single node, and the methods required to access that node.
Method Overview:

Node GetNext()
void SetNext(Node)
Node GetPrev()
void SetPrev(Node)
String GetData()
void SetData(String)
int[] GetLoc()
static void SetNodeType(char)
static void SetDimensions(int, int)
bool IsReachable()
void SetReachable(bool)
void DrawMe()

Method: Node GetNext()
Description: Returns the next or right node associated with a given node.

Method: void SetNext(Node)
Description: Sets the next or right node associated with a given node.

Method: Node GetPrev()
Description: Returns the previous or left node associated with a given node.

Method: void SetPrev(Node)
Description: Sets the previous or left node associated with a given node.

Method: String GetData()
Description: Returns the data field of a node.

Method: void SetData(String)
Description: Sets the data field of a node.

Method: int[] GetLoc()
Description: Returns the x,y location of a node on the screen.

Method: static void SetNodeType(char)
Description: The node can thus know whether it is single linked, doubly linked, or a tree node.

Method: static void SetDimensions(int, int)
Description: Determines the height and breadth of a node, so that the dimensions can be changed if necessary.

Method: bool IsReachable()
Description: Return the boolean value that states whether that particular node object is reachable.

Method: void SetReachable(bool)
Description: Sets whether or not a node is reachable. Used to find memory leaks.

Method: void DrawMe()
Description: Tells the node to draw itself on the screen.

2. Link Objects

Associated Data:
int linkType
Line[] linkComponent
int numLines
Object Overview:

The link object stores information about one link. A link is a collection of line segments starting at some node and ending at some node. Each line segment is stored in the LinkComponents array. These segments shall be stored in sorted order, where the first segment will be the one departing the source node, and the last shall be the one pointing to the destination node.

Method Overview:
void AddLine(Line)
Line GetLastLine()
void DeleteLink()
void DrawMe()
void UnDraw()
Method: void AddLine(Line)
Description: This method adds a specified Line pointer to the LinkComponents array.

Method: Line GetLastLine(void)
Description: This method returns the linkComponent[numLines] line.

Method: void DeleteLink()
Description: This method invokes the delete method on each element of linkComponent.

Method: void DrawMe()
Description: This moves through each element of LinkComponents, invoking the DrawMe() method on each. The final segment in the list has an arrow appended to it.

Method: void UnDraw()
Description: This method moves through each element of LinkComponents, invoking the UnDraw() method on each.

3. Line Objects

Associated Data:

int start
int end
int lineCount
boolean setAxis
int fixedAxis
int lineType
int numLeft

Object Overview:

The line object holds a specific line segment. The data is the start and end of the line segment, and then count, which is a count of how many times that line segment occurs. The Axis boolean indicates whether the line is fixed on the X or Y axis, and the FixedAxis contains what that constant value is. The lack of facility for setting data reflects that it is easier to simply create a new line object with correct data than to recycle old ones. Since line objects will only be altered in groups, when associated links are changed, it is quite possible that the number of lines will change as well.

Method Overview:
int GetStart()
int GetEnd()
boolean GetAxis()
int GetFixedAxis()
void SetLineCount(bool, bool)
int GetLineCount()
void CheckMerge(int lineType)
void Paint()
Method: int GetStart()
Description: Returns the Start of the line.

Method: int GetEnd()
Description: Returns the End of the line.

Method: boolean GetAxis()
Description: Returns which axis is constant.

Method: int GetFixedAxis()
Description: Returns the value of the constant axis.

Method: void SetLineCount(int)
Description: Changes the number of times a line occurs on the screen, for purposes of detecting merges.

Method: int GetLineCount()
Description: Returns the number of times a line occurs on the screen.

Method: void CheckMerge(int lineType)
Description: Determines if this line segment is now a part of two different linktypes, in which case the color must be updated.

Method: void DrawMe()
Description: Draws a line segment.

Method: void UnDraw()
Description: Undraws a line segment.

4. Master Node Object

Associated Data:

char NodeType
Node p,q,r,s
Node NodeArray[][]
static Node uninitializedNode
Object Overview:
The master node object keeps track of where every node is on the screen, as well as the associations between nodes. This object is also responsible for detecting memory leakage, adjusting the data of a given node, and deleting nodes. The master node object invokes changes on the master link object. It is also the responsibility of the master node object to be keep the uninitialized node, which is what pointers intended to seem uninitialized to the user should point to.
Method Overview:

Node NewNode(Node From)
void DrawNodes()
void LeakCheck()
void DeleteNode(int x, int y)
void SetNodeType(char NodeType)
char GetNodeType(void)
Method: Node NewNode(Node From)
Description: This creates a new node at the nearest appropriate space on the screen.

Method: void DrawNodes()
Description: Invokes DrawMe() on each non-null member of NodeArray.

Method: void LeakCheck()
Description: Determines if there is a memory leak, and tosses an error if there should happen to be one.

Method: void DeleteNode(int x, int y)
Description: Delete the node at location x,y in the two dimensional array NodeArray.

Method: void SetNodeType(char NodeType)
Description: Set NodeType to this.NodeType.

Method: char GetNodeType(void)
Description: Return NodeType.

5. Master Link Object

Associated Data:

Link nextLink[][]
Link prevLink[][]

Object Overview:

The master link object maintains a two dimensional array of links, indexed by the source node of the link. It also invokes the master line object, when necessary.

Method Overview:

void AddLink(Node from, char linkType)
Link LinkFrom(Node, char linkType)
void DeleteLink(Link)
Method: void AddLink(Node from, char linkType)
Description: If setNext and setPrev are already invoked from the master node object, we have the pointer to the appropriate node set, and from that information can deduce where the link should go. This information can be used to construct an appropriate link.

Method: Link LinkFrom(Node, char linkType)
Description: We need the ability to get a link object. To delete a node, it is possible to examine the master node object and determine that a given node has a pointer to another node. We must have some means to reference the correct link object, and the LinkFrom method is a means to do so.

Method: void DeleteLink(Link)
Description: Dereference the pointer to a link, after invoking ClearLine() for each line that is a member of that link.

6. Master Line Object

Associated Data:

Line XLine[]
Line YLine[]
boolean testedIntersection[][]

Object Overview:

The master line object contains two distinct lists of lines; one list for vertical lines, and one for horizontal. This makes the checking involved in MakeLink a great deal easier.

Method Overview:

Link AddLink(FromX, FromY, ToX, ToY)
void ClearLine(Line)
void PaintAll()
Method: Link AddLink(FromX, FromY, ToX, ToY)
Description: This method creates a link object with line segments that point from a node to a node. It handles all collision checking, and will generate an error message if no more lines can be drawn. It is important that this process, when permitted merges, increment the LineCount on the Line object associated with the merged line.

Method: void ClearLine(Line)
Description: This method decrements the LineCount on the specified line object, and removes the line object should the LineCount hit zero.

Method: void PaintAll()
Description: This method moves through the XLine and YLine arrays, invoking the Paint() function on each line object therein.

7. Command Object

Associated Data:

int NodeType
boolean UndoOkay
Object Overview:
The command object updates the undo object, then communicates to the Master Node Object the substance of the command.
Method Overview:
void NewNode(Node From)
void NewNext(Node src, Node dest)
void NewPrev(Node src, Node dest)
void NewData(Node, String data)
void Restart(int NodeType)
void FlipOkay()
Method: void NewNode(Node From)
Description: This method tells the master node object to create a new node, and then performs a NewPrev or NewNext (depending upon the syntax passed by the parser) on Node From and NewNode.

Method: void NewNext(Node src, Node dest)
Description: This method creates a next or right link from src to dest.

Method: void NewPrev(Node src, Node dest)
Description: This method creates a prev or left link from src to dest.

Method: void NewData(Node, String data)
Description: This method puts data into the data field of a node.

Method: void Restart()
Description: This method resets the master node, master link, and master line objects, giving the master node object an appropriate node type.

Method: void FlipOkay()
Description: Reverse the state of the UndoOkay; when UndoOkay is TRUE, the undo object will be updated before each command is executed. When UndoOkay is false, the undo object will not be updated.

8. Parser Object

Associated Data:

void
Object Overview:
The parser is the object that handles all the syntax checking. It is the responsibility of the parser to take the C++ input generated by the user and translate it into function calls to the command object. For example, p->next->next=q->next->prev should be translated to Command.NewNext(Next(p),Prev(Next(q))).
Method Overview:
void Parse(String)
void ParseFor(String)
void ParseWhile(String)
Method: void Parse(String)
Description: This method evaluates an entry from the command line object. Errors in syntax invoke the appropriate method on the Error Object, whereas correct commands are translated and passed on to the Command Object.

Method: void ParseFor(String)
Description: This method handles for loops in a manner nearly identical to Parse(), the exception being that parsing must include a pause after each step if the user wishes to step through a loop, or simply toss each line into the command object if the user wishes to complete quickly. It may also FlipOkay() the command object, depending on undo behavior in loops.

Method: void ParseWhile(String)
Description: See above, excepting only that ParseWhile manages while loops.

9. Error Object

Associated Data:

string ErrorType; the type of error
boolean isError
Label theMessage; the error message

Object Overview:
The Error Object draws the window that corresponds with the current error type.

Method Overview:
void DrawError(string ErrorType)
boolean IsError

Method: void DrawError(string ErrorType)
Description: This method draws the window that corresponds with ErrorType.
Method: boolean IsError()
Description: Returns true if there is an error, false otherwise.

10. Loop Object

Associated Data:

string lines[]
StringBuffer loopText
boolean loopType
boolean stepThrough
int focus

Object Overview:
The loop object handles user input for loop routines and draws a window that goes with the current loop type. To execute the commands entered into the loop windows the Loop Object invokes the Parser Object.

Method Overview:
void SetLoopType()
boolean SetFocus(int focus)
void DisplayCommand(String command)
int GetFocus()
void DrawMe()
void Run()
void Step()
string GetText()

Method: void SetLoopType(boolean Type)
Description: Sets the loop type to for or while.
Method: boolean SetFocus()
Description: Sets focus to current line.
Method: int GetFocus()
Description: Returns the current line.
Method: DisplayCommand(String command)
Description: Calls CommandLine.DisplayCommand().
Method: void DrawMe(boolean LoopType)
Description: Draws a window with the correct loop text displayed.
Method: void Run()
Description: Calls the Parser with the loop text.
Method: void Step()
Description: Steps through the loop.
Method: GetText()
Description: Returns the text of the loop.

11. Command Line Object

Associated Data:


StringBuffer executed
StringBuffer inProgress
String CommandText

Object Overview:
This object stores the list of commands from the current session, adding to it when a new command is entered. It also handles the input from the command line by calling the Parser object.

Method Overview:
void RunCommand(string command)
void AddText(string command)
void DisplayText(string command)
StringBuffer GetTextExecuted()
void SetTextExecuted(string command)
void SetTextInProgress(string command)
StringBuffer GetTextInProgress()
void DrawTextWindow()
void EnableLine()
void DisableLine()
void ClearLog()

Method: void RunCommand(string command)
Description: Calls the parse method from the Parser Object.
Method: void AddText(string command)
Description: Adds the new command to the SessionText.
Method: DisplayText(string command)
Description: Displays the command in the "Command to be executed" field.
Method: StringBuffer GetTextExecuted()
Description: Get the commands stored in Executed.
Method: void SetTextExecuted(string command)
Description: Put the command in Executed.
Method: StringBuffer GetTextInProgress()
Description: Get the commands in InProgress.
Method: void SetTextInProgress(string command)
Description: Put the command in InProgress.
Method: void DrawTextWindow()
Description: Draws a window to display the commands thus far typed.
Method: void EnableLine()
Description: Enable input on the command line.
Method: void DisableLine()
Description: Disable input on the command line.

12. Lesson Object

Associated Data:

String LessonText
String startCode
MasterNodeObject endState

Object Overview:
The Lesson Object contains the text of the lesson and its end state. The start state of the lesson will be loaded from disk when the lesson is opened or when a restart is desired. This object also checks if the current state of the Master Objects is the same as the endstate of the lesson and handles saving lessons.

Method Overview:
void ShowInstructions()
boolean CheckDone()
void LoadLesson(URL lessonURL)
void SaveLesson(string emailAddress)
void LessonIntstructions(string instructionsLocation)
void LoadStartState()

Method: void ShowText()
Description: Draws a window that displays the lesson text.
Method: boolean CheckDone()
Description: Compares the current Master Node Object with the EndState.
Method: void LoadLesson(URL lessonURL)
Description: Loads the lesson start state from disk: Master Node, Link, and Line Objects.
Method: void SaveLesson(string emailAddress)
Description: Saves the current master objects to disk.
Method: void LessonInstructions(string intructionsLocation)
Description: Loads the lesson text into private variables.
Method: void LoadStartState()
Description: Loads the start state of the lesson.

13. CPMenu Object

Associated Data:

boolean Enabled[]

Object Overview:
The CPMenu Object contains an array of boolean values for each menu item that is used to determine which items are enabled. The method CheckState checks to see if a menu item is enabled, and the method SwapState enables a disabled menu item and disables an enabled menu item. The other methods in the CPMenu object draw windows for each of the menu items that require windows and invoke the related object for each item.

Method Overview:

boolean IsEnabled(int item)
void FlipEnabled(int item)
void InvokeForLoop()
void InvokeWhileLoop()
void LoadLesson()
void RestartLesson()
void SaveLesson()
void Undo()
UserManualScreen()
AboutScreen()
HelpKeyScreen()
void CheckDone()
Method: boolean IsEnabled(int item)
Description: Checks the state of an item in the Enabled array to see if it is enabled or disabled.
Method: void FlipEnabled(int item)
Description: Toggles the value in the array to enable or disable the item.
Method: void InvokeForLoop()
Description: Invokes the draw method for the For loop.
Method: void InvokeWhileLoop()
Description: Invokes the draw method for the While loop.
Method: void LoadLesson()
Description: Figure out what lesson to load, by popping up a file I/O window.
Method: void RestartLesson()
Description: Calls Lesson.LoadLesson() will a null URL.
Method: void SaveLesson()
Description: Save a lesson as... window, then passes the appropriate file to Lesson.SaveLesson().
Method: void Undo()
Description: Invoke Undo from the undo object.
Method: UserManualScreen()
Description: Display the user manual.
Method: AboutScreen()
Description: Display the About screen.
Method: HelpKeyScreen()
Description: Display the Keys.
Method: void CheckDone()
Description: Find out if the lesson has been successfully completed.

14. Undo Object

Associated Data:

MasterNode OldMNO
MasterLink OldMLkO
MasterLine OldMLnO

Object Overview:
The undo object contains a copies of the master node, master link, and master line objects that are one stage behind the current objects. These copies are updated when called from the Command Object. When the user wants to undo the last command, the Menu object calls the Undo object which destroys the current Master objects and replaces them with the copies. This method works by using Java's garbage collection scheme; when an object is dereferenced, it is removed. As long as it remains referenced by an old object, it will stick around. The undo object's job is to keep old objects referenced until they are more than one step behind.
Method Overview:
void Undo()
void Update()

Method: void Undo()
Description: Replaces the master node, link, and line objects with the Old versions, then tells them to draw themselves. The replaced objects are thus unreferenced, and will be automatically cleaned up by Java.
Method: void Update()
Description: Copies the master node, link, and line objects, and updates the pointers in the undo object so that the next instruction can be executed.

Search engine sitemap created by AutoSitemap.com