Académique Documents
Professionnel Documents
Culture Documents
Ingolf Krueger
Department of Computer Science & Engineering University of California, San Diego La Jolla, CA 92093-0114, USA
California Institute for Telecommunications and Information Technologies La Jolla, CA 92093-0405, USA
CSE
Learning Goals
Know the use of the Unified Modeling Language (UML) for requirements capture and design.
CSE
UML
A visual language for specifying, constructing, and documenting system artifacts. Provides different language elements (diagrams/text) to model systems from various viewpoints
Structure Behavior
OMG standard since 1997, now at version UML 2.2 Especially useful for modeling/documenting objectoriented systems: requirements, architecture, design
but not limited to that
Ingolf Krueger, 2010 CSE 5
Behavior
State Machine Use case
Structure
Class
Object Component Composite Structure Deployment
Interaction Overview
Sequence Activity
Communication
Ingolf Krueger, 2010
Package
CSE 6
CSE
public class ChatServer extends BaseChatServer {! ... ! private String[] clients; ! private int client_index;! ... ! public void sign_on(String client_id) {! clients[client_index++] = client_id;! }! ...! }!!
CSE
inheritance relationship
public class ChatServer extends BaseChatServer {! ... ! private String[] clients; ! private int client_index;! ... ! public void sign_on(String client_id) {! clients[client_index++] = client_id;! }! ...! }!!
CSE
public class ChatServer extends BaseChatServer {! ... ! private String[] clients; ! fields private int client_index;! ... ! public void sign_on(String client_id) {! clients[client_index++] = client_id;! }! ...! }!!
CSE
10
public class ChatServer extends BaseChatServer {! ... ! private String[] clients; ! private int client_index;! methods ... ! public void sign_on(String client_id) {! clients[client_index++] = client_id;! }! ...! }!!
CSE
11
CSE
12
CSE
17
CSE
18
Associations, Aggregation
CSE
23
Example: ChatClient
package simplechat.client;! import simplechat.server.*;! ...! public class ChatClientImp {! !private String name;! private ChatServer server;! public void setName(String name) {! this.name = name! }! ...!
Ingolf Krueger, 2010 CSE 24
ChatClientImp.java !
Example: ChatClient
!public ChatClientImp(String client_id, ! String server_id) {! ! !try {! ! ! !Registry registry = ! LocateRegistry.getRegistry();! ! ! !server = ! (ChatServer) ! registry.lookup(server_id);! ! ! !! ! ! !server.sign_on(client_id);! ...! ! ! !!
Ingolf Krueger, 2010 CSE 25
Undirected Association
any number of exactly one
Association (undirected)
CSE
26
Undirected Association
role/field name
CSE
27
Undirected Association
read: every object of class ChatClientImp has exactly one ChatServer every object of class ChatServer has many ChatClientImps
Ingolf Krueger, 2010 CSE 28
Undirected Association
Undirected Association
Undirected Association
Symbol 1 n n..m *
CSE
32
Design Patterns: Proven solutions for recurring design problems in specific contexts
Ingolf Krueger, 2010 CSE 33
Why bother? Lets Design a Chat Server that can Handle Messages
Ingolf Krueger, 2010 CSE 34
First Design
CSE
35
CSE
36
CSE
37
CSE
38
CSE
39
CSE
40
CSE
41
Cons:
Unclear design decomposition strategy:
why should message handling dominate logging? why should logging dominate encryption?
What if we want to replace the logging/encryption algorithm at runtime: requires restart of entire server!
CSE
42
Separation of Concerns
Let me try to explain to you, what to my taste is characteristic for all intelligent thinking. It is, that one is willing to study in depth an aspect of one's subject matter in isolation for the sake of its own consistency, all the time knowing that one is occupying oneself only with one of the aspects. [] But nothing is gained on the contrary! by tackling these various aspects simultaneously. It is what I sometimes have called "the separation of concerns", which, even if not perfectly possible, is yet the only available technique for effective ordering of one's thoughts, that I know of.1
1E.
W. Dijkstra: "On the role of scientific thought", in E.W. Dijkstra, Selected Writings on Computing: A Personal Perspective, New York, NY, USA: Springer-Verlag New York, Inc., pp. 6066 Ingolf Krueger, 2010 CSE 43
What are the separate concerns of the Server design? Message Handling, Logging, Encryption
Ingolf Krueger, 2010 CSE 44
CSE
45
CSE
46
CSE
47
CSE
48
CSE
49
!private MessageHandler handler;! !private MessageLogger logger;! !private MessageEncryptor encryptor;! public Server() {! handler = null;! logger = null;! encryptor = null;! } ...!
Ingolf Krueger, 2010 CSE 50
public void setLogger(MessageLogger logger) {! this.logger = logger;! }! public void setEncryptor(MessageEncryptor en) { ! this.encryptor = en;! }! ...!
Ingolf Krueger, 2010 CSE 51
public void doLogMessage(Message msg) {! this.logger.handleMessage(msg);! }! public void doEncryptMessage(Message msg) {! this.encryptor.handleMessage(msg);! }! }!
Ingolf Krueger, 2010 CSE 52
Example: RSAFileServer
RSAFileServer.java !
public RSAFileServer() {! super();! setHandler(new BasicHandler());! setLogger(new FileLogger());! setEncryptor(new RSAEncryptor()); } ...! }!
CSE
53
Develop Against Interfaces rather than Implementations Favor Composition over Inheritance
Ingolf Krueger, 2010 CSE 54
CSE
56
Learning Goals
Know the use of the Unified Modeling Language (UML) for requirements capture and design.
CSE
57