Docsity

Design Patterns in Software Development, Study Guides, Projects, Research of Law

Toggle sidebar
bg1
ASSIGNMENT 2 FRONT SHEET
Qualification
BTEC Level 5 HND Diploma in Computing
Unit number and title
Unit 20: Advanced Programming
Submission date
Date Received 1st submission
Re-submission Date
Date Received 2nd submission
Student Name
Pham Hai Viet
Student ID
GCD210217
Class
GCD1101
Assessor name
Pham Thanh Son
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
Viet
Grading grid
P3
P4
M3
M4
D3
D4
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
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a

Partial preview of the text

Download Design Patterns in Software Development and more Study Guides, Projects, Research Law in PDF only on Docsity!

ASSIGNMENT 2 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Unit 20: Advanced Programming Submission date Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Pham Hai Viet Student ID GCD Class GCD1101 Assessor name Pham Thanh Son 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 Viet Grading grid P3 P4 M3 M4 D3 D

Summative Feedback:Resubmission Feedback: Grade: Assessor Signature: Date: Lecturer Signature:

Chapter I: Introduction

This study will demonstrate how to apply design patterns to produce software that actually solves a problem. The report is divided into three sections:

  • The program uses a Design Pattern to address real problems. By mixing object-oriented programming with the
  • Chapter I: Introduction
  • Chapter II: Build an application derived from UML Class Diagrams (P3)
      1. A short description of the chosen scenario
      1. UML Class Diagram
      1. Solution
      1. OOP in the diagram
      1. Structure of application
      1. Code implements
      1. Result of running code
  • pattern types (P4) Chapter III: Discuss a range of design patterns with relevant examples of creational, structural and behavioral
      1. Introduce about Design Pattern
      1. Creational Pattern Types
      1. Behavioral Pattern Types
      1. Structural Pattern Types.................................................................................................................................
  • Figure i: UML Class diagram...................................................................................................................................
  • Figure ii: Inheritance
  • Figure iii: Encapsulation
  • Figure iv: Polymorphism
  • Figure v: Abstraction
  • Figure vi: Structure of application
  • Figure vii: Code snippet
  • Figure viii: Code snippet
  • Figure ix: Code snippet
  • Figure x: Code snippet
  • Figure xi: Code snippet
  • Figure xii: Code snippet
  • Figure xiii: Code snippet
  • Figure xiv: Code snippet
  • Figure xv: Code snippet
  • Figure xvi: Code snippet
  • Figure xvii: Code snippet
  • Figure xviii: Code snippet
  • Figure xix: Code snippet
  • Figure xx: Code snippet
  • Figure xxi: Code snippet
  • Figure xxii: Code snippet
  • Figure xxiii: Code snippet
  • Figure xxiv: Code snippet
  • Figure xxv: Code snippet
  • Figure xxvi: Code snippet
  • Figure xxvii: Code snippet
  • Figure xxviii: Code snippet
  • Figure xxix: Code snippet
  • Figure xxx: Code snippet
  • Figure xxxi: Code snippet
  • Figure xxxii: Code snippet
  • Figure xxxiii: Code snippet
  • Figure xxxiv: Code snippet
  • Figure xxxv: Code snippet
  • Figure xxxvi: Code snippet
  • Figure xxxvii: Code snippet
  • Figure xxxviii: Code snippet
  • Figure xxxix: Code snippet
  • Figure xl: Singleton Pattern
  • Figure xli: Factory pattern.......................................................................................................................................
  • Figure xlii: Builder pattern
  • Figure xliii: Iterator Pattern
  • Figure xliv: Strategy pattern....................................................................................................................................
  • Figure xlv: Observer Pattern
  • Figure xlvi: Decorator Pattern
  • Figure xlvii: Flyweight Pattern
  • Figure xlviii: Adapter Pattern
  • Depends on the the management Student system has. We have planned to do it and chose Best Design Pattern to do so.We chose to use Decorator Patterns to script that table after reaching consensus. Class The diagram that we have created to do the aforementioned project is shown below

Figure i: UML Class diagram

Figure ii: Inheritance

  • Inheritance:  Student class (inheriting from Person class): Represents a student and extends the Person class. Include additional attributes such as ID and list of subjects. Provide methods for adding and deleting courses to students. Implement PrintInfo() method to display student information.  Teacher class (inheriting from Person class):

Represents a teacher and extends the Person class. Include the additional TeacherID attribute. Implement PrintInfo() method to display teacher information.  Encapsulation

  • In the source code you provided, the encapsulation functionality is demonstrated through the use of access modifiers such as private , internal , and public to manage access to the elements of the classes. Figure iii: Encapsulation
  • The Person class is declared with internal access, accessible only from the same assembly (project) and not from other assemblies. The Student class and the Teacher class both inherit from the Person class and use internal access, allowing access only from the same assembly.

Figure iv: Polymorphism

  • Polymorphism: Polymorphic functionality is demonstrated by using abstract methods and overriding them in subclasses. Specifically:  The Person class is an abstract class that has an abstract method PrintInfo(). The Student and Teacher subclasses inherit the Person class and override the PrintInfo() method to customize how student and teacher information is displayed.

 Abstraction

 In this case, the Student and Teacher subclasses inherit from the Person class and implement the PrintInfo() method separately. This allows each subclass to customize their own display of information.  Using such an abstract class and abstract method helps to define a common contract for the subclasses, ensuring that each subclass provides the right implementation for the abstract method.

  • Beside of that, there are two types of relationships between classes:  Inheritance relationship: The class Student inherits from the class Person using the syntax : base(name, age). This indicates that Student is a specialized type of Person and inherits its attributes and methods. The Student class extends the functionality of the Person class by adding additional attributes like ID and Subjects.  Association relationship:

 The class Student has a list of Subject objects as an attribute called Subjects. This represents an association relationship between the Student class and the Subject class. Each Student can be associated with multiple Subject objects.  The Program class and the Student, Subject, and Teacher classes have an association because the Program class contains lists of objects of these classes. This is represented by arrows from the Program class to the Student, Subject, and Teacher classes with the labels "+students", "+subjects", and "+teachers" respectively.

 Use Relatioship: The Program class and the Login class have a use relationship because the Program class creates a Login object to authenticate the user before continuing to run the main program. This is represented by an arrow from the Program class to the Login class with the label "uses".

5. Structure of application - The program has 6 classes in total, as shown in the structure below. In addition, to learn more about the properties and methods in each class, proceed to the following section

Figure vi: Structure of application

6. Code implements - Login: The Login class in the provided code represents the functionality of user authentication in a system. Here is a brief explanation of this class:  Properties: username: Represents the username of the user. password: Represents the password of the user.  Constructor: Login(string username, string password): Initializes an instance of the Login class with the provided username and password.  Method: Authenticate(): Performs the authentication process by prompting the user to enter their username and password. It compares the entered credentials with the stored username and password. If the credentials match, it displays a success message and returns true, indicating a successful login. Otherwise, it displays a failure message and returns false, indicating an unsuccessful login.