1651 GCS0701B - Gcs17556 - Nguyen Cao Tri [PDF]

  • 0 0 0
  • Gefällt Ihnen dieses papier und der download? Sie können Ihre eigene PDF-Datei in wenigen Minuten kostenlos online veröffentlichen! Anmelden
Datei wird geladen, bitte warten...
Zitiervorschau

Assignment 1 Report

[1670] Advanced Programming Learner’s Name: Nguyen Cao Tri Assessor Name: Le Ngoc Thanh Class: ................. GCS0705B ID: ......... GCS17556 Assignment due: 22 Aug 2020 Assignment submitted: 22 Aug 2020

ASSIGNMENT 1 Qualification

BTEC HND Diploma in Computing and Systems Development

Unit number and title

Unit 19: Object Oriented Programing

Assignment due

22 Aug 2020

Assignment submitted

22 Aug 2020

Learner’s name

Nguyen Cao Tri

Assessor name

Le Ngoc Thanh

Learner declaration: I certify that the work submitted for this assignment is my own and research sources are fully acknowledged.

Learner signature

Date

Grading grid P1

P2

M1

Assignment title

M2

D1

D2

Assignment 1: OOP principles, features and design.

In this assignment, you will have opportunities to provide evidence against the following criteria. Indicate the page numbers where the evidence can be found.

Assessment criteria

Expected evidence

Task no.

LO1. Understand the principles of object oriented programming. - Object/Class, P1. Discuss the principles; characteristics and features of object orientated programming.

- Abstraction, - Encapsulation, - Inheritance, - Polymorphism,

- Abstract classes, LO2. Be able to design object oriented programming solutions. - Interfaces

1

Assessor’s Feedback

P2. Identify the objects and

- Use-case diagrams

data and file structures

- Class diagrams

required to implement a given design.

- Pseudo-codes

2

- Activity Diagrams. Design an object orientated programming solution for a given problem.

Assessment criteria

- Judgments for features have been included/excluded and why certain features have been used over others (where applicable)

Expected Evidence

Feedback (note on Merit/Distinction if applicable)

Merit descriptor No. (M1) Merit descriptor No. (M2) Distinction descriptor No. (D1) Distinction descriptor No. (D2)

Summative feedback:

Assessor’s Signature:

Date:

ASSIGNMENT 1 BRIEF Unit Number and Title

20: Advance Programming

Academic Year

2020

Unit Tutor

Le Ngoc Thanh

Assignment Title

Assignment 1

Issue Date Submission Date

22 Aug 2020

IV Name & Date

Pass

Merit

Distinction

LO1 Examine the key components related to the object-orientated programming paradigm, analysing design pattern types P1 Examine the

M1 Determine a

D1 Analyse the relationship

characteristics of the

design pattern from

between the object-

object-orientated

each of the

orientated paradigm and

paradigm as well as

creational, structural

design patterns.

the various class

and behavioural

relationships.

pattern types.

FRM03_Assignment brief_14.11.2012

Page 6

LO2 Design a series of UML class diagrams P2 Design and build

M2 Define class

class diagrams using a

diagrams for specific

D2 Define/refine class

UML tool.

design patterns using

diagrams derived from a given

a UML tool.

code scenario using a UML tool.

Scenario You’ve just made a contract with FPT Academy International, and are about to be appointed as a Project Leader for a group of programmers to develop its Student Management System.

Specific requirements

In this Student Management System, you are required to create an application to store list of students and list of lecturers. Following information are to be stored for each student:

(see Appendix for assessment criteria

- stdId: The student ID of the form like GTxxxxx or GCxxxxx (x: is a digit)

and grade

- stdName: Student name

descriptors)

- stdDoB: Student date of birth - stdEmail: Student email - stdAddress: Student address - stdBatch: The batch (class) of the student Following information are to be stored for each lecturer:

FRM03_Assignment brief_14.11.2012

Page 7

- lecId: Lecturer ID with 8 digits (fixed) - lecName: Lecturer - lecDoB: Lecturer date of birth - lecEmail: Lecturer email - lecAddress: Lecturer address - lecDept: Lecturer department (e.g., Computing, Business, etc) This application will need to provide following functionalities via a menu ======================= 1. Manage Students 2. Manage Lecturers 3. Exit ======================= Please choose: When user selects 3, the program will exit. When user selects 1, the program will display submenu for managing students: ======================= 1. Add new student 2. View all students 3. Search students 4. Delete students 5. Update student

FRM03_Assignment brief_14.11.2012

Page 8

6. Back to main menu ======================= Please choose: When user selects 2, the program will display submenu for managing lecturers: ======================= 1. Add new lecturer 2. View all lecturers 3. Search lecturers 4. Delete lecturers 5. Update lecturer 6. Back to main menu ======================= Please choose: For the submenu: When user chooses 1, program will prompt user to input student’s/lecturer’s information (specified previously). After that, program will validate the input data and if they are all valid, program will add a new student/lecturer to the current list of students/lecturers. Program should inform to the user corresponding messages. When user chooses 2, the program will list all the students/lecturers to the screen, each student/lecturer in a row and student’s/lecturer’s data FRM03_Assignment brief_14.11.2012

Page 9

fields are separated by ‘|’. When user chooses 3, the program will ask user to input student’s/lecturer’s name to search for, the user can just type part of the name in order to search for complete student/lecturer information. When user chooses 4, program will ask user to input student/lecturer id to delete the student/lecturer with the specified id if it exists, otherwise, it will display a message to inform users that the student/lecturer with such id doesn’t exist. When user chooses 5, program will first ask user to input student/lecturer id to update, once inserted and a student/lecturer with the inserted id exists, it will display current data for each field of the student/lecturer and user can type in new data to update or just press enter to keep the current data for the field. When user chooses 6, program will back to the main menu. Task 1 Produce a written, self-learning course for managers/senior developers that explain the principles and features of OOP and that show how OOP is good for code re-use. You can include appropriate sample Java code where it aids your points and/or provides further clarification. Ensure that any diagrams that are included have captions and are referenced in the text. Hint: You must include the following terms - Object/Class, - Abstraction,

FRM03_Assignment brief_14.11.2012

Page 10

- Encapsulation, - Inheritance, - Polymorphism (Overloading and Overriding), - Abstract classes, - Interfaces Task 2 Problem Analysis, for the scenario above. You need to produce a full design for the requirements given. The design must include - Use-case diagrams for the most important features; - Class diagrams for all objects identified as well as class relationships. - Pseudo-code for the Algorithms for the main functionalities (3 flowcharts for most complex functions). Example code can be used to help clarify OOP features. For the assignment assessments, you are required to: Student guidelines

1. Produce a design in UML that fully utilizes OOP principles and features. (Use case, class diagrams, collaboration diagrams etc.).

Submission requirements

Students are expected to submit hard copy of assignment

FRM03_Assignment brief_14.11.2012

Page 11

Grade Descriptor PASS criteria

LO

Learning outcome

AC

(LO)

In this assessment you will have the

Task

opportunity to present evidence

no.

that shows you are able to: LO1

Examine the key

1

Examine the characteristics of the

components related

object-orientated paradigm as well

to the object-

as the various class relationships.

1

orientated programming paradigm, analysing design pattern types LO2

Design a series of

Design and build class diagrams

UML class diagrams

using a UML tool.

In addition to the above PASS criteria, this assignment gives you the opportunity to submit evidence in order to achieve the following MERIT and DISTINCTION grades Grade Descriptor M1

Indicative characteristic/s

Contextualization

Determine a design pattern from each of the creational, structural and behavioural pattern types.

FRM03_Assignment brief_14.11.2012

Page 12

M2

Define class diagrams for specific design patterns using a UML tool.

D1

Analyse the relationship between the object-orientated paradigm and design patterns.

D2

Define/refine class diagrams derived from a given code scenario using a UML tool.

This brief has been verified as being fit for purpose

Internal Verifier 1

Internal Verifier 2

FRM03_Assignment brief_14.11.2012

Signature

Date

Signature

Date

Page 13

Contents P1 characteristics of the object-orientated paradigm as well as the various class relationships. .................................................................................................................. 15 1.

Object-oriented programming ................................................................................... 15

2.

Abstract calculation concept ..................................................................................... 16

3.

Encapsulation. ....................................................................................................... 17

4.

The concept of inheritance ................................................................................. 18

P2 Design and build class diagrams using a UML tool.................................................... 26 Information Gathering:..................................................................................................... 26 Use-case Diagrams: ........................................................................................................ 28 Class Diagrams: .............................................................................................................. 32 Activity Diagram: ............................................................................................................. 35 Referrences : ................................................................................................................... 37

FRM03_Assignment brief_14.11.2012

Page 14

P1 characteristics of the object-orientated paradigm as well as the various class relationships. 1. Object-oriented programming Object-oriented programming (OOP) is one of the very important programming techniques nowadays. It is applicable in most practical construction applications at businesses. Most popular programming languages and programming frameworks such as Java, C# and .NET support object-oriented programming. Most programmers have learned about objectoriented programming in universities, but the basic principles of object-oriented programming sometimes do not know how to misuse the wrong philosophy of programming. object-oriented. In this article, I will summarize the basic principles of object-oriented programming to help you get an overview of OOP and how convenient it is. What is object-oriented programming? Object-oriented programming is a programming technique that allows programmers to create objects in code that abstract actual objects in life. This approach is currently very successful and has become one of the software development templates, especially for software using on business. When developing applications using OOP, we will define classes (classes) to model actual objects. In the application these classes will be initialized into objects and during the time the application runs, the methods of this object will be called. What is the class that defines the object: include methods and properties. An object is just an FRM03_Assignment brief_14.11.2012

Page 15

instance of the class. Classes interact with each other by the public API: its set of methods, its public properties. 2. Abstract calculation concept Abstraction in Java is a non-specific property that only names the problem. It is a process of hiding the inner activities and only showing the essential features of the object to the user. For example, if a person uses his phone to send a message, he will enter the text of the message, the recipient's information and press the send button. When he started sending the message, he didn't know what was going on during the sending process but only knew if the result of the message was successfully sent to the recipient. So in this example, the process of sending the message has been hidden and only shows the functions that the user needs is the function of entering the message content, the recipient information, the result of sending the message successfully or failure. That is abstraction. Advantages of using abstraction for programming: Abstraction allows programmers to eliminate the complexity of an object by only giving the object's needed attributes and methods in programming, improving the maintainability of the system. Abstraction helps us focus on the essential core of the object rather than being concerned with how it works. Abstraction provides many extended features when used in combination with polymorphism and inheritance in object-oriented programming. Java abstracts through abstract classes and interfaces. In this article, I will guide you to learn about abstract classes and abstract methods

FRM03_Assignment brief_14.11.2012

Page 16

3.

Encapsulation.

Definition -

This property does not allow the user to change the intrinsic state of an object. Only the object's internal methods allow to change its state. In any way, allowing the external environment to affect the internal data of an object is entirely up to the person writing the code. This is a property that ensures the integrity of the object. Encapsulation enables a group of properties, methods and other members to be considered a single unit or object. Example

FRM03_Assignment brief_14.11.2012

Page 17

Implementation - Public: Access to all code in the program - Private: Access to only members of the same class - Protected: Access to members of same class and its derived classes - Internal: Access to current assembly 4. The concept of inheritance + Definition -

This feature allows an object to have the properties that other objects already have through inheritance. This allows objects to share or expand available features without having to redefine. However, not all object-oriented languages have this property. - Multi-level Hierarchy: A derived class can have only one direct base class. However, inheritance is transitive. If ClassC is derived from ClassB, and ClassB is derived from ClassA, ClassC inherits the members declared in ClassB and ClassA.

.+Purpose FRM03_Assignment brief_14.11.2012

Page 18

-

The purpose of inheritance is to reuse common methods and attributes among

classes without recreating them. Reusability of a code enables you to use the same code in different applications with little or no changes. +Syntax -

: +Example

-

I am presenting an example that is quite familiar to movies viewer. You know in the “Lion King”, Simba is Mufasa son and in “Lion King 2”, Kiara is Simba daughter, meaning Simba inherits from Mufasa and Kiara inherits from both Simba and Mufasa:

FRM03_Assignment brief_14.11.2012

Page 19

FRM03_Assignment brief_14.11.2012

Page 20

Protected Access Modifier: - The protected access modifier protects the data members that are declared using this modifier. - The protected access modifier is specified using the protected keyword. - Variables or methods that are declared as protected are accessed only by the class in which they are declared or by a class that is derived from this class. - The following figure displays an example of using the protected access modifier:

FRM03_Assignment brief_14.11.2012

Page 21

Base keyword: - The base keyword allows you to do the following: +

Access variables and methods of the base class from the derived class

+

Re-declair the methods and methods defiened in the base class

+

Invoke the derived class data members

+

Access the base data using “base” keyword

- Example:

FRM03_Assignment brief_14.11.2012

Page 22

New keyword: - The new keyword can either be used as an operator or as a modifier in C#. This allows you to redefine the inherited methods or variables in the derived class. Since redefining the base class members in the derived class results in base class members being hidden, the only way you can access these is by using the base keyword.

- Syntax:

4 . Concept of polymorphism Polymorphic techniques in object-oriented programming languages enable programmers to increase the ability to reuse code written in a general way and can change behavior flexibly. depending on the type of object. Polymorphism in Java is understood in each case, different circumstances, the object has different morphology depending on the context. The polymorphic object is FRM03_Assignment brief_14.11.2012

Page 23

considered to be a special object because sometimes it becomes another object and sometimes it becomes another object (depending on the situation). This "role-playing" in different objects makes it possible for the original polymorphic object to perform different actions of each specific object.

5. Interface Features of Interface The interface has only abstract methods. Interface is a technique to achieve complete abstraction and multiple inheritance in Java. The interface always has a modifier: public interface, whether you explicitly specify it or not. If there are fields, they are: public static final, whether or not you specify them. Its methods are abstract methods, meaning there is no function body, and all modifiers are: public abstract, whether you declare it or not. Interface has no constructor. An interface is not a class. Writing an interface is like writing a class, but they have two different definitions. A class describes the properties and behavior of an object. An interface contains the behaviors a class implements. Unless an interface implementation class is an abstract class, all of the interface's methods need to be defined in the class. The Java Compiler adds the keyword public abstract before the interface method and public static final keywords before data members.

An interface similar to a class by the following points: FRM03_Assignment brief_14.11.2012

Page 24

An interface is written in a file in .java format, with the interface name the same as the file name. The interface's Bytecode is saved in a .class file format. Declaring interfaces in a package, the corresponding bytecode files also have a directory structure with the same package name.

An interface differs from a class in some of the following ways: You cannot initialize an interface. An interface does not contain any Contruct or functions. All interface methods are abstract. An interface cannot contain any fields except those that are both static and final. An interface cannot inherit from a class, it is implemented by a class. An interface can inherit from many other interfaces. 2- Analysis

FRM03_Assignment brief_14.11.2012

Page 25

P2 Design and build class diagrams using a UML tool. Information Gathering: Based on the scenario, we are developing a Student Management System for FPT Academy International. The system requirement the information below:

FRM03_Assignment brief_14.11.2012

Page 26

FRM03_Assignment brief_14.11.2012

Page 27

Use-case Diagrams: In order to present a brief look at what the system can actually do, we need to draw out a use-case diagram - a diagram showing how users in the system can interact with the system via the features. Thus, and according to the above information, we can have the following use-case diagrams

FRM03_Assignment brief_14.11.2012

Page 28

In the above diagram, you can see that User (or Admin) can access 3 main option, “Managing Student”, “Managing Lecturer” and “Exit” Choosing “Managing Student”, system will display a Menu allowing user to manage the students via the functionalities (Add, Search, View, Delete, Update) Choosing “Managing Lecturer”, system will display a Menu allowing user to manage the lecturers via the functionalities (Add, Search, View, Delete, Update) Choosing “Exit”, system will end. We can briefly imagine how the system would work through the above diagram, now we will take a closer look on how we can manage the students and the lecturers.

FRM03_Assignment brief_14.11.2012

Page 29

FRM03_Assignment brief_14.11.2012

Page 30

As you can see, the user will manage the students and lecturers through the functionalities Add new Student/Lecturer, View all Student/Lecturer, Search Student/Lecturer, Update Student/Lecturer, Delete Student/Lecturer and Return to Main Menu in case we want to stop adjust and examine the target or want to change to the other Managing side.

FRM03_Assignment brief_14.11.2012

Page 31

Class Diagrams: After knowing the actual functionalities that will be used to manage the targets, we now need to determine the classes, the interfaces and their relationship that will be used in the system. And to determine those, I drew the following Class Diagram - one of the most important diagrams of software design, it shows the structure and relationship between the components that make up the software.

As you can see in the diagram, there are 6 classes (Main Menu, Student Menu, Lecturer Menu, Student, Lecturer, Person) and one interface (IFunction) that will be used in the system and their relationships are also clearly defined. FRM03_Assignment brief_14.11.2012

Page 32

Name

Type

Description

Relationship

Main Menu

Class

Including the ability to

Association

access the menu of

Relationships:

student and lecturer as well as exit the program Function

Interface

With “Student Menu” and “Lecturer Menu”

Including the functionalities

Generalization

of Add new object, View all

relationship: inherit by

objects, Search object,

“Student Menu” and

Delete object, Update

“Lecturer Menu”

object and Return to Main Menu (object here refer to both student and lecturer) Person

class

Including the properties of

Generalization

the object (student and

relationship: inherit by

lecturer): Name, Date of

“Student” and “Lecturer”

birth, Address, Email with the conditions in the scenario Student

class

Including the properties

Generalization

from “Person” and other

relationship: inherit from

properties: Id and Name

“Person”.

with the conditions in the scenario, Student List for data storage

FRM03_Assignment brief_14.11.2012

Dependency Relationships: with “Student Menu”

Page 33

Lecturer

class

Including the properties

Generalization

from “Person” and other

relationship: inherit from

properties: Id and Name

“Person”.

with the conditions in the scenario, Lecturer List for data storage

Student

class

Menu

Dependency Relationships: with “Lecturer Menu”

Including the functionalities

Association

in the “function” as well as

Relationships:

the data in the “Student”

With “Main Menu”. Dependency Relationships: with “Student”

Lecturer Menu

Class

Including the functionalities

Association

in the “function” as well as

Relationships:

the data in the “Lecturer”

With “Main Menu”. Dependency Relationships: with “Lecturer”

FRM03_Assignment brief_14.11.2012

Page 34

Activity Diagram: As you know briefly about the functionalities of the system (thanks to the Use-case diagrams above), now we will take a look at workflows of the functionalities and the flow of the activities, events occur as the functionalities is executed via the following Activity Diagram-a diagram that focuses on describing the activities, processing threads within the system and can be used to describe processes in a system, flows of a function or activities of an object.

With the above diagram, we can now see the flow of the functionalities. As we start the program, we can either choose to access the Student, Lecturer Management or Exist to end the program. After accessing either Student or Lecturer Management Menu, we can use the functionalities to manage either students or lecturers, also we can return to the main menu to exist or accessing other Management Menu. Note: after every functional (except the “Return to Main”), system will return to either Student or Lecturer Management Menu depend on the functionality for continuing managing the targets. And to take a clearer look at how the events occur as the FRM03_Assignment brief_14.11.2012

Page 35

functionalities are executing, we have the following diagrams that sequentially are “Student Management Activity Diagram” and “Lecturer Management Activity Diagram”:

FRM03_Assignment brief_14.11.2012

Page 36

Referrences :

1. yellowcodebooks, V. (2019). Java Bài 33: Interface - YellowCode.Books. [online] YellowCode.Books. Availableat:https://yellowcodebooks.com/2017/10/15/java-bai33-interface/#Cac_Dac_Tinh_Cua_Interface [Accessed 24 May. 2020]. 2. Viblo. (2019). 4 tính chất của lập trình hướng đối tượng trong Java. [online] Available at:

https://viblo.asia/p/4-tinh-chat-cua-lap-trinh-huong-doi-tuong-trong-

java-bJzKmMjPK9N [Accessed 24 may. 2020]. 3. Viblo. (2019). So sánh Interface và Abstract trong lập trình hướng đối tượng.. [online] Available at: https://viblo.asia/p/so-sanh-interface-va-abstract-trong-laptrinh-huong-doi-tuong-63vKjpk6l2R [Accessed 24 may. 2020]. 4. Vi.wikipedia.org. (2019). Lập trình hướng đối tượng. [online] Available at: https://vi.wikipedia.org/wiki/L%E1%BA%ADp_tr%C3%ACnh_h%C6%B0%E1%BB %9Bng_%C4%91%E1%BB%91i_t%C6%B0%E1%BB%A3ng [Accessed 24 may. 2020]. 5. Vi.wikipedia.org. (2019). Giao thức (lập trình hướng đối tượng). [online] Available at: https://vi.wikipedia.org/wiki/Giao_th%E1%BB%A9c_(l%E1%BA%ADp_tr%C3%AC nh_h%C6%B0%E1%BB%9Bng_%C4%91%E1%BB%91i_t%C6%B0%E1%BB%A 3ng) [Accessed 24 may. 2020]. 6. GeeksforGeeks.(2019). C#|AbstractClasses-GeeksforGeeks.[online]Available at: https://www.geeksforgeeks.org/c-sharp-abstract-classes/

FRM03_Assignment brief_14.11.2012

Page 37

[Accessed 24 may. 2020]. 7. viblo.asia. (2019). Introduce to design pattern. [online] Available at: https://viblo.asia/p/tonghop-cac-bai-huong-dan-ve-design-pattern-23-mau-co-bancua-gof-3P0lPQPG5ox [Accessed 24 May. 2020]. 8. Unit 1 – Programming 2019, Lecture 3-4, University of Greenwich (Alliance with Vietnam FPT Education), United Kingdom [Accessed 24 May. 2020]. 9. Unit 1 – Programming 2019, Lecture 5-6, University of Greenwich (Alliance with Vietnam FPT Education), United Kingdom [Accessed 24 May. 2020]. 10. Unit 1 – Programming 2019, Lecture 5-6, University of Greenwich (Alliance with Vietnam FPT Education), United Kingdom [Accessed 24 May. 2020]. 11. Unit 1 – Programming 2019, Lecture 5-6, University of Greenwich (Alliance with Vietnam FPT Education), United Kingdom [Accessed 24 May. 2020]. 12. Unit 1 – Programming 2019, Lecture 5-6, University of Greenwich (Alliance with Vietnam FPT Education), United Kingdom [Accessed 24 May. 2020].

FRM03_Assignment brief_14.11.2012

Page 38