Skip to content

Latest commit

 

History

History
467 lines (394 loc) · 23.6 KB

week9.md

File metadata and controls

467 lines (394 loc) · 23.6 KB

Issue

I took on the issue that dealt with storing information on equipment. Looking at the ERD, there are three tables that relate to this.

  1. Equipmennt. This table stores information on each piece of equipment.
  2. Equipment_Type. This table stores a list of equipment categories
  3. Equipment_Allocation. This table stores information on where and when equipment is allocated

Maintaining agreed architecture

My code base followed the following code architecture. This was decided by the group after undertaking the ToDoList example.

  1. Database class for CRUD operations was added to the Data folder
  2. The table structures were added to the models folder
  3. The views and their underlying code were added to the Views folder.

The table structures were added to the models architucture. The example below (fig 1) is for the Equipment Allocation table. The knowledge gained from last week was applied in the method of adding a foreign key. Furthermore, I learnt that SQLite does not use the DATE data structure, ratht that the dates are stored in strings.

fig 1 (Equipment Table model)

A seperate database class was created to store the CRUD functions for the Equipment related tables. In figure 2, the InitiateDataBase method creates a new local database if it does not already exists

fig 2 (Initiate Database and tables)

The code below shows 2 CRUD methods in the database class. They have comments placed on top to add Doxygen documents, have single responsbility and short. Improvments would include changing the name strings in line 80 to something more meaningfull, such as names_returned. The SQL statement for the GetEquipment method is vulnerable to SQL injection attacks as the serach query is embedded in the statement. Given the scope of this project, it was decided not to add protection this week. However, this is something I will learn and implement in future projects.

There are three seperate views for the graphical interface which was added to the view model. A equipment UI was created with three buttons: add equipment type, add equipment and allocate equipment.

Error capturing was added to the Add Equipment Page. Fig 3 shows an error message when data fields are null prior to saving. Fig 4 shows the code that validates user input by checking if the editor boxes is null. If so, it returns false.

Fig 4 shows how the error capture is handled if the validation is false, by the use of a condition. If it is false, a error message will apear as in fig 3, otherwise it will save the record

fig 3(Error capturing)

fig 4(Validate user input method)

fig 5(Error capture handling in AddEquipment method)

Code Review

I undertook the code view (fig 6). Whilst most of the code was clean, it did lack comments and some lines of code was commented out. I provided this in a feedback (fig 7) and requested for changes.

fig 6 (Code Review Example)

fig 7(Review feedback)

Documentation

Documentation was undertaken using Doxygen and added to the Document folder in the repo. Fig 7 is an example

My Project
</script> <script type="text/javascript" src="menudata.js"></script> <script type="text/javascript" src="menu.js"></script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ $(function() { initMenu('',true,false,'search.php','Search'); $(document).ready(function() { init_search(); }); }); /* @license-end */ </script>
Loading...
Searching...
No Matches
UNDAC_Project.Data.EquipmentDB Class Reference

Static Public Member Functions

static async Task InitiateDataBase ()
 Check if local database exists. Creates new one with table if it does not exist.
 
static async Task< int > GetEquipmentTypeForeignKey (string eType)
 Gets equipment type id number.
 
static async Task ListEquipment (Equipment eq)
 Add Equipment to database.
 
static async Task AddEquipment (Equipment eq)
 Add Equipment to database.
 
static async Task< string[]> GetEquipmentType ()
 Return list of equipment types from database.
 
static async Task< List< Equipment > > GetEquipment (string name)
 Return list of equipment from database based the the search condition of equipment name.
 
static async Task AddEquipmentAllocation (Equipment_Allocation ea)
 Add equipment allocation to database.
 
static async Task AddEquipmentType (Equipment_type et)
 Add Equipment type to database.
 

Detailed Description

Definition at line 8 of file EquipmentDB.cs.

Member Function Documentation

◆ AddEquipment()

static async Task UNDAC_Project.Data.EquipmentDB.AddEquipment ( Equipment  eq)
static

Add Equipment to database.

Parameters
eq
Returns

Definition at line 63 of file EquipmentDB.cs.

◆ AddEquipmentAllocation()

static async Task UNDAC_Project.Data.EquipmentDB.AddEquipmentAllocation ( Equipment_Allocation  ea)
static

Add equipment allocation to database.

Parameters
ea
Returns

Definition at line 108 of file EquipmentDB.cs.

◆ AddEquipmentType()

static async Task UNDAC_Project.Data.EquipmentDB.AddEquipmentType ( Equipment_type  et)
static

Add Equipment type to database.

Parameters
et
Returns

Definition at line 120 of file EquipmentDB.cs.

◆ GetEquipment()

static async Task< List< Equipment > > UNDAC_Project.Data.EquipmentDB.GetEquipment ( string  name)
static

Return list of equipment from database based the the search condition of equipment name.

Parameters
name
Returns

Definition at line 95 of file EquipmentDB.cs.

◆ GetEquipmentType()

static async Task< string[]> UNDAC_Project.Data.EquipmentDB.GetEquipmentType ( )
static

Return list of equipment types from database.

Returns

Definition at line 74 of file EquipmentDB.cs.

◆ GetEquipmentTypeForeignKey()

static async Task< int > UNDAC_Project.Data.EquipmentDB.GetEquipmentTypeForeignKey ( string  eType)
static

Gets equipment type id number.

Parameters
eType
Returns
Foreign Key

Definition at line 38 of file EquipmentDB.cs.

◆ InitiateDataBase()

static async Task UNDAC_Project.Data.EquipmentDB.InitiateDataBase ( )
static

Check if local database exists. Creates new one with table if it does not exist.

Returns

Definition at line 19 of file EquipmentDB.cs.

◆ ListEquipment()

static async Task UNDAC_Project.Data.EquipmentDB.ListEquipment ( Equipment  eq)
static

Add Equipment to database.

Parameters
eq
Returns

Definition at line 51 of file EquipmentDB.cs.


The documentation for this class was generated from the following file:

Generated by doxygen 1.9.8

fig 7(Documentation fo the EquipmentDB database class)

Reflection

The following reflections were made from this portfolio

  1. There could be a debate of having a database class for each of the equipment related tables. However, it was decided to keep them in one database class using the following that the InitateDataBase function creates all related equipoment tables. This was decided to do this in one function given that they are linked with foreign keys. This was to minimise the risk of tables not being created properly if a foreign key does not yet reference an existing table. Furthermore, given that there were only 8 methods, it was decided that this was not too much for one class.

  2. Whilst using a local database in the early development, I have recognise that this is problematic in the following ways 2.1 There is the requirement for features to be merged into the development branch in order to sync the local database with changes due to added tables. 2.2 Datasets would need to be provded to be added to the local database to sync up data. 2.3 Not having a fully sync database would provide difficulty in testing for system wide compatability.

  3. No unit tesing was put in place. I was able to figure out using mock tests for this week. This is an area I recognise I need to gain knowledge and skilsl on for both the project module for semester 2, as well as for professional practice.

  4. Given that SQL injection vulnerability was recognised, I would need to read up on optimising SQL statments to mitigate for these risks.