Software Architecture Text Browser
Summary
Problem
Imagine you are building a text browser.
Components
What components would you need from a GUI library?
- Window
- Scrollbar
We also need a component to supply the text
- File Manager
- Provide a module that can retrieve a limited length, consecutive subsequence of the file’s lines
ViewPort
- Need to be able to display textual content graphically
- Displays an integer number of lines
- [0, 100]
- Can be resized
- All text is same font and point size.
ScrollBar
- Need to give user some way to access different parts of the file
- “Handle” sits in “tray”
Use Cases
Imagine how the user will use the intended solution
- Viewing Text
- Scrolling
- Resizing ViewPort
Analyisis Model
We will be using UML
- Rectangles for class/components
- Divided vertically into 3 components
- Component Name
- Attributes
- Operations
- Divided vertically into 3 components
- Lines between components denote relationships
Exercise
Create a diagram with classes for the three components we’ve identified
Apparently I was only supposed to fill it in with names and not like attributes and operations, but whatever I’m leaving it
Operation
Operations comprise those actions that the user can undertake to interact with the application.
- Moving Handle
- Resizing ViewPort
Can provide parameters and return types
Attributes
Attributes are things entities own/have
Percepts are attributes that the user can see
- Handle’s Position
- Size of ViewPort
- Text
- Size of Handle
FileManager
Not visible to the user
Supplies contents of the file
TextBrowser interacts with the file system through operating system
Document is a percept that is supplied by the operating system actor
Relationships
3 types
- Associations
- Aggregations
- Generalizations
context LinesVisible inv:
ViewPort : viewContents->size() = ViewPort : height.min(FileManager : document->size())
func LinesVisible(vp ViewPort, fm FileManager) {
vp.viewContents.size = Min(vp.height, fm.document.size)
}
context displays inv:
let topLineNumber = Scrollbar : handlePosition *
FileManager : document->size()
in ViewPort : viewContents = FileManager :
document->subsequence(topLineNumber, topLineNumber + ViewPort :
viewContents->size() -1)
context scalesHandle inv:
Scrollbar : handleSize = ViewPort : viewContents->size() / FileManager : document->size()