higher nationals in computing advanced programming assignment

42 0 0
Tài liệu đã được kiểm tra trùng lặp
higher nationals in computing advanced programming assignment

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

The presentation should be about approximately 20-30 minutes and it should be summarized of the teamreport.Learning Outcomes and Assessment CriteriaLO1 Examine the key components related

Trang 1

Higher Nationals in Computing

Advanced ProgrammingASSIGNMENT 1

Learner’s name: NGUYỄỄN HOÀNG PHƯƠNG ID: GCS200104

Class: GCS0902Subject code: 1651

Assessor name: Nguyễễn Văn Sơn

Trang 3

ASSIGNMENT 1 FRONT SHEET

Unit number and title Unit 20: Advanced Programming

submissionRe-submission DateDate Received 2nd

submission

Trang 5

Summative Feedback: Resubmission Feedback:

Lecturer Signature:

Trang 7

ASSIGNMENT 1 BRIEF

Assignment title Examine and design solutions with OOP and Design Patterns

Submission Format:

Format: The submission is in the form of a group written report This should be written in a concise,

formal business style using single spacing and font size 12 You are required to make use ofheadings, paragraphs and subsections as appropriate, and all work must be supported withresearch and referenced using the Harvard referencing system Please also provide a bibliographyusing the Harvard referencing system.

Submission Students are compulsory to submit the assignment in due date and in a way requested by theTutors The form of submission will be a soft copy in PDF posted on corresponding course of

Note: The Assignment must be your own work, and not copied by or from another student or frombooks etc If you use ideas, quotes or data (such as diagrams) from books, journals or other sources, you mustreference your sources, using the Harvard style Make sure that you know how to reference properly, and thatunderstand the guidelines on plagiarism If you do not, you definitely get fail

Assignment Brief and Guidance:

Scenario: You have recently joined a software development company to help improve theirdocumentation of their in-houses software libraries which were developed with very poor

Trang 8

docu eooeouses so w ebes w cwe e deve oped wve y poodocumentation As a result, it has been very difficult for the company to utilise their code in multipleprojects due to poor documentation Your role is to alleviate this situation by showing the efficient ofUML diagrams in OOAD and Design Patterns in usages.

You and your team need to explain characteristics of Object-oriented programming paradigm byapplying Object-oriented analysis and design on a given (assumed) scenario The scenario can be smallbut should be able to presents various characteristics of OOP (such as: encapsulation, inheritance,polymorphism, override, overload, etc.).

The second task is to introduce some design patterns (including 3 types: creational, structural andbehavioral) to audience by giving real case scenarios, corresponding patterns illustrated by UML classdiagrams

To summarize, you should analyze the relationship between the object-orientated paradigm and designpatterns.

Trang 9

The presentation should be about approximately 20-30 minutes and it should be summarized of the teamreport.

Learning Outcomes and Assessment Criteria

LO1 Examine the key components related to the object-orientated programming paradigm, analysing design pattern types

P1 Examine the characteristics of the object-orientated paradigmas well as the various classrelationships.

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 codescenario using a UML tool

Trang 10

Table of Contents

1.Examine the characteristics of the object-orientated paradigm as well as the various class relationships (P1) 6

Trang 11

1.3.Various Class Relationship 12

2.Design and build class diagrams using a UML tool (P2) 16

2.2.Usecase diagram 16

2.3.Class diagram 18

Bibliography 20

Trang 12

1 Examine the characteristics of the object-orientated paradigm as wellas the various class relationships (P1)

1.1.What is OOP ?

Trang 13

- Object oriented programming (OOP) is a programming structure where programs are organized around objects as opposed to action and logic This is essentially a design philosophy that uses a different set of programming languages such as C# Understanding OOP concepts can help make decisions about how you should design an application and what language to use.[ CITATION ALE17 \l 1066 ]

- A simple example would be a class representing a person The person class would contain attributes to represent information such as the person’s age, name, height, etc The class definition might also contain functions such as "sayMyName" which would simply print that person’s name to the screen.

- A family could be constructed by instantiating person objects from the class for each member of the family Each person object would contain different data attributes since each person is unique.

Trang 14

1.2.4 Basic concept of OOP

- Object-oriented programming has four basic concepts: encapsulation, abstraction, inheritance, andpolymorphism Even if these concepts seem incredibly complex, understanding the general

Trang 15

framework of how they work will help you understand the basics of an OOP computer program Below, we outline these four basic principles and what they entail:

+ Encapsulation+ Abstraction+ Inheritance

+ Polymorphism [ CITATION Kyl21 \l 1066 ]

1.2.1 Encapsulation

- The word, “encapsulate,” means to enclose something Just like a pill "encapsulates" or contains the medication inside of its coating, the principle of encapsulation works in a similar way in OOP:by forming a protective barrier around the information contained within a class from the rest of the code.

- In OOP, we encapsulate by binding the data and functions which operate on that data into a single unit, the class By doing so, we can hide private details of a class from the outside world and only expose functionality that is important for interfacing with it When a class does not allow calling code access to its private data directly, we say that it is well encapsulated.

- Example: Elaborating on the person class example from earlier, we might have private data in the class, such as "socialSecurityNumber," that should not be exposed to other objects in the program.By encapsulating this data member as a private variable in the class, outside code would not have direct access to it, and it would remain safe within that person’s object.

- If a method is written in the person class to perform, say, a bank transaction called "bankTransaction()," that function could then access the "socialSecurityNumber" variable as

Trang 16

necessary The person’s private data would be well encapsulated in such a class [ CITATION Kyl21 \l 1066 ]

Trang 17

[ CITATION AKs22 \l 1066 ]

1.2.2 Abstraction.

- Often, it’s easier to reason and design a program when you can separate the interface of a class from its implementation, and focus on the interface This is akin to treating a system as a “black box,” where it’s not important to understand the gory inner workings in order to reap the benefits of using it.

- This process is called “abstraction” in OOP, because we are abstracting away the gory

Trang 18

p , g y g yimplementation details of a class and only presenting a clean and easy-to-use interface via the class’ member functions Carefully used, abstraction helps isolate the impact of changes made to the code, so that if something goes wrong, the change will only affect the implementation details of a class and not the outside code.

- Example: Think of a stereo system as an object with a complex logic board on the inside It has buttons on the outside to allow for interaction with the object When you press any of the buttons, you're not thinking about what happens on the inside because you can't see it Even though you

Trang 19

can't see the logic board completing these functions as a result of pressing a button, it's still performing them., albeit hidden to you.

- This is the concept of abstraction, which is incredibly useful in all areas of engineering and also applied to great effect in object-oriented programming

- Example: In OOP, we might have a class defined to represent the human body One might define some functions as part of its publicly facing interface such as “walk()” or “eatFood().” Calling code could call these functions and remain completely oblivious to the complex inner workings ofthe human body and its necessary functions to perform the act of walking or eating These details are completely hidden in the implementation of the walk() and eatFood() body functions and are, therefore, us abstracted away from the end user In these cases, it’s not important for calling code to understand how the brain coordinates walking or how the stomach manages digesting the food, but rather simply that a human walked or ate [ CITATION Kyl21 \l 1066 ]

Trang 20

[ CITATION Vik18 \l 1066 ]

Trang 21

1.2.3 Inheritance

- Object-oriented languages that support classes almost always support the notion of “inheritance.” Classes can be organized into hierarchies, where a class might have one or more parent or child classes If a class has a parent class, we say it is derived or inherited from the parent class and it represents an “IS-A” type relationship That is to say, the child class “IS-A” type of the parent class.

- Therefore, if a class inherits from another class, it automatically obtains a lot of the same functionality and properties from that class and can be extended to contain separate code and data.A nice feature of inheritance is that it often leads to good code reuse since a parent class’ functionsdon’t need to be re-defined in any of its child classes.

- Consider two classes: one being the superclass—or parent—and the other being the subclass—or child The child class will inherit the properties of the parent class, possibly modifying or extending its behavior Programmers applying the technique of inheritance arrange these classes into what is called an “IS-A” type of relationship.

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

Trang 22

[ CITATION Ris20 \l 1066 ]

Trang 23

1.2.4 Polymorphism

- In OOP, polymorphism allows for the uniform treatment of classes in a hierarchy Therefore, calling code only needs to be written to handle objects from the root of the hierarchy, and any object instantiated by any child class in the hierarchy will be handled in the same way.

- Because derived objects share the same interface as their parents, the calling code can call any function in that class’ interface At run-time, the appropriate function will be called depending on the type of object passed leading to possibly different behaviors.

- Example: Suppose we have a class called, “Animal” and two child classes, “Cat,” and “Dog.” If the Animal class has a method to make a noise, called, “makeNoise,” then, we can override the "makeNoise" function that is inherited by the sub-classes, "Cat" and "Dog," to be “meow” and “bark,” respectively Another function can, then, be written that accepts any Animal object as a parameter and invokes its "makeNoise" member function The noise will be different: either a “meow” or a “bark” depending on the type of animal object that was actually passed to the function [ CITATION Kyl21 \l 1066 ]

Trang 24

[ CITATION San20 \l 1066 ]

Trang 25

1.3.Various Class Relationship

- Classes are interrelated to each other in specific ways In particular, relationships in class diagrams include different types of logical connections The following are such types of logical connections that are possible in UML:

+ Association+ Directed Association+ Reflexive Association+ Multiplicity + Aggregation+ Composition+ Realization

+ Inheritance/Generalization

Trang 27

-Association: is a broad term that encompasses just about any logical connection or relationship between classes For example, passenger and airline may be linked as above.

Trang 28

For example, a staff member working in an airport may be a pilot, aviation engineer, a ticket dispatcher, a guard, or a maintenance crew member If the maintenance crew member is managed by the aviation engineer there could be a managed by relationship in two instances of the same class.

Trang 29

-Multiplicity: is the active logical association when the cardinality of a class in relation to another is being depicted For example, one fleet may include multiple airplanes, while one commercial airplane may contain zero to many passengers The notation 0 * in the diagram means “zero to many”.

-Aggregation: refers to the formation of a particular class as a result of one class being aggregatedor built as a collection For example, the class “library” is made up of one or more books, among other materials In aggregation, the contained classes are not strongly dependent on the lifecycle of the container In the same example, books will remain so even when the library is dissolved Toshow aggregation in a diagram, draw a line from the parent class to the child class with a diamond shape near the parent class To show aggregation in a diagram, draw a line from the parent class to the child class with a diamond shape near the parent class.

Trang 31

Composition: The composition relationship is very similar to the aggregation relationship with the only difference being its key purpose of emphasizing the dependence of the contained class to the life cycle of the container class That is, the contained class will be obliterated when the container class is destroyed For example, a shoulder bag’s side pocket will also cease to exist once the shoulder bag is destroyed To show a composition relationship in a UML diagram, use a directional line connecting the two classes, with a filled diamond shape adjacent to the containerclass and the directional arrow to the contained class.

Inheritance / Generalization: refers to a type of relationship wherein one associated class is a child of another by virtue of assuming the same functionalities of the parent class In other words, the child class is a specific type of the parent class To show inheritance in a UML diagram,a solid line from the child class to the parent class is drawn using an unfilled arrowhead.

Trang 33

Realization: denotes the implementation of the functionality defined in one class by another class To show the relationship in UML, a broken line with an unfilled solid arrowhead is drawn from the class that defines the functionality of the class that implements the function In the example, the printing preferences that are set using the printer setup interface are being implemented by the printer.

2 Design and build class diagrams using a UML tool (P2)2.1.Scenario

- The University of Greenwich is expanding, so the management of staff and students is becoming more and more complicated We need to create a software that can manage students and staff inthe school The application allows to manage students, students' grades, staff management, staff salaries.

Ngày đăng: 08/05/2024, 14:39

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan