---
title: "Development process and mapping design to code"
subject: "Object Oriented Analysis and Design"
chapter: 4
key: "semester_6/object_oriented_analysis_and_design:development-process-map-design-code"
source: https://www.bctengineer.com/q/semester_6/object_oriented_analysis_and_design/development-process-map-design-code
site: BCT Engineering
---

# Development process and mapping design to code

Object Oriented Analysis and Design · Chapter 4: Implementation

- Asked in: 2069 Poush, 4+7 marks
- Video: [CS-8592/OOAD /UNIT 4/ MAPPING DESIGN TO CODE](https://www.youtube.com/watch?v=5SpOw4l95NY) — Dr.Saveetha. P
- Page: https://www.bctengineer.com/q/semester_6/object_oriented_analysis_and_design/development-process-map-design-code
- Whole chapter: https://www.bctengineer.com/md/semester_6/object_oriented_analysis_and_design/chapter-4

## Question

Explain development process with suitable example. How can you map design into code? Illustrate with diagrams produced in question number five (Ministry of Health and Population collaboration diagram and use case diagram) by using any object oriented languages like C++, Java, C# etc.

## Short answer

The Unified Process uses iterative phases: Inception, Elaboration, Construction, Transition. Design maps to code by turning classes into classes, attributes into private fields, operations into methods, associations into references, collaboration messages into method calls, and use cases into controller methods.

## Answer

#### Development process
A development process is the set of ordered activities to build software. In OOAD we use the iterative **Unified Process (UP)**, with four phases and the disciplines run in every iteration:

```text
 Inception -> Elaboration -> Construction -> Transition
   (idea,      (core arch,    (build the       (deploy,
    scope)      main risks)    rest)            train)
 each phase: several iterations of
   Requirements -> Analysis -> Design -> Code -> Test
```

**Example (Population Information System):** Inception - scope is to display population data; Elaboration - use cases "View Data" and "Login" are analysed, classes and architecture chosen; Construction - the `Admin` data entry and graphs are built over iterations; Transition - system is installed in the Ministry.

#### Mapping design into code
The design models (use case, collaboration, class diagram) map to code as follows:
1. Each class in the design -> a class.
2. Attributes -> private fields; operations -> methods.
3. Associations -> reference fields or collections.
4. Messages in the collaboration diagram -> method calls in the bodies of methods.
5. Use cases -> controller methods/events.

**Use case diagram:** actors `User` and `Admin`; use cases `View Population`, `Visualize`, `Login`, `Enter Data`.
**Collaboration diagram:** `1: viewPopulation(place)` from `:User` to `:DataController`, `2: query(place)` to `:Database`, `3: render(data)` to `:ChartView`.

```java
import java.util.*;

class Database {                                   // stores monthly data
    private Map<String,Integer> population = new HashMap<>();
    public void save(String place, int count) { population.put(place, count); }
    public int query(String place) { return population.getOrDefault(place, 0); }
}

class ChartView {
    public void render(String place, int count) {
        System.out.println(place + " : " + count);  // chart/table
    }
}

class DataController {                             // use case controller
    private Database db; private ChartView view;
    public DataController(Database db, ChartView view) { this.db = db; this.view = view; }
    public void viewPopulation(String place) {     // msg 1
        int c = db.query(place);                   // msg 2
        view.render(place, c);                     // msg 3
    }
    public void enterData(String place, int count) { db.save(place, count); }
}

class Admin {                                      // actor class
    private String id, password;
    public Admin(String id, String pw) { this.id = id; this.password = pw; }
    public boolean login(String i, String p) { return id.equals(i) && password.equals(p); }
}

class User {
    public void viewPopulation(DataController c, String place) { c.viewPopulation(place); }
}

public class Main {
    public static void main(String[] args) {
        Database db = new Database();
        DataController ctrl = new DataController(db, new ChartView());
        Admin admin = new Admin("admin", "1234");
        if (admin.login("admin", "1234")) ctrl.enterData("Kathmandu", 1000000);
        new User().viewPopulation(ctrl, "Kathmandu");
    }
}
```

The use case diagram gave the actor classes and controller methods, the collaboration diagram gave the order of calls in `viewPopulation`, and the class diagram gave the fields and associations.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Which is the correct order of the four phases of the Unified Process?
   A. Elaboration, Inception, Construction, Transition
   B. Inception, Elaboration, Construction, Transition
   C. Inception, Construction, Elaboration, Transition
   D. Construction, Inception, Elaboration, Transition
   Answer: B. UP runs Inception (scope), Elaboration (core architecture and risks), Construction (build the rest), then Transition (deploy, train). (Key point: Unified Process phases)

2. How are requirements, analysis, design, code and test performed in the Unified Process?
   A. Once each, strictly one after another, over the whole project
   B. Only during the Construction phase
   C. Repeated within several iterations of every phase
   D. Only during Inception and Elaboration
   Answer: C. Each phase has several iterations, and the disciplines (requirements to test) run in every iteration. (Key point: Iterative disciplines)

3. In mapping a collaboration diagram to code, what does a numbered message such as 2: query(place) become?
   A. A private attribute of the sender
   B. A method call inside the body of the sender's method
   C. A new subclass of the receiver
   D. A database table
   Answer: B. Messages become method calls in method bodies, in the numbered order (e.g. viewPopulation calls db.query then view.render). (Key point: Messages to method calls)

4. How are attributes, operations and associations of a design class mapped to code?
   A. Attributes to private fields, operations to methods, associations to reference fields or collections
   B. Attributes to methods, operations to fields, associations to interfaces
   C. Attributes to public static constants, associations to inheritance
   D. Attributes to local variables, operations to constructors only
   Answer: A. Attributes become private fields, operations become methods, and associations become reference fields or collections. (Key point: Mapping rules for class members)

## Related in Object Oriented Analysis and Design

- [Collaboration and use case diagram case](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Apopulation-system-collaboration-usecase) — Object Oriented Analysis and Design, chapter 2
- [Health care center class diagram to code](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Ahealth-care-class-diagram-code) — Object Oriented Analysis and Design, chapter 4
- [Create classes from design class diagrams](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Aclasses-from-design-class-diagram) — Object Oriented Analysis and Design, chapter 4, asked 2×
- [Map sequence diagram to pseudo code](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Aorder-model-mapping-pseudocode) — Object Oriented Analysis and Design, chapter 4
- [Algorithmic vs object-oriented decomposition](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Aalgorithmic-vs-oo-decomposition) — Object Oriented Analysis and Design, chapter 1
- [KUKL customer system design and code](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Akukl-use-case-class-diagram-code) — Object Oriented Analysis and Design, chapter 4

## Related in other subjects

- [Compare procedural and object oriented programming](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Aprocedural-vs-oop-compare) — Object Oriented Programming, chapter 1
- [Case study: critical factors in process control](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Acs-critical-factors) — Instrumentation II, chapter 10, asked 2×
- [Case study: workflow, factors, proposed design, benefits](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Acs-2076chaitra) — Instrumentation II, chapter 10
- [Object replication; process resilience](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Aobject-replication-resilience) — Distributed System, chapter 7
