Docsity

SDLC Nhap Assignment 2, Study Guides, Projects, Research of Software Engineering

Toggle sidebar
bg1
PROGRAM TITLE: BTEC in Computing (Software Engineering)
UNIT TITLE: Advanced Programming
ASSIGNMENT NUMBER: 1
ASSIGNMENT NAME: Design Pattern
SUBMISSION DATE: 9/3/2022
DATE RECEIVED: 9/3/2022
TUTORIAL LECTURER: Pham Son Tung
WORD COUNT: 4726
STUDENT NAME: Hoang Van Hiep
STUDENT ID: BKC 12227
MOBILE NUMBER: 0866814728
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20

Partial preview of the text

Download SDLC Nhap Assignment 2 and more Study Guides, Projects, Research Software Engineering in PDF only on Docsity!

PROGRAM TITLE: BTEC in Computing (Software Engineering) UNIT TITLE: Advanced Programming ASSIGNMENT NUMBER: 1 ASSIGNMENT NAME: Design Pattern SUBMISSION DATE: 9/3/ DATE RECEIVED: 9/3/ TUTORIAL LECTURER: Pham Son Tung WORD COUNT: 4726 STUDENT NAME: Hoang Van Hiep STUDENT ID: BKC 12227 MOBILE NUMBER: 0866814728

Summative Feedback:

  • A. Introduction............................................................................................................................................
  • B. Theoretical basis......................................................................................................................................
    • I. Object Oriented Programming (OOP)...................................................................................................
        1. Define..............................................................................................................................................
        1. Structure of object-oriented programming.....................................................................................
        1. Main principles of OOP....................................................................................................................
        1. Benefits of OOP...............................................................................................................................
        1. Advantages of OOP..........................................................................................................................
        1. Disadvantages of OOP.....................................................................................................................
        1. Relationship between Class and Object in OOP...............................................................................
        1. Relationships between Classess.......................................................................................................
        • 8.1. IS-A Relationship.......................................................................................................................
        • 8.2. Dependency..............................................................................................................................
        • 8.3. Has-a.........................................................................................................................................
        • 8.4. Association..............................................................................................................................
        • 8.5. Aggregation.............................................................................................................................
        • 8.6. Composition............................................................................................................................
    • II. Unified Modeling Language...............................................................................................................
        1. Define............................................................................................................................................
        1. Importance of UML........................................................................................................................
        1. Types of UML.................................................................................................................................
        1. Structural UML Diagrams...............................................................................................................
        1. Behavior Diagrams.........................................................................................................................
        1. Tools to draw UML.........................................................................................................................
        • 6.1. Draw.io...................................................................................................................................
        • 6.2. Lucidchart...............................................................................................................................
        • 6.3. Visual Paradigm......................................................................................................................
        • 6.4. Edraw Max..............................................................................................................................
        1. Class diagram drawing tutorial......................................................................................................
        • 7.1. Visual Paradigm......................................................................................................................
        • 7.2. Draw.io...................................................................................................................................
        • 7.3. Analyze the components that make up the class diagram in UML.........................................
        1. Example of UML.............................................................................................................................
    • III. Design Pattern..................................................................................................................................
        1. Define............................................................................................................................................
        1. Uses of Design Patterns.................................................................................................................
        1. Design pattern classification..........................................................................................................
        • 3.1. Creational design patterns......................................................................................................
        • 3.2. Structural design patterns.......................................................................................................
        • 3.3. Behavioral design patterns.....................................................................................................
    • IV. Example of Design Pattern................................................................................................................
        1. Example of Creational Design Pattern............................................................................................
        1. Example of Structural Design Pattern............................................................................................
        1. Example of Behavioral Design Pattern...........................................................................................
  • References.................................................................................................................................................

A. Introduction

  • I am an employee holding the title of fresher at BK Job company. The company gave me the task to learn about Object Oriented Programming, Design Pattern and related things. After some time allowed to learn about the above, I created a report on what I have learned. In the report I gave an overview of object-oriented programming, the relationship between classes and objects and their characteristics and relationships in object-oriented programming Object- oriented programming. Next I learned about UML including overview, tools, and usage. Finally on the Design Pattern section I learned about 3 groups including creational, structural and behavioral. And for each group I also took specific examples including UML and code. After understanding the basic theories above, I was able to code an exercise using Design Pattern to create the company's UML-designed music player application. Not only that, but I also discuss how to use that design in the application and give suggestions for other development direction for the application using an alternative design pattern. B. Theoretical basis I. Object Oriented Programming (OOP)
  1. Define
  • Object-oriented programming (OOP) is a computer programming model that organizes software design around data, or objects, rather than functions and logic. An object can be defined as a data field that has unique attributes and behavior.
  1. Structure of object-oriented programming
  • The structure, or building blocks, of object-oriented programming include the following:
  • Classes are user-defined data types that act as the blueprint for individual objects, attributes and methods.
  • Objects are instances of a class created with specifically defined data. Objects can correspond to real-world objects or an abstract entity. When class is defined initially, the description is the only object that is defined.
  • Methods are functions that are defined inside a class that describe the behaviors of an object. Each method contained in class definitions starts with a reference to an instance object. Additionally, the subroutines contained in an object are called instance methods. Programmers use methods for reusability or keeping functionality encapsulated inside one object at a time.
  • Easily upgradable and scalable: Programmers can implement system functionalities independently.
  • Interface descriptions: Descriptions of external systems are simple, due to message passing techniques that are used for objects communication.
  • Security: Using encapsulation and abstraction, complex code is hidden, software maintenance is easier and internet protocols are protected.
  • Flexibility: Polymorphism enables a single function to adapt to the class it is placed in. Different objects can also pass through the same interface.
  1. Advantages of OOP
  • Productivity of software development increased: Object-arranged writing computer programs is measured, as it gives detachment of obligations in object-based program advancement. It is additionally extensible, as articles can be stretched out to incorporate new qualities and practices. Items can likewise be reused inside and across applications. Due to these three variables – particularity, extensibility, and reusability – object-situated programming gives further developed programming advancement usefulness over conventional strategy based programming methods.
  • Software maintenance improved: For the reasons referenced above, object-oriented programming is likewise simpler to keep up with. Since the plan is secluded, a piece of the framework can be refreshed if there should arise an occurrence of issues without a need to roll out huge scope improvements.
  • Quicker improvement: Reuse empowers quicker advancement. Object-situated programming dialects accompany rich libraries of articles, and code created during projects is additionally reusable in later ventures.
  • Cost of development lowered: The reuse of programming likewise brings down the expense of advancement. Normally, more exertion is placed into the article situated examination and plan, which brings down the general expense of improvement.
  • Good quality software: Faster improvement of programming and lower cost of advancement permits additional time and assets to be utilized in the confirmation of the product. Albeit quality is reliant upon the experience of the groups, object-situated programming will in general bring about greater programming.
  1. Disadvantages of OOP
    • Steep expectation to learn and adapt: The perspective engaged with object-situated programming may not be normal for certain individuals, and it can invest in some opportunity to become accustomed to it. It is complex to make programs in view of the cooperation of articles. A portion of the key programming procedures, like inheritance and polymorphism, can be tested to appreciate at first.
    • Bigger program size: Object-arranged programs commonly include more lines of code than procedural projects.
    • More slow projects: Object-arranged programs are normally slower than procedure- based programs, as they ordinarily require more guidelines to be executed.
    • Not appropriate for a wide range of issues: There are issues that loan themselves well to useful programming style, rationale programming style, or strategy based programming style, and applying object-arranged programming in those circumstances will not bring about effective projects.
  2. Relationship between Class and Object in OOP
    • An object is an element (or instance) of a class; objects have the behaviors of their class. The object is the actual component of programs, while the class specifies how instances are created and how they behave.
  3. Relationships between Classess 8.1. IS-A Relationship
    • In object-oriented programming, the concept of IS-A is a totally based on Inheritance, which can be of two types Class Inheritance or Interface Inheritance. It is just like saying "A is a B type of thing". For example, Apple is a Fruit, Car is a Vehicle etc. Inheritance is uni- directional. For example, House is a Building. But Building is not a House.
    • It is a key point to note that you can easily identify the IS-A relationship. Wherever you see an extends keyword or implements keyword in a class declaration, then this class is said to have IS-A relationship. 8.2. Dependency
    • One class object is a component of another class in this relationship. A part-of relationship exists between two classes, A and B if class A's object is a part of class B or vice versa.

8.4. Association

  • Association is a commonly used term in Object-Oriented Programming for both has-a and part-of relationships, but it is not restricted to these. When we say that two objects are in an association relationship, we are making a generic statement, which means that we are not concerned with the objects’ lifetime dependency.
  • Consider the relationship between a doctor and a patient. A doctor may be associated with more than one patient. A patient can see multiple doctors for treatment or consultation at the same time. Each of these objects has its own life cycle, and there is no “owner” or “parent” to speak of. Objects in an association relationship can be created and destroyed independently. 8.5. Aggregation
  • The has-A model is used for aggregation. This establishes a parent-child relationship between two classes, with one owning the object of the other.
  • So, what distinguishes aggregation? The lifetime of the owned object does not depend on the lifetime of the owner in aggregation. The owner object may be deleted, but the owned object may remain in the program. The parent only contains a reference to the child in aggregation, which removes the child’s dependency.

8.6. Composition

  • The practice of creating other class objects in your class is known as composition. In this case, the class that creates the object of the other class is known as the owner, and it is responsible for the object’s lifetime.
  • Composition relationships are Part-of relationships in which the part must be a component of the entire object. We can achieve composition by combining smaller pieces of other classes to form a larger unit.
  • So, what distinguishes the composition? In composition, the lifetime of the owned object is determined by the owner’s lifetime.
  • A house, for example, may have one or more rooms. If the house is destroyed, then all of the rooms within it are also destroyed.
  • A car is made up of three parts: an engine, tires, and doors. In this case, a Car owns these objects, so the Car class is an Owner class, while the tire, door, and engine classes are Owned classes. II. Unified Modeling Language
  1. Define
  • Unified Modeling Language (UML) is a general purpose modelling language. The main aim of UML is to define a standard way to visualize the way a system has been designed. It is quite similar to blueprints used in other fields of engineering.

behaviour when objects have been instantiated, we are able to study the behaviour of the system at a particular instant. An object diagram is similar to a class diagram except it shows the instances of classes in the system. We depict actual classifiers and their relationships making the use of class diagrams. On the other hand, an Object Diagram represents specific instances of classes and relationships between them at a point of time.

  • Component Diagram – Component diagrams are used to represent the how the physical components in a system have been organized. We use them for modelling implementation details. Component Diagrams depict the structural relationship between software system elements and help us in understanding if functional requirements have been covered by planned development. Component Diagrams become essential to use when we design and build complex systems. Interfaces are used by components of the system to communicate with each other.
  • Deployment Diagram – Deployment Diagrams are used to represent system hardware and its software.It tells us what hardware components exist and what software components run on them.We illustrate system architecture as distribution of software artifacts over distributed targets. An artifact is the information that is generated by system software. They are primarily used when a software is being used, distributed or deployed over multiple machines with different configurations.
  • Package Diagram – We use Package Diagrams to depict how packages and their elements have been organized. A package diagram simply shows us the dependencies between different packages and internal composition of packages. Packages help us to organise UML diagrams into meaningful groups and make the diagram easy to understand. They are primarily used to organise class and use case diagrams.
  1. Behavior Diagrams
  • State Machine Diagrams – A state diagram is used to represent the condition of the system or part of the system at finite instances of time. It’s a behavioral diagram and it represents the behavior using finite state transitions. State diagrams are also referred to as State machines and State-chart Diagrams. These terms are often used interchangeably.So simply, a state diagram is used to model the dynamic behavior of a class in response to time and changing external stimuli.
  • Activity Diagrams – We use Activity Diagrams to illustrate the flow of control in a system. We can also use an activity diagram to refer to the steps involved in the execution of a use case. We model sequential and concurrent activities using activity diagrams. So, we basically depict workflows visually using an activity diagram.An activity diagram focuses on condition of

flow and the sequence in which it happens. We describe or depict what causes a particular event using an activity diagram.

  • Use Case Diagrams – Use Case Diagrams are used to depict the functionality of a system or a part of a system. They are widely used to illustrate the functional requirements of the system and its interaction with external agents(actors). A use case is basically a diagram representing different scenarios where the system can be used. A use case diagram gives us a high level view of what the system or a part of the system does without going into implementation details.
  • Sequence Diagram – A sequence diagram simply depicts interaction between objects in a sequential order i.e. the order in which these interactions take place.We can also use the terms event diagrams or event scenarios to refer to a sequence diagram. Sequence diagrams describe how and in what order the objects in a system function. These diagrams are widely used by businessmen and software developers to document and understand requirements for new and existing systems.
  • Communication Diagram – A Communication Diagram(known as Collaboration Diagram in UML 1.x) is used to show sequenced messages exchanged between objects. A communication diagram focuses primarily on objects and their relationships. We can represent similar information using Sequence diagrams,however, communication diagrams represent objects and links in a free form.
  • Timing Diagram – Timing Diagram are a special form of Sequence diagrams which are used to depict the behavior of objects over a time frame. We use them to show time and duration constraints which govern changes in states and behavior of objects.
  • Interaction Overview Diagram – An Interaction Overview Diagram models a sequence of actions and helps us simplify complex interactions into simpler occurrences. It is a mixture of activity and sequence diagrams.
  1. Tools to draw UML 6.1. Draw.io
  • Draw.io is a free open-source collaborative workspace for drawing UML diagrams. It also contains predefined templates for drawing any UML diagram, creating wireframes, business charts, etc. It is available as both software and online tool. It is used by many enterprises. Draw.io supports enterprise browsers. It is linked with Google Drive so it automatically saves our work. It has a beginner-friendly interface and is mostly used for professional diagrams. It
  1. Class diagram drawing tutorial 7.1. Visual Paradigm
    • Step 1: After you click on the link https://online.visual-paradigm.com/. You just need to click on the button "Get started for free" and you can start drawing class diagrams
    • Step 2: The next displayed page will look like this. Here, besides drawing class diagrams, you can draw other diagrams
    • Step 3: You just need to enter "Class diagram" in the search box and you will find the list of class maps
  • Step 4: You just need to choose 1 of 4 class diagram suggestions and draw as you like 7.2. Draw.io
  • Step 1: You click on the link https://www.draw.io/ and then register with an email account, a page like this will appear. Click on the class diagram to start drawing the class diagram
  • In there,
    • Class Name: is the name of the class.
    • Attributes: describe the properties of objects. For example, a person has their own Code, Name, Age, Date of Birth, etc.
    • Method: only the actions that this object can perform in the system. It represents the behavior of objects created by this class.
  • Class relationship: where a class shares structure and/or behavior with one or more other classes
  • Single inheritance
  • Multiple inheritance
  • There are four types of relationships:
    • Inheritance: A class inherits from another class.
    • Association: 2 classes that are related but do not specify the relationship.
  • Composition: If the object created from class A is lost, the object created from class B will be lost.
  • Agreegation: The object created from class A is lost, the object created from class B still exists independently.
  1. Example of UML
    • UML
    • Code