420 likes | 535 Vues
INF123 – Software Architecture. INF 123 – Software Architecture Thomas ( Debeauvais ) tdebeauv@uci.edu. Software Architecture. The set of most important design decisions “Most important” According to the stakeholders “Design decisions” Aware of the options Also called constraints
E N D
INF123 – Software Architecture INF 123 – Software Architecture Thomas (Debeauvais) tdebeauv@uci.edu
Software Architecture • The set of most important design decisions • “Most important” • According to the stakeholders • “Design decisions” • Aware of the options • Also called constraints • More than just the code structure • Elegant
Software architecture • Components • Connectors • Data • Style • If you follow the constraints • You’ll gain the benefits
How • Basic tools: the MASC • Modularity • Abstraction • Separation of Concerns • More advanced tools • Object-oriented paradigm • Domain-specific architectures
Non-functional requirements • Functional • “The system prints medical records” • Non-functional • “The system prints medical records quickly and confidentially.”
Connectors • Allow components to transfer control and data with each other • Aka facilitating control flow and data flow What is control?
Style: Main program and subroutines main Function calls Subroutine 1 Subroutine 2 Subroutine N … Subroutines: no side-effects, and not calling each other.
Distributed system • Components run concurrently • Components fail independently • No global clock • Latency Host 2 Component 3 Host 1 Host 3 Component 1 Component 4 Component 2 Component 5 Network interface of the OS
OSI model: layers Web browser Web page Transparent! HTTP HTTP TCP TCP IP IP Physical link (copper wire, optic fiber, …)
Constraints • Clients initiate the communication • Communication usually over the network • Server has the main functionality • No client-to-client communication • Fat vs thin clients
Client-server: pros and cons • Pros • Computation and data collocated • Server = single authority, trusted • Ignore bad clients without affecting good clients • Cons • Server = single point of failure • Server can be a bottleneck
Pipe and filter • Constraints: • Each task runs in its own process • Stream of data passed between tasks • Input/output formats • Gains: modularity, reuse, concurrency input simulation/ logic display
Describing a Software Architecture • “Just look at the source code!” • Natural language • Easy to discuss and contract-like, but long to read • XML, JSON • Good for hierarchical structures, but hard to read • Images/screenshots • Good for usability arch, not for system or deploy • Box-and-arrow diagrams • Back and forth with XML/JSON
Your own diagrams • Use the same symbol for the same things • Use standard symbols and representations • Don’t use the same symbol for different things • Add a legend if needed Client 1 Client 2 Send position Has a 2-way connection server
p2p • Each peer is client and server to other peers • The topology can change • Pros • Scaling: each node provides CPU and storage • Robust if one node fails • Cons • Complex protocols for resource discovery • Security, trust management
Napster Server = bottleneck Server = single point of failure Content Directory 2) Who has Gangnam Style? 3) A has Gangnam Style 1) I have Gangnam Style 4) Give me Gangnam Style Peer A Peer B 5) Here is Gangnam Style
Flooding in Gnutella Broadcast to discover resources TTL flag limits flooding Seeds = reliable list to start
Skype Privacy + Security: Hard to hack
Sensor networks • Non-functional properties: • Low energy consumption • Fault-tolerance • Scalability
Pubsub Eugster 2003: The many faces of publish/subscribe
Event broker vs pubsub • Event broker = pubsub • With an intermediary • Where subscribers publish • And publishers subscribe • And usually with function callbacks rather than over the network • GUIs
Dr. Eval eval(readline()), eval(message), …
generated Sun RPC Hand-written Import function signature Import function signature interface.h caller.c callee.c Generate Call Call interface.x caller_stub.c callee_stub.c Generate Send XDR Recv XDR network
XML RPC - request • POST /RPC2 HTTP/1.1 • User-Agent: Frontier/5.1.2 (WinNT) • Host: betty.userland.com • Content-Type: text/xml • Content-length: 181 • <?xmlversion="1.0"?> • <methodCall> • <methodName>examples.getStateName</methodName> • <params> • <param> • <value><int>41</int></value> • </param> • </params> • </methodCall> Verbose (SOAP!) bandwidth
Remote Method Invocation Client Process Proxy Object B Proxy object is a hollow container of Method names. Remote Reference Module translates between local and remote object references. Object A Remote Reference Module Comm. Module Server Process Remote Reference Module Comm. Module Dispatcher sends the request to Skeleton Object Skeletondeserializes parameters, sends it to the object, & marshals the results for return Dispatcher Object B Skeleton for B’s Class MIDDLEWARE http://courses.engr.illinois.edu/cs425/fa2012/L8.fa12.ppt
Service-oriented architecture Web Server Client (Browser) Web Server Web Server Business, Mashups Presentation Web Server
Good: • Colorful • Bad: • - Yes goes down, then Yes goes right (be consistent)
Good: • Transition labels are verbs (“Coin” should be “insert coin”) • States are participles (“locked”, “unlocked”) • Verb+ing is fine too! (e.g. “waiting for user input”) • States are circles • No end state: don’t need any in this case • Start state is obvious (nitpicking: convention is double circle)
Good: • Server lifeline starts at the same time as the computer’s • The server lifeline is active only when the server works • Dotted arrow for the response • OK/meh: • sendUnsentEmail has no arrow back: what is happening on the server? Maybe it does not matter … • Bad: • “response” label for the response
Metadata vs verbosity There are two kinds of pain. The sort of pain that makes you strong, or useless pain that is only suffering.
SOAP vs REST • SOAP is verbose: large overhead of metadata and boilerplate text • SOAP • REST <?xml version="1.0"?> <soap:Envelopexmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:bodypb="http://www.acme.com/phonebook"> <pb:GetUserDetails> <pb:UserID>12345</pb:UserID> </pb:GetUserDetails> </soap:Body> </soap:Envelope> GET http://www.acme.com/phonebook/UserDetails/12345
REST is made of several styles • Client-Server • Stateless • Cache • Layered • Code on demand • Uniform Interface • These styles are not always inter-compatible • But they are in the case of the WWW
Common security design decisions • Principle Of Least Authority – POLA • Separation of privilege • Complete mediation • Fail-safe defaults • Access control • …
POLA Don’t touch it! Something shiny!
Complete mediation • Make sure every access is permitted So easy … Frodo’s path Access control data Mordor checkpoints
Impersonation Bob Alice Bob is reliable and everyone has a good opinion about Bob “I am Bob” Mallory (malicious)