1. Trang chủ
  2. » Luận Văn - Báo Cáo

Information Technology Assignment 2 Unit Advanced Programming.pdf

106 0 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Nội dung

Trang 1

BTEC FPT INTERNATIONAL COLLEGE

INFORMATION TECHNOLOGYASSIGNMENT 2

UNIT: ADVANCED PROGRAMMING

STUDENT : HO TAN RINCLASS : IT16101STUDENT ID : BDAF200038

SUPERVISOR : NGUYEN HOANG ANH VU

Da Nang, December 2022

Trang 2

ASSIGNMENT 2 FRONT SHEETQualificationBTEC Level 4 HND Diploma in ComputingUnit number

Re-Date received (2nd submission)

Student name

HO TAN RIN (Leader)

DOAN XUAN DUYEN (Member)

PHAM MINH THONG (Member)

PHAN ANH TUAN (Member)

PHAN NGOC CHINH (Member)

Grading grid:

Trang 3

❒Summative Feedbacks: ❒Resubmission Feedbacks:

Internal Verifier’s Comments:

Signature & Date:

Trang 4

OBSERVATION RECORD

Student 1HO TAN RIN (Leader)

Description of activity undertaken

Assessment & grading criteria

How the activity meets the requirements of the criteria

Student signature: TAN RINDate: 14/12/2022

Assessor signature: Date:

Assessor name: Nguyen Hoang Anh Vu

Student 2DOAN XUAN DUYEN (Member)

Trang 5

Assessment & grading criteria

How the activity meets the requirements of the criteria

Student signature: XUAN DUYENDate: 14/12/2022

Assessor signature: Date:

Assessor name: Nguyen Hoang Anh Vu

Student 3PHAM MINH THONG (Member)

Description of activity undertaken

Trang 6

How the activity meets the requirements of the criteria

Student signature: MINH THONGDate: 14/12/2022

Assessor signature: Date:

Assessor name: Nguyen Hoang Anh Vu

Student 4PHAN NGOC CHINH (Member)

Description of activity undertaken

Trang 7

How the activity meets the requirements of the criteria

Student signature: NGOC CHINHDate: 14/12/2022

Assessor signature: Date:

Assessor name: Nguyen Hoang Anh Vu

Student 5PHAN ANH TUAN (Member)

Description of activity undertaken

Assessment & grading criteria

Trang 8

Student signature: ANH TUANDate: 14/12/2022

Assessor signature: Date:

Assessor name: Nguyen Hoang Anh Vu

Trang 9

TABLE OF CONTENT

INSTRUCTOR/ SUPERVISOR/ ASSESSOR……….i

OBSERVATION RECORD……….………iv

TABLE OF CONTENT ………ix

LIST OF TABLES AND FIGURES……….xi

LIST OF ACRONYM……….xii

INTRODUCTION ……… 1

CHAPTER 1 IMPLEMENT CODE APPLYING DESIGN PATTERNS……… 2

1.1 Build an application derived from uml class diagrams (P3)……… 2

1.1.1 Analysis the chosen scenario……… 2

1.1.2 OOP code implementation……… 3

1.1.3 Java Code Implements……….3

1.1.4 Result Of Code……… 12

1.2 Develop code that implements a design pattern for a given purpose M3……… 18

1.2.1 Comparison between class diagram before using design patterns and after using design patterns……… 18

1.2.2 Apply Singleton pattern and JDBC to the project……… 20

1.2.3 Why use Singleton for the project……… 33

CHAPTER 2 INVESTIGATE SCENARIOS WITH RESPECT TO DESIGN PATTERNS (LO4) 342.1 Discuss a range of design patterns with relevant examples of creational, structural and behavioural pattern types……… 34

2.1.1 Creational Pattern……… 34

2.1.2 Structural Pattern ……… 57

2.1.3 Behavioral patterns……… 69

Trang 10

scenarios (M4) 84

CONCLUSION……… 87

REFERENCES……… 88

CRITICAL EVALUATION……… 89

Trang 11

LIST OF TABLES AND FIGURES

Figure 1- 1 Management System 2

Figure 1- 2 Management System 3

Figure 1- 3 Add student 13

Figure 1- 4 Edit student 14

Figure 1- 5 Delete Student 15

Figure 1- 6 Sort student by gpa 16

Figure 1- 7 Sort student by name 17

Figure 1- 8 Show student 18

Figure 1- 9 Management System 19

Figure 1- 10 Management System 19

Figure 1- 11 XAMPP is running Apache and MySQL 20

Figure 1- 12 Create Databas 20

Figure 1- 13 Create Admin Table 21

Figure 1- 14 Set up admin table data 21

Figure 1- 15 Admin Table 22

Figure 1- 16 Create Admin Table 22

Figure 1- 17 Download JDBD Libraries 23

Figure 1- 18 DatabaseConnection Singleon 23

Figure 1- 19 Add admin 24

Figure 1- 20 Login Form 24

Trang 12

Figure 1- 22 Student Management Form 25

Figure 1- 23 Code Student Management Form 26

Figure 1- 24 Add Student Form 26

Figure 1- 25 Code Add Student Form 27

Figure 1- 26 Student Form 28

Figure 1- 27 Code Student Form 28

Figure 1- 28 Operation and Show Student Form 29

Figure 1- 29 Code Show Student Form 29

Figure 1- 30 Data in Admin table 30

Figure 1- 31 Login fail 30

Figure 1- 32 Login Management system 31

Figure 1- 33 Add Student in Management System 31

Figure 1- 34 Data in Student table 32

Figure 1- 35 Search, Update, Delete Student 32

Figure 1- 43 Object Adapter – Composition 57

Figure 1- 44 Class Adapter – Inheritance 58

Figure 1- 45 Bridge Pattern 62

Trang 13

Figure 1- 47 Interpreter Design Pattern 69

Figure 1- 48 Components in the model 71

Figure 1- 49 Template Method Design Pattern 75

Figure 1- 50 Command 79

Figure 1- 51 singleton pattern 84

Figure 1- 52 Prototype Pattern 85

Trang 14

Recently, we joined a software development business to assist them better document their internal software library, which had been produced with very little documentation As a result of the inadequate documentation, the organization finds it challenging to use their code in various projects Our job is to remedy this issue by demonstrating the value of UML diagrams in OOAD andthe application of Design Patterns.

As a result, we applied the student management object-oriented analysis and design to thistask to describe the characteristics of the object-oriented programming model This student management program exhibits a number of OOP traits (such as: encapsulation, inheritance, polymorphism, overriding, overloading, etc.) The audience will next be introduced to certain design patterns by way of real-world examples; the related patterns are then shown in UML class diagrams Let's find out in this assignment!

1

Trang 15

1.1 Build an application derived from uml class diagrams (P3)

1.1.1Analysis the chosen scenario

This is the manager's development plan Create a system that can simultaneously manage

subject teachers and students When users start the app for the first time, they can choose to view

the student or professor management displays The administration has the authority to add,update, and delete as well as perform query operations like search You will then be able tocomprehend what you have seen This is the manager's development strategy.

Figure 1- 1 Management System

Create a system that can simultaneously manage subject teachers and students When users start the app for the first time, they can choose to view the student or professor management displays The administration has the authority to add, amend, and remove data as well as perform query activities like searching Then, we'll be able to recognize our modifications This could be viewed as a management-simplifying strategy.

2

Trang 94

Can do undo

Reduce connection dependencies between Invoker and Receiver

Allows encapsulation of requirements into objects, easy data transfer between system components

Trang 95

Create an abstract Order.

Step 3

Create Buying and Selling command classes.

82

Trang 97

Use Broker to receive and process requests.

84

Trang 98

a) Singleton pattern

The singleton pattern is a design pattern that ensures that a class has only one instance andit provides a broad way to access that instance When the single design pattern is espoused, a single instance of a class will appear in the Java virtual machine To make up for it, a singleton class that conforms to the singleton pattern must provide a global access point In other words, a single design restricts the number of times a class can be represented The singleton pattern is used to create active jacks Maintaining thread pools or buffers also uses it.

Figure 1- 51 singleton pattern

b) Prototype Pattern:

Prototype is a design pattern belonging to the group of Creational Patterns - design patterns for instantiating objects of the class Prototype specifies the type of objects to be created using a template object, created by copying this template object without making the code dependent on their classes The Prototype Pattern is used when creating an object is costly and time consuming when you already have a similar object in existence The Prototype Pattern

85

Trang 99

properties if necessary.

Figure 1- 52 Prototype Pattern

c) Compare tables of patterns:

Singleton patternPrototype Pattern

Only 1 Instance of Singleton class is created during the program (only one instance in a class.).Hide class constructor (The hidden constructor ensures that singleton classes can never be instantiated from outside) The main idea in this model is to make that class responsible for controlling its instantiation (it is initialized only once)

Provides access to the global Object: + Eliminates unnecessary variables, managing only those required by the application + Singleton will only use a few resources, while global variables are often created from many languages / complex data types, so it consumes more resources

A class of Singleton type means: it has only a single instance, anywhere can access the instance

Adding and removing concrete classes at run-time: Prototype incorporates the process of instantiating anew object into the system simply by registering a prototype entity with the client That's a bit more flexible than other building patterns because the client can install and remove prototypes at run-time.Initialize a new object by changing some properties of the object (objects have little difference): A flexible system will let us define a certain action through association with an object ( means a method of a class) rather than defining a new class The client can perform another action by delegating the prototype class At the same time, this initialization method also helps us to declare a "new class" without having to program anything In fact, copying a prototype is like instantiating an object from a new class Prototype pattern helps to reduce the number of classes that the system needs to use

86

Trang 100

class has only 1 Instance, it is often used for solving problems that need access to applicationssuch as: Shared resource, Logger, Configuration, Thread pool, Used in some classes of core java like: java.lang.Runtime, java.awt.Desktop.

Many applications build systems from multiple parts and subsections The subparts are initialized from many other subparts (subdividing the problem) The prototype pattern also supports this That is, the parts can be instantiated from copying a prototype from another "struct" As long as the composites all represent Clone() and are used with different constructs as prototypes But Clone complex objects with circular dependencies (Circular Reference) can be very difficult.

d) The reason for choosing the template for the scenario:

The problem that comes from our scenario is that we use the same resources for a general purpose reading and writing log files, database And that's also why we use Singleton pattern Singleton pattern offers many advantages such as anyone can access the singleton class instance, call it anywhere, no need to search FindObjectOfType<T> or GetComponent, etc The data does not change because there is only one instance at best, can persist the data after changing the scene (DontDestroyOnLoad(object)) Singleton class supports interface while static class does not, this is the difference that needs to be determined to create a static class or a singleton class Support inheritance, static class does not support inheritance.

e) Conclusion

Singleton pattern is a very useful pattern Sometimes you want to make sure that only one instance of a class is instantiated and that your application only uses that instance.Although the Singleton pattern is quite easy to use and useful, we also need to be careful when using it to avoid abuse that makes it difficult to control the code and debug.

After completing this report, we understood and grasped this problem by demonstrating the value of UML diagrams in OOAD and the application of Design Patterns Moreover, we have applied the student management object-oriented analysis and design to this task to describe the

87

Trang 101

demonstrates OOP characteristics and displays in the UML class diagram.

Advanced programming is really great! Thanks to it, we understand how the devices aroundus work This is very interesting and wonderful Thankyou our mentor!

88

Trang 102

REFERENCES[1] Design Patterns for Dummies, Steve Holzner, PhD[2] Head First, Eric Freeman

89

Trang 103

CRITICAL EVALUATION

Through this post, I think I deserve an M for what I can do I have completed all requirements both M and P as instructed by the teacher and brief required.

90

Trang 104

After completing this report, we understood and grasped this problem by demonstrating the value of UML diagrams in OOAD and the application of Design Patterns Moreover, we have applied the student management object-oriented analysis and design to this task to describe the characteristics of the object-oriented programming model This student management program demonstrates OOP characteristics and displays in the UML class diagram.

Advanced programming is really great! Thanks to it, we understand how the devices aroundus work This is very interesting and wonderful Thankyou our mentor!

91

Trang 105

CRITICAL EVALUATION

After completing this Exercise with our own efforts and with the help of my mentor During the learning process, he was very dedicated to teaching and always answered our questions With the knowledge that I have learned, we have presented very fully the questions that Assignment raised in brief, with clear and specific images Moreover, we are confident that we can self-study and can make the advanced programming process for business.

During the development, we did our best to develop the project successfully Here is our group review:

- Ability, background knowledge, programming languages to develop projects.

- Have a strong sense of responsibility

- Encourage participants to finish allocated job on time on a regular basis.

- Afraid to seek assistance from others.- Frequently becoming enraged due to bugs.- Work alone and fully commit to the task at hand.

- Always complete tasks on time and in accordance with the guidelines.

- Products made well, are satisfied and workers of the company and customers.

- Create cooperative relationships to develop later and have better website transactions and products.

- Never stop learning while you're at work.

- Always looking forward to being able to collaborate on new projects with good teams to develop great products together.Also, we have mastered the basics of advanced programming, so we can definitely create a project to help more people connect with each other and make life better!

92

Trang 106

3 javatpoint.com (2022) Design Patterns in Java [Online] Available:

93

Ngày đăng: 13/05/2024, 14:54