Tải bản đầy đủ (.pdf) (62 trang)

unit 20 advanced programming

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (5.45 MB, 62 trang )

<span class="text_page_counter">Trang 1</span><div class="page_container" data-page="1">

ASSIGNMENT 1 FRONT SHEET

Qualification 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.

</div><span class="text_page_counter">Trang 3</span><div class="page_container" data-page="3">

OBSERVATION RECORD

Student 1 Do Hoang Nhan

Description of activity undertaken

- <small>Design and build class diagrams using a UML tool: 50%</small>

Assessment & grading criteria

How the activity meets the requirements of the criteria

</div><span class="text_page_counter">Trang 5</span><div class="page_container" data-page="5">

Student 2 To Phuoc Thanh

Description of activity undertaken

- <small>Design and build class diagrams using a UML tool: 50%</small>

Assessment & grading criteria

How the activity meets the requirements of the criteria

</div><span class="text_page_counter">Trang 7</span><div class="page_container" data-page="7">

Student 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

</div><span class="text_page_counter">Trang 9</span><div class="page_container" data-page="9">

Student 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

</div><span class="text_page_counter">Trang 11</span><div class="page_container" data-page="11">

Summative Feedback: Resubmission Feedback:

Internal Verifier’s Comments:

</div><span class="text_page_counter">Trang 12</span><div class="page_container" data-page="12">

Signature & Date:

</div><span class="text_page_counter">Trang 13</span><div class="page_container" data-page="13">

B. 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

</div><span class="text_page_counter">Trang 15</span><div class="page_container" data-page="15">

Figure 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

</div><span class="text_page_counter">Trang 17</span><div class="page_container" data-page="17">

I. 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

</div><span class="text_page_counter">Trang 18</span><div class="page_container" data-page="18">

concepts. [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.

</div><span class="text_page_counter">Trang 19</span><div class="page_container" data-page="19">

Consider 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 <small>Figure 1. Class Example</small>

<small>Figure 2. Object Example</small>

</div><span class="text_page_counter">Trang 20</span><div class="page_container" data-page="20">

specify 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."

</div><span class="text_page_counter">Trang 21</span><div class="page_container" data-page="21">

4. Method: The ac ons or behaviors that an object can carry out are referred to as methods.

<small>Figure 3. Properties Example</small>

</div><span class="text_page_counter">Trang 23</span><div class="page_container" data-page="23">

As 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.

</div><span class="text_page_counter">Trang 25</span><div class="page_container" data-page="25">

A 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

</div><span class="text_page_counter">Trang 26</span><div class="page_container" data-page="26">

to 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

</div><span class="text_page_counter">Trang 27</span><div class="page_container" data-page="27">

Complexity: 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.

</div><span class="text_page_counter">Trang 29</span><div class="page_container" data-page="29">

Inheritance allows reusing source code and building new classes on top of exis ng classes. Example: [3]

Result:

<small>Figure 4. Encapsulation </small>

</div><span class="text_page_counter">Trang 30</span><div class="page_container" data-page="30">

b. 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.

<small>Figure 5 Encapsulation Result. </small>

</div><span class="text_page_counter">Trang 31</span><div class="page_container" data-page="31">

Abstrac on helps hide the complexity of the class's internals and focus on using the services provided by that class. Example: [4]

</div><span class="text_page_counter">Trang 32</span><div class="page_container" data-page="32">

Result:

<small>Figure 6. Abstraction </small>

</div><span class="text_page_counter">Trang 33</span><div class="page_container" data-page="33">

c. 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:

<small>Figure 8. Interface </small>

</div><span class="text_page_counter">Trang 34</span><div class="page_container" data-page="34">

<small>Figure 9 Interface Result . </small>d. Polymorphism.

</div><span class="text_page_counter">Trang 35</span><div class="page_container" data-page="35">

Compile- 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:

<small>Figure 10. Interface Result</small>

</div><span class="text_page_counter">Trang 36</span><div class="page_container" data-page="36">

Runtime 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]

<small>Figure 11. Compile-time Polymorphism Result</small>

</div><span class="text_page_counter">Trang 38</span><div class="page_container" data-page="38">

Result:

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

<small>Figure 13. Runtime polymorphism Result</small>

</div><span class="text_page_counter">Trang 39</span><div class="page_container" data-page="39">

the same name in the superclass, and it is called when the subclass is executed. For example: [5]

</div><span class="text_page_counter">Trang 41</span><div class="page_container" data-page="41">

The compiler will determine the specific method to be called based on the arguments passed. For example: [5]

Result:

<small>Figure 14. Method overloading Result </small>

<small>Figure 16. Method overloading</small>

<small>Figure 17. Method overloading Result</small>

</div><span class="text_page_counter">Trang 42</span><div class="page_container" data-page="42">

2. 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

</div><span class="text_page_counter">Trang 43</span><div class="page_container" data-page="43">

in 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]

<small>Figure 18. Association</small>

</div><span class="text_page_counter">Trang 44</span><div class="page_container" data-page="44">

<small>Figure 19. Aggregation</small>

</div><span class="text_page_counter">Trang 45</span><div class="page_container" data-page="45">

Composition: 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]

<small>Figure 20. Composition</small>

</div><span class="text_page_counter">Trang 47</span><div class="page_container" data-page="47">

<small>Figure 21. Inheritance</small>

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]

</div><span class="text_page_counter">Trang 48</span><div class="page_container" data-page="48">

<small>Figure 22. Dependency</small>

</div><span class="text_page_counter">Trang 49</span><div class="page_container" data-page="49">

Realization: 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]

<small>Figure 23. Realization</small>

</div><span class="text_page_counter">Trang 50</span><div class="page_container" data-page="50">

<small>Figure 24. Multiplicity</small>

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]

</div><span class="text_page_counter">Trang 51</span><div class="page_container" data-page="51">

<small>Figure 25. Association Classes</small>C. 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.

</div><span class="text_page_counter">Trang 52</span><div class="page_container" data-page="52">

Draw.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

</div><span class="text_page_counter">Trang 53</span><div class="page_container" data-page="53">

The 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.

</div>

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×