Transcript INF123

INF123 – Software Architecture
INF 123 – Software Architecture
Thomas (Debeauvais)
[email protected]
1
Today …
• Class info, syllabus
• Introduction
– Why, who, where, when, how
– Definitions
– Multiple architectures
• Assignment 2 (= assignment 1)
2
CLASS INFO AND SYLLABUS
3
Class info
• Lecture MW 3:30- 4:50p in ICS 180
• Discussion Tu 5:00-5:50p in SSTR 103
• Out of town Wed 4/2 and Mon 4/7
• Requirements
– Basics in CS and software engineering
– Fluent in Python
4
Goals
• Learn some architecture theory
• And lots of practical knowledge and tools
– This includes Python and Github
– Github is a must-have in a resume
• To write elegant software
• Domain: online games
From www.hurl.it
5
Graded workload
• Mid-term exam – 20%
• Final exam – 40%
• Quarter-long project – 40%
– Groups of 2 or 3
– Weekly updates – 20%
– Final report and presentation – 20%
6
Not-always-graded workload
• Weekly assignments
– Due on Thursdays 11:59p
– For practice, not always graded
• Weekly QQ (quick quizzes)
– First 5 minutes of the Monday class
– For practice, never graded
7
QQ
1
Name a sorting algorithm
2
d = {‘Thomas’: ‘France’, ‘Arthur’: ‘Brasil’}
d[‘Thomas’]
3
[n*2 for n in range(3)]
4
Write a comment in Python
5
Name a development process
6
What does GUI stand for?
7
class ClientHandler(Handler):
# What is Handler for ClientHandler?
8
What does OS stand for?
Answer
8
QQ
Answer
1
Name a sorting algorithm
{merge, heap, quick, bubble, …} sort
2
d = {‘Thomas’: ‘France’, ‘Arthur’: ‘Brasil’}
d[‘Thomas’]
‘France’
3
[n*2 for n in range(3)]
[0, 2, 4]
4
Write a comment in Python
# this is a single-line comment
“”” This is a multi-line comment
“””
5
Name a development process
Waterfall, incremental / spiral / iterative,
agile (Scrum, TDD, XP), …
6
What does GUI stand for?
Graphical User Interface
7
class ClientHandler(Handler):
# What is Handler for ClientHandler?
Handler = parent class of ClientHandler.
ClientHandler inherits Handler.
8
What does OS stand for?
Operating System
9
Syllabus
• Check the website
10
WHY, WHO, WHERE, WHEN, HOW
11
Why and Who
• Objective: source code
• Hacker
– Code that works
– 1 file with 5k lines of code
• Developer
– Code with structure
– 10 files, 3k lines total
• Engineer/Architect
– Code with a purpose
– 1 API, 13 files, 4k lines
12
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
13
More than just the code structure
• Off-the-shelf components/reuse
– Should I use Pygame?
• Stakeholders
– Stakeholder Thomas says: “Pygame is mandatory”
• Deployment
– py2exe or command line? Embed libraries?
• Code structure AND behavior
– At the file, package, and project levels
• The decisions may change over time
– Which decisions are certain vs unsure, critical vs minor?
14
Where
• Every software has at least one architecture
– One from the requirements
– Another from the documentation
– Another in the code itself
– They are usually all different …
15
When
• Architecture is not a phase of development
– Think, document, write code faithful to the doc
– Write OK code, debug, code is documentation
– Think, write, think, write, think, write …
• In all cases, there are architectures
16
How
• Basic tools: the MASC
– Modularity
– Abstraction
– Separation of Concerns
• More advanced tools
– Object-oriented paradigm
– Domain-specific architectures
17
This is not a SCAM
• Separation of Concerns
– Divide a problem into independent parts
• Abstraction
– Reduce to its essential structure/behavior
• Modularity
– Consequence of separation of concerns
– Modules have interfaces
– Monolithic is the opposite of modular
18
OO Paradigm
• Pros
– Design patterns
– UML
• Cons
– Only 1 connector (method call)
– At the programming level
– Sometimes, other programming paradigms
(functional, constraint, …) are more appropriate
19
Domain-specific architectures
• Your system belongs to a domain
– Online games, banking, web servers, airplanes
• This domain has existing solutions
– Game engines, infrastructures, architectural styles
• You have business goals
– Reduce costs (Battle.net = one authentication for all
Blizzard games)
– Develop a product line (FIFA 2010  FIFA 2011  …)
• DSSA = reference architecture with replaceable
“parts”
20
What is a part?
DEFINITIONS
21
Definitions
•
•
•
•
Component
Connector
Configuration
Style
• While we’re at it … some basic sw eng terms
– Non-functional requirements
– Reverse-engineering
22
Component
• Functionality or data
• With a way to access it
– Otherwise it’s called a “black box”
• Examples: database, web server, library
Database
23
Connector
• A link between components
• Between 2, 3, .. N components
• Examples: procedure call, DB connector, global
variable, event brokers
DB connector
24
Configuration
• Graph of components and connectors
– Graph as in “edges and vertices”, not as in
“drawn”
Game Logic
DB connector
Database
25
Architectural Style
• Proven, recurring, and named architecture
• Ex: Three-tier and related architectures
Display
GUI
Web browser
Logic
Game Logic
Web server
State
Model
Database
26
Style vs patterns
27
Non-functional requirements
•
•
•
•
•
•
Adaptability
Availability
Compliance
Complexity
Efficiency
Fault-tolerance
•
•
•
•
•
•
Interoperability
Robustness
Scalability
Security
Usability
…
28
Non-functional requirements
• Functional
– “The system prints medical records”
• Non-functional
– “The system prints medical records quickly and
confidentially.”
29
Reverse engineering
• “How does this work?” = curious hacker
• “Why does this work?” = curious engineer
• Reverse:
– Hardware
– Binaries
– Source code
– Protocol
– Architecture
• Aka arch recovery
http://www.youngmindsatplay.com/
30
MULTIPLE ARCHITECTURES
31
Multiple Architectures
• Usability architecture: HCI
– The user experience
• Deployment architecture: sys admin
– Mapping between software and hardware
• System architecture: sys engineer
– The system’s concept and operation
• Software architecture: software architect
– The software itself
32
Web usability architecture
33
Web deployment architecture
34
Web system architecture
35
Apache HTTPD software architecture
36
Why so many?
• Different stakeholders
• Different concerns
• Different perspectives
– Each abstracts away irrelevant details
– Each exemplifies something
– Better understanding
• Different granularity/level of details
37
Focus of this class
• Software and system architectures
Display
Web browser
Logic
Web server
State
Database
38
ASSIGNMENT 1 = ASSIGNMENT 2
39
Weekly Assignment 2
•
•
•
•
•
•
•
•
Due Thursday 10th of April, 23:59pm
Install Python 2.7 (NOT Python 3)
Install Pygame 1.9.1 or 1.9.2
Create a github account
Create a repository
Push a single-player game to your repo
Submit on EEE dropbox the URL of your repo
DO NOT SUBMIT CODE ON EEE
40
Resources – Python
• Python path in Windows
– http://stackoverflow.com/questions/3701646/ho
w-to-add-to-the-pythonpath-in-windows-7
• Notepad++, vim, …
• Eclipse (+ PyDev plugin)
– Help – install software – http://pydev.org/updates
41
Resources – Pygame
• Pygame 1.9.1 or 1.9.2
– http://www.pygame.org/download.shtml
– 64-bit for Windows at
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyga
me
– Ubuntu: sudo apt-get python-pygame
– Double-check: “import pygame” in python console
42
Resources – Git
• Git
– https://help.github.com/articles/set-up-git
– Cheat sheet: http://cheat.errtheblog.com/s/git
– Troubleshooting:
https://help.github.com/categories/56/articles
• Windows: Git Bash, GitHub Windows
• Frequently used Git commands
–
–
–
–
–
git pull
git status
git add .
git commit –m ‘finished assignment 5; fixed issue #3’
git push
43
Resources – single-player game
• Pummel the chimp
– https://www.pygame.org/docs/tut/chimp/ChimpL
ineByLine.html
• Solo snake or whale from my github
https://github.com/gentimouton/swarch/tree
/master/solo
• Your own game
– No extra library beyond Pygame!
44