Đang tải... (xem toàn văn)
OBSERVATION RECORD Student 1 Do Hoang Nhan Description of activity undertaken - Design and build class diagrams using a UML tool: 50%Assessment & grading criteria How the activity meets
Trang 1ASSIGNMENT 1 FRONT SHEETQualification BTEC Level 5 HND Diploma in IT
Unit number and title Unit 20: Advanced Programming
Group number:
1 Do Hoang Nhan BSAF200035 –2 To Phuoc Thanh BS00181 –3 Tran Minh Chien BS00213 –4 Nguyen Vu Quang BS00230 –
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 da form of malpractice
Trang 3OBSERVATION RECORD Student 1 Do Hoang Nhan
Description of activity undertaken
- Design and build class diagrams using a UML tool: 50%
Assessment & grading criteria
How the activity meets the requirements of the criteria
Trang 5Student 2 To Phuoc Thanh
Description of activity undertaken
- Design and build class diagrams using a UML tool: 50%
Assessment & grading criteria
How the activity meets the requirements of the criteria
Trang 7Student 3 Tran Minh Chien Description of activity undertaken
- Examine the characteristics of the object- orientated paradigm as well as the various class relationships: 50%
Assessment & grading criteria
How the activity meets the requirements of the criteria
Trang 9Student 4 Nguyen Vu Quang Description of activity undertaken
- Examine the characteristics of the object- orientated paradigm as well as the various class relationships: 50%
Assessment & grading criteria
How the activity meets the requirements of the criteria
Trang 11Summative Feedback: Resubmission Feedback:
Internal Verifier’s Comments:
Trang 12Signature & Date:
Trang 13B Principles or characteristics of OOP 14
2 Design and build class diagrams using a UML tool (P2) 21
A What are the Class Diagrams 21
B Relationships in Class Diagrams 22
C Introducing some class diagram tools 26
D Use the apply tool to draw the class diagram 26
E Explain the functions of the system 28
III CONCLUSION 30
IV REFERENCES 30
Trang 15Figure 6 Interface Result 17
Figure 7 Interface Result 18
Figure 8 Compile- me Polymorphism Result 18
Figure 9 Run me polymorphism 19
Figure 10 Run me polymorphism Result 19
Figure 11 Overriding methods Result 20
Figure 12 Overriding methods 20
Figure 13 Method overloading 21
Figure 14 Method overloading Result 21
Figure 21 Mul plicity 25
Figure 22 Associa on Classes 26
Figure 23 Class diagram for Employee system management 28
Trang 17I INTRODUCTION
Recently, we joined a so ware development company to improve the poor documenta on of internal so ware libraries This situa on makes it di cult to use so ware code in projects My role is to e ec vely represent UML diagrams in OODA and design pa erns to reduce this situa on UML diagrams in OODA help capture the structure and func onality of the so ware, while design pa erns take advantage of proven solu ons This helps improve documenta on and more e cient use of so ware code, while increasing reliability and saving the company me In this essay I will present the characteris cs of the object-oriented model as well as various class rela onships and build class models using UML tools
II CONTENT
1 Examine the characteristics of the object-orientated paradigm as well as the various class relationships (P1)
A Object-orientated paradigm a Definition
The main goal of OOP is to model data and behaviour as "objects," which are derived from "classes." These objects have a ributes (their state) and methods (their ac vi es), re ec ng actual or abstract things Classes (object blueprints), objects (class instances), inheritance (crea ng new classes from exis ng ones), polymorphism ( exible method func onali es across types), encapsula on (preven ng unauthorized access to object data), and abstrac on (hiding intricate details) are important OOP principles OOP encourages modular and adap ve so ware design that re ects real-world dynamics through these
Trang 18concepts [1]
b Example: class, object, properties, method, constructor
1 Class: A class is a model or prototype from which new objects can be made Consider a class called "Book" in the context of a library This course doesn't count as a book because it doesn't de ne what a book is
Trang 19Consider a set of house's architectural plans, for instance Despite not being the actual house, these designs describe its structure
2 Object: A par cular instance of a class cons tutes an object It follows the guidelines the class gave
Example: "Several houses can be constructed using the architectural plans Every house is a thing Despite sharing the same designs, every house may have a di erent color scheme or garden design
3 Properties (or Attributes): These are particular pieces of informa on that Figure 1 Class Example
Figure 2 Object Example
Trang 20specify an object's status or features
Such as: "For a speci c house (object) built from the plans (class), its proper es might include its color, the number of oors, or the type of roo ng it has."
Trang 214 Method: The ac ons or behaviors that an object can carry out are referred to as methods
Figure 3 Properties Example
Trang 23As an illustra on, consider the ac ons "open door," "close window," or "turn on light" in a home A "Book" might have methods to "open," "close," or "bookmark a page" in a similar way
5 Constructor: When an object is formed, this par cular method within a class ini alizes or sets it up
Trang 25A founda on must be laid, walls must be built, and the roof must be placed, for instance, when a house is originally being constructed When a new book object is produced, the constructor of our 'Book' class may set the tle, author, and number of pages
Advantages-Disadvantages of OOPAdvantages of OOP
Modularity: OOP supports modular design, which enables independent development and maintenance of various program parts, hence enabling scalability and maintainability
Reuse: The DRY (Don't Repeat Yourself) philosophy is supported by the ability
Trang 26to reuse code through inheritance and composi on
Maintainability: Because OOP systems are modular in design, they are typically simpler to expand, change, and debug
OOP is frequently regarded as intui ve since it replicates real-world en es and interactions
Flexibility: Because methods may be implemented di erently for many subclasses in large-scale applica ons, polymorphism allows for exibility in how they are invoked.
- Disadvantages of OOP
Trang 27Complexity: Adding more classes and objects might make the program more di cult, which is a drawback of OOP
Performance: Procedural programming may not have overhead that OOP can bring (such as method calls or keeping object metadata)
Steep Learning Curve: At rst, beginners may nd it di cult to understand the fundamentals of OOP
Overhead: Since objects store addi onal data like method and property metadata, they may use more memory
Not always appropriate: Not all issues are amenable to object-oriented xes Func onal or procedural solu ons may occasionally be more e ec ve [2]B Principles or characteristics of OOP
a Encapsulation: Encapsula on is one of the important principles in OOP It refers to encapsula ng data and related methods in a class The internal components of the class, such as member variables and methods, are hidden from the outside and cannot be accessed directly Instead, the class provides a public interface that allows access and interac on with these internal components Inheritance: Inheritance allows a subclass to inherit proper es and methods from a superclass This creates an "is-a" rela onship between classes, meaning that the subclass is a concrete form of the superclass
Trang 29Inheritance allows reusing source code and building new classes on top of exis ng classes Example: [3]
Result:
Figure 4 Encapsulation
Trang 30b Abstraction: Abstrac on is an important aspect of OOP It refers to crea ng abstract classes that de ne interfaces, but do not implement concrete methods
Figure 5 Encapsulation Result
Trang 31Abstrac on helps hide the complexity of the class's internals and focus on using the services provided by that class Example: [4]
Trang 32Result:
Figure 6 Abstraction
Trang 33c Interface: Interface is a form of abstrac on in OOP It is a set of abstract methods that a class must implement when implemen ng that interface Interfaces allow mul ple inheritance and make the code exible, since a class can implement mul ple interfaces For example: [4]
Result:
Figure 8 Interface
Trang 34Figure 9 Interface Result d Polymorphism
Trang 35Compile- me Polymorphism: Compile- me Polymorphism occurs when we use method overloading, which means the same method can have many di erent characteris cs, such as number di erent parameters or parameter types Example: [4]
Result:
Figure 10 Interface Result
Trang 36Runtime Polymorphism: Run me polymorphism occurs when we use method overriding, which means a subclass re-implements a method that the parent class has de ned When calling a method, the implementa on of the method will be determined based on the actual object it references [5]
Figure 11 Compile-time Polymorphism Result
Trang 38Result:
e.Overriding method: Overriding methods allows a subclass to implement a method from a parent class The method in the subclass replaces the method of
Figure 13 Runtime polymorphism Result
Trang 39the same name in the superclass, and it is called when the subclass is executed For example: [5]
Trang 41The compiler will determine the specific method to be called based on the arguments passed For example: [5]
Result:
Figure 14 Method overloading Result
Figure 16 Method overloading
Figure 17 Method overloading Result
Trang 422 Design and build class diagrams using a UML tool (P2) A What are the Class Diagram?
Class diagrams, a component of the Uni ed Modeling Language (UML) employed in the eld of so ware engineering, serve as visual tools for depic ng the arrangement and associa ons among classes in a system or applica on These diagrams are crucial in the realm of object-oriented design, aiding both developers and stakeholders in comprehending the structure of a so ware system Typically u lized
Trang 43in the design and analysis stages of so ware development, class diagrams play a pivotal role in the so ware development process [6]
B Relationships in Class Diagrams
Association: Associa ons represent a connec on between classes and are o en used to express a "has-a" rela onship They can be one- -one, one- -many, or to tomany-to-many [7]
Aggrega on: Aggrega on represents a part-whole rela onship, where one class is part of another class It is o en used to express a "has-a" rela onship, but with a weaker associa on [7]
Figure 18 Association
Trang 44Figure 19 Aggregation
Trang 45Composition: Composi on is a stronger form of aggrega on, indica ng that the part's existence depends on the whole In a composi on rela onship, if the whole class is destroyed, the part class is also destroyed [7]
Inheritance (Generalization): Inheritance rela onships depict an "is-a" rela onship They show that one class (the subclass or derived class) inherits a ributes and methods from another class (the superclass or base class) This rela onship is used for modeling hierarchical structures [7]
Figure 20 Composition
Trang 47Figure 21 Inheritance
Dependency: Dependency represents a rela onship in which one class relies on another class in some way It is typically shown as a dashed line with an arrow poin ng from the dependent class to the class it depends on Dependencies may be temporary or weak connec ons between classes [7]
Trang 48Figure 22 Dependency
Trang 49Realization: Realiza on is used to show that a class implements the opera ons or methods speci ed by an interface It's a rela onship between a class and an interface, indica ng that the class provides concrete implementa ons for the methods declared in the interface.[7]
Multiplicity: Mul plicity indicates the number of instances of one class related to instances of another class in an associa on It is o en expressed using numerical ranges specifying how many objects are involved in the rela onship [7]
Figure 23 Realization
Trang 50Figure 24 Multiplicity
Association Classes: In some cases, associa ons themselves can have a ributes and methods associated with them These are represented as associa on classes, which are classes connected to the associa on rela onship [7]
Trang 51Figure 25 Association ClassesC Introducing some class diagram tools
UML Class Diagram: UML Class Diagram helps you represent classes, proper es, methods, and rela onships between classes This helps you see the overall structure of the system and be er understand the objects and their interac ons
Visual Paradigm class diagram tool: Visual Paradigm is a popular modeling tool that allows you to create and manage class diagrams You can use this tool to create classes, proper es, methods, and rela onships between classes
Astah: Astah is a so ware design and modeling tool similar to Visual Paradigm You can use Astah to create class diagrams, sequence diagrams, ac vity diagrams, and many other types of diagrams
Visual Studio Class Diagram Tool: Visual Studio uses a built-in tool to create class diagrams Visual Studio provides a graphical class designer that allows you to create classes, proper es, and methods
Trang 52Draw.io: An online tool for crea ng and edi ng diagrams with an easy- -use tointerface It provides many drawing and forma ng tools for you to create diagrams as you like [8]
D Use the apply tool to draw the class diagram
I use draw.io it is a free and open- urce diagramming tool that supports class sodiagrams among other diagram types This is a web-based applica on with a simple interface that makes it easy to create and customize class diagrams draw.io also o ers integra on with various cloud storage pla orms
Class Diagram for Employee system management
Trang 53The Employee management interface of this system is where I can display, search, add, edit and delete informa on related to employees Key en es such as Role, Jobs, Person, Fullname, Employee, and Address play an important role in the process of managing and maintaining employee informa on
Management Interface:
This interface provides the ability to control and perform necessary human resources management tasks, including viewing informa on, searching, adding new employees, edi ng informa on and dele ng
Main En es:
Role and Jobs: Helps manage employee roles and jobs in the organiza on Person and Fullname: Process employee personal informa on, including full
name and related informa on
Employee: Represents general informa on of employees in the system Address: Manage the employee's residen al address
Class diagram:
Merging these en es into the class diagram gives me an overview of how the system interacts and helps maintain employee informa on e ciently Through this management interface, I have the ability to track and manage personnel informa on, including details about roles, jobs, personal informa on and residen al addresses, helping to create a system Human resource management system is e ec ve and easy to use