1651 huynhhuuhoang gcs210952 assignment 1re

22 18 0
1651   huynhhuuhoang gcs210952   assignment 1re

Đ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

asm1 cac ban se pass mon hoc nay neu mua bai cua minh chuc cac ban hoc tap tot nhe sdfghjkutyoukhljosldjthd;jeojsdkfgjas;lgjas;kjghSFDJSKJDJFKSDJKGJKSDFjSDG;KSAGKesKJASG;HJG;KjfbKJDZWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW

Higher Nationals in Computing Unit 20: Advanced Programming ASSIGNMENT Learner’s name: ID: Class: Subject code: 1651 Assessor name: PHAN MINH TAM Assignment due: Assignment submitted: ASSIGNMENT FRONT SHEET Qualification BTEC Level 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 HUYNH HUU HOANG Student ID GCS210952 Class GCS1007 Assessor name Phan Minh Tam 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: Grade: Signature & Date:  Resubmission Feedback: Assessor Signature: Date: ASSIGNMENT BRIEF Qualification BTEC Level HND Diploma in Business Unit number Unit 20: Advanced Programming Assignment title Examine and design solutions with OOP and Design Patterns Academic Year Unit Tutor Issue date Submission date IV name and date Submission Format: Format: The submission is in the form of a group written report and presentation This should be written in a concise, formal business style using single spacing and font size 12 You are required to make use of headings, paragraphs and subsections as appropriate, and all work must be supported with research and referenced using the Harvard referencing system Please also provide a bibliography using the Harvard referencing system Submission Students are compulsory to submit the assignment in due date and in a way requested by the Tutors The form of submission will be a soft copy in PDF posted on corresponding course of http://cms.greenwich.edu.vn/ Note: The Assignment must be your own work, and not copied by or from another student or from books etc If you use ideas, quotes or data (such as diagrams) from books, journals or other sources, you must reference your sources, using the Harvard style Make sure that you know how to reference properly, and that understand the guidelines on plagiarism If you not, you definitely get fail Assignment Brief and Guidance: Scenario: You have recently joined a software development company to help improve their documentation of their in-houses software libraries which were developed with very poor documentation As a result, it has been very difficult for the company to utilise their code in multiple projects due to poor documentation Your role is to alleviate this situation by showing the efficient of UML diagrams in OOAD and Design Patterns in usages Tasks You and your team need to explain characteristics of Object-oriented programming paradigm by applying Object-oriented analysis and design on a given (assumed) scenario The scenario can be small but should be able to presents various characteristics of OOP (such as: encapsulation, inheritance, polymorphism, override, overload, etc.) The second task is to introduce some design patterns (including types: creational, structural and behavioral) to audience by giving real case scenarios, corresponding patterns illustrated by UML class diagrams To summarize, you should analyze the relationship between the object-orientated paradigm and design patterns The presentation should be about approximately 20-30 minutes and it should be summarized of the team report Learning Outcomes and Assessment Criteria Pass Merit Distinction LO1 Examine the key components related to the object-orientated programming paradigm, analysing design pattern types P1 Examine the characteristics of the objectorientated paradigm as well as the various class relationships M1 Determine a design pattern from each of the creational, structural and behavioural pattern types D1 Analyse the relationship between the object-orientated paradigm and design patterns LO2 Design a series of UML class diagrams P2 Design and build class diagrams using a UML tool M2 Define class diagrams for specific design patterns using a UML tool D2 Define/refine class diagrams derived from a given code scenario using a UML tool Table of Contents Unit 20: Advanced Programming ASSIGNMENT ASSIGNMENT ANSWERS P1 OOP general concepts I What is OOPs 1 Class and Object a Class b Object Inheritance Polymorphism Encapsulation 5 Abstraction II Object oriented relationship Inheritance: Composition: Association: Aggregation 10 P2 Design and build class diagrams using a UML tool 11 Scenario 11 Use Case Diagram 11 Class Diagram 12 4.Sequence diagram 13 REFERENCES 15 ASSIGNMENT ANSWERS P1 OOP general concepts I What is OOPs Object-oriented programming (OOP) is a computer programming model that organizes software design around data, or objects, rather than functions and logic An object can be defined as a data field that has unique attributes and behavior Class and Object a Class A class can be understood as a template or a blueprint, which contains some values, known as data members, and some set of rules, known as behaviors or methods The data and methods that are defined in the class are automatically taken when an object is created The class is a template or blueprint for objects One can make as many objects as they want to be based on a class Page |1 Explain: • In class Person: The Person class has two properties (Name and Age) to store information about the person's name and age The Person class has a method (DisplayInfo) to display information about the person Page |2 b Object A class contains the properties and behaviors of a set of objects, many objects can be formed using a class • Take the example of a dog as an object • There are different varieties of dogs which means different varieties of objects according to the dog class For example, one dog has black color, another dog may have grey color, or white, etc • However, we can notice that most of the behaviors are the same like barking, wagging their tail, eating, sleeping, etc • Properties and behavior of these objects can be the same but their values would be different Page |3 Explain: • Person object: In the Main section of the program, we create a new Person object named person1 Then we assign the value "John" to the Name property and the value 25 to the Age property of person1 Finally, we call person1's DisplayInfo method to display that person's information on the screen Inheritance Inheritance is one of the core concepts of object-oriented programming (OOP) languages It is a mechanism where you can to derive a class from another class for a hierarchy of classes that share a set of attributes and methods Explain: We have an animal class and a mammal class The mammal class inherits from the animal class with a colon When a class inherits from another class, it "inherits" that class's properties and methods Page |4 Polymorphism Polymorphism is one of the core concepts of object-oriented programming (OOP) that describes situations in which something occurs in several different forms In computer science, polymorphism describes the concept that you can access objects of different types through the same interface Each type can provide its own independent implementation of this interface Explain : • The Animal class represents an animal and has a Make Sound() method marked with the virtual keyword This method can be overridden by subclasses • The Dog class is a subclass of Animal, and it overrides the parent class's Make Sound method In this case, when an object of the Dog class calls the Make Sound method, it executes the code in its own Make Sound method, printing the string "Woof" to the screen Encapsulation By definition, encapsulation describes bundling data and methods that work on that data within one unit, like a class in Java We often use this concept to hide an object’s internal representation or state from the outside This is called information hiding Page |5 Explain : The sound property is declared private, meaning only the Animal class has direct access Any external class cannot directly change the sound value This hides the inline details of the Animal class, exposing only the necessary information through the public interface Abstraction Abstraction is one of the key concepts of object-oriented programming (OOP) languages Its main goal is to handle complexity by hiding unnecessary details from the user That enables the user to implement more complex logic on top of the provided abstraction without understanding or even thinking about all the hidden complexity Page |6 Explain : Animal class - Abstract class The Animal class is set as abstract because it contains at least one abstract method (MakeSound) The abstract class cannot be instantiated directly, and it defines a common interface for subclasses Cat and Dog Class - Implementation class Both Cat and Dog are implementation classes from the abstract class Animal You must override the MakeSound method in each subclass II Object oriented relationship One of the advantages of Object-Oriented programming language is code reuse This reusability is possible due to the relationship b/w the classes Object oriented programming generally support types of relationships that are: inheritance , association, composition and aggregation All these relationship is based on "is a" relationship, "has-a" relationship and "part-of" relationship Inheritance: Inheritance is “IS-A” type of relationship “IS-A” relationship is a totally based on Inheritance, which can be of two types Class Inheritance or Interface Inheritance Inheritance is a parent-child Page |7 relationship where we create a new class by using existing class code It is just like saying that “A is type of B” Example : This arrow mark is often drawn from the subclass to the base class in class diagrams or other diagrams to represent an "is-a" relationship between them If you see that the Cat class inherits from Animal, you can infer that cat is a type of animal, not vice versa This demonstrates the natural nature of the "is-a" relationship Composition: Composition is a "part-of" relationship Simply composition means mean use of instance variables that are references to other objects In composition relationship both entities are interdependent of each other Page |8 Example : This Composition relationship is often depicted using a black diamond-shaped arrow to represent the owner-owner relationship between the owner object and the component object Association: Association is a “has-a” type relationship Association establish the relationship b/w two classes using through their objects Association relationship can be one to one, One to many, many to one and many to many Example : The arrow in an Association relationship usually does not indicate direction, because both objects can interact with each other in both directions Page |9 This relationship only represents the connection or interaction between objects, without mentioning direction or "who created whom" Aggregation Aggregation is based is on "has-a" relationship Aggregation is a special form of association In association there is not any classes (entity) work as owner but in aggregation one entity work as owner In aggregation both entities meet for some work and then get separated Aggregation is a one way association Example : The arrow in the Aggregation relationship usually indicates the direction from the owner object (in this case, College) to the component objects (Student and Teacher) This relationship only represents the association or association between objects, without requiring the component objects to exist in the relationship P a g e | 10 P2 Design and build class diagrams using a UML tool Scenario I created this to manage documents and books in the library to help readers easily search and managers to more easily manage documents Administrators can add books, show all books, search for books by id, edit, delete books and exit Use Case Diagram Explain: Function 1: Users can add books they have to the library Function 2: Users can edit books already in the library Function 3: User can delete books in library Function 4: User can show all books in the library Function 5: User can search for books in the library by id P a g e | 11 Class Diagram Explain: Program: Is an implementation class, usually containing the main method to start program execution Book: Interface for a book's information • Properties: id: Unique number of the list title: Title of the book author: The author of the book genre: The genre of the book • Method: getNumPages(): Returns the number of pages of the book P a g e | 12 Management book: Is a management class • Properties: bookList: List of Book objects • Method: addBook(book: Book): Add a book to the list editBook(id: String, newBookInfo: Book): Edit information of a book in the list deleteBook(id: String): Delete a book from the list showAllBooks(): Displays a list of all books Relationship: Program uses ManagerBook: Indicates that the executable program uses management features provided by ManagerBook ManagerBook has a Component relationship with Books: Know that ManagerBook owns and manages a list of books, and when ManagerBook is destroyed, the books are also destroyed 4.Sequence diagram Add Book (Add book): The administrator (Administrator) sends a request to add books to the library system (LibrarySystem) The library system creates a new book record in the database and returns a confirmation P a g e | 13 Search Book: The administrator sends a book search request to the library system The library system performs searches in the database and returns book information to the administrator Edit Book (Edit book): The administrator sends a request to modify book information to the library system The library system retrieves book information from the database, modifies and updates it, and then returns a confirmation to the administrator P a g e | 14

Ngày đăng: 04/12/2023, 14:53

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

Tài liệu liên quan