Mastering Object-Oriented Programming: Principles and Relationships, Study Guides, Projects, Research of Internet and Information Access

A comprehensive overview of the fundamental principles of object-oriented programming (oop), including encapsulation, inheritance, polymorphism, and abstraction. It delves into the importance of these concepts and how they enable programmers to create modular, extensible, and maintainable software applications. The document also explores the various types of logical relationships between classes, such as association, aggregation, composition, and inheritance, and how they are represented in uml class diagrams. By understanding these oop principles and class relationships, developers can design and build robust, scalable, and well-structured software systems that effectively model real-world entities and their interactions. This knowledge is crucial for students and professionals alike who are working with object-oriented programming languages and frameworks, as it lays the foundation for writing clean, efficient, and maintainable code.

Typology: Study Guides, Projects, Research

2021/2022

Uploaded on 08/04/2023

le-dinh-hoai-anh-fgw-dn
le-dinh-hoai-anh-fgw-dn 🇻🇳

4 documents

1 / 13

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
01/06/2023
Date Received 1st submission
Re-submission Date
Date Received 2nd submission
Student Name
LE DINH HOAI ANH
Student ID
GCD210065
Class
GCD1101
Assessor name
PHAM THANH SON
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.
Students signature
Anh
Grading grid
P1
P2
M1
M2
D1
D2
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Mastering Object-Oriented Programming: Principles and Relationships and more Study Guides, Projects, Research Internet and Information Access 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 01/06/2023 Date Received 1st submission

Re-submission Date Date Received 2nd submission

Student Name LE DINH HOAI ANH Student ID GCD

Class GCD1101 Assessor name PHAM THANH SON

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 Anh

Grading grid

P1 P2 M1 M2 D1 D

Summative Feedback:Resubmission Feedback:

Grade: Assessor Signature: Date:

Lecturer Signature:

What is object-oriented programming?

  • Object-oriented programming (OOP) is a programming methodology that enables programmers to represent real-world objects

through code abstraction. This approach has gained significant traction and has emerged as a standard software development

paradigm, particularly in the realm of business applications. When developing applications using OOP, programmers define

classes to model real-life objects. These classes serve as blueprints, encapsulating the behavior and characteristics of the

objects they represent. Within the application, these classes are instantiated into objects, which are instances of the respective

class

  • Throughout the application's execution, the methods defined within the class are invoked on these objects, allowing them to

perform specific actions and manipulate their internal state. Additionally, objects possess properties that define their attributes

and characteristics. In OOP, objects interact with each other through a public API, which encompasses the set of methods and

public properties that are accessible to other objects. This facilitates communication and collaboration between different

objects and classes within the system.

2. 4 Basic concept of OOP:

2.1. Encapsulation :

  • Encapsulation is a fundamental concept in OOP that brings several advantages. It promotes code modularity and reusability by

encapsulating related data (attributes or properties) and methods (functions or behavior) within a class. Encapsulation hides the

internal implementation details of an object and provides a well-defined interface through which other objects can interact with

it. This ensures that the internal state of an object remains consistent and can only be accessed or modified through the defined

methods, ensuring data integrity. Encapsulation also protects the object's data from unauthorized access and manipulation,

enhancing security. Additionally, encapsulation makes code maintenance easier, as changes made to the internal

implementation of a class do not affect other parts of the program that rely on its interface.

2.2. Inheritance :

  • Inheritance is a powerful mechanism in OOP that enables code reuse, extensibility, and code organization. It allows classes to

inherit properties and behaviors from other classes, forming a hierarchical relationship. The base or parent class serves as a

blueprint, defining common attributes and methods, which are inherited by derived or child classes. Inheritance promotes code

reuse by eliminating the need to rewrite common functionalities in multiple classes. It enhances code extensibility, as derived

classes can add or override behaviors specific to their context. Inheritance enables the concept of specialization, where classes

at higher levels of the hierarchy provide more generalized behavior, while classes at lower levels provide more specific and

specialized behavior. It also helps in code organization by representing relationships and hierarchies among objects, making

the codebase more structured and easier to manage.

  • Example: For instance, in the animal world, an insect could be represented by an Insect superclass. All insects share similar

properties, such as having six legs and an exoskeleton. Subclasses might be defined for grasshoppers and ants. Because they

inherit or are derived from the Insect class, they automatically share all insect properties. [ CITATION Kyl21 \l 1066 ]

2.4. Abstraction :

  • Abstraction is a key principle in OOP that simplifies complex systems by capturing essential features while hiding unnecessary

details. It allows developers to work at a higher level of abstraction, focusing on the core concepts without being concerned

with specific implementations. Abstraction is achieved through abstract classes and interfaces. Abstract classes cannot be

instantiated but serve as a blueprint for derived classes. They define common characteristics and behaviors that derived classes

must implement. Interfaces, on the other hand, define a contract that concrete classes must adhere to, specifying the methods

they must implement. Abstraction promotes code modularity and reusability by providing a clear separation between the

interface and the implementation. It enhances code maintainability, as changes to the internal implementation of an abstract

class or interface do not affect other classes that rely on it as long as the contract is upheld. Abstraction also enhances code

readability and comprehensibility by providing clear and concise interfaces for interacting with objects.

3. Various Class Relationship:

In object-oriented programming, classes are connected to each other through various types of logical relationships depicted in class

diagrams. These relationships define the associations and dependencies between classes. Below are some common types of logical

connections found in UML

  • Association: Association represents a relationship between two classes, indicating that objects of one class are connected to

objects of another class. It can be a one-to-one, one-to-many, or many-to-many relationship.

  • Directed Association: Directed association specifies the directionality of the relationship between classes, indicating that the

relationship is navigable from one class to another.

  • Reflexive Association: Reflexive association occurs when a class is associated with itself, representing a relationship within

the same class.

  • Multiplicity: Multiplicity defines the cardinality of the association, specifying the number of instances of one class that can be

associated with the instances of another class.

  • Aggregation: Aggregation represents a whole-part relationship between classes, where one class is considered the whole and

another class is considered a part. The part class can exist independently of the whole class.

  • Composition: Composition is a stronger form of aggregation, indicating a whole-part relationship where the part class cannot

exist independently of the whole class. If the whole class is destroyed, the part class is also destroyed.

  • Realization: Realization represents the implementation of an interface or the fulfillment of a contract specified by another

class. It shows that one class implements the behavior defined by another class or interface.

  • Inheritance/Generalization: Inheritance or generalization represents an "is-a" relationship between classes, where one class

inherits the attributes and behaviors of another class. It allows the creation of hierarchical class structures, promoting code

reuse and specialization.

  • The software has only 2 users, teachers and administrators. Teachers can only add students, edit teachers and enter student scores, teachers do not have the right to delete students. The member admin can add, remove or edit teachers, add students, and edit or delete students. Admin can also add new subjects and delete new subjects
  • This system has 5 class:

 Person: This class acts as the foundation and superclass of the system. It encapsulates common attributes and behaviors shared by both students and teachers. It demonstrates the concept of inheritance in Object Oriented Programming, allowing derived classes to inherit and extend its functionality.  Student: The Student class is designed to store and manage student information. It includes attributes like student ID, name, age, and contact details. In addition, it may have methods for accessing and modifying student-specific data  Teacher: The Teacher class is responsible for handling information related to the teacher. It encapsulates attributes such as Teacher ID, Name, Age and Earnable Salary. It may also contain teacher-specific data management methods and perform related operations.  Subject: The Subject class is used to store and manage information about various topics provided in the system. It can include attributes such as the subject code, name, and description. This class can provide methods to access topic details and perform topic related operations.  Student Grade: The Student Grade class is dedicated to storing and managing student grades. It can include attributes such as student IDs, course codes, and grades. In addition, it can provide methods for averaging, retrieving specific points, and performing point- related operations.

  • Concept are displayed in diagram:  The Person class serves as the parent class of both the Student class and the Teacher class. That is Inheritance in Object-Oriented Programming.  The Student class is used to store student information, while the Teacher class is used to store teacher information.  Both the Student class and the Teacher class override the showInfo() method of the Person class. That is Polymorphism in Object- Oriented Programming.  The Subject class is used to store subject information.  The Student Grade class is used to store students' grades.

References:

  • Herrity, K., 2021. What Is Object-Oriented Programming? The Four Basic Concepts of OOP. [Online] Available at: https://www.indeed.com/career-advice/career-development/what-is-object-oriented- programming#:~:text=The%20four%20basics%20of%20object,abstraction%2C%20inheritance%2C%20and%20polymorphism.
  • Raut, A., 2022. Encapsulation in Object Oriented Programming. [Online] Available at: https://akshayraut.medium.com/encapsulation-in- object-oriented-programming-4cfb0ee28f
  • Kukurba, V., 2018. JavaScript ES7 OOP. Abstraction. Class. #1. [Online] Available at: https://www.youtube.com/watch?v=1eSCCQPBqP
  • Sidhu, R., 2020. How to Code Inheritance in Java — Beginner’s Tutorial in OOP. [Online] Available at: https://towardsdatascience.com/how-to-code-inheritance-in-java-beginners-tutorial-in-oop-d0fc0a71be

Index of comments 2.1 1. What is good You have shown some knowledge about OOP characteristics and various relationships.

  1. What is not good
  • You need to give more examples and code snippets about the characteristics of the object-orientated paradigm and the various class relationships. You have to drawn UML diagram in your report Powered by TCPDF (www.tcpdf.org)