Before a house is built, the builder draws it. Before software is written, developers draw it too. UML is the set of drawings. Four diagrams cover the book: use case, class, sequence and activity.
Section 1.5 of Chapter 1 in the PECTAA Computer Science 11 book is Graphical Representation of Software Systems. This note covers it for FSc Part 1 (1st year, Class 11) students in Lahore, Faisalabad, Sargodha, Rawalpindi, Multan, Gujranwala and the other Punjab boards. Gujrat district comes under the Gujranwala board. PECTAA writes the books. Your own board sets your paper.
What to know
Why draw? The book says visual diagrams show the structure and behavior of a software system. They simplify a complex system. Developers and stakeholders can then understand, communicate and manage it more easily.
UML. Unified Modeling Language is a standardized way to visualize the design of a software system. It helps developers understand how a system works and communicates.
1. Use case diagram (1.5.2.1).
- It shows the functionality of the system from the user's point of view.
- A use case is a set of interactions between a user (actor) and a system to reach a specific goal.
- The book lists three purposes: capture functional requirements, understand user interactions, and help with the development process and designing test cases.
- Steps to identify use cases: identify actors, define goals, outline interactions, validate use cases with stakeholders.
- Book example (Figure 1.5), a library system: the actors are the Librarian and the Student. The use cases are Borrow book and Return book.
2. Class diagram (1.5.2.2).
- The book calls it a map that shows how things are organized in a system.
- Book example (Figure 1.6), organizing your room. Room is the overall space. A Box is a container, like a class. Attributes are the items a box holds. Methods are actions such as open and close.
- In the figure, the class Room has the attributes name and size. The class Box has label and contents. ToyBox (toys), BookBox (books) and ClothesBox (clothes) sit under Box. The book describes them as distinct instances of the general Box class.
3. Sequence diagram (1.5.2.3).
- It shows how objects interact with each other in a particular sequence.
- It helps in understanding the flow of messages between objects over time.
- Book example (Figure 1.7): a User sends open() to the Toys Box, the Books Box and the Clothes Box. Then the User puts toys, books and clothes inside. Last, the User sends close() to each box.
4. Activity diagram (1.5.2.4).
- It shows the flow of activities or steps in a process.
- It is useful for modeling the logic of complex operations.
- Book example (Figure 1.8): a restaurant system goes from Order Placement to Food Preparation. A decision "Food Ready?" has two branches: Yes leads to Order Delivery, and No leads to Re-Prepare Food. The diagram ends at End.
Key points
| Diagram | Question it answers | Book example |
|---|---|---|
| Use case | What can each user do? | Library: Borrow book, Return book |
| Class | What are the parts and what do they hold? | Room, Box, ToyBox, BookBox, ClothesBox |
| Sequence | Who sends which message, and in what order? | User opens and closes boxes |
| Activity | What are the steps and decisions? | Restaurant order |
Where UML is used (1.5.3). The book gives three uses:
- Design: map out requirements and design before writing code.
- Development: developers refer to the diagrams to understand the structure and relationships.
- Communication: team members and non-technical stakeholders understand how the system works.
Worked examples
Example 1. The book gives an online shopping system. The actors are Customer, Administrator and Delivery Personnel. Match each use case to an actor.
- Customer: Browse Products, Add Items to Cart, Make Purchase.
- Administrator: Manage Product Listings, Process Orders, Handle Customer Inquiries.
- Delivery Personnel: Update Delivery Status.
Example 2. Which diagram would show the order of open() and close() messages for three boxes?
- The question is about messages in a particular sequence.
- That is a sequence diagram.
- Figure 1.7 is the book example.
Example 3. In the restaurant activity diagram, what happens if the food is not ready?
- The decision "Food Ready?" has a No branch.
- The No branch leads to Re-Prepare Food.
- A Yes answer leads to Order Delivery.
Example 4. Count the use cases in the online shopping list of Example 1.
- Customer has 3.
- Administrator has 3.
- Delivery Personnel has 1.
- The total is 3 + 3 + 1 = 7.
Common mistakes in the exam
- Mixing the four diagrams. Link each one to its question: what, parts, order, steps.
- Leaving out the actor. A use case diagram shows the actors and their goals.
- Calling UML a programming language. The book calls it a standardized way to visualize design.
- Writing a sequence diagram without order. The messages must run top to bottom in time order.
- Forgetting the decision in an activity diagram. Show the question and both answers.
- Naming only three diagrams. The book discusses four.
Exam technique
- For a "define UML" question, write the full form first, then one line from the book.
- For a diagram question, draw the book example and label every part.
- For a list question, write the four diagrams as a numbered list.
- Check your board's notice for the sections in your paper.
Practice questions
- Write the full form of UML. Answer: Unified Modeling Language.
- Who are the two actors in the book library example? Answer: The Librarian and the Student.
- In the room example, what stands for a class and what stands for a method? Answer: A box stands for a class. Actions such as open and close stand for methods.
- Which diagram shows the flow of messages between objects over time? Answer: The sequence diagram.
- Name the activities that come before the decision in the restaurant example. Answer: Order Placement and Food Preparation, then the decision "Food Ready?".
Ready to practise this? Continue in 1st Year Computer Science.