Managing Source Code 2016 01 16
Managing Source Code 2016 01 16
Bogusz JELIŃSKI ?
Warsaw, Sep 17th, 2015
? the plot from the title slide
depicts cyclomatic complexity –
how software evolves with time
Agenda
• What is it all about?
• How to prevent the loss of code?
• What is actually source code?
• What does "good quality code" mean?
• Let's measure it!
• Metrics for coding standards
• Software process made hermetic
• Misleading alternatives for the process
encapsulation
• Skipped topics - there is much more behind
What is it all about?
You should care because:
• code is a vital asset - it is the core of the digital
business
• not visible by business, but may become a huge
issue
• the knowledge how to use the code is a neglected
asset which vendors will use to blackmail you
• a pure product of human thought – millions of
lines, each can be written in a hundred ways, each
can be a mistake
• bugs can ruin security and performance. And they
will.
How to prevent the loss of code?
• take care of legal aspects, it is not simple
• store the code in your own repository
• store every single line, do not neglect the smallest
systems
• make your software process hermetic (hints to be
presented)
• get rid of the human factor - automate! Or at least
supervise the process!
• review your code - use static analyzers!
What is actually „source code”?
• any command in any language, interpreted or to be
compiled, affecting a system's behavior
• compilation sequence (yes!)
• resources needed for compilation or execution
• shell scripts used to compile, configure, run, manage
and monitor the system
• unit tests
• runtime configuration, especially when there is no
explicit configuration management. The boundary
between code and configuration is fuzzy these times (is
web.xml a code or a config item?)
What does "good quality code" mean?
Trait Description If neglected
up to date coherent with the production environment some functionalities missing
complete containing all the elements from the previous slide a blocker for development and
maintenance
compilable the software process (dynamic) perspective - should a blocker like above
compile if complete
fully merged no change/functionality forgotten for a release some functionalities missing
well tested had all expected functionalities been delivered before More issues on production likely
tests started? What does the Kan's integration pattern to appear
(see the next slide) look like?
coding ISO-9126-3 (replaced by ISO-25010) or other good Security or performance issues,
standards programming practices conformed with. code hard to maintain
obeyed
open-source One has to be sure that a software complies with open- It can restrict the use of
licenses source (BSD, ASL, …) and free software (GPL, LGPL) software. In the best case - you
obeyed licenses, as these licenses are unconsciously used by shall be forced to reveal your
developers. source-code.
low IT debt that metaphore of the coding standards has gained The interest is the cost of bug-
momentum lately fixing
code covered what proportion of code is being tested by tests such Higher risk of bugs
as unit tests?
CAST health factors
Health Description Example business benefits
factor
Transferability It assesses how quickly a new team or member can understand and work with an • Reduces inefficiency in transferring application work
application. It provides the means to understand how easily applications can be between
moved between teams or team members including in-house and outsourced teams
development teams. • Reduces learning curves
• Reduces lock-in to suppliers
Changeability It measures the effort necessary to modify applications in order to implement • Improves business agility in responding to markets or
new features, correct errors, or change the applications' environment. Measuring customers
and monitoring changeability is especially important for mission-critical • Reduces cost of ownership by reducing modification
applications when change is driven by tight time-to-market schedules. effort
Robustness It shows what affects the stability of the application and assess the likelihood of • Improves availability of the business function or
introducing defects when modifying it. Robustness measures the level. service
Robustness also measures the level of effort that is required to test the • Reduces risk of loss due to operational malfunction
application, i.e. how easy it is to test it and check its behavior • Reduces cost of application ownership by reducing
rework
Performance / It measures the likelihood of potential performance bottlenecks and potential • Reduces risk of losing customers from poor service or
efficiency future scalability problems. response
• Improves productivity of those who use the
application
• Increases speed of making decisions and providing
information
• Improves ability to scale application to support
business growth
Security Attributes that affect an application’s ability to • Improves protection of competitive information-based
prevent unauthorized intrusions. Security measures the likelihood of potential assets
security breaches linked to coding practices and application source code. This • Reduces risk of loss in customer confidence or
represents risk analysis and provides prevention measures necessary to avoid financial damages
opening critical vulnerabilities and security issues that can damage the business • Improves compliance with security-related standards
and the entire company running the applications.
A bit more on „well tested" – the code
integration pattern
Stephen H. Kan, Metrics and Models in Software Quality Engineering 2nd ed,
pp. 242, Addison-Wesley, Boston (2004)
How much
code do
you deliver
during
tests ???
https://books.google.pl/books?id=EaefcL3pWJYC
Let's measure it !
Or at least do something about it!
fully merged Numerous tools on the market to track requirements Binary: all feature branches
and their implementation merged to the integration one
well tested Measure the size of changes at particular milestones size of code comitted during
(eg svn diff) tests devided by the size of the
whole change/project
coding standards Use static analyzers – eg Sonar Eg Sonar’s Rules Compliance
obeyed Index
Open-source Use Palamida. Binary: scanned/not scanned
licenses obeyed
low IT debt Use static analyzers – eg Sonar Sonar’s Technical Debt