document, test and refactor an existing application
Assignment1/.vs/Assignment1/v15/.suo
Assignment1/.vs/Assignment1/v15/Server/sqlite3/db.lock
Assignment1/.vs/Assignment1/v15/Server/sqlite3/storage.ide
Assignment1/.vs/Assignment1/v15/Server/sqlite3/storage.ide-shm
Assignment1/.vs/Assignment1/v15/Server/sqlite3/storage.ide-wal
Assignment1/.vs/Assignment1-1720/DesignTimeBuild/.dtbcache
Assignment1/.vs/Assignment1-1720/v15/.suo
Assignment1/.vs/Assignment1-1720/v15/Server/sqlite3/db.lock
Assignment1/.vs/Assignment1-1720/v15/Server/sqlite3/storage.ide
Assignment1/.vs/Assignment1-1720/v15/Server/sqlite3/storage.ide-shm
Assignment1/.vs/Assignment1-1720/v15/Server/sqlite3/storage.ide-wal
Assignment1/Assignment1.sln
Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27703.2042 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assignment1", "Assignment1\Assignment1.csproj", "{B24CA810-B8D8-499E-8D91-DA2DC672D033}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {B24CA810-B8D8-499E-8D91-DA2DC672D033}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B24CA810-B8D8-499E-8D91-DA2DC672D033}.Debug|Any CPU.Build.0 = Debug|Any CPU {B24CA810-B8D8-499E-8D91-DA2DC672D033}.Release|Any CPU.ActiveCfg = Release|Any CPU {B24CA810-B8D8-499E-8D91-DA2DC672D033}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {390CBD4A-CA37-4C8C-ADCF-FDDE8019E4CA} EndGlobalSection EndGlobal
Assignment1/Assignment1/.vs/Assignment1/v15/Server/sqlite3/db.lock
Assignment1/Assignment1/.vs/Assignment1/v15/Server/sqlite3/storage.ide
Assignment1/Assignment1/.vs/Assignment1/v15/Server/sqlite3/storage.ide-shm
Assignment1/Assignment1/.vs/Assignment1/v15/Server/sqlite3/storage.ide-wal
Assignment1/Assignment1/Adoption.cs
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Assignment1_1720 { class Adoption { public Client adoptingClient; public Boolean confirmed = true; public double adoptionFee; public Animal adoptedPet; public ArrayList adoptedPets; public Adoption(Client adoptingClient, Boolean confirmed) { this.adoptingClient = adoptingClient; this.confirmed = confirmed; } public Adoption(Client adoptingClient, double adoptionFee, Animal adoptedPet) { this.adoptingClient = adoptingClient; this.adoptionFee = adoptionFee; this.adoptedPet = adoptedPet; } public Adoption(Client adoptingClient, double adoptionFee, ArrayList adoptedPets) { this.adoptingClient = adoptingClient; this.adoptionFee = adoptionFee; this.adoptedPets = adoptedPets; } } }
Assignment1/Assignment1/Animal.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Assignment1_1720 { class Animal { public double adoptionFee; public String animalID; public Boolean adopted = false; public Animal(double adoptionFee, String animalID) { this.adoptionFee = adoptionFee; this.animalID = animalID; } } }
Assignment1/Assignment1/AniMate.cs
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Assignment1_1720 { class AniMate { Branch thisBranch; public AniMate() { SetupBranch(); } public void SetupBranch() { thisBranch = new Branch("AniMate Ballarat"); ArrayList dogs = new ArrayList(); for (int i = 0; i < 15; i++) { dogs.Add(new Animal(220.00, "D-PUP" + i)); } for (int i = 0; i < 20; i++) { dogs.Add(new Animal(180.00, "D-JUN" + i)); } for (int i = 0; i < 12; i++) { dogs.Add(new Animal(150.00, "D-ADU" + i)); } for (int i = 0; i < 8; i++) { dogs.Add(new Animal(40.50, "D-SEN" + i)); } ArrayList cats = new ArrayList(); for (int i = 0; i < 15; i++) { cats.Add(new Animal(250.00, "C-KIT" + i)); } for (int i = 0; i < 26; i++) { cats.Add(new Animal(210.50, "C-JUN" + i)); } for (int i = 0; i < 8; i++) { cats.Add(new Animal(175.90, "C-ADU" + i)); } for (int i = 0; i < 12; i++) { cats.Add(new Animal(50.75, "C-SEN" + i)); } ArrayList mice = new ArrayList(); for (int i = 0; i < 15; i++) { mice.Add(new Animal(7.90, "M-PUP" + i)); } for (int i = 0; i < 30; i++) { mice.Add(new Animal(5.00, "M-ADU" + i)); } ArrayList hamsters = new ArrayList(); for (int i = 0; i < 4; i++) { hamsters.Add(new Animal(10.50, "H-PUP" + i)); } for (int i = 0; i < 15; i++) { hamsters.Add(new Animal(7.50, "H-ADU" + i)); } ArrayList birds = new ArrayList(); for (int i = 0; i < 3; i++) { birds.Add(new Animal(60.00, "B-CHI" + i)); } for (int i = 0; i < 8; i++) { birds.Add(new Animal(45.50, "B-ADU" + i)); } ArrayList weasels = new ArrayList(); for (int i = 0; i < 3; i++) { weasels.Add(new Animal(110.00, "W-PUP" + i)); } for (int i = 0; i < 1; i++) { weasels.Add(new Animal(100.00, "W-ADU" + i)); } for (int i = 0; i < 4; i++) { weasels.Add(new Animal(50.75, "W-SEN" + i)); } thisBranch.addAdoptionList("dog", dogs); thisBranch.addAdoptionList("cat", cats); thisBranch.addAdoptionList("mouse", mice); thisBranch.addAdoptionList("hamster", hamsters); thisBranch.addAdoptionList("bird", birds); thisBranch.addAdoptionList("weasel", weasels); } public Adoption adoptAnimal(String animalType, Client theClient, int numberToAdopt) { ArrayList animalList; if (animalType.Equals("dog", StringComparison.OrdinalIgnoreCase)) animalList = thisBranch.getAdoptionList("dog"); else if (animalType.Equals("cat", StringComparison.OrdinalIgnoreCase)) animalList = thisBranch.getAdoptionList("cat"); else if (animalType.Equals("mouse", StringComparison.OrdinalIgnoreCase)) animalList = thisBranch.getAdoptionList("mouse"); else if (animalType.Equals("hamster", StringComparison.OrdinalIgnoreCase)) animalList = thisBranch.getAdoptionList("hamster"); else if (animalType.Equals("bird", StringComparison.OrdinalIgnoreCase)) animalList = thisBranch.getAdoptionList("bird"); else if (animalType.Equals("weasel", StringComparison.OrdinalIgnoreCase)) animalList = thisBranch.getAdoptionList("weasel"); else animalList = null; if (available(animalList, numberToAdopt)) { ArrayList adoptedAnimals = new ArrayList(); int currentAnimal = 0; double adoptionFee = 0; while (numberToAdopt > 0) { Animal thisAnimal = (Animal)animalList[currentAnimal]; if (!thisAnimal.adopted) { adoptedAnimals.Add(thisAnimal); adoptionFee += thisAnimal.adoptionFee; thisAnimal.adopted = true; numberToAdopt--; } currentAnimal++; } return new Adoption(theClient, adoptionFee, adoptedAnimals); } else { return new Adoption(theClient, false); } } public Boolean available(ArrayList animalList, int number) { int availableCount = 0; for (int i = 0; i < animalList.Count; i++) { if (!((Animal)animalList[i]).adopted) availableCount++; } return number <= availableCount; } } }
Assignment1/Assignment1/App.config
Assignment1/Assignment1/Assignment1.csproj
Debug AnyCPU {B24CA810-B8D8-499E-8D91-DA2DC672D033} Exe Assignment1_1720 Assignment1-1720 v4.5.2 512 true AnyCPU true full false bin\Debug\ DEBUG;TRACE prompt 4 AnyCPU pdbonly true bin\Release\ TRACE prompt 4
Assignment1/Assignment1/bin/Debug/Assignment1-1720.exe
Assignment1/Assignment1/bin/Debug/Assignment1-1720.exe.config
Assignment1/Assignment1/bin/Debug/Assignment1-1720.pdb
Assignment1/Assignment1/Branch.cs
using System; using System.Collections.Generic; using System.Collections; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Assignment1_1720 { class Branch { Dictionary<String, ArrayList> adoptionList = new Dictionary<String, ArrayList>(); String name; public Branch(String name) { this.name = name; } public void addAdoptionList(String animalType, ArrayList animals) { this.adoptionList.Add(animalType, animals); } public ArrayList getAdoptionList(String animalType) { return (ArrayList)adoptionList[animalType]; } } }
Assignment1/Assignment1/Client.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Assignment1_1720 { class Client { String lastname, firstname; String clientID; String address; String contactPhone; String emailAddress; public Client(String firstname, String lastname, String clientID, String address, String contactPhone, String emailAddress) { this.firstname = firstname; this.lastname = lastname; this.clientID = clientID; this.address = address; this.contactPhone = contactPhone; this.emailAddress = emailAddress; } } }
Assignment1/Assignment1/obj/Debug/Assignment1.csproj.CoreCompileInputs.cache
ed4adc8f68117860c407585e939f5ee4f05cd46c
Assignment1/Assignment1/obj/Debug/Assignment1.csprojAssemblyReference.cache
Assignment1/Assignment1/obj/Debug/Assignment1-1720.csproj.CoreCompileInputs.cache
ed4adc8f68117860c407585e939f5ee4f05cd46c
Assignment1/Assignment1/obj/Debug/Assignment1-1720.csproj.FileListAbsolute.txt
C:\Users\ameade\Desktop\Work\Courses\ITECH3201\1717-20\Assignment 1\Assignment1-1720\Assignment1-1720\obj\Debug\Assignment1-1720.csprojResolveAssemblyReference.cache C:\Users\ameade\Desktop\Work\Courses\ITECH3201\1717-20\Assignment 1\Assignment1-1720\Assignment1-1720\bin\Debug\Assignment1-1720.exe.config C:\Users\ameade\Desktop\Work\Courses\ITECH3201\1717-20\Assignment 1\Assignment1-1720\Assignment1-1720\bin\Debug\Assignment1-1720.exe C:\Users\ameade\Desktop\Work\Courses\ITECH3201\1717-20\Assignment 1\Assignment1-1720\Assignment1-1720\bin\Debug\Assignment1-1720.pdb C:\Users\ameade\Desktop\Work\Courses\ITECH3201\1717-20\Assignment 1\Assignment1-1720\Assignment1-1720\obj\Debug\Assignment1-1720.exe C:\Users\ameade\Desktop\Work\Courses\ITECH3201\1717-20\Assignment 1\Assignment1-1720\Assignment1-1720\obj\Debug\Assignment1-1720.pdb C:\Users\visha\Downloads\Assignment1-1720\Assignment1-1720\bin\Debug\Assignment1-1720.exe.config C:\Users\visha\Downloads\Assignment1-1720\Assignment1-1720\bin\Debug\Assignment1-1720.exe C:\Users\visha\Downloads\Assignment1-1720\Assignment1-1720\bin\Debug\Assignment1-1720.pdb C:\Users\visha\Downloads\Assignment1-1720\Assignment1-1720\obj\Debug\Assignment1-1720.csprojAssemblyReference.cache C:\Users\visha\Downloads\Assignment1-1720\Assignment1-1720\obj\Debug\Assignment1-1720.csproj.CoreCompileInputs.cache C:\Users\visha\Downloads\Assignment1-1720\Assignment1-1720\obj\Debug\Assignment1-1720.exe C:\Users\visha\Downloads\Assignment1-1720\Assignment1-1720\obj\Debug\Assignment1-1720.pdb
Assignment1/Assignment1/obj/Debug/Assignment1-1720.csprojAssemblyReference.cache
Assignment1/Assignment1/obj/Debug/Assignment1-1720.csprojResolveAssemblyReference.cache
Assignment1/Assignment1/obj/Debug/Assignment1-1720.exe
Assignment1/Assignment1/obj/Debug/Assignment1-1720.pdb
Assignment1/Assignment1/obj/Debug/CoreCompileInputs.cache
97469e789a4ebbcc9bdc8725907d9c4c4ca76750
Assignment1/Assignment1/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Assignment1/Assignment1/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
Assignment1/Assignment1/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
Assignment1/Assignment1/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
Assignment1/Assignment1/Program.cs
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Assignment1_1720 { class Program { static void Main(string[] args) { AniMate homeFinder = new AniMate(); Client client1 = new Client("Scarlett", "Fields", "C192837", "23 Hiplon Street", "0400111222", "[email protected]"); Adoption adoption1 = homeFinder.adoptAnimal("dog", client1, 2); Console.Write("Congratulations! For the adoption fee of ${0}", adoption1.adoptionFee); Console.WriteLine(", Client 1 has been allocated: "); ArrayList animalList = adoption1.adoptedPets; for (int i = 0; i < animalList.Count; i++) Console.Write("{0}\t", ((Animal)animalList[i]).animalID); Console.WriteLine(); Console.WriteLine(); Client client2 = new Client("Daniel", "Junyard", "309R25Z", "1 Lipold Road", "0400987345", "[email protected]"); Adoption adoption2 = homeFinder.adoptAnimal("mouse", client2, 1); Console.Write("Congratulations! For the adoption fee of ${0}", adoption2.adoptionFee); Console.WriteLine(", Client 2 has been allocated: "); animalList = adoption2.adoptedPets; for (int i = 0; i < animalList.Count; i++) Console.Write("{0}\t", ((Animal)animalList[i]).animalID); Console.WriteLine(); Console.WriteLine(); Client client3 = new Client("Wilma", "Ridley", "BI30192C", "1/16 Caliper Close", "0401825476", "[email protected]"); Adoption adoption3 = homeFinder.adoptAnimal("cat", client3, 6); Console.Write("Congratulations! For the adoption fee of ${0}", adoption3.adoptionFee); Console.WriteLine(", Client 3 has been allocated: "); animalList = adoption3.adoptedPets; for (int i = 0; i < animalList.Count; i++) Console.Write("{0}\t", ((Animal)animalList[i]).animalID); Console.WriteLine(); Console.WriteLine(); Client client4 = new Client("Bobby", "Reynes", "G3029A2V", "8 Main Road", "0421965328", "[email protected]"); Adoption adoption4 = homeFinder.adoptAnimal("dog", client3, 1); Console.Write("Congratulations! For the adoption fee of ${0}", adoption4.adoptionFee); Console.WriteLine(", Client 4 has been allocated: "); animalList = adoption4.adoptedPets; for (int i = 0; i < animalList.Count; i++) Console.Write("{0}\t", ((Animal)animalList[i]).animalID); Console.WriteLine(); Console.WriteLine(); Console.ReadLine(); } } }
Assignment1/Assignment1/Properties/AssemblyInfo.cs
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Assignment1-1720")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Assignment1-1720")] [assembly: AssemblyCopyright("Copyright © 2017")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("b24ca810-b8d8-499e-8d91-da2dc672d033")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
Assignment1/ITECH3201 Assignment 1 specification.docx
ITECH3201 Software Engineering: Analysis and Design
Assignment 1
Overview
This is an individual assignment that requires you to document, test and refactor an existing application.
Timelines and Expectations
Percentage Value of Task: 20%
Due: Week 7
Minimum Time expectation: 10 hours
Learning Outcomes Assessed
The following course learning outcomes are assessed by completing this assessment:
· S1. Apply software design principles to design and document software that utilises design patterns
· S2. Analyse source code and develop comprehensive unit test suites
· S3. Operate CASE software to document the design of a piece of software
· S4. Apply refactoring to identify poor programming practice in existing source code and improve its structure and readability
· S5. Apply an appropriate software development methodology to the development of a software system
Assessment Details
You are required to document, test and refactor an existing application.
You will be given a copy of an existing C# application which is responsible for allocating animals to new owners for an animal rescue organisation. This application is badly in need of refactoring and even a casual viewing of the source code reveals many examples of the “code smells” talked about in Fowler’s book.
The base application consists of five classes: AniMate, Branch, Animal, Adoption and Client.
Clients are able to adopt animals based on availability and choice of animal type.
Assignment Requirements
Step 1 – Rename the base code
1. Download the code from Moodle and unzip it in the filesystem
2. Rename the base folder to “Assignment 1 – yourid” (your id equals your student number)
3. Open the solution up in Visual Studio right click on the Solution and rename it as per (2)
4. Build the solution and inspect the output. Spend some time becoming familiar with the code before you do anything else.
Step 2 – Identify “code smells”
Open up a new document in Word (or equivalent), start documenting any code smells you identify in the code in point form. You might want to cut and paste the code into Word to illustrate the problems.
Step 3 – Create a class diagram of the initial code.
Do this in Enterprise Architect and copy the resultant diagram into your Word file. Ensure your EA file is saved and labelled as “starting code base”.
Step 4 – Refactor and unit test code
Ensure that your starting code and EA file is backed up. Once this is done, commence refactoring the code in Visual Studio. Document each change you make and provide an explanation of why you have done so.
Your final code should be fully refactored and have unit tests developed for every method (other than any ToString and Get and Set methods). These unit tests should be documented to demonstrate the results before and after the changes to confirm that the functionality of the code has not changed.
Step 5 – Create diagrams of the final code.
Do this in Enterprise Architect and copy the resultant diagram into your Word file. Create a class diagram of the final code, and a sequence diagram showing how a new adoption request is processed in the final code. Ensure your EA file is saved and labelled as “final code base”.
A word of caution: there is some software available that enables automatic generation of sequence diagrams. These tend to produce over-complicated sequence diagrams with considerably more detail than is useful to us. Only the key messages specifically relevant to processing a new adoption are to be included in the sequence diagram. You will not receive full credit for sequence diagrams if you provide excessively complex diagrams.
Submission
Your program code and all documentation should be zipped into a single file and loaded into the Assignment Box provided in Moodle by the due date and time. This includes:
· All code representing your refactored application and unit tests
· The accompanying Enterprise Architect file with model versions that correspond to your final code submission
· An electronic report, in Microsoft Word, containing your UML, identification of any problems with the initial code, and an explanation of your Refactorings.
IMPORTANT NOTE: Make sure that you submit the source code (.cs files) NOT the compiled program. Your work will NOT be marked if the .cs files are not provided.
CRICOS Provider No. 00103D
1
of
5
CRICOS Provider No. 00103D
ITECH3201 Assignment 1
2
of
5
CRICOS Provider No. 00103D
ITECH3201 Assignment 1
Pa
ge
3
of
5
Marking Criteria/Rubric
|
Student ID |
|
|
|
|
Student Name |
|
|
|
|
Task |
Available Marks |
Student Mark |
|
|
Documentation of Initial Code |
|
|
|
|
• Report documenting “code smells” present in the initial code base |
2 |
|
|
|
• Class diagram of the initial code provided in both Enterprise Architect AND the documented report. |
2 |
|
|
|
Refactoring |
4 |
|
|
|
• Completed refactored code base, eliminating the bad smells present in the initial code base |
|
|
|
|
• Report identifying and documenting changes made to the code and justification of each change |
2 |
|
|
|
Unit Testing |
|
|
|
|
• A comprehensive set of unit test cases that covers all the required functionality in the provided code base |
3 |
|
|
|
• Report documenting completed unit tests demonstrating that the refactored code has maintained previous functionality |
3 |
|
|
|
Documentation of Final Code |
|
|
|
|
• Class Diagram of final code in Enterprise Architect AND the report |
2 |
|
|
|
• Sequence Diagram in Enterprise Architect AND the report showing the processing of a new adoption request. Note that full credit will not be given for overly complex diagrams – only key, relevant messages are to be included. |
2 |
|
|
|
Total |
20
|
|
Feedback
Assignments will be marked within 2 weeks of submission. Marks will be loaded in fdlGrades, and a completed marking sheet will be available via Moodle.
Plagiarism:
Plagiarism is the presentation of the expressed thought or work of another person as though it is one's own without properly acknowledging that person. You must not allow other students to copy your work and must take care to safeguard against this happening. More information about the plagiarism policy and procedure for the university can be found at http://federation.edu.au/students/learning-and study/online-help-with/plagiarism.
CRICOS Provider No. 00103D
ITECH3201 Assignment 1
Pa
ge
3
of
5
CRICOS Provider No. 00103D
ITECH3201 Assignment 1
Pa
ge
3
of
5
CRICOS Provider No. 00103D
ITECH3201 Assignment 1
Pa
ge
3
of
5