Tomas Petricek
email: t.petricek@kent.ac.uk
twitter: @tomaspetricek
office: S129A
Mathematician's answer to software engineering
Use mathematical methods to prove system correctness
People don't do it, yet, software mostly works.
Detailed upfront models
We know where
we want to get
Useful if predictability matters more than cost and delivery time
In contrast to upfront model
We know that we continue
moving in the right direction
Tools and practices to ensure that
Source control and collaborative development
Testing and build automation
Continuous integration and reproducibility
How open-source software development works
Code quality, naming and "good code"
Software Maintenance
You spend more time reading and modifying code than writing it.
Investing into readability when writing pays off
Keeping code simple
Shared understanding in a team
Code for readability
Always code as if the person maintaining your code will be a violent psychopath who knows where you live.
The person maintaining it will likely be future you.
Hacker culture
Coding standards
Do programming languages matter?
[It] appear[s] that strong typing is modestly better than weak typing, and among functional languages, static typing is also somewhat better than dynamic typing.
Do programming languages matter?
Attempt to reproduce the study mostly failed
"I believe they do in my heart of hearts, but it's kind of an impossible experiment to run."
Aspects of code quality
Processes for keeping quality
Good naming is easy today!
Computers supports
lower case letters!
Long names fit in
computer memory
Auto-complete helps
you avoid typos
What is the following function doing?
1: 2: 3: |
|
Converting temperature from Celsius to Fahrenheit!
1: 2: 3: |
|
Was that descriptive enough?
1: 2: 3: 4: |
|
Can we improve this by using abbreviations?
1: 2: 3: |
|
Are all variable names in this example descriptive?
1: 2: 3: |
|
This is too much. Sensible exceptions allowed!
1: 2: 3: 4: |
|
Name should add semantic information
No need to say it's number, string, etc.
Longer names are good, but don't overdo it!
Follow common conventions where applicable
The more local, the less it matters
Combining words in names
PascalCase
camelCase
snake_case
Using spaces in a name
Is the following naming consistent or not?
1: 2: 3: 4: 5: 6: 7: 8: |
|
Pascal case Program
, camelCase adminMode
, main
Java standards use PascalCase
for class names
camelCase
is used for variables and method names
You should generally follow coding standards
Exceptions such as numerical code: P
or alpha
How does compiler understand structure
Indentation or
curly brackets?
Compiler may ignore whitespace, but human brain does not!
What is the right spacing and line breaks?
1: 2: 3: 4: 5: 6: 7: 8: |
|
Compiler ignores whitespace, but humans do not!
Follow style of a project or a language; be consistent!
Indent nested code by the same number of spaces or tabs
1: 2: 3: 4: 5: 6: 7: 8: 9: |
|
Software engineering today
Process that ensures things keep improving
Supported by tools and good practices
What is code quality and why it matters
More time is spent reading code than writing it
Extreme programming - simplicity & shared understanding
Specific rules for keeping high code quality
Naming variables, upper/lower case
Follow consistent indentation rules
What you should remember from this lecture
Tomas Petricek
t.petricek@kent.ac.uk | @tomaspetricek
Selected chapters from books
Papers and articles