

















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


















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 Nguyen Thi Thanh Mai Student ID GCH Class GCH0 901 Assessor name Doan Trung Tung 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 mai Grading grid P1 P2 M1 M2 D1 D
Grade: Assessor Signature: Date: Lecturer Signature:
To put it simply, object-oriented programming supports OOP technology. Has the effect of increasing productivity and speeding up work. From there, allowing programmers to influence subjects like in reality. Thereby to fix software errors, proactively maintain and maintain the system. Object-oriented programming languages are very diverse, most of which are class-based languages. Each object has the ability to receive messages, process data, and send responses to other objects or to the environment (Nauduri, 2021). II. GENERAL CONCEPTS OF OOP.
o An object consists of two pieces of information: properties and methods. o Attributes are the information and characteristics of the object. For example, humans have characteristics such as eyes, nose, hands, feet, etc. o Methods are operations and actions that an object can perform. For example, a person would be able to do the act of speaking, walking, eating, drinking,... (Araballi, 2020)
The main class is the template for creating objects. In a class, there are usually variables to describe properties, functions to describe object methods. For easy use of class, it is common to use class as a data type to create objects through the constructor system (Araballi,
Difference between object and class. Class you can understand it as template, object is an instance instance based on that template. For example: We talk about dogs, you can understand it as a dog class with:
This is a common class in object-oriented programming, but has the added property of inheriting some or all of the properties of another class. The class that shares the inheritance is the parent class (Araballi, 2020).
This class cannot be instantiated into a pragmatic object. Which is designed to create a class with generic properties, but the class itself is not or meaningful enough to proceed with coding for the entity (Araballi, 2020).
Method is a term to describe the behavior of an object or of a class. When designing OOP object-oriented programming, one can use methods to describe and implement object behaviors. Each method is usually defined as a function. The operations to perform the
the various data elements of different objects with different values when they are created. It is used to overload constructors (Araballi, 2020).
Related data and methods are encapsulated into classes for ease of management and use. That is, each class is built to perform a specific set of functions for that class. In addition, packaging is used to hide some information and details of internal settings so that it cannot be seen from the outside (McCormick, 2021). For example we see a cold pill. We only know it cures runny nose, headache and some main ingredients, but what specific active ingredients are inside it is completely unknown.
It allows to construct a new class based on existing class definitions. This means that the parent class can share data and methods with the child classes. Subclasses do not have to be redefined, in addition, they can extend the inherited components and add new components. Reuse the source code optimally, take advantage of the source code. Some common types of inheritance: single inheritance, multiple inheritance, multi-level inheritance, hierarchical inheritance. When we start to build the application we will start designing the definition of the classes first. Usually some classes are related to other classes, they have similar properties (Belker, 2021).
Polymorphism is an action that can be performed in many different ways. This is again a property that can be said to contain most of the power of object-oriented programming. In simpler terms: Polymorphism is a concept where two or more classes have the same methods but can be implemented in different ways (Williams, 2020). For example: the above in practice. We have two animals: dog and cat. Both of these animals are class animals. But when we tell both animals to wail, the dog will woof, the cat will meow. So in the example dog and cat are treated as objects. 2 animals can understand the same call but in different ways.
Abstraction means to generalize something up, without paying attention to the details inside. It doesn't care what the details are inside and people still understand it every time they hear about it. For example: If you ride a scooter, the action is to increase the throttle to accelerate, the function of increasing the throttle is representing abstraction. Users only need to know that when accelerating, the car accelerates, no matter how it is inside. Here in OOP programming, abstraction means choosing the properties and methods of the object needed to solve the problem you are programming. Because an object has a lot of method properties, but for a particular problem, it is not necessary to select them all (Gamma, 2009). For example: In the student management problem, we only need to manage information such as :Full name, Date of birth, Sex , Test score … without the need to manage additional information: Hair color ,Interests ,Height,…Because they are not really necessary. III. OOP SCENARIO.
IV. DESIGN PATTERN. A design pattern provides a general reusable solution for the common problems that occur in software design. The pattern typically shows relationships and interactions between classes or objects. The idea is to speed up the development process by providing well- tested, proven development/design paradigms. Design patterns are programming language independent strategies for solving a common problem. That means a design pattern represents an idea, not a particular implementation. By using design patterns, you can make your code more flexible, reusable, and maintainable. Goal: Understand the purpose and usage of each design pattern in order to pick and implement the correct pattern as needed (ritveak, 2021). Example:
Factory Method is a creational design pattern that provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created. B. MOTIVATION Imagine that you’re creating a logistics management application. The first version of your app can only handle transportation by trucks, so the bulk of your code lives inside the Truck class. After a while, your app becomes pretty popular. Each day you receive dozens of requests from sea transportation companies to incorporate sea logistics into the app.
Structure of Factory Method Scenario When running the program, it will have two main functions that allow the user to view information about the motorcycle or the car. Two main functions are demonstrated in the CarFactory class with two methods creatCar () and creatMoto (). However, two methods in the CarFactory class do not directly create objects, but through the methods of the Honda class and the Yamaha class to create the object. Class Honda and class Yamaha inherit from the class Carfactory. The methods of the Honda class and the Yamaha class will refer to the Car class and the Moto class. Class Car and class Moto are super classes. Classes carYamaha, motoYamaha, carHonda, carYamaha are subclasses. Objects are created from these classes. When the user chooses the functions in the Menu, objects are created on request and displayed to the user.
BEHAVIORAL - OBSERVER
Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. (Gamma, 2009)
The spreadsheet and the bar chart don't know about each other, thereby letting you reuse only the one you need. But they behave as though they do. When the user changes the information in the spreadsheet, the bar chart reflects the changes immediately, and vice versa.
Structure of Observer Scenario Description: Libraries have librarians and readers. The Library sorts books by genre, price, title, and author. Librarians manage books. Every month, they will import more books into the library, can add and delete information of books, lend books to readers, and set a date when the readers return books. Readers can borrow books to read. If a book is returned overdue by a reader, a fine of VND 25, will be charged. If the book is lost or damaged, the book must be fully compensated. Both readers and librarians can look up books by title, author, price, and genre.
ConcreteSubject The task is to store the status of ConcreteObserver objects and from these states send a notification every time the state is changed.
STRUCTURAL PATTERN – DECORATOR. INTENT Decorator is a structural design pattern that lets you attach new behaviors to objects by placing these objects inside special wrapper objects that contain the behaviors. STRUCTURE OF DECORATOR SCENARIO BraceletsJ is a jewelry store about bracelets. However, many customers want to have bracelets designed according to their own ideas. So they designed the class "BasicBracelets" and "BraceletsDecorator". "BasicBracelets" are products designed by SraceletsJ. "BraceletsDecorator" is a class designed specifically for customers who want to design their own bracelets. Customers can freely choose charms (shape, quantity, color), material and size. After that, all price information, product name will be displayed.