1651 - Advanced Programming ( MERIT ), Study Guides, Projects, Research of Information Technology

This unit introduces students to the core concepts of programming with an introduction to algorithms and the characteristics of programming paradigms. Among the topics included in this unit are: introduction to algorithms, procedural, object-orientated & event-driven programming, security considerations, the integrated development environment and the debugging process.

Typology: Study Guides, Projects, Research

2021/2022

Uploaded on 10/27/2022

thanh-phong-1
thanh-phong-1 🇻🇳

4.6

(7)

2 documents

1 / 48

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
ASSIGNMENT 1 FRONT SHEET
Qualification
BTEC Level 5 HND Diploma in Computing
Unit number and title
Unit 20: Advanced Programming
Submission date
07/01/22
Date Received 1st submission
Re-submission Date
Date Received 2nd submission
Student Name
Do Thanh Phong
Student ID
GCH190859
Class
GCH0902
Assessor name
Doan Trung Tung
Student declaration
I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that
making a false declaration is a form of malpractice.
Student’s signature
Grading grid
P1
P2
M1
M2
D1
D2
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30

Partial preview of the text

Download 1651 - Advanced Programming ( MERIT ) and more Study Guides, Projects, Research Information Technology in PDF only on Docsity!

ASSIGNMENT 1 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing

Unit number and title Unit 20: Advanced Programming

Submission date 07 / 01 /2 2 Date Received 1st submission

Re-submission Date Date Received 2nd submission

Student Name Do Thanh Phong Student ID GCH 190859

Class GCH 0902 Assessor name Doan Trung Tung

Student declaration

I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that

making a false declaration is a form of malpractice.

Student’s signature

Grading grid

P1 P2 M1 M2 D1 D

Summative Feedback:Resubmission Feedback:

Grade: Assessor Signature: Date:

Lecturer Signature:

  • Introduction.
  • I. OOP general concepts.
    • a) Definition
    • b) General concepts of OOP
        1. Object
        1. Class
        • 2.1 Creating Classes
        • 2.2 Main() Method
        • 2.3 Methods.
        • 2.4 Method Parameters and Arguments.
        • 2.5 Static Classes.
        • 2.6 Static Methods.
        • 2.7 Static Variables.
        • 2.8 Access Modifiers.
        • 2.9 Constructors.
        1. Characteristics of OOP.
        • 3.1. Encapsulation
        • 3.2. Inheritance.
        • 3.3. Polymorphism.
        • 3.4. Abstraction.
  • II. OOP Scenario.
    • A. Scenario.
    • B. Use case diagram.
    • C. Class diagram.
  • III. Design Patterns.
    • a) Overview
    • b) Creational patterns
      • Factory Method
    • c) Structural patterns
    • d) Behavioral Patterns
      1. Strategy
      1. Observer
  • IV. Compare: OOP vs Design Pattern.
  • V. Conclusion.
  • References
  • Presentation Slides
  • Figure 1: Object Identity, Characteristics, and Behavior (Aptech, 2013). Table of Figures
  • Figure 2: Class Students (Aptech, 2013).
  • Figure 3: Accessibility Levels (Aptech, 2013).................................................................................................................
  • Figure 4: Encapsulation
  • Figure 5:Inheritance
  • Figure 6: Polymorphism
  • Figure 7: Use case diagram for Payroll System.
  • Figure 8: Class diagram for payroll system.
  • Figure 9: User Abstract Class Diagram
  • Figure 10: Rates Abstract class
  • Figure 11: Menu Abstract Class
  • Figure 12: User Factory Method
  • Figure 13: Decorator Class Diagram
  • Figure 14: Strategy Pattern Example
  • Figure 15: Observer Class Diagram
  • Figure 16: Observer Pattern Diagram
  • Figure 17: Factory Method Diagram

Introduction.

In this report we will present about OOP programming concept along with its properties. We will then come

up with an OOP scenario from which our team will present its Use case diagram and a Class diagram.

In the latter part of the report, we will provide the theories behind the Design Patterns. From which, everyone

will choose a scenario to draw the class diagram. The last is the relationship between OOP and design

patterns.

Several objects have a common state and behavior and thus, can be grouped under a single class (Aptech,

For example, a Ford Mustang, a Volkswagen Beetle, and a Toyota Camry can be grouped together under

the class Car. Here, Car is the class whereas Ford Mustang, Volkswagen Beetle, and Toyota Camry are

objects of the class Car.

Figure 2 : Class Students (Aptech, 2013).

2.1 Creating Classes

The concept of classes in the real world can be extended to the programming world, similar to the concept

of objects. In object-oriented programming languages like C#, a class is a template or blueprint which

defines the attribute and behavior of all objects belonging to that class. A class comprises attribute,

properties, methods, and so on, collectively called data members of the class (Aptech, 2013).

2.2 Main() Method.

The Main() method indicates to the CLR that this is the first method of the program. This method is declared

within a class and specifies where the program execution begins. Every C# program that is to be executed

must have a Main() method as it is the entry point to the program. The return type of the Main() in C# can

be int or void (Aptech, 2013).

2.3 Methods.

Methods are functions declared in a class and may be used to perform operations on class variables. They

are blocks of code that can take parameters and may or may not return a value. A method implements the

behavior of an object, which can be accessed by instantiating the object of the class in which it is defined

and then invoking the method (Aptech, 2013).

For example, the class Car can have a method Brake() that represents the ’Apply Brake’ action. To perform

the action, the method Brake() will have to be invoked by an object of class Car.

2.4 Method Parameters and Arguments.

The variables included in a method definition are called parameters. When the method is called, the data

that the developers send into the method’s parameters are called arguments (Aptech, 2013).

A method may have zero or more parameters, enclosed in parentheses and separated by commas. If the

method takes no parameters, it is indicated by empty parentheses (Aptech, 2013).

2.5 Static Classes.

Classes that cannot be instantiated or inherited are known as static classes. To create a static class, during

the declaration of the class, the static keyword is used before the class name. A static class can consist of

static data members and static methods. It is not possible to create an instance of a static class using the new

keyword. The main features of static classes are as follows (Aptech, 2013):

  • They can only contain static members.
  • They cannot be instantiated.
  • They cannot be inherited.
  • They cannot contain instance constructors. However, the developer can create static constructors to

initialize the static members.

Since there is no need to create objects of the static class to call the required methods, the implementation

of the program is simpler and faster than programs containing instance classes (Aptech, 2013).

2.6 Static Methods.

A method, by default, is called using an object of the class. However, it is possible for a method to be called

without creating any objects of the class. This can be done by declaring a method as static. A static method

is declared using the static keyword. For example, the Main() method is a static method and it does not

require any instance of the class for it to be invoked. A static method can directly refer only to static variables

2.9 Constructors.

A C# class can contain one or more special member functions having the same name as the class, called

constructors. Constructors are executed when an object of the class is created in order to initialize the object

with data. A C# class can also have a destructor (only one is allowed per class), which is a special method

and also has the same name as the class but prefixed with a special symbol ~. A destructor of an object is

executed when the object is no longer required in order to de-allocate memory of the object (Aptech, 2013).

Constructors.

A class can contain multiple variables whose declaration and initialization becomes difficult to track if they

are done within different blocks. Likewise, there may be other startup operations that need to be performed

in an application like opening a file and so forth. To simplify these tasks, a constructor is used. A constructor

is a method having the same name as that of the class. Constructors can initialize the variables of a class or

perform startup operations only once when the object of the class is instantiated. They are automatically

executed whenever an instance of a class is created (Aptech, 2013).

Default Constructors.

C# creates a default constructor for a class if no constructor is specified within the class. The default

constructor automatically initializes all the numeric data type instance variables of the class to zero. If a

constructor is defined in the class, the default constructor is no longer used (Aptech, 2013).

Static Constructors.

A static constructor is used to initialize static variables of the class and to perform a particular action only

once. It is invoked before any static member of the class is accessed. Only one static constructor can be

present in the class. The static keyword is used to declare a constructor as static. A static constructor does

not take any parameters and does not use any access modifiers because it is invoked directly by the CLR

instead of the object. In addition, it cannot access any non-static data member of the class (Aptech, 2013).

Constructor Overloading.

The concept of declaring more than one constructor in a class is called constructor overloading. The process

of overloading constructors is similar to overloading methods. Every constructor has a signature similar to

that of a method. Multiple constructors in a class can be declared wherein each constructor will have

different signatures. Constructor overloading is used when different objects of the class might want to use

different initialized values. Overloaded constructors reduce the task of assigning different values to member

variables each time when needed by different objects of the class (Aptech, 2013).

3) Characteristics of OOP.

3.1. Encapsulation

Weiner (2000) described Encapsulation as the combination of underlying data with a set of actions that

define the data type. The data's internal representation is encapsulated (hidden), but some specified actions

can manipulate it.

Clark (2013) remarked that by encapsulating data, the system's data becomes safer and more trustworthy as

the developers are aware of the data's structure, what activities are being performed on the data, and how it

is being accessed. This makes program upkeep and the debugging process a lot easier.

Figure 4 : Encapsulation

For example, the author creates a class called Animal with 1 attribute called “name”. And as seen in Fig.1,

the access modifier of “name” is set to private, thus external calls from outside the class cannot be executed.

To access it, we have to use the variable “Name”, which has a public access modifier instead.

3.2. Inheritance.

One of the most significant features of Object-Oriented Programming is inheritance (OOP). The key to

grasping Inheritance is that it allows for code reuse. We may just inherit the attributes of one class into the

other instead of writing the same code over and again (Kumar, 2019).

For example, the Import Book class has declared and called the variable ImportBookName. When we create

an additional class ImportBookName to reduce the code, we use its inheritance and reuse the code. This

allows the ImportBookName function to use the codes that ImportBook has declared, when the code we just

call back and align the things we don't need out.

For example, the author created an abstract class called “Animal” with the abstract method Move. Then he

created its children classes, which are “Dog” and “Bird”, and both of them have their own Move method.

In which, the Dog class will print out the line “the dog runs”, and “the bird flies’ for the Bird class. And as

seen on Fig 1., because the author defined the kind of Animal for each new objects, the computer could

know which “Move” method to be executed, making the dog runs and the bird flies when the methods are

called.

3.4. Abstraction.

According to (Knowledge Hut, 2011), Abstraction is an important part of object oriented programming. It

means that only the required information is visible to the user and the rest of the information is hidden.

Abstraction can be implemented using abstract classes in C#. Abstract classes are base classes with partial

implementation. These classes contain abstract methods that are inherited by other classes that provide

more functionality.

Some of the salient points about abstract classes are as follows:

  • The abstract class is created using the keyword abstract and some of the methods of the abstract

class also contain the keyword abstract.

  • No object can be created of the abstract class i.e.it cannot be instantiated.
  • The abstract methods in the abstract class are implemented actually only in the derived classes.
  • If all the methods in the abstract class contain the keyword abstract, then that class is known as

pure Abstract class.

II. OOP Scenario.

A. Scenario.

It is widely known as accountants are constantly in high demand in every country, in corporations, and in

economic organizations. The reason behind this need is simply because accounting is a necessary aspect of

all organizational units. Payroll accounting is an important aspect of businesses and economic organizations

since it helps to determine the existence and growth of those businesses and organizations. But it is

undeniable that this process is extremely complex and requires a lot of time and effort.

To ease the process, the author proposes a Payroll Management Application, created with the goal of

keeping track of the different allowances and deductions that must be granted to the company's employees.

Also, it aims to replace manual calculations, which may include many small mistakes, with a totally

automated process. This application has the potential to make the current management process quicker,

more productive, and need fewer staff to operate.

Using the C# language and the OOP paradigm, the system brings meny benefits to the organizations’s. In

addition to managing salary based on different level of the company’s hierachy, it can also store and manage

employee’s information

The system includes the following functions for each actor:

  • Employee management: View the list of employees, update, add, edit, delete, detailed information

of each employee.

  • Accountant: Update, edit, delete salary information such as salary coefficient, bonus, allowance,

update employee timekeeping, view list, print payroll...

  • Admin: Track detailed employee statistics, salary, timekeeping, add and delete users
  • Employees: View salary, wages and report.

Use case document template.

  • Login function. Name of Use Case: Login Created By: Group 1 Last Updated By: Group 1 Date Created: 12/12/2021 Last Revision Date: 12/14/ Description: This use case describes how a user logs into the payroll system. Actors: Employee Preconditions: 1. Users need to have an account in the system. Postconditions: If the use case was successful, the actor is now logged into the system. If not, the system state is unchanged. Flow: 1. The system requests that the actor enter user name and password.
  1. The actor enters his/her name and password.
  2. The system validates the entered name and password and logs the actor into the system.
  3. The system starts to decentralize. Alternative Flows: 3.1. Invalid Name / Password If in the Basic Flow the actor enters an invalid name and/or password, the system displays an error message. The actor can choose to either return to the beginning of the Basic Flow or cancel the login, at which point the use case end Exceptions: No exceptions
  • Logout function. Name of Use Case: Logout Created By: Group 1 Last Updated By: Group 1 Date Created: 12/12/2021 Last Revision Date: 12/14/ Description: This use case describes how a user logs out of the payroll system. Actors: Employee Preconditions: 1. User needs to Login first or stay in logged in state.

Postconditions: The user's account will be logged out.

Flow: 1. User selects logout function.

  1. The system logs the user.
  2. System off Alternative Flows: N/A Exceptions: No exceptions
  • Check Salary function. Name of Use Case: Check Salary Created By: Group 1 Last Updated By: Group 1 Date Created: 12/12/2021 Last Revision Date: 12/14/ Description: This use case describes how a user checks his salary in a payroll system. Actors: Employee Preconditions: 1. User needs to Login first or stay in logged in state.
  1. User must select the salary check function. Postconditions: The payroll information table for the employee and the employee's salary will be displayed. Flow: 1. The user selects the salary check function.
  2. The system will present the employee's salary information. 2.1, If the user wants to print the receipt, the system will print it out. Alternative Flows N/A Exceptions: No exceptions
  • Edit Personal Information function. Name of Use Case: Edit Personal Information Created By: Group 1 Last Updated By: Group 1 Date Created: 12/12/2021 Last Revision Date: 12/14/ Description: This use case describes how a user edits personal information such as name, age, username, password... in a payroll system. Actors: Employee Preconditions: 1. User needs to Login first or stay in logged in state.
  1. User must select Edit Personal Information function. Postconditions: If the user changes the information, the system will update the information for the user. Flow: 1. User selects Edit personal information function.
  2. The system prints the user's information.
  3. User selects information to correct.
  4. User enters alternate information.
  5. The system asks for confirmation
  6. Confirm that the user's information has been changed in the system Alternative Flows: 5.1. If you confirm cancel, the system will not change the information. Exceptions: No exceptions

3.5 if the admin chooses the Exit function, the system will turn off. Alternative Flows: 3.5. If the admin enters the wrong option, the system will report "Invalid option" and the system will ask to re-enter the option. 3.2.1’. If the admin enters the wrong id, the system will say "id not found" and ask to re-enter the id. 3.3.1’. If the admin enters the wrong id, the system will say "id not found" and ask to re-enter the id. Exceptions: No exceptions

  • Check Report Information function. Name of Use Case: Check Report Created By: Group 1 Last Updated By: Group 1 Date Created: 12/12/2021 Last Revision Date: 12/14/ Description: Users need to Login first or be logged in and have admin rights Actors: Admin Preconditions: 1. Users need to Login first or be logged in and have admin rights. Postconditions: Display the interface of the Check Report function. Flow: 1. The system displays all report messages
  1. Admin selects the report message
  2. Admin responds to the report. Alternative Flows: 2.1. If the report is accepted, the admin will send the error back to the manager and accountant. 2.2. If the message is not accepted, the admin will send a response back to the employee. Exceptions: No exceptions
  • Manager Work Hours function. Name of Use Case: Manager Work Hours Created By: Group 1 Last Updated By: Group 1 Date Created: 12/12/2021 Last Revision Date: 12/14/ Description: This use case describes how a manager manages employee hours. Actors: Manager Preconditions: 1. Manager needs to Login first or login and have administrator permissions
  1. Manager must have data from manager sent down.

Postconditions: show manager interface

Flow: 1. The system prints the menu and asks the manager to select the function.

  1. Manager select options
  2. The system moves to the respective functions such as, Timekeeping, Edit, Show Ifo, Exit. 3.1. If the manager chooses Timekeeping, the system will ask the admin to enter the user's working time and confirm saving. 3.1.1. The employee manager enters the employee's working time. 3.1.2. Manager confirms saving. 3.2. If Manager chooses Edit 3.2.1. The employee manager enters the employee id to edit. 3.2.2. The system asks the manager to enter the type of information that needs to be edited 3.2.3. Manager selects information to edit 3.2.4. The system asks to enter a new working time 3.2.5. Manager enters new working time. 3.2.6. The system sends a confirmation request 3.2.7. Manager has confirmed and employee's working time has been changed. 3.3. if Manager chooses the Show function. 3.3.1 The system will print all the user's information 3.4 if Manager chooses Exit function, the system will shut down. Alternative Flows: 3.5. If the manager enters the wrong option, the system will report "Invalid option" and the system will ask to re-enter the option. 3.2.1’. If the manager enters the wrong id, the system will say "id not found" and ask to re-enter the id. Exceptions: No exceptions