Question: SIT232 ObjectOriented Development Trimester 1, 2021 1 Practical Task 4.2 (Credit Task) Submission deadline: 10:00am Monday, May 10 Discussion deadline: 10:00pm Friday, May 28 General

SIT232 ObjectOriented Development Trimester 1, 2021

1

Practical Task 4.2

(Credit Task)

Submission deadline: 10:00am Monday, May 10

Discussion deadline: 10:00pm Friday, May 28

General Instructions

This practical task focuses on the program design, mainly the functional composition and the code

reusability, and on the composition as a type of class relationships.

In the first part, you will need to examine an existing source code to identify duplicate code, which means

that there are sequences of commands that occur more than once. Duplicate code is generally considered

undesirable for a number of reasons, for example:

Duplicate code makes your program lengthy and bulky.

Duplication makes software maintenance more difficult.

Duplication decreases your code quality. Code quality is a necessity to make your software survive for

long. Having duplicate code will make your code smelly and increases the technical debt associated

with it. The cost of repair of this debt is the amount of capital and time required to pay to a developer

to simplify or deduplicate it.

Duplication leads to socalled Shotgun Surgery: Suppose you wrote a buggy code and have to make a

code review to find out the issue and then fix it. You now have to fix every location of that code, losing

your time, efficiency and sometimes temper.

Duplicate code increases security risks: When someone takes a code from somewhere and adds into

other parts of program, they might forget about the holes and endings that the code has.

This issue related to the given code will require you to work on the function composition, which implies that

complex problems should be solved by decomposing them into many smaller problems so that each can be

worked out easily. Eventually, those small pieces have to be put together to form the overall solution. One

way of combining these small pieces is the function composition, a mechanism to combine simple functions

to build more complicated ones. Also the function composition is a great tool that makes the code more

compact and reduces noise. Because of the concise syntax, there are fewer possibilities to make mistakes

like, for example, mixing up parameters.

In the second part, your task is to extend the program by adding new features and functionality. To make the

design efficient, you should use a mechanism known as the class composition, the most commonly used class

relationship. In general terms, composition allows a class to contain an object instance of another class.

The composition can be denoted as being an "as a part" or a "has a" relationship between classes. Thus, the

main class becomes the frontend class and another represents the backend class. The composition

approach provides strong encapsulation because a change to a backend class does not necessarily break

any code that relies on the frontend class. Thus, it maintains the same access interface to the frontend

despite of backend changes.

Now, let's move to the task. Imagine, as it commonly happens in the IT world, that you have been hired by

BuggySoft, a leading producer of buggy software, to replace one of their staff who is leaving. You are asked

to continue working on a simple Task Planner. They assure you that the task is very simple and should not

take more than a couple of hours because the program looks fine from the perspective of the user interface.

So they just want you to extend the program a bit as their customer wants to add some additional features.

You agree, and ...

SIT232 ObjectOriented Development Trimester 1, 2021

2

1. Open the source code file attached to this practical task. Suppose that this is the code inherited from the

previous programmer. As you can see, the code itself is not large, but everything is placed in a single Main

method. This code is messy and not documented, but you are lucky because you at least can compile and

run it.

You now must spend some time to understand how the code works, what it produces, and how it interacts

with the user. The best way to do it is to make a new C# Console Application project and import the

given file. You then should run the code stepbystep in the debug mode to explore the control flow.

2. To demonstrate that you are a more experienced programmer than your leaving colleague, you should

ensure the function composition and avoid any code duplication because of the aforementioned reasons.

Find all sequences of commands that should be placed together to form logically complete methods

parametrised with a set of arguments. Work on this to make your code as clean as possible. In addition,

add comments so that your methods and key points of your program make sense in case you want to

return to it later.

Once finished, save your source code file as 'RevisedCode.cs'. You will need to submit this as part of

your solution.

3. As you can see, this is a Task Planner program that partitions tasks into a number of categories. The tasks

in a same category form a priority list. All tasks are printed in a table format. The program provides a very

limited functionality and is for sure not competitive. Because of this, the customer requested BuggySoft

to add the following capabilities:

The user must be given an option to add new and delete existing categories. If a category is removed,

all associated tasks should be removed as well.

The user must be given an option to delete an existing task.

It must be possible to move a task in its respective priority list by setting the place (priority).

It must be possible to move a task from one category to another.

It must be possible to highlight important tasks so that they appear in red in the terminal.

Every task must be characterised by a due date printed along with the name. This might need to

enlarge the size of the table's columns.

From what you see, the customer does not specify a particular design and leaves this with you. You, as a

programmer, are also free to implement the internal logic of the program as you decide. However, a

proper design will likely rely on composition. For example, you might have already noticed that tasks are

to be "a part of" category and they are deleted along with their category. Remember that the class

composition ensures the whole/part or parent/child relationship; that is, the life cycle of the part (or

child) is controlled by the whole (or parent) that owns it. If the parent object is destroyed, then the child

objects also cease to exist.

Note that you will likely need to create new classes to manipulate objects as data structures. For example,

each task is characterised by a colour tag (to stress its importance) and a due date. This is not currently

presented in the existing source code as well as any classes but the main class. Because we do not know

how many classes you wish to create, we leave it with you and expect you to add them together to the

'FinalCode.cs', which is to be the only file that you must submit as your final solution.

In addition, you will deal with a collection of objects to represent categories and task priority lists.

Therefore, we recommend you to focus on the use of dynamic List data structure rather than a quite

static array. You are also allowed to alter the existing code in order to improve it.

Finally, you will have to significantly extend the existing menu to interact with the user to serve incoming

requests.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!