John Hoffer
Software Engineer at Harvard Medical School
Github Pages
Password Manager
Setup works for any app!
92 Days!
1 Week
No Class!
Text
Counts as 20%!
Prototypes are little experiments
to test technologies
by implementing a tiny feature of the project
or exploring suitable architectures
and algorithms
Jupyter Notebook ("glue"-code)
Package structure
Package structure
from .controller import *
from .view import *
from .mathengine import MathEngine
class MathEngine:
def __init__(self):
'''
A constructor.
'''
print('Really new Math Engine instance.')
def add(self, number1, number2):
'''
Takes 2 integers, and adds them.
'''
return number1 + number2
No user interaction here! Just Logic!
from .ui import UI
class UI:
def __init__(self):
'''
'''
print('New UI')
def start(self, controller):
'''
We ask the user for 2 numbers.
'''
print('Please enter number1')
number1 = input()
print('Please enter number2')
number2 = input()
result = controller.add(int(number1), int(number2))
print('Result:', result)
UI stuff here that calls the logic!
Package structure
Controller is separate! (All calculations, logic, algorithms etc.)
View is separate! (All user interactions)
Everything is bundled as one package!
We can import the package and use it!
This was the VC (View and Controller) part of the MVC pattern!
Why structure the code like this?
Architecture is more important than features!
Remember this!
Use Case Diagram
Activity Diagram
Properties
Methods
Class Diagram
Sequence Diagram
Keep it simple!
Divide and Conquer
Problem
Sub-Problem
Sub-Problem
Sub-Problem
Solved
Sub-Problem
Solved
Solution
Divide
Divide
Conquer
Conquer
It's a lifestyle!
Modularity
Split things up...
Subsystem
Module
vs.
independent value
can not function on its own
Information Hiding
treat stuff as black boxes!
Information Hiding
class MathEngine:
def __init__(self):
'''
A constructor.
'''
print('Really new Math Engine instance.')
def add(self, number1, number2):
'''
Takes 2 integers, and adds them.
'''
return number1 + number2
....
controller = MathEngine()
result = controller.add(int(number1), int(number2))
....