home page ->
teaching ->
pragmatic issues in programming ->
1. intro
Lecture 1 - Intro
Issues
- Why the velocity of a project may starts high and then slows to a grinding halt? When does it happen and how to
prevent it?
- Why a project may start from a clean, "blank slate", and evolve to a mess?
- Is it desirable to write "elegant code"?
Inquiry: what is important?
There are 2 possible reasons for doing something:
- it has bussines value:
- implements desirable features (note: prioritization of the features);
- keeps running time, needed memory, needed other resources, within acceptable limits (from customer perspective);
- keeps bugs acceptable.
- it improves the maintainability of the code:
- keeps complexity under control — note: the complexity is the number one issue!
- code is readable,
- no surprises (least astonishment),
- bugs are reasonably easy to track,
- foreseeable changes can be implemented by changes in few places.
Goals and means subordinated to maintainability:
- understandability (readability):
- single responsibility principle (SRP),
- structure,
- documentation
- testability: unit tests, integration tests, etc;
- code easy to use / integrate; well choosen API;
- extensibility
- simplicity
- code easy to reuse,
Notes:
- Enough is enough: as you keep adding features or increasing peformance, the cost per feature tends to increase,
while the added benefit tends to decrease;
- When in doubt, experiment and measure: it's easy to be wrong in estimations of performance or of how good
a design will be; the only sure way is to experiment and measure;
- A bug can hide another: buggy behaviour is hard to understand so that when a new (and maybe much more important)
bug appears it is easy to notice, understand and fix.
Radu-Lucian LUPŞA
2018-10-03