Start learning with our library of video tutorials taught by experts. Get started

Foundations of Programming: Object-Oriented Design
Illustration by Mark Todd

Creating sequence diagrams


From:

Foundations of Programming: Object-Oriented Design

with Simon Allardice

Video: Creating sequence diagrams

We've seen a few diagrams, conceptual models, use case diagrams, class diagrams. These are what are considered Structural or Static diagrams. They are great at representing things like the overview of the classes in your application and seeing Inheritance and Composition or the actors in a system. But they are not so great at representing, say, the lifetime of an object or actually how objects interact with one another. So there are also Behavioral or Dynamic diagrams in UML. And these can describe how different objects change and how they communicate with each other.
Expand all | Collapse all
  1. 11m 35s
    1. Welcome
      1m 25s
    2. Who this course is for
      1m 15s
    3. What to expect from this course
      3m 6s
    4. Exploring object-oriented analysis, design, and development
      1m 41s
    5. Reviewing software development methodologies
      4m 8s
  2. 26m 14s
    1. Why we use object-orientation
      2m 42s
    2. What is an object?
      5m 22s
    3. What is a class?
      4m 43s
    4. What is abstraction?
      2m 45s
    5. What is encapsulation?
      3m 45s
    6. What is inheritance?
      3m 35s
    7. What is polymorphism?
      3m 22s
  3. 12m 16s
    1. Understanding the object-oriented analysis and design processes
      4m 13s
    2. Defining requirements
      6m 9s
    3. Introduction to the Unified Modeling Language (UML)
      1m 54s
  4. 23m 35s
    1. Understanding use cases
      6m 11s
    2. Identifying the actors
      4m 16s
    3. Identifying the scenarios
      5m 7s
    4. Diagramming use cases
      4m 18s
    5. Employing user stories
      3m 43s
  5. 16m 36s
    1. Creating a conceptual model
      1m 59s
    2. Identifying the classes
      2m 27s
    3. Identifying class relationships
      2m 38s
    4. Identifying class responsibilities
      6m 43s
    5. Using CRC cards
      2m 49s
  6. 22m 25s
    1. Creating class diagrams
      6m 11s
    2. Converting class diagrams to code
      4m 57s
    3. Exploring object lifetime
      5m 55s
    4. Using static or shared members
      5m 22s
  7. 19m 49s
    1. Identifying inheritance situations
      6m 49s
    2. Using inheritance
      2m 43s
    3. Using abstract classes
      2m 2s
    4. Using interfaces
      4m 20s
    5. Using aggregation and composition
      3m 55s
  8. 9m 23s
    1. Creating sequence diagrams
      5m 18s
    2. Working with advanced UML diagrams
      2m 3s
    3. Using UML tools
      2m 2s
  9. 10m 39s
    1. Introduction to design patterns
      2m 40s
    2. Example: the singleton pattern
      4m 53s
    3. Example: the memento pattern
      3m 6s
  10. 21m 47s
    1. Introduction to object-oriented design principles
      2m 50s
    2. Exploring general development principles
      3m 55s
    3. Introduction to SOLID principles
      6m 43s
    4. Introduction to GRASP principles
      8m 19s
  11. 7m 1s
    1. Reviewing feature support across different object-oriented languages
      3m 50s
    2. Additional resources
      2m 27s
    3. Goodbye
      44s

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
please wait ...
Foundations of Programming: Object-Oriented Design
3h 1m Intermediate May 22, 2012

Viewers: in countries Watching now:

Most modern programming languages, such as Java, C#, Ruby, and Python, are object-oriented languages, which help group individual bits of code into a complex and coherent application. However, object-orientation itself is not a language; it's simply a set of ideas and concepts.

Let Simon Allardice introduce you to the terms—words like abstraction, inheritance, polymorphism, subclass—and guide you through defining your requirements and identifying use cases for your program. The course also covers creating conceptual models of your program with design patterns, class and sequence diagrams, and unified modeling language (UML) tools, and then shows how to convert the diagrams into code.

Topics include:
  • Why use object-oriented design (OOD)?
  • Pinpointing use cases, actors, and scenarios
  • Identifying class responsibilities and relationships
  • Creating class diagrams
  • Using abstract classes
  • Working with inheritance
  • Creating advanced UML diagrams
  • Understanding object-oriented design principles
Subjects:
Developer Design Patterns Programming Foundations
Software:
Java
Author:
Simon Allardice

Creating sequence diagrams

We've seen a few diagrams, conceptual models, use case diagrams, class diagrams. These are what are considered Structural or Static diagrams. They are great at representing things like the overview of the classes in your application and seeing Inheritance and Composition or the actors in a system. But they are not so great at representing, say, the lifetime of an object or actually how objects interact with one another. So there are also Behavioral or Dynamic diagrams in UML. And these can describe how different objects change and how they communicate with each other.

And the most common one is the Sequence diagram. Now a Sequence diagram does not describe the entire system just one particular part of it, one particular interaction between a few objects in one scenario. We start a Sequence diagram with some boxes at the top that represent the objects, the participants in this sequence, could have two, could have three, could have several more. Because we are trying to describe an interaction between what will actually be instantiated objects they usually named a little differently, so not just customer class but a customer.

Instead of shopping cart class, we'd have a cart. If you want to use the name of the class you can actually have instance name: class name, and if you do just want to use the class name it's good practice to keep the colon as in colon order. Beneath these we stretch out some dotted lines, these represent lifelines, the timeline of these objects, we are going to begin at the top representing this timeline of interaction, a sequence. And we start to represent the messages that go between the objects. First will be say a checkout message, Customer is telling the Shopping Cart, I want to check out.

The Shopping Cart is going to create a new order to initiate an order object. Once that happens we realize that the shopping cart needs to start adding the different items to this order object. These messages that we are writing can be named very simply or they can be named with parameters such as I'm doing here, when I add an item I know that I will need to tell the order, what item it is, what quantity it is. So if I am doing solid arrows with the full head here, these are regular calls, regular messages. If I want a diagram then I'm expecting a response I would use a dashed arrow with a stick head.

Now you don't always need to write down the return messages only when they add value. You'll also sometimes see solid boxes written on the lifeline called Activation boxes or method-call boxes. These really are representing processing being done in response to--in this case the addItem message. Now these boxes aren't terribly important, and if I'm drawing on paper or on a white board I'll rarely use these because they're kind of annoying to do. Now if we realize that this addItem message might need to happen multiple times if I have multiple items in the cart we can surround this with what's called a Frame and in this case I am saying it's a loop, I'm going to do this for all items in the cart.

Now quite importantly we are not trying to model this entire scenario down to the last conditional and the last iteration, that's not what sequence diagrams are for, they offer an overview of the important parts of this process not to try and model every last if statement or while loop. So we continue on realizing the shopping cart, we will then say, okay, we need to calculate the discount, and we need to start finalizing the sale. That's going to involve a bit of processing in the order object, that will then send the total back.

And even though this might go back to the cart, we realize that effectively that's being passed all the way back to the customer who is going to be the one to submit payment. Now the way that we might have started charting out our conceptual model or class diagrams we now realize we don't have anything here to take care of that payment itself we are using an actual payment class for that. So I can write down the idea that we can initiate a message from order that's going to create a new payment object, and the only reason for this payment object to exist is to validate that payment and return a response, and then it goes off the Timeline. In fact, we can indicate that by saying we will send back some results, and then we'll put in the x here to say the payment's lifeline is now over.

Whether that was successful or not, the object doesn't exist anymore. So order has been given results, we then send those all to the customer. Now one of the benefits of a Sequence diagram is that at this level of interaction you should be able to sit down with say a business user, someone who is not a developer and explain this general process and they can hopefully give you some ideas whether that would be correct or whether something else is missing out of this. These are a thinking tool to help you think through this process.

You may create several Sequence diagrams to help you understand the specific scenarios, but do be aware that there is no need to try and diagram every single part of your application. That's a common beginner's mistake. You don't need to do that. These are for sketching out a situation that's not completely clear already, and they do a great job of making it clear who needs to perform processing in response to what. And they will often result in you realizing that a new class needs  to be created somewhere.

And if that happens in this process, then that's great. You may end up changing your class diagrams in response to the work that you do here.

There are currently no FAQs about Foundations of Programming: Object-Oriented Design.

 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

join now Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Foundations of Programming: Object-Oriented Design.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Notes cannot be added for locked videos.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.