CS代考 ICT283 Topic 5 (not assessed in this lab but must be completed)

B215 Practical exercises – Week 7

ICT283 Topic 5 (not assessed in this lab but must be completed)
Objectives:

Copyright By PowCoder代写 加微信 powcoder

· Preparation for assignment 1 – Questions 1 and 5 must be completed before attempting the assignment. Assessment of these questions is in the assignment.
· To learn

· OO Design and appreciate the value of doing this design properly
· practical implications of cohesion and coupling
· to do refactoring and code maintenance
· to do testing
· to pay attention to detail
It is very important not to fall behind with these exercises.
You should note that even though an exercise is not assessed, not attempting the exercise would make it very difficult for you to understand subsequent material.

If you want to work on you own computer, install graphviz first, then install doxygen.
Reading list is for Topic 5. Some of the chapters are repeat readings from previous topics. See “Reading List for ICT283”. The textbook chapter on “Overloading and Templates” is particularly important – needed for the assignment.

Do not start coding until you have worked out exactly what is required. Do this on paper. Draw a UML diagram illustrating how the classes are connected and being used. You need to read all the questions (sub tasks) below first to work out what is needed and then plan the best way to tackle each of the sub tasks listed. You may need to read the specifications more than once to understand what is really needed. Make sure you document all code using doxygen style comments.

Think about the test data you will use to demonstrate that your program works. You can assume that the input data file contains data in the correct format. This means that you must create the data file correctly.
Question 1 shown below requires you to follow the specifications as provided. When you finish question 1, you would have an appreciation of how C++ classes work and are ready to do your own design and implementation.
From question 2 onwards, you have to do your own design. So reflect on all the work you have done so far and re-design and re-implement all the classes that have been created in the previous exercises. The aim is to create classes that can be re-used in many contexts without re-coding of the classes. Aim for high cohesion and low coupling in your design.
Just getting code to work is not going to be sufficient to pass. Design is very important.
1. Modify the design of the previous topic’s exercise (Topic04) so that each student id has an associated student name.
Each unit has a unit coordinator and the unit coordinator’s details include: coordinator’s name, room number, telephone number and email.
Each unit has a list of enrolled students. Store this list in an encapsulated dynamic array (uses “new” to create memory on the heap) – the array is a private member of a template class called Vector. You write the Vector class and provide controlled access to the dynamic array via the Vector’s public methods. Do not use the STL vector class (i.e. you must not have #include in any part of your code for this lab or assignment 1). The template Vector class that you have to write is an example of a linear data structure. The entire (declaration and implementation) template Vector class is written in a file called Vector.h. There is no Vector.cpp although the textbook explains schemes for having .cpp files for template classes. There is no need to complicate the issue by having a .cpp file for template classes.

Vector.h contains the following:

#ifndef VECTOR_H

#define VECTOR_H

// The class declaration must have doxygen comments – put these in
template

class Vector

// class declaration

// you fill in the rest and include doxygen comments

// class implementation follows with normal comments
// you fill in the rest

Keep the Vector minimal but complete. Methods or operators should not have duplicated functionality. See Rule 33 Prefer minimal classes to monolithic classes in the unit’s reference book: C++ Coding Standards: 101 Rules, Guidelines, and by Alexandrescu et al. Ebook is in the library if the following link does not work. http://lib.myilibrary.com.libproxy.murdoch.edu.au/Open.aspx?id=291948

You will need to unit test this Vector before using it in this exercise. Discuss your ideas with your tutor. You will need this template Vector class for the assignment.
2. Reflect on the re-design you have to do to cater for new requirements. How would you “future-proof”
your design so that any new code that you write will introduce additional functionality to cater for new requirements and not keep on modifying existing code? Note that in the past, you were given an example of what output the program should do. What if the output format was changed? Would you have to go back and change existing classes? Ideally, to change the output format should only require a changed “main program” and not a change to the data classes. What about a change in the input format? For example, how would you cater for the input format shown at the end of the document? You will be using the first version of the input format for the rest of this unit/module.
You have a free hand in re-designing all the classes to attempt to future-proof them. Later, you will be learning from your mistakes when you discover the amount of re-designing and coding that you have to do to cater for expanded requirements if your new design is not good.
You should use UML for the design.

For this particular question, did you have to change the Vector class from question 1 so that it will work in your new design in this question 2? If you did, then you had designed your Vector class badly in question 1.
Did you make your Vector class dependant on any part of application? Is the student class part of the member data of Vector? If it is, the Vector can’t be used correctly for question 5 of this lab and the assignment: your Vector is done incorrectly.

Vector must not depend on any part of the application. Vector is just an encapsulated array that can store any other data type. To be able to have this flexibility, Vector must not know about the data type that it is storing.
3. Implement your new design. Demonstrate how flexible your design is so that different output formats can be catered for by writing different main programs. Note that just getting different output formats this way is not sufficient to indicate good design – but it is a start.
See sample input formats are at the end of this list of questions. Use the first version of the input format (CSV) for this question.
4. Run doxygen and examine the output to see that your initial design matches the design as shown in doxygen.
5. Use the text editor Notepad++ (https://notepad-plus-plus.org/) to examine the data file data/MetData-31-3.csv. This data was obtained from http://wwwmet.murdoch.edu.au/. This online weather station was originally created by one of our final year Science project teams. You can view the site if the current administration has it online.

Open the same file (data/MetData-31-3.csv) using a spreadsheet like Microsoft Excel. Compare the views shown in Excel and notepad++. This is the type of data that will be used for assignment 1. The notepad++ version is what your program will see.
The first row shows the sensor codes. See the file SensorCodes.rtf for their meaning.

The first field contains both the date and time. You will need to split the date and time values. The date can be stored in the Date class from a previous exercise. You need to create and unit test a Time class to store time values.

For this question, we are interested only in the first field marked “WAST” and the field marked “S”. The data in the S field is the wind speed. You should assume that the speed recorded in the data file is in m/s. You can download your own data files to check the units. The units are shown in the raw data files you download. For lab 5 you will use the following data structure:
// #include anything else you need
#include “Date.h” // your Date class from a previous lab
#include “Time.h” // your Time class from this lab
#include “Vector.h” // your Template Vector class from this lab
typedef struct {

float speed;

} WindLogType;

Vector windlog; // Vector is a realised vector. See lecture notes. What would the UML diagram look like.
The Date class was created and unit tested in topic 4. The Time and Vector classes were created and unit tested as part of this topic. Note that as you are creating classes, the classes get reused later in other contexts, so make sure you design for reuse. Remember to keep the classes simple. The more you add to classes beyond the bare minimum, their reusability goes down. Apply the principles of low coupling and high cohesion. See Rule 33 Prefer minimal classes to monolithic classes in the unit’s reference book: C++ Coding Standards: 101 Rules, Guidelines, and by Alexandrescu et al. Ebook is in the library if the following link does not work. http://lib.myilibrary.com.libproxy.murdoch.edu.au/Open.aspx?id=291948
Write a C++ program to read data from the file data/MetData-31-3.csv into windlog.
Once the data is read into windlog, your program will use windlog to work out the average wind speed in km/h. The program will then round this average speed to the nearest whole number. This number is printed to the screen on a new line.

The program will go through windlog and when a value of speed is found that matches the average speed that was printed out, the date and time stored (in windlog) for this speed is printed on a new line.
Something for you to consider: Is it possible that the average speed would not be in windlog?

Once you have the correct results, check your program on the larger data file, data/MetData_Mar01-2014-Mar01-2015-ALL.csv. This data file is used for assignment 1.

You should test your program in question 5 using more data files. Question 5 and Assignment 1 needs to work with only 1 data file at a time. Download from http://wwwmet.murdoch.edu.au/. When downloading, use the data group on the left, don’t tick UTC date/time, select all in the left column of data at the web site. You will get a .csv file that will have the sensor legend at the top. Open the csv file in Microsoft Excel and delete the top few rows but keep the header row. Check that the data/time format is correct in Excel, and then save the file as a .csv file in the data directory for this lab. If the date is not in the dd/mm/yyyy format, use Excel’s help to find out how to change the date format, and then save as indicated earlier. Open the csv file in notepad++ (https://notepad-plus-plus.org/) to examine what your program will see when reading in the file.
Some essential things to consider:

· A number of fields that are not of interest would be read and discarded for question 5. Other fields will be used later (Ambient Air Temperature T, Solar Radiation SR).
· How big is the Vector going to be? This is the same consideration as in question 1 above. Once you create the internal array on the heap using “new”, the size is fixed. What happens if there is more data to be added? The Vector would need to resize itself (grow) once full. The user of Vector should not be bothered with this detail as the Vector would take care of this behind the scenes. Naturally, you as the designer of Vector would have to write the code to do the resize. The amount to resize is typically 1.5 to 2 times current size.
· How do you know that the data is being read in correctly? Hint: before you attempt to read the data into the data structure, you need to read, split the data and print it out on screen or a file for debugging. Then manually check the output. Your program doesn’t have to do this for the entire data file – just the first few lines will be sufficient to check. Once this limited manual check is successful, check that you can read the whole file correctly. You do this check by reading MetData-31-3.csv and printing the date, time and wind speed into an output file (testoutput.csv). Commas separate the date, time and wind speed, with 3 data values per line. Open MetData-31-3.csv and testoutput.csv in a text editor and spreadsheet, and then manually check that the values are correct in testoutput.csv. Once you can visually confirm that the values are correct, you start on this question and use the windlog data structure. Test your program by printing out all the data from windlog into the output file called testoutput.csv. The three values in the output file must be separated by commas. Do a visual check to see that the data in testoutput.csv is correct. Once you can confirm that the output is correct, do the average speed calculation and output date/time on screen. Make sure that you check that the screen output is correct by viewing the input data file in a spreadsheet (application test). Use the spreadsheet’s average formula calculation to verify your program’s calculation.
· Can you think of any good reason why WindLogType should be a class and not a struct? When would you use a class and when would you use a struct? Think very carefully about this. Readings from this topic and earlier topics would guide you. The assignments do require (mandatory
) you to provide rationale (reasons why) for data structure approaches you take.
Sample input formats for questions 2 and 3:
There are two formats to experiment with. The first one is easier than the second. Attempt the second version only if you can complete the first version. The first version below is needed for assignment 1 preparation.
Both versions of the data format do not show student name and unit coordinator details. Get your design and program to work without these details. Once you have a working design and program, think of how you could incorporate student name and unit coordinator details into the input data. Would you use a separate data file to store unit coordinator information?

First version of the input data format: (All assignments will use this input format)
This format is commonly called the CSV (comma-separated value) format. This is usually used when the number of fields appearing on a line is fixed. Data may be missing. Use this format for question 5 above and the assignments.
All data is separated by commas until the end of line. Each row (line) is called a record. Each piece of data is called a field.
ID,Semester,Unit ID, Unit Name, Credit, Marks, Date
Once you have a working design and program using the above data format, think of how you could incorporate student name and unit coordinator details into the input data.
For question 5, the data will come from the data files that have been provided.

——————————————————————————————————————————————

Second version of the data format: (not for the Assignments – for additional practice)
Attempt this version only if you can get the first version to work, have completed question 5 above and are looking for something more “challenging”. This format is not needed for Assignment 1.
All data for one student id is on one line. Major separator symbol is the semicolon (;) and minor separators are commas (,). Each line is called a record.
ID;Semester,Unit ID, Unit Name, Credit, Marks, Date, Unit ID, Unit Name, Credit, Marks, Date;Semester, .. etc

From the above, you will notice that within a semester, there can be more than one unit. Any item in between a separator is called a “field”. So Unit Name is a field, so is ID, Semester, Credit, .. etc.
The date is the when the marks were entered into the system. The semester is when the unit was actually studied.

Notice that the record (line) is identified by the student ID. So each student will have all his/her details on one line. After the student ID, the semi-colon separates units completed according to semester.

Once you have a working design and program using the above data format, think of how you could incorporate student name and unit coordinator details into the input data.

————————————————————————————————————————————-

From the above, you will note that a record contains one or more fields and that each record appears on a line.

Think about how you might handle an alternative Date format that has the date and time in the one field as in question 5’s data file. This means that the date and time is only separated by one or more spaces.

When thinking about how to resolve the above Date issue, would you make the Date class handle all these possibilities? If so, what happens when the input format is changed again to another specification?

You need to complete question 5 now. If you start having problems with assignment 1, we may ask you to demonstrate completion of all labs that are marked as preparation for assignment 1. Detailed testing would need to be demonstrated for the labs. Once you have completed the preparatory labs, assignment 1 is not that complicated. This same approach also applies to assignment 2.
� It may not be possible to get a perfect design which will cater for all future requirements. What you may want to hope for is minimal change to existing code to cater for new requirements.

� The assignment must meet the mandatory requirements. So attention to detail is critical.

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com