Assignment 1 1651 Advanced Programming Merit

96 0 0
Assignment 1 1651 Advanced Programming Merit

Đ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

This exercise earns Merit points in C programming. This exercise presents design patterns, especially the Strategy pattern, APIE rules in objectoriented programming, exception handling, and error handling.

ASSIGNMENT FRONT SHEET Qualification BTEC Level HND Diploma in Computing Unit number and title Unit 20: Advanced Programming Submission date 8/12/2023 Date Received 1st submission Re-submission Date 8/12/2023 Date Received 2nd submission Student Name Tran Duc Long Student ID GCH210562 Class GCH1106 Assessor name Lê Việt Bách 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  Summative Feedback:  Resubmission Feedback: 2.1 Grade: Lecturer Signature: Assessor Signature: Date: Table of Contents Introduction OOP general concepts 2.1 Define and Structure of object-oriented programming 2.2 principles of object-oriented programming (APIE) 12 Abstraction: Simplifying Complexity 12 Polymorphism: Enhancing Flexibility 14 Inheritance: Streamlining Code Through Hierarchies 15 Encapsulation: The Foundation of Data Integrity 16 2.3 The SOLID Principles of Object-Oriented Programming 18 OOP scenario 24 Scenario -trees 24 Usecase Diagram 26 Class Diagram 29 Design Patterns 31 4.1 General concepts 31 Creational Design Patterns 31 Structural Design Patterns 31 Behavioral Design Patterns 32 4.2 Creational Design Patterns 32 Factory Method 32 Abstract Factory Method 34 Builder 36 Prototype 39 Singleton 41 Creational Pattern Scenario 43 4.3 Structural Design Pattern 46 Adapter 46 Bridge 48 Composite 51 Decorator 52 Facade 56 Flyweight 58 Proxy 60 Structural pattern scenario 63 4.4 Behavior Design Pattern 65 Chain of responsibility 65 Command 67 Iterator 69 Mediator 71 Memento 74 Observer 77 State 79 Strategy 82 Template method 84 Visitor 86 Behavior Pattern Scenario: 89 Design Pattern vs OOP 91 Conclusion 91 References 93 Table of Figures Figure 1: OOP example image Figure 2: OOP class diagram example image 10 Figure 3: Abstraction example image 13 Figure 4: Polymorphism example image 14 Figure 5: Inheritance example image 16 Figure 6: Encapsulation example image 18 Figure 7: SOLID example image 19 Figure 8: Single Responsibility Principle example 19 Figure 9: Open-Closed Principle example 20 Figure 10: Liskov Substitution Principle example 21 Figure 11: Interface Segregation Principle example 22 Figure 12: Dependency Inversion Principle example 23 Figure 13: Garden management usecase diagram image 26 Figure 14: Garden management class diagram image 29 Figure 15 Factory method (guru, 2020) 34 Figure 16: Abstract Factory structure image 35 Figure 17: Builder structure image 38 Figure 18: Prototype structure image 40 Figure 19 Singleton (guru, refactoring.guru, 2020) 43 Figure 20: Mouse production class diagram image 45 Figure 21 Adapter (guru, refactoring.guru, 2020) 48 Figure 22: Bridge structure image (guru, n.d.) 50 Figure 23: Composite stucture image (guru, n.d.) 52 Figure 24: Decorator structure image (guru, n.d.) 55 Figure 25 facade (guru, refactoring.guru, 2020) 58 Figure 26: Fly weight structure image (guru, n.d.) 59 Figure 27: Proxy structure image (guru, n.d.) 61 Figure 28: Vacation Planner class diagram 63 Figure 29: Chain of responsibility structure image 66 Figure 30: Command structure image 68 Figure 31 Iterator (guru, refactoring.guru, 2019) 71 Figure 32 Intent (guru, refactoring.guru, 2018) 73 Figure 35 memento (guru, refactoring.guru, 2020) 77 Figure 36 Observer (guru, refactoring.guru, 2018) 79 Figure 37: State structure image 81 Figure 38: Strategy structure image 84 Figure 39: Template structure image 86 Figure 40: Visitor structure image 88 Figure 41: Cooking plan class diagram image 89 Introduction This report presents an illustrative scenario to demonstrate the application of object-oriented design and analysis, aiming to explore the fundamental aspects of the object-oriented programming paradigm (OOP) Through this example, we aim to elucidate various OOP principles such as abstraction, polymorphism, inheritance, and encapsulation We have included diagrams and code representations for each wallet, highlighting their OOP characteristics Providing a practical example facilitates better understanding We will also supply examples and explanations for each type of diagram mentioned earlier Additionally, we will introduce the concept of design patterns, categorized into three types: creational, structural, and behavioral These patterns will be illustrated using diagrams within real-world scenarios, with discussions on how to implement them using UML classes and C# programming techniques OOP general concepts 2.1 Define and Structure of object-oriented programming a define Object-oriented programming (OOP) can be easily understood as creating a digital representation of a real-world object This approach allows users to interact with the program as if they are dealing with an actual object OOP has become a prevalent method in programming, though it's not always necessary as many programs can still be developed without it The key benefit of OOP lies in its code organization, which becomes increasingly vital as the project size and complexity grow OOP mandates thorough planning before coding begins, ensuring that the code adheres to a predefined structure from start to end This organized approach greatly simplifies the process of locating and resolving errors in the code (geeksforgeeks, 2023) Figure 1: OOP example image This provided example demonstrates the use of Object-Oriented Programming (OOP) to create a model of a dog In this model, the 'Dog' class acts as a blueprint for depicting a dog This class is responsible for defining various aspects of a dog, including its shape, size, name, age, and behaviors, which are displayed in the main program The model illustrated consists of four key components: class, object, attribute, and method In this context, the 'Dog' class represents a generic category of dogs, encompassing various breeds like Alaska, Belarus, Dogo, etc This class is equipped with specific attributes such as weight, height, and preferred food, which characterize a dog Additionally, it outlines common actions like running, playing, and eating that all dogs are capable of Each individual dog is an object of the 'Dog' class, identifiable by unique attributes like its name While the 'Dog' class is a broad category, the specific properties, methods, and objects within it allow for the differentiation of each unique dog within the larger class This approach showcases how OOP can be used to organize and represent complex entities in a structured and understandable manner Figure 2: OOP class diagram example image b Class In object-oriented programming (OOP), a class functions as a template for constructing objects, and each class is designed with a distinct purpose to describe a particular object Users create custom objects by employing the 'class' keyword for their definition A class essentially encapsulates a predefined set of plans, detailing how objects should be structured and behave Within a class, users define various components like attributes, objects, and methods (geeksforgeeks, 2023) Referring to the earlier dog example, the class represents the framework for creating a dog's representation This class lays out all the specific details of the dog, such as its characteristics and behaviors Attributes, objects, and methods unique to the dog are all intricately defined within the class, providing a comprehensive and organized way to represent

Ngày đăng: 24/02/2024, 01:57

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan