This file reviews the concepts and ideas covered from the beginning of the semester to 3/1/23. The document follows the format we followed in the class prior to the exam. First off all the topics we covered are listed and then it delves into more specific info, such as relevant commands.
- Software vs. programs
- Time allocation to various SE tasks
- Linux / command line
- typical program / commands
- loops / conditions
- file path (
basename
' &dirname
' commands) - scripting (shabang / permissions)
- text editors (nano and vim)
- Version Control Systems
- centralized vs. distributed
- deltas vs. snapshots
- get basics → staging & working directory
- commit histories
- branching, tags, head
- rebase, merge
- remote / pull requests / forks
- commit messages best practices
- Quality Assurance & Testing
- internal vs. external quality
- rice's theorem & limits of assessment
- unit, system, integration, and load testing
- test driven development
- test cases
- mocking
Software vs. Programs
Program - Collection of instructions or ordered operations for a computer to preform a function or task
Software - Collection of programs procedures, data, or instructions that work together to provide a specified functionality
- Similarities and differences:
- similarities: programming languages, coding
- differences: public, size, security, usability, quality control
Time allocation to various SE tasks
- 70 - 90% of the budget / time is spent on maintenance
Linux / command line
-
typical program / commands_
-
loops / conditions
-
file path (
basename
' &dirname
' commands) -
scripting (shabang / permissions)
-
text editors (
nano
' andvim
') -
Command lines give access to run tools under the hood
-
Shell is a program that exposes an OS' services to a human user or other programs
-
A shell script is a text file containing commands for a shell to execute
- The first line starts with a "shabang" or
#!/bin/bash
'
- The first line starts with a "shabang" or
-
Useful commands:
chmod
': a command to change permissionschmod +x \<file>
': is used to make a file executable
ls
': list the content in a directorypwd
': present working directorycd
': change directorycurl
': transfer from URLmkdir
': make directoryless
': open fileman
': help manualssh
': secure shell, allows remote access to shell on another computerbasename
': extracts only the file namedirname
': extracts only the file path|
(pipe): take output from one program as input to a second programxargs
': popes but as command line argumentscut
': delimiter to break up lineswc
': word count
- For loop:
for i in {0..100}
do
...
done
- Conditionals:
if [-f name]
then
...
else
...
fi
- `f`' is used for files
- `d`' is used for directories
- `z`' is to check for empty files
-
Redirecting
'\>
': overwriting the target file'\>>
': appends to the target file2>
': sends the error output1>
': sends the standard output
-
Text editors: nano, vi(m), emacs
- vi commands:
i;
' insert mode':q!
' force quit, no ! for quit':w
' write the file- <escape> leave insert mode
- vi commands:
-
Version Control Systems
- centralized vs. distributed
- deltas vs. snapshots
- git basics → staging & working directory
- commit histories
- branching, tags, head
- rebase, merge
- remote / pull requests / forks
- commit messages best practices
-
Dominant activity of software development is maintenance
-
Version control systems allow modifying files, mark files as ready to contribute, and bundle and share changes to everyone.
-
Version control systems simplify maintaining code
-
Centralized systems:
- 1 unified history
- everyone agrees on versions available
- client must have a set of working files
- to commit revisions a user must connect to the main server
-
Distributed system:
- shared history
- redundancy → multiple copies of history
- client makes copy on own system
- client check in / commits to their own history
- potential for disagreement, so there must be a way to resolve conflicts and sync histories
-
Encoding the history of a repository:
- Deltas: track the changes (deltas) and save those changes
- Snapshots: keep full copies of changed files while the unchanged files are pointers to previous versions
-
Git workspace has 3 states / locations:
- Working directory
- Staging
- Repository
-
History of a repository forms a tree
- Committing is inserting a new node
-
Head: marks our working directory
-
Hashes create unique IDs for each commit
-
Branches are additional labels to keep track of parts and version history
-
Tags are permeant label or nickname on a commit
-
Recombining branches
merge
: combine commits & form a new commit with combined changes (two parents)rebase
: "copy" the commits into another branch - like a transplant
-
Commits:
- message should describe problem being solved or features being added
- can reference a bug report but should stand alone
- don't want to assume access to outside resources
- describe changes being done
- first line of the message should be the subject
- message should wrap at 72 or 80 characters
nano -r 72
- message should describe problem being solved or features being added
-
Dos and Don'ts:
- don't mix whitespace / formatting with functional changes
- don't mix unrelated functional changes
- don't submit all code with one commit
- do try to keep commits small & modular
-
Git
- git is a distributed version control system
- connect a repo to another copy of the repo specify by
git remote -v
- Sync commands:
git fetch
: download new commits from remotegit merge
: combine downloaded commits with local historygit pull
: does both the operations of a fetch and merge commandsgit push
: upload our new commits to the remote
- all remote branches are prefixed with the remote in the name
- example:
hans/main
- example:
- general rule:
rebase
' unshared changesmerge
' with shared changes
- pull requests: request for developer to pull your commits to upstream repo
- Assign yourself an issue / bug report
- Fork/clone the repo
- Make branch for the fix
- Commit to the new branch
- Push to the fork
- Open a full request
Git commands from Learn Git Branching
git commit
git branch
git checkout
git merge
git rebase
git reset
git revert
git clone
git fetch
git pull
-
Quality Assurance & Testing
- internal vs. external quality
- rice's theorem & limits of assessment
- unit, system, integration, and load testing
- test driven development
- test cases
- mocking
-
Developers want to deliver high quality software at low cost
Quality Assurance - The maintenance of desired level of quality in a service or product, especially by means of attention to every stage of the delivery or production
-
Two types of quality
- External: customer facing, essentially does the software do the right thing
- Internal: source code is readable, well document, maintainable
-
Internal quality is mostly about maintainability
- human code review
- code analysis tools (linters)
-
- use programming idioms & design standards
- follow local coding standards
-
Rice's Theorem: prevents programs from always giving the right answer, all non-trivial semantic properties are undecidable
- x is not always wrong, but not always right
-
We approximate correctness with type checkers, linters, static analysis
-
Software testing is an investigation conducted to provide stakeholder with information about quality of software
-
Testing gives confidence that your implementation adheres to specification
-
An oracle is the source of sample output for test cases
-
System testing: test end-to-end system for correctness
-
Regression testing: try to see regression in the source code
-
Unit testing: test chunks of code
- frameworks: JUnit, Python unittest
-
Test cases:
- Establish some condition
- Preform an operation
- Assert post condition
- each test case should be run in a "fresh environment"
-
Test fixture: surrounds a test case to provide code that is run before and after each test case
-
Unit testing discover: python3 -m unittesting discovery
-
Test driven discover:
- Write a test to add a new feature
- Write code that the unit test is testing for
- Run all available tests
-
Integration testing: one layer up from unit, do the chunks work well together?
-
Challenges of testing:
- Different hardware configurations
- What if the tool is broken? (test is broken)
- Cost / speed (external APIs)
-
Mocking: using mock objects (simulated objects) that mimic the behavior of real objects in a controlled way
- cash test dummies, sometimes called stubs
-
Functional properties: correct solution
-
Non-functional properties: memory, runtime, security, power, performance with many users
-
Load testing: how does the system respond under typical usage
- stress test → test under extreme usage
-
Testing & QA is about 25-35% of IT budgets
-
Measuring quality of tests:
- code coverage: how much code is executed by the test suite
- statement coverage: fraction of source code statements that are executed by test suite → loosely the same as line coverage
- test suite quality metrics asses the quality of a test suite (with respect toe external notion o futility) and allows test suites to be compared
- line coverage is on such metrics
- how do we measure line coverage?
- coverage instrumentation programs that auto modify code to track coverage, such as
python coverage
orgcc gcov
- coverage instrumentation programs that auto modify code to track coverage, such as
- implicit control flow: hidden if statements
- interest test cases cause implicit or explicit changes of control → causes different branches of conditionals to execute
- branch coverage: total number of conditional branches covered by test suite