Abstract
This report contains all the documents relating to the second software project for ECE3311 course taken at Northeastern university, fall 1993 by Dr David R. Kaeli.
sort Linked_list
import List_Element
This specifications defines a sort called Linked_List, the operations are to find and entry on the list and to append an entry at the end of the list.
Create \(\rightarrow \)Linked_List
Find( Linked_List,Key)\(\rightarrow \)List_Element
Append(Linked_List,List_Element,Key)\(\rightarrow \)Linked_List
Find(Create(),Key)=Undefined — Linked_list is empty
Append(Create(),List_element,Key)=Success — List_element added to Linked_list
sort Date
import integer
This specifications defines a class Date that is used to manipulate Date, it supports operations
to create Date and set the Date to different dates and to print the date to a file, this sort makes
the date easier to work with
Create\(\rightarrow \)Date
Set(Date,mm/dd/yy)\(\rightarrow \)Date
Get_Day(Date)\(\rightarrow \)integer — this integer is the day part of Date
Get_Month(Date)\(\rightarrow \)integer — this integer is the month part of Date
Get_Year(Date)\(\rightarrow \)integer — this integer is the year part of Date
Set(Create(),mm/dd/yy)=Success — Date now holds mm/dd/yy internally
Get_Day(Create())=undefined — must set the date first to valid value
Get_Day(Set(Create,mm/dd/yy))=dd
Get_Month(Create())=undefined — must set the date first to valid value
Get_Month(Set(Create,mm/dd/yy))=mm
Get_Year(Create())=undefined — must set the date first to valid value
Get_Year(Set(Create,mm/dd/yy))=yy
sort Name
import string,integer
This specification defines a sort called Name, Name is used to hold string names in it with the name length to make it easier to manipulate names
Create\(\rightarrow \)Name
Set(Name,string)\(\rightarrow \)Name
Get(Name)\(\rightarrow \)string
Get_Length(Name)\(\rightarrow \)integer — the length of name
Set(Create,string)=Name
Get(Create)=undefined — Name must be set first
Get(Set(Name,string))=string
Get_Length(Create)=undefined — Name must be set first
Get_Length(Set(Name,string))=integer — the length of string name
import Boolean,string
This specification defines a sort called Io_Device, Io_Device is used to hold the files used by the system, and to allow operations of open the input and output files, and to read the next line from the file
Create\(\rightarrow \)Io_Device
Open(Io_Device)\(\rightarrow \)Boolean
Read(Io_Device)\(\rightarrow \)string
Open(Create())=Boolean
Read(Create())=Undefined — must open file first
Read(Open(Io_Device))=string — data read
Read(Open(Io_Device))=undefined — when end of file reached
sort Account
Import float,Boolean
This specification defines a sort called Account. Account holds information relating to the account itself, operations such as credit, debt,set_balance,get_balance, are used on this sort.
Create\(\rightarrow \)Account
Debt(Account,float)\(\rightarrow \)Account
Credit(Account,float)\(\rightarrow \)Account
Set_Balance(float,Account)\(\rightarrow \)Account
Get_Balance(Account)\(\rightarrow \)float
Debt(Create,float)=Account — the account balance has been debited
Set_Balance(Create)=Account — created account has its balance set
Credit(Create,float)=Account — Account updated with new credit
sort Saving_Account
import Account,float — this sort inherits sort Account
This specification defines a sort called Saving_Account. Saving_Account hold information relating to the saving account, operations such as interest calculations, setting the date last accessed are used on this sort
Create\(\rightarrow \)Saving_Account
Interest(Date,Saving_Account)\(\rightarrow \)float
Set_Date_Accessed(Date,Saving_Account)\(\rightarrow \)Saving_Account
Interest(Date,Saving_Account)=undefined
Interest(Date,Create_Account)=0 — no interest on new created account
Set_Date_Accessed(Date,Create)=Saving_Account
sort Checking_Account
import Account — this sort inherits sort Account
This specification defines a sort called Checking_Account. Checking_Account hold information relating to the Checking account, operations such as incrementing number of withdraws,setting flag to indicate that the less than 500 penalty has been debited from the account are used on this sort
Create\(\rightarrow \)Checking_Account
Increment(Checking_Account)\(\rightarrow \)Checking_Account
Penalty_Set(Checking_Account)\(\rightarrow \)Checking_Account
Increment(Create)=Checking_Account
Penalty_Set(Create)=Checking_Account
sort Account_Manager
import Saving_Account,Checking_Account,Io_Device
This specification defines a sort called Account_Manger, Account_Manager does operations such as open,deposit,balance,withdraw,and transfer on both the saving and checking account.
Create\(\rightarrow \)Account_Manager
Checking_Open\(\rightarrow \)Checking_Account.Create()
Saving_Open\(\rightarrow \)Saving_Account.Create()
Checking_Balance\(\rightarrow \)Checking_Balance.Get_Balance()\(\rightarrow \)float
Saving_Balance\(\rightarrow \)Saving_Balance.Get_Balance()\(\rightarrow \)float
Checking_Deposit\(\rightarrow \)Checking_Account.credit()\(\rightarrow \)Checking_Account
Saving_Deposit\(\rightarrow \)Saving_Account.credit()\(\rightarrow \)Saving_Account
Checking_Deposit\(\rightarrow \)Checking_Account.debt()\(\rightarrow \)Checking_Account
Saving_Deposit\(\rightarrow \)Saving_Account.debt()\(\rightarrow \)Saving_Account
Checking_Transfer\(\rightarrow \)Saving_Account.credit(Checking_Account.debt())\(\rightarrow \)Checking_Account
Deposit_Transfer\(\rightarrow \)Checking_Account.credit(Saving_Account.debt())\(\rightarrow \)Saving_Account
Checking_Balance\(\rightarrow \)Io_Device.Write(Checking_Account.Get_Balance())
Saving_Balance\(\rightarrow \)Io_Device.Write(Saving_Account.Get_Balance())
sort Input_Tran
import transaction
This specification defines a sort Input_Tran, Input_Tran read and input transactions and validates the inputs
Create\(\rightarrow \)Input_Tran
Read(Input_Tran)\(\rightarrow \)Transaction
Valid(Transaction)\(\rightarrow \)Boolean
Read(Create)=Transaction — line is read from input file, this is the transaction to be processed
Valid(Create)= undefined – need to read transaction first
Please see the CRC cards included.
A total of 10 classes were used, one Abstract class (Account class), and 2 abstract structures to describe layout of input record and layout of head of linked list. I did not include these 2 structures in the CRC classes since they do not include member functions, but are structures to describe layout.
The maximum inheritance depth is 2, this is where Saving_Account and Checking_Accounts inherit the Account class.
The subsystems can be determined as: IO subsystem, Account Manager, Parsing and Validation of input subsystem and the Account subsystem, so a total of 4 subsystem can be recognized. The 10 classes is divided among these 4 general subsystems.
To find number of contracts per class, I looked at the CRC cards and grouped similar responsibilities within each class into one group, I called this one contract, I indicated this on the CRC card on this side by ”{” to group similar responsibilities, by doing this I see that there are about 25 different contracts over 10 classes, given an average of 2.5 contract per class, some classes have one contract while others have up to 4. A low number of contracts such as 2-3 per class is better than having a large number of contracts per class as that would complicate the issue of maintenance.
OO design leads well to bottom up testing, since individual objects can be tested separately and then integrated within the overall system.
I started by testing the lower level classes in separate files, classes such the Date, Time, Linked_List, Io_Device were tested by writing a simple test driver that calls them to make sure they work well, Then I wrote the other major classes such as Account_Manager, Parser, Saving_Account, Checking_Account, I then integrated these classes into one file along with the other lower level classes mebioned above. I also tested each functionality as I added it, for example, After the Open account functionality was coded, I tested this alone by write in the trans.act a transaction that exercise the Open code, when I added Balance, I also tested that before adding more code , this way if an error is found, I know that this errors must be relating to the latest code I added, making my task of finding the problem easier.
I utilized regression testing. I have saved from the first project all the trans.act files I used with the output of each test, I then used the new C++ program and run this against each of those trans.act, then I compared the output from each run with the output of the C program. I used the ”diff” command on the system to tell me if there are any differences in the output. I ran all the 33 test cases I have saved, and found that each test case passed by giving the same output as the C program. I also know that that the C program produces correct output .
To summarize, I used bottom up development and tested each of the classes that can be tested alone separately, I then used incremental tested, and then at the end I used regression testing to verify the final product.