Advanced Software Engineering
YAGNI
"You ain't gonna need it" Only design for the current iteration, not classes/responsibilities/collaborators that may come up later
large class
"bloater" class that has grown too large, typically through adding
Design Sprints - Friday
- 1-on-1 interviews with 5 'customers', show prototype and ask open-ended questions - Rest of team observes interaction - Review customer patterns - positive, negative, neutral and move on from there
Waterfall
- A plan-driven, step-by-step sequential process - Review and sign-off at each step - Each step must be verified before going on to the next - Benefits: Easy to explain to non-tech management/government agents. "Road map" to coordinate multiple developers. Some control over scope of project--> More predictability of const and schedule - Drawbacks: One chance to get it right (when problems are found during one step, they may be due to a flaw at a previous step. Backtracking can cause >100% schedule overrun). Emphasis on scope control-->Inflexibility for later changes. No frequent customer involvement (developer doesn't know what the customer wants) - Replaced by adaptive processes like Agile
Continuous Deployment
- Adds automatic deployment to continuous integration. Installs on the production server(s) and our produces a patch to customers. - Examples: Jenkins, Travis CI
What is the goal of a unit test?
- Aim to test a method or class in isolation from the rest of a program
Design Sprints - 0th day
- Assemble team, get space, buy supplies
Design Sprints - Monday
- Assess long term goal - Make a workflow sketch of customers/key players interacting with product - Ask experts on projects for advice - Pick a target to focus on for the rest of sprint
Teardown Code
- Associated with unit testing - Cleans up the state of the unit test so there are no externally visible side effects
Setup Code
- Associated with unit testing - Setup code is invoked before unit testing to set up a state of the world that simulates the state the program would be in when the methods invoked during the full system execution
Test runner/harness
- Call and run unit tests of a program rather than the program itself running tests - Call stubs and mocks rather than calling code in the program
Continuous Integration/Deployment (Pre-Commit)
- Does a local build once the commit command is run, commit doesn't go through if build doesn't pass
Continuous Integration/Deployment (Post-Commit)
- Does a remote build on the repo server after the commit finishes
How do developers determine the estimate?
- Don't ask the customer! - Previous experience - "Planning poker" - playing cards marked 1⁄2, 1, 2, 3, 5, 8, 13, 20, 40, ∞, ? days - Estimates larger than 8 days (2 weeks with time for meetings, demos, disasters) are suspect: "I have no clue how long this will take"
Build tools
- Example: make for C compilation - Automate lots of things for non-compiled languages (e.g. runs package manager to update all external dependencies and/or packages up your program to be installable from a package manager)
Design Sprints - Wednesday
- Go through sketches, critique each, choose best - Weave into storyboard and fill in gaps
What is a test case? What does it do?
- Identified by naming convention or annotation - Usually maintained in a parallel directory/folder hierarchy to corresponding source code - Constructs input for a method and involves method with input parameters - Supplies non-parameter inputs (e.g. inputs from simulated human user, file, network, database, device) - Collects results of method - A set of asserts check results are as expected - Assumes test oracle can always tell whether actual output is correct for given input
Design Sprints - Thursday
- Implement prototype - Do a trial run of the interview script
Continuous Integration
- Integrates version control with build - Anytime anything is checked into the version control system a full build is done
Package Managers
- Keep track of 3rd party code units - They utilize the metadata associated with each package - Work like a mobile app store - Eliminate need for manual installs and updates - Examples: npm, pip
What are the priorities that come from the user?
- Minimum viable product - Categorization of high, medium, and low priorities - Typically there will be more higher priority features than will fit in iteration, remember time box vs. scope box Possibly micro-prioritize within priority category (buckets 10, 20, 30, 40, 50)
GUI Unit testing
- Need something that simulates human user interactions - Examples: selenium, appium
Why is project velocity needed?
- Predicting how long it will take developers to do work can never be 100% accurate - Computers have lives (hardware and software maintenance and downtime) - Developers have lives (personal days, bad days) - Projects have lives (training, meetings, customer interruptions) - Organizations have lives (CTO unexpectedly schedules full-day all-hands meeting)
Design Sprints - Tuesday
- Review existing ideas from other products - Team members separately sketch ideas - "Crazy 8s" - set of 8 quick sketches, then 3 panel storyboard - Start recruiting customers for tests on Friday
What can bug finders detect?
- Secret keys embedded in code - Using 3rd party libraries with known security vulnerabilities - Too many paths in a given function or method (cyclomatic complexity) - Dereferencing a null pointer - Checks/limits on array bounds to prevent buffer overflow - In multi-threaded code check that data dependencies cannot race and locks are matched with unlocks
Bug finders (bug checkers
- Sophisticated tools that look for generic bugs as well as code smells - They don't know about the functionality of code - Sometimes encode domain-specific rules (web/client server messaging formats and protocols) or knowledge of error specifications (C library functions return 0 on success and negative on failure)
What are time point estimates and who they come from?
- Time point estimates are how many time units to complete a given user story (typical minimum unit = 1⁄2 day) - Completion of a user story includes wireframes, design, coding, testing, review - Often use "points" or other relative units instead of explicit time, X seems likely to take 1⁄2 as long as Y or 3 times as long as Z - Schedule time/points for preparing and doing demo/delivery too!
What is the accuracy of static analysis bug checkers?
- Typically produce many false positives - Cannot avoid false negatives (cannot find all bugs) - They do not replace testing
How do testing and debugging fit into iteration?
- Unit testing and code review is often included in time point estimates - Bugs may be reported by testing team or user - Debugging/fixing can be defined as special kind of user story (e.g., pink cards) - also prioritized and estimated - Fit significant bug stories into current iteration by pushing some previously planned stories to next iteration (overflow)
Regression
- When fixing a bug or adding a feature causes previously working code to break or regress.
Package Managers and Dependencies
- When you organize your own codebase into multiple code units then come of your code units are dependent on other code units - When you reuse code units or other resources written by others, your code is dependent on those resources
Storyboard
-A sequence of wireframes, often corresponding to a user story or use case -Often used for the "fake it" prototypes of design sprints
Wireframe
-A sketch of a screen or page for a website/mobile app -Lays out content and functionality, establishes basic structure and what interface elements will be shown -In the case of a single-page app, use different wireframes depicting different states of that single page
Agile
-Adaptive Process -All customers/stakeholders involved throughout software process. -Customer wants to know: How much will it cost, how long will it take, what does the software need to do -Change: Customers can change their mind at any time -Incremental: Pick one part of the app, develop it, then go on to the next part -Iteration: Short project, deliver in increments. Iteration also called a "Sprint". Each includes full range of planning/reqs/design/testing -Emphasis on delivery: Incremental shipping to customer. This is why Agile shouldn't be used for safety-critical systems.
User Stories
-As who I want what so that why -short simple description of ONE function -typically need acceptance criteria -DOES NOT CONTAIN CRUD(create, read, update, delete) -done before development starts
Task board
-Associated with adaptive/agile processes -Says who does what component, and which components have been completed
Standup Meetings
-Associated with adaptive/agile processes -Short, ~10 minutes -Daily--> update task board and burndown chart, detect/remove blockages
class diagram-closed aggregation
-CONSISTS_OF, strong lifecycle -strong lifecycle: deleting will delete all children -filled diamond
Single Responsibility Principle(SRP)
-Every object should have a single responsisbility -check with "the <class name><method name> itself" -reason to change: requirement of the project change
What is the basic process for building an abstract model of the app domain?
-Identify "entities" (nouns)- roles, events, physical tangible devices. Identify static relationships between them -Construct scenarios corresponding to a single path through a use case -Identify dynamic responsibilities of the things during these scenarios
LSP
-Liskov Substitution Principle -extends OCP to require that subtypes must be substitutable for their base types -do inherited methods make sense for instances of the subclass
Time Box vs. Scope Box
-You can increase scope of an iteration, but this increases time -If originally planned features of an iteration take longer than scheduled, you must reduce scope or increase time -You can't both increase scope and decrease/keep constant time -Choosing time boxing over scope boxing controls costs and maintains some predictability (you will complete something each iteration)
Functionalities of version control systems
-backup and restore collection of files - sync among multiple users - short term undo - long term undo -track changes
Difference between framework and library
-code in charge when code calls library - framework calls code and framework in control.
epics
-collections of user stories -different type of user along a sequence
class diagrams
-convey information about static structure of your application domain -useful to communicate, visualize and analyze -broken down to attributes, operations, association, open aggregation
Version Control-VNC
-example: windows backup and restore, dropbox, google drive -you need to know exactly what was done to fix the bug -does not address multiple using a file
Use Cases
-expand user stories -describe the step by step details of how the user role interacts with the software - capture anything and everything that can go wrong
Software Enginnering
-ill defined problems -teams -ten-thousands bugs -runs in production -excisting codebase -use anything that saves time -continual availability -potentially high cost of errors
class diagram-realization
-implemtation from an interface -dash line with unfilled arrow
class diagram-generalization
-inheritance from super class to subclass -unfilled arrow
class diagram-association
-instances of one know about or communicate with instrance of another class -normal arrow
Version Control-renaming files
-keeps your work safe, can undo mistakes -okay for small number of files and versions -quickly becomes unmangable
OCP
-open closed princple -classes should be open for extension and closed for modification, allows change but without modifying any eisting code
Problems with customer requirements
-requirements may be very vague in customer's own mind, or diffucult for customer to explain -little techinical sophistication and ability to articulate software requirments
Version Control-Git
-synchronization among multiple user -short term undo, long term undo -track changes -repository -client -head -all basic git control
Pair Programming-definition
-take turns driving -switch roles at designated intervals such as 25 min -do not divide work
Pair Programming-con
-takes double the amount of man power for the same amount of code -hard to convince non-technical management
Design Principles
-technique that can be applied to designing or writing code to make that code more maintainable, flexiable, and extensible
Pair Programming-pro
-truck factor: multiple people know how to use the problem -shared responsibility to complete tasks on time -stay focus and on task -each member of pair expects other to follow "best practices" -better quality solutions -pool knowledge resources
What are the two stages of Object-Oriented Analysis and Design (OOAD)?
1. Build an abstract model of the problem domain or application domain (what) 2. Add architectural style, design patterns, implementation constraints to make it concrete (how)
Sprint Backlog
A breakdown of the product backlog that addresses each needed feature/fix in a sprint.
Design Sprints - definition
A concept designed by Google Ventures to answer business questions in 5 days without full development and launch cycle
Transitive dependencies
A depends on B depends on C depends on D
What is a unit?
A method or class
Dependency (another definition)
A relationship among work tasks, such as one task cannot be done until the other is done. These should be minimized
Sprint
A set amount of time in which an iteration of a project is done. A sprint can last anywhere from a week to a month. Usually its 2 weeks.
Product Backlog
A set of features/fixes that need to be implemented for a product based on user cases and user stories.
What should you do if you run out of work to do? (concerning project velocity)
Add projects from the backlog to your schedule
Static relationship between entities (concerning OOAD)
Association- "uses" (Car uses road) Inheritance- "is a" (professor is a human) Aggregation- weak containment (grouping. Child can exist independent. Delete class and students still exist) Composition- strong containment (Real-world whole part. Child not independent. Delete house deletes rooms)
Mocks
Behavior verification of a test
What do class diagrams include?
Class name, attributes, operations. Some show structure of a single class, others show relationships between classes.
CRC cards
Class name= thing/entity Responsibility=What it needs to do Collaborators=Classes it interacts with
Coupling (also referred to as dependency)
Degree to which your code unit depends on the innards of another code unit, so that if the other code unit changes, then you need to change your own code. Always bad.
Client
Developer machine
DRY
Don't repeat yourself principle: avoid duplicate code and redundant work
Unit testing tools
Execute the test cases you write. Some may write skeletons of test cases, but they don't write them for you.
Sprint (more info)
First release of new product might take several sprints, e.g., 3 months (fiscal quarter), where delivery may require its own release sprint rather than fitting into per-sprint review
class diagram-open aggregation
HAS-A, no lifecycle relationship -open diamond
What does project velocity account for?
Lost time
What do you do once your CRC cards cover every user story for the current iteration?
Make class diagrams
Design Sprints - Decider
Makes ultimate decision in any debate
What should you do if you cannot finish the scheduled work? (concerning project velocity)
Move projects from your schedule into the backlog.
Flaky test
Produces different results on different test suite executions even when nothing is changed
How do you detect regression?
Re-run all test cases that previously passed and see if any start to fail
Design Sprints - Facilitator
Runs meetings throughout sprints
Allocating responsibilities of classes (when making CRC cards)
Split classes with too many responsibilities Combine classes with too few responsibilities. Remove duplicates Avoid classes with only CRUD operations (create, read, update, delete)
Stubs
State verification of a test
Project velocity
The amount of work that your team schedules to do divided by the amount of work that your team should be able to do. Most companies have a product velocity of 80%. So if your team should be able to do 100 units of work and you want a project velocity of 70%, you schedule 70 units of work to do.
YAGNI
Your aren't gonna need it: do simplest thing that could possibly work
feature envy
a "coupler" class that uses public method of another class excessive
static analysis
a tool that just looks at code without execution
refused bequest
an "object-oriented abuser" class that overrides a method of a base class in such a way that the contract of the base class is not honored by the derived class
data clump
another "bloater" that occurs when group of variables passed around together in various parts of code
inappropriate intimacy
another kind of "coupler" class that has dependencies on implementation details (internal fields and methods) of another class
Use Case Element - Events
any new triggers initiated by the completion of use case
Use Case Element - Preconditions
anything that is expected to be true before case begins
Use Case Element - Postconditions
anything that must be true
message chains
asks for one object of another object, which then asks for another... just keeps going. lots of code, can be simplified
code smells
badly written code, refers to symptom in the source cold. makes changes more difficult and leads to bugs
switch statements
complex switch operator or sequence of if statements
technical debt
cost of additional rework later on caused by fast and easy solution instead of better one
dead code, speculative generality
dispensable" unused code, once previously used and just in case (don't need)
checkin/commit/push
doesn't work to just add to local copy, need to tell VCS to track
checkout/pull
download or copy from repo to local working set
Brainstorming workshops(Requirements elicitation)
drawing on a board to create an idea
Use Case Element - Exception flows
error cases, prevent user from achieving goal
Repository
file database
diff/delta
find differences between two revisions
contrived complexity
forced usage of overcomplicated design where simpler design would suffice.
branching
fork a copy of code base and track changes separately
update/sync
get latest revision of files from repo
coding conventions
govern how and when to use comments, white spaces, naming, grouping, organization, structure
observation and interview when creating a new project(Requirements elicitation)
how will software fit into buisness workflow -constrainst on how it interact with existing system
Design Sprint - Overview
http://www.ehousestudio.com/uploads/blog/DesignSprint-Process-v1.jpg
merge
integrate changes from working set into previous revision
Head
latest revision
Use Case Element - Alternate flows
less common user/system interactions, special cases
too many parameters
list is hard to read, calling and testing complicated
Working set/working copy
local directory on client where dev makes changes
LOCO model
lock on checkout, unlock on checkin (need way to break lock
bug finders
look for generic bugs as well as code smells
URL routing
maps HTTP request to resource, the code that will handle the request and receive any query parameters
tagging
marks the set of all file revisions contributing to some milestone
MOM model
merge on modify
Truck factor
number of engineers that would have disappear before project would be in serious jeopardy
Use Case Element - Description
paragraph (copy user story)
role playing when creating a new project(Requirements elicitation)
pretend to be the software intereacting with the user
main = master = trunk
primary set of versions
dynamic analysis
requires execution
Framework
set of generic components that work together to accomplish common development tasks and functionalities for a popular target domain
Use Case Element - Basic Flow
set of steps actor needs to take to accomplish goal
revert
throw away local changes and reload latest revisions from repo
Use Case Element - Actor
type of users who engage
Use Case Element - Name
verb/noun or actor/verb/noun communicates scope
class diagram-attributes
what describes it
class diagram-operations
what doe sit do
Use Case Element - Triggers
whatever causes the initiation of use case
Server
where repo lives
Burndown Chart
y-axis: Time remaining x-axis: Milestones left Ideal burndown is a constant downward slope to zero You don't want to have more milestones left than time. Associated with agile processes.