DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Culture and Methodologies
  3. Agile
  4. Object-Oriented Analysis and Design (Part 3)

Object-Oriented Analysis and Design (Part 3)

In part 3 of 4, we look at putting the concepts of Object-Oriented Analysis and Design that we've already discussed into practice.

Muhammad Umair user avatar by
Muhammad Umair
·
Feb. 25, 18 · Tutorial
Like (22)
Save
Tweet
Share
12.97K Views

Join the DZone community and get the full member experience.

Join For Free

Introduction

Welcome to part three of a four-part series. Okay, enough of learning principles and theory in part one and part two. Let's apply them here using a very simple example.

Example of Object-Oriented Analysis and Design

Here is an example which depicts a simple process for object-oriented analysis and design.

First, I will share a user story that we will tackle in this example:

user requirements


User Story

  • A customer arrives at checkout with items to purchase.
  • The shopkeeper at the counter greets them and starts a new sale.
  • The shopkeeper enters all the items.
  • The system calculates the order total and taxes.
  • The customer pays.
  • The system printed the receipt and updates the inventory.

Steps for Object-Oriented Analysis

There are three steps in the following order:

  • Identify class names.
  • Identify attributes.
  • Identify associations.

Now I suggest that you underline all the nouns in the text of the user story which you think will be good candidates for class names in our code.

Here are all the names of the classes that I can think of by reading the user story above:

Domain Model

UML Domain Model


You can see in the diagram that it is not developed using any UML tool. I just used a pen and a rough sheet of paper. More than 60 percent of my designing is done on either paper or a whiteboard.

Next steps: identifying attributes and associations. An attribute is what defines a class or object. An attribute can be an Id, amount, or anything that can be measured. The association defines a relationship between classes and objects about how a class is connected to another class.

The following diagram shows the attributes and associations for the class diagram that I have shown above:

UML Domain Model with attributes and associations


Steps in Object-Oriented Design

After the analysis, we moved to object-oriented design. Here are the steps:

  • Draw sequence diagram(s) for each scenario.
  • Draw a design class diagram.
  • Apply design principles and software design patterns.

A sequence diagram is used to show the message passing between objects of classes. It is the most important tool in object oriented design since it helps in designing the behavior of objects involved in a software.

Here is the sequence diagram that I drew to address the user story:

UML Seqence Diagram

This sequence diagram shows the messages and the ordering in which they are sent among the objects to complete the objective of a user story.

From the sequence diagram, we can easily come up with a design class diagram. A design class diagram is the last artifact that I usually create before diving into code.

It is very easy to draw a design class diagram from the sequence diagram. Just write down the method names in the classes where the arrow is pointing. For example, the GetItem() message is going from the Sale Class to the Item Class. Therefore, the item class will contain the GetItem() method.

UML Design Class Diagram


After creating the design class diagram, we can apply the principles of object-oriented design and design patterns, but I will put up another post for applying design patterns and principles.

From here, we can move to coding and start coding.

This is a very simple example to depict the process. For a real-life and real-world example of object-oriented analysis and design, you can check out this link.

Summary Up to Now

Up to now, you have learned about the software development process, the software development methodology, the differences between them, and why object-oriented analysis and design are more important than object oriented programming. You learned steps, techniques, and the purpose for object-oriented analysis and object-oriented design.

You also learned from a simple example how you can start properly designing the software using basic but important principles and techniques.

What Next?

You have learned the technical part. Is that enough?

Will you convince your less-technical (or non-technical) boss to give you time and other resources to apply these activities? This is because these principles will not produce lines of code. And do not produce any functionality for an end-customer demo.

In last part (part 4), I will discuss how can you persuade your boss to let you perform these activities. In addition to this, I will also bust some other myths about object-oriented design.

Design Diagram Software development Object-oriented design User story Class diagram

Published at DZone with permission of Muhammad Umair. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Easy Smart Contract Debugging With Truffle’s Console.log
  • How and Why You Should Start Automating DevOps
  • Using JSON Web Encryption (JWE)
  • Top 12 Technical Skills Every Software Tester Must Have

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: