Assignment 1 - P - Advanced Programing, Assignments of Advanced Computer Programming

This assignment just get Pass.

Typology: Assignments

2022/2023

Uploaded on 06/10/2023

do-trong-thinh-fgw-dn
do-trong-thinh-fgw-dn 🇻🇳

3 documents

1 / 25

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ASSIGNMENT 1 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 Do Trong Thinh Student ID GCD210397
Class GCD1102 Assessor name Nguyen Van Loi
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 Thinh
Grading grid
P1 P2 M1 M2 D1 D2
1 | P a g e
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19

Partial preview of the text

Download Assignment 1 - P - Advanced Programing and more Assignments Advanced Computer Programming in PDF only on Docsity!

ASSIGNMENT 1 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 Do Trong Thinh Student ID GCD Class GCD1102 Assessor name Nguyen Van Loi 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 Thinh Grading grid P1 P2 M1 M2 D1 D

❒ Summative Feedback: ❒ Resubmission Feedback:

Grade: Assessor Signature: Date: Lecturer Signature:

  • Table of figure..............................................................................................................................................................................................
  • I. INTRODUCTION....................................................................................................................................................................................
  • II. OOP GENERAL CONCEPTS....................................................................................................................................................................
      1. General concepts of OOP.................................................................................................................................................................
      • 1.1. Object Oriented Programming (OOP).......................................................................................................................................
      • 1.2. Structure of object-oriented programming..............................................................................................................................
      1. Characteristics of OOP......................................................................................................................................................................
      • 2.1. Encapsulation:...........................................................................................................................................................................
      • 2.2. Abstraction:...............................................................................................................................................................................
      • 2.3. Classes and Objects:..................................................................................................................................................................
      • 2.4. Inheritance and Composition:...................................................................................................................................................
      • 2.5. Binding:....................................................................................................................................................................................
      • 2.6. Message Passing:.....................................................................................................................................................................
      • 2.7. Polymorphism:........................................................................................................................................................................
      1. Class relationships..........................................................................................................................................................................
      • 3.1. Association:.............................................................................................................................................................................
      • 3.2. Aggregation:............................................................................................................................................................................
      • 3.3. Composition:...........................................................................................................................................................................
  • III. OOP SCENARIO..................................................................................................................................................................................
      1. Scenario..........................................................................................................................................................................................
  • IV. Design Patterns..................................................................................................................................................................................
      1. Creational Patterns.........................................................................................................................................................................
      1. Structural pattern...........................................................................................................................................................................
      1. Behavioral pattern..........................................................................................................................................................................
  • REFERENCE.................................................................................................................................................................................................
  • Figure 1: Encapsulation................................................................................................................................................................................ Table of figure
  • Figure 2: Abstraction....................................................................................................................................................................................
  • Figure 3: Class and Object............................................................................................................................................................................
  • Figure 4: Composition vs Inheritance........................................................................................................................................................
  • Figure 5: Binding........................................................................................................................................................................................
  • Figure 6: Message Passing.........................................................................................................................................................................
  • Figure 7: Association..................................................................................................................................................................................
  • Figure 8: Aggregation.................................................................................................................................................................................
  • Figure 9: Composition................................................................................................................................................................................
  • Figure 10: Design Patterns.........................................................................................................................................................................
  • Figure 11: Class diagram example for creational pattern.........................................................................................................................
  • Figure 12: Class diagream example for structural pattern........................................................................................................................
  • Figure 13: Class diagram example for behavior pattern...........................................................................................................................

I. INTRODUCTION The report discuss about OOP general concepts, what is OOP scenario and to show about design patterns. II. OOP GENERAL CONCEPTS

1. General concepts of OOP

1.1. Object Oriented Programming (OOP)

The object-oriented programming (OOP) paradigm for computer programming organizes software's design on data or objects rather than around functions and logic. A data field with specific traits and behavior is called an object.

1.2. Structure of object-oriented programming

Classes: are special sorts of data that may be specified by an individual and form the basis for their own objects, properties, and methods. Objects: The creation of objects with precisely defined data results in instances of a class. Real-world items or abstract concepts can both be seen as objects. The description is the sole item defined when a class is first created. Methods: are described within a class as functions, and these functions specify how an object behaves. Beginning with a reference to an instance object, each method found in class declarations. Furthermore, an object's instance methods are the subroutines that make up the object. For reusability or to keep functionality contained to a single object at a time, programmers employ many techniques. Attributes: are defined in the class template and used to represent an object's status. The attributes field of objects will include data. The class itself is responsible for class characteristics.

members. Only classes in the same package can see default members. The class in which they are declared is the only one that can see private members.  Property: Encapsulation in Java is a technique for combining the code (methods) and data (variables) operating on the data into a single entity. Only the methods of the current class can access a class's variables, which are concealed from other classes. Data protection is achieved by encapsulation because properly protected files cannot be mistakenly changed by outsiders. We must employ certain access modifiers in order to encapsulate the members of our class. These terms define the degree of access or protection that class members have.

2.2. Abstraction:

We possess the abstraction quality. Reusable objects are being created using this method in order to standardize common business logic. The utilization of the items is a crucial aspect of abstraction. In a variety of applications, they ought to be used consistently. This makes the logic more consistent and simpler to maintain across many programs. Abstraction facilitates the application of OOP in other people's systems in addition to aiding in the standardization of the logic and making it simpler to maintain. It promotes teamwork among several parties, making it simpler to develop applications that incorporate various functions and data sources. programs may be made that are far more scalable and maintained than conventional non-OOP programs. But for this to be feasible, abstraction is necessary.  Abstract method: An interface common to a number of classes is defined using abstract methods. With their help, you may provide a method's signature without having to supply an implementation. This enables the development of a group of linked classes that implement the same interface but differ in their internal workings.  Abstract class: A class that cannot be instantiated and is used as a foundation class for additional classes is known as an abstract class. It may include abstract procedures, or methods without a physical embodiment. Any non-abstract derived class must implement abstract methods.  Interface: A contract that outlines the methods and attributes that a class must implement is known as an interface. It does not offer an implementation for the methods and attributes it describes, which a class must implement on its own.

Figure 2 : Abstraction

2.3. Classes and Objects:

The classification of classes is a feature of object-oriented programming. It's in a class that an object's design is laid out. Methods, characteristics, and other facets of the object are described in the blueprint. From classes, objects are produced. One more name for a class is an object's blueprint. It outlines the object's attributes, including its methods and properties. From classes, objects are produced. In essence, a class is an object's design manual. It outlines the object's attributes, including its methods and properties.

fields again while also adding new methods and properties to the current class. The extends keyword in Java is used to implement inheritance.  Keyword of inheritance: To change the behavior of methods and attributes that are inherited from a base class, C# programmers utilize the new, virtual, and sealed keywords. The new keyword can be used to replace a base class method or property with a new method or property in a derived class. The virtual keyword is used to provide overriding of a base class method or property in a derived class. The sealed keyword is used to stop a derived class's method or attribute from being overwritten by any other derived classes. Figure 4 : Composition vs Inheritance

2.5. Binding:

The technique of binding involves connecting a certain property of one object to another object in your program. For instance, you may link a text box to a button's text attribute so that when the button is chosen, the value of the text box is set to whatever was typed into it. It will be much simpler to manage and debug your code while it runs on the server if you're constructing a web application and you want a form to submit data to your server. Figure 5 : Binding

Overriding method: A derived class implements a method that is already given by its base class in its own way, which is known as method overriding. Overwriting (replacing) the implementation in the base class is the implementation in the derived class.  Overloading method: A class that contains several methods with the same name but distinct arguments is said to be method-overloaded. The methods must have separate parameter lists, albeit they may have different access modifiers or return types.

3. Class relationships

3.1. Association:

An association in object-oriented programming is a connection between two objects. It explains the connections between items and how they communicate with one another. Associations can be one-to-one, one-to-many, or many-to-many, among other variations. Each item is related to exactly one other object in a one-to-one connection. Each item is connected to one or more other objects in a one-to-many connection. Each item is connected to several other things in a many-to-many connection. Diagrams created with UML may show associations. Lines drawn between classes in the UML are used to indicate relationships. The type of line and the number of lines both reveal the type of relationship and its degree of multiplicity. Figure 7 : Association

3.2. Aggregation:

A "has-a" link between two things is referred to as an aggregate in the context of association. A whole-part relationship is represented by this unique kind of interaction. One item is comprised of one or more other objects in an aggregation connection. Typically, the constructed things are referred to as pieces or elements of the total object. The lifespan of an object's component pieces must be managed by the entity as a whole. UML diagrams are used to depict aggregation. On the end of the line connecting the two classes in the UML, aggregation is shown as a diamond shape. To identify the sort of connection, the word "aggregation" or "composition" is generally written on the diamond shape. Figure 8 : Aggregation

3.3. Composition:

Composition is one of the core ideas in object-oriented programming that enables you to reuse existing code, create tidy APIs, and modify the implementation of a class used in a composition without modifying any external clients. Composition, as opposed to inheritance from a base or parent class, is performed by including instances of additional classes that embody the needed functionality. Figure 9 : Composition

Lecturer: Person  ID: integer  Object: string Main menu: 1 Manage Lecturer 2 Manage Student 3 Exit ====================== When choise « 1 Manage lecturer » the system will open Manage Lecturer system : 1 Add lecturer 2 Update lecturer 3 Delete lecturer 4 Search lecturer 5 View all lecturer 6 Back to main menu ====================== When choise « 2 Manage Student » the system will open Manage Student system :

1 Add student 2 Update student 3 Delete student 4 Search student 5 Sort student follow mark 6 View student list 7 Back to main menu ====================== For error cases:  When user enter number > 8 or < 0 The system will print “No invalid! Choose option in menu” to enter again.  When user choose 5/6/7 but student list do not have data the system will print “Empty student list”  When user enter wrong ID of student to update or delete the system will print “No invalid!” IV. Design Patterns A design pattern is a general, reoccurring fix for a common problem in software design that is employed in software engineering. A design pattern isn't an already-completed thing that can be put into code straight immediately. It is a description or model for addressing problems that may be used in a number of situations. (Fadatare, n.d.)

Singleton Design Pattern: ensures that a product is only created once.  Factory Design Pattern: builds objects without specifying which specific class will be utilized.  Abstract Factory Design Pattern: enables the production of objects without requiring something specific to be specified.  Builder Design Pattern: Make a complicated object's creation and representation unique such that several representations may be made using the same building procedure.  Prototype Design Pattern: changes an existing item into a new one.

Figure 11 : Class diagram example for creational pattern  I demonstrate the architecture of Abstract Factory Pattern using the information description software on a smartphone.  I demonstrate the architecture of the Abstract Factory Pattern using the information description software on a smartphone.