- 2069 Poush · 4+7 marks
Development process and mapping design to code
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.
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.
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:
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:
- Each class in the design -> a class.
- Attributes -> private fields; operations -> methods.
- Associations -> reference fields or collections.
- Messages in the collaboration diagram -> method calls in the bodies of methods.
- 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.
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.
Related questions
- Collaboration and use case diagram case · Object Oriented Analysis and Design, chapter 2
- Health care center class diagram to code · Object Oriented Analysis and Design, chapter 4
- Create classes from design class diagrams · Object Oriented Analysis and Design, chapter 4 · asked 2×
- Map sequence diagram to pseudo code · Object Oriented Analysis and Design, chapter 4
- Algorithmic vs object-oriented decomposition · Object Oriented Analysis and Design, chapter 1
- KUKL customer system design and code · Object Oriented Analysis and Design, chapter 4
- Compare procedural and object oriented programming · Object Oriented Programming, chapter 1
- Case study: critical factors in process control · Instrumentation II, chapter 10 · asked 2×
- Case study: workflow, factors, proposed design, benefits · Instrumentation II, chapter 10
- Object replication; process resilience · Distributed System, chapter 7
All Object Oriented Analysis and Design chapter 4 questions →