1651: Advanced Programming - ASSIGNMENT 1 - PASS, Assignments of Programming Methodologies

1651: Advanced Programming - ASSIGNMENT 1 - PASS

Typology: Assignments

2021/2022

Available from 02/01/2023

flex.lowey
flex.lowey 🇻🇳

4.8

(104)

33 documents

1 / 27

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b

Partial preview of the text

Download 1651: Advanced Programming - ASSIGNMENT 1 - PASS and more Assignments Programming Methodologies in PDF only on Docsity!

Higher Nationals in Computing

Unit 20: Advanced Programming

ASSIGNMENT 1

Learner’s name: NGUYEN GIA HUY

ID: GCS 200801

Class: GCS0905C

Subject code: 1651

Assessor name: LE NGOC THANH

Assignment due: Assignment submitted:

❒ Summative Feedback: ❒ Resubmission Feedback:

Grade: Assessor Signature: Date: Lecturer Signature:

of range of design patterns. Tasks: Your team is now separated and perform similar tasks in parallel. You will choose one of the real scenarios that your team introduced about DP in previous phase, then implement that scenario based on the corresponding class diagram your team created. You may need to amend the diagram if it is needed for your implementation. In additional, you should discuss a range of DPs related / similar to your DP, evaluate them against your scenario and justify your choice. In the end, you need to write a report with the following content:  A final version of the class diagram based on chosen scenario which has potential of using DP.  Result of a small program implemented based on the class diagram, explain how you translate from design diagram to code.  Discussion of a range of DPs related / similar to your DP, evaluate them against your scenario and justify your choice (why your DP is the most appropriate in that case). 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 object-orientated 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.

OOP GENERAL CONCEPTS

1. Introduce OOP OOP (short for Object Oriented Programming) – object-oriented programming is a programming method based on the concept of classes and objects. OOP focuses on manipulating objects rather than the logic for manipulating them. OOP is the foundation of today's design patterns. The goal of OOP is to optimize source code management, increase reusability, and most importantly, help encapsulate known procedures using objects. 2. General concepts of OOP (need references / citations here) 2.1. Object/Class Objects in OOP consist of 2 main components:  Attributes: are the information and characteristics of the object  Methods: are the behaviors that the object can perform

To make it easier to imagine, we have a real-life example of an object that is a smartphone. This object will have:  Attributes: color, memory, operating system…  Methods: calling, taking photos, texting, recording... Class Class is an abstraction of the object. Objects with similar properties are grouped into a class. The class will also include two pieces of information: properties and methods. An object will be treated as an instance of the class. Continuing the example in the object section above, we have a smartphone class consisting of 2 components:  Attributes: color, memory, operating system…  Methods: calling, taking photos, texting, recording...  Objects of this class can be iPhone, Samsung, Oppo, Huawei, etc. 2.2. Abstraction Abstraction is one of the four important characteristics of object-oriented programming languages (OOP). Its main goal is to reduce complexity by hiding details that are not directly related to the user (the user here is not the end user but the programmer). That allows the user to still perform the necessary work based on a provided abstract entity without understanding or even thinking about all the complexity lurking within.

 Packaged for convenient management and use. That is, each "package" is built to perform a specific set of functions for that "package".  Encapsulation also hides some information and details of internal settings so that the outside cannot see (Data Hiding). How the outside environment is allowed to affect the data, functions, and methods of an object is entirely up to the coder. This is the property that ensures the integrity and confidentiality of the object. Programmers can rely on this mechanism to prevent the assignment of invalid values to each object's data member. 2.4. Inheritance Inheritance allows building 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.

The image above shows that when applying inheritance, we only need to write the other methods in the parent class once and let the subclasses inherit again. This will avoid errors when editing and increase reusability. For example, if you want to add a class MayMac , you just need to declare it to inherit from Class Mayvitin to be able to use the above properties and methods already. 2.5. Polymorphism (Overloading and Overriding) Polymorphism (polymorphism) is a word of Greek origin, translated into Vietnamese meaning "a name with many different forms and shapes". In other words, an object has many forms or a name with many different functions. "Poly" means many and "morph" means forms. Polymorphism provides the ability to execute multiple classes with the same name. As mentioned above, polymorphism in C# deals with multiple classes with the same name, which are related to each other. This is an important concept in object-oriented programming after encapsulation and inheritance. Polymorphic Types in C# There are basically 2 types of polymorphism in C#, including:  Static polymorphism / Compile Time.  Dynamic/Runtime polymorphism. Static Polymorphism in C# (Or Compile Time)

The essence here is understood as the type, type, and task of the class. Each derived class (subclass) can inherit from an abstract class. The abstract keyword is used to define an Abstract Class. Classes defined using the abstract keyword are not allowed to instantiate objects of that class. 2.7. Interfaces Interface: is a function that we can add to any class. Function here is not synonymous with method (or function). Interface can include many functions/methods and all of them serve the same function. Thus, Interface is used to describe a "blueprint" for a function of the class. If you want to create a blueprint, use an abstract class. A blueprint will of course have things built in and things that are abstract. Interface is not a class. Classes derived from an Interface must fully define the methods and properties that inherit from the Interface. The purpose of an Interface is to define the capabilities we want in a class.

OOP SCENARIO

1. Scenario The library of the University of Greenwich Vietnam has imported a large number of books of all genres. The school's library has always controlled and managed books by manual human resources, now they decided to build an effective book management software and I am the programmer assigned to do this task. For this project of the library, I decided to choose an object- oriented programming solution combined with the C# programming language to support software implementation. The reason for this choice of mine is because: Object-oriented programming has outstanding advantages in the software development process such as security, ease of management and development, and optimization in many situations. The C# programming language is one of the most popular object-oriented programming languages in the world. With the backing from Microsoft, C# will be the trusted language in software development that I choose. The software will include the following main functions:  Add, delete, edit books.  Print the entire book to the screen.  Search for books.  Borrow books and return books. Software requirements include:

Reader: Specification for readers.

  • Specification name: Search for books (Teacher or Student). Specification Target: User can search book by name or Id. Description: The user selects the book search item, the search message panel appears asking to enter the name or book ID. After entering, the system does the task of searching and outputting book information according to the id (name) entered.
  • Specification name: Borrow book (Teacher or Student). Target specification: Users can borrow books and schedule return appointments (No more than 14 days). Description: The user selects the item to borrow a book, then enters the book he wants to borrow and personal information to borrow. After receiving the information, the system will start counting down time.
  • Specification Name: View the entire book (Teacher or Student). Specification goal: Allow users to view all existing books in the library. Description: The user selects the item to view all books in the program, all the details of the book will be displayed on the screen for the user. Specification for Librarian:
  • Specification Name: Book Search (Librarian).

Target specification: Librarians can search books by name or Id. Description: The librarian selects the book search item; the search message panel appears asking to enter the name or book ID. After entering, the system does the task of searching and outputting book information according to the id (name) entered.

  • Specification Name: View Full Book (Librarian). Specification goal: Allow librarians to view all existing books in the library. Description: librarian selects to view all books in the program, all the details of the book will be displayed on the screen for the librarian.
  • Specification name: Add book (Librarian). Specification Objective: Allow librarians to add new books to the library. Description: The librarian chooses to add a new book in the program, then adds the necessary information of the book and clicks save. Once saved, the book will be added and will be displayed if needed.
  • Specification name: Delete book (Librarian). Specification Objective: Allow librarians to delete existing books in the library. Description: librarian chooses to delete books in the program and enter the book id to delete, then press delete. The program will find the correct books entered by the librarian and delete them and then notify them that they have been deleted.
  • Specification name: Edit book information (Librarian). Specification goal: Allow librarians to edit information about books already in the library.