leaning on the two ts
DESCRIPTION
Leaning on the two Ts is a talk on improving code quality, personal practise and developing good habits using tools and techniques. Attendees of this talk will learn about my experience when learning to use static analysis tools (i.e. SonarQube) and some of its features. In addition also find out how it can be used to improve your code quality and personal practice. A number of tools will also be mentioned and how to include them in your practise. Powerpoint-like presentation sharing information from a perspective higher than just the use of tools, although no runtime implementation or live coding will be performed. Live examples might be shown depending on time constraints. The presentation is definitely for intermediate and experienced Java developers, but also beginner developers who would like to know more about code quality and tools that can be of help. Also for those already using static analysis or other tools in anger or just casually. Especially those who would like to know how to use tools as a medium to learn from.TRANSCRIPT
![Page 1: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/1.jpg)
@theNeomatrix369
Are you pairing with tools to improve code quality ?
Leaning on tools & techniques to improve code quality
![Page 2: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/2.jpg)
@theNeomatrix369
About meMani (@theNeomatrix369)
● LJC Associate● Adopt OpenJDK and JSR (JCP Member)● blog: http://neomatrix369.wordpress.com● github: http://github.com/neomatrix369● bitbucket: https://bitbucket.org/neomatrix369
Avatar: courtesy of Recworks: Dan Smallman @dsrecworks
![Page 3: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/3.jpg)
@theNeomatrix369
- I’m only sharing my learning experience - YMMV !- Experimental yet practical methods- Learning via validating and verifying- A silver bullet to solve all problems- One shirt fits all solution- Not about any specific product
Disclaimer
![Page 4: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/4.jpg)
@theNeomatrix369
Agenda- How it all started for me...- First steps to learning to use these tools...- Inventions- Observations- Introspection- Discoveries- Conclusion
![Page 5: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/5.jpg)
@theNeomatrix369
How it all started for me...
![Page 6: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/6.jpg)
@theNeomatrix369
My first computer - 8088 processor (8-bit processor)
My first game - Digger (not PacMan)
Mid-1990s
![Page 7: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/7.jpg)
@theNeomatrix369
Between 2000-2010
Career started as a hobby - years later become a profession
![Page 8: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/8.jpg)
@theNeomatrix369
Early 2010
Desire…more knowledge,
experience & skills
![Page 9: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/9.jpg)
@theNeomatrix369
Communities...met dev. communities in London and other parts of Europe!
LSCC
![Page 10: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/10.jpg)
@theNeomatrix369
Sowing of seeds...
![Page 11: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/11.jpg)
@theNeomatrix369Source: SonarQube (aka Sonar)
What does code quality mean to you ?
Is it the seven axes of quality ?
![Page 12: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/12.jpg)
@theNeomatrix369
How do we improve quality ?
![Page 13: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/13.jpg)
@theNeomatrix369
Pair programming is good...
![Page 14: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/14.jpg)
@theNeomatrix369
...but not always available...
![Page 15: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/15.jpg)
@theNeomatrix369
Then I had an idea...
![Page 16: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/16.jpg)
@theNeomatrix369
Why not use tools...
![Page 17: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/17.jpg)
@theNeomatrix369
First steps to learning to use these tools...
![Page 18: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/18.jpg)
@theNeomatrix369
Treemaps are awesome...
10,000 feet view !
![Page 19: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/19.jpg)
@theNeomatrix369
Dashboard - my own Quality metrics
![Page 20: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/20.jpg)
@theNeomatrix369
Issue violations & Duplications
Checkstyle, Findbugs, PMD rules
![Page 21: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/21.jpg)
@theNeomatrix369
What is Cyclomatic Complexity
or Complexity ?
![Page 22: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/22.jpg)
@theNeomatrix369
In simple words, it is thenumber of pathways
due to decision logic in a software program.
See Wikipedia definition
![Page 23: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/23.jpg)
@theNeomatrix369
ComplexitySee Definitions glossary
![Page 24: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/24.jpg)
@theNeomatrix369
Refactoring saves the day...Higher complexity (CCI: 4) void doSomethingBasedOnCurrentState( int state ) {
switch ( state ) {
case INACTIVE: //doSomethingForInActiveState(); break;
case ACTIVE: //doSomethingForActiveState(); break;
case UNKNOWN: //doSomethingForUnknownState(); break;
}
}Lower complexity (CCI: 1)
public enum CurrentState { INACTIVE { void doSomething() {} }, ACTIVE { void doSomething() {} }, UNKNOWN { void doSomething() {} };
abstract void doSomething();}
CCI Source: SonarQube (Complexity scores)
![Page 25: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/25.jpg)
@theNeomatrix369
Refactoring resources...
![Page 26: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/26.jpg)
@theNeomatrix369
Test coverage - unit & integration tests
Hint: EclEmma, JaCoCo and IntelliJ Code Coverage
![Page 27: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/27.jpg)
@theNeomatrix369
Performance tuning tools (short and long feedback loops)
- Application behaviour- GC behaviour (on the JVM)- Early or late feedback (during development, or post- development)- Profiling
Some known tools: Java Mission Control, Java Flight Recorder, jconsole, GC Viewer, VisualVM, HeapAnalyzer, PerfAnal, JAMon, HPJMeter, HonestProfiler, mjProf, Eclipse Memory Analyzer (MAT)
![Page 28: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/28.jpg)
@theNeomatrix369
Performance tuning tools(short feedback loop)
Profiling tools
- Honest profiler- mjProf- Eclipse Memory Analyzer (MAT)- others
![Page 29: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/29.jpg)
@theNeomatrix369
Performance tuning tools(short feedback loop)
JITWatch* - @chriswhocodes
Understand...Java HotSpot Just-In-Time (JIT) compiler...program execution.
Hot Method too big - among other JIT optimisation errors
Java 7 and Java 8 core methods above the default hot method inlining threshold
*an Adopt OpenJDK F/OSS project
![Page 30: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/30.jpg)
@theNeomatrix369
Performance tuning tools(long feedback loop)
Censum - jclarity.com
- GC Analysis, similar to GC Viewer- Additional metrics and graphs- Built-in analytics, recommendations & heuristics
![Page 31: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/31.jpg)
@theNeomatrix369
The others... Google CodePro
Coverity ThreadSafe
IntelliJ IDEA Squale
Veracode
![Page 32: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/32.jpg)
@theNeomatrix369
Collaborate...share, crowd-source, machine learning...
(Hippie completion)
![Page 33: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/33.jpg)
@theNeomatrix369
Inventions...
![Page 34: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/34.jpg)
@theNeomatrix369
Strategies (checklists)
[ ] Strategy (method in the madness)[ ] Strategy (interesting, ear-marked)
Find the checklists in the Resources section at the bottom
![Page 35: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/35.jpg)
@theNeomatrix369
Continuous Inspection
Individual inspections
(local first)
![Page 36: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/36.jpg)
@theNeomatrix369
Continuous Inspection (local first)
Some more individual inspections
![Page 37: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/37.jpg)
@theNeomatrix369
Rule of thumbMetrics Rule Mitigating action
Method complexity >= 6 pathways Refactor: split method
Class complexity >= 60 pathways Refactor: split class
LCOM4 >=2 responsibilities Refactor: new class / subclass
RFC per class > 40 connections (both ways - afferent & efferent)
Refactor: reduce dependencies and dependents, split class
Source: SonarSource resource, Book: SonarQube in Action
![Page 38: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/38.jpg)
@theNeomatrix369
Observations...
![Page 39: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/39.jpg)
@theNeomatrix369
Repetition...helps build muscle memory
![Page 41: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/41.jpg)
@theNeomatrix369
Katas - individual partsissues violations
duplicationscode (test) coverage
mutation testingquickcheck
immutability checkcomplexity check
performance check
![Page 42: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/42.jpg)
@theNeomatrix369
Introspection...
![Page 43: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/43.jpg)
@theNeomatrix369
Trust but verify
Trust your tool(s)……believe in your method(s)
Adopt advice from peers & experts… ...but also evaluate it yourself
![Page 44: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/44.jpg)
@theNeomatrix369
Do these factors make up quality ?
developer: knowledge and skillsx
tool: tunability, features & capabilitiesx
(environment & team)
![Page 45: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/45.jpg)
@theNeomatrix369
(when you take a plunge)
...its not just about tools, there is more….
Discovery…
![Page 46: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/46.jpg)
@theNeomatrix369
Discovery…
...firstly a tool is onlya temporary scaffolding…
![Page 47: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/47.jpg)
@theNeomatrix369
Discovery…
...its about methods and techniques...
(because tools are only a dumb conduit)
![Page 48: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/48.jpg)
@theNeomatrix369
Discovery…
(...if you dive deeper…)its about the practise and developing good habits
"I'm not a great programmer; I'm just a good programmer with great habits.” Kent Beck, http://en.wikiquote.org/wiki/Kent_Beck
![Page 49: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/49.jpg)
@theNeomatrix369
Realisations...
Writing good quality code takes practice, effort and time
![Page 50: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/50.jpg)
@theNeomatrix369
Quality is a concerted effort of not just a single developer but a team of developers !
Realisations...
![Page 51: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/51.jpg)
@theNeomatrix369
- Repetition- Measuring progress- Early detection- Short feedback loop- Reliable pairing - Filling the (missing) gap- Powerful & effective ally
Conclusion
![Page 52: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/52.jpg)
@theNeomatrix369
Summary
● Personal story● Various methods & techniques: processes● Strategies (checklists)● Inventions & observations: continuous inspection (local first) & katas ● Discoveries and Realisations ● (My) conclusion
![Page 53: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/53.jpg)
@theNeomatrix369
Gratitude - big thanks !...to the dev communities of London and Europe!
LSCC
![Page 54: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/54.jpg)
@theNeomatrix369
Q & A
Keep them coming !
![Page 55: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/55.jpg)
@theNeomatrix369
Its time to share your methods and help improve our craft !
Please tweet your feedback at @theNeomatrix369
![Page 56: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/56.jpg)
@theNeomatrix369
Devoxx UK - 17-19th June 2015
Socrates UK - 4-7th June 2015
Conferences
![Page 57: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/57.jpg)
@theNeomatrix369
Let’s change the Java ecosystem, together!
Daniel Bryant @danielbryantuk Mani Sarkar @theNeomatrix369
With support from the JCP, London Java Community and Java communities worldwide
@adoptajsr@adoptopenjdk
[email protected]@openjdk.java.net
![Page 58: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/58.jpg)
@theNeomatrix369
Resources● SonarQube resources● SonarQube Nemo project● Discussions on Sonar on JavaRanche● Installing SonarQube (formerly Sonar) on MacOsX Mountain Lion● Using SonarQube on MacOsX Mountain Lion● SonarGraph (http://www.hello2morrow.com/products/sonargraph)● Jitwatch: http://github.com/AdoptOpenJDK/jitwatch● QuickCheck (https://bitbucket.org/blob79/quickcheck)● Mutation Testing (http://pitest.org/ or http://ortask.com/mutator/)● Mutability Detector (https://github.com/MutabilityDetector/)● AssertJ - fluent assertions for Java (plus other fluent libraries)● Censum (@jclarity product - see http://www.jclarity.com/censum/)● Profilers: HonestProfiler, mjProf, Eclipse Memory Analyzer (MAT)● Books: Sonar in Action (http://www.manning.com/papapetrou/), Software
Craftsmanship by Sandro Mancuso, Uncle Bob’s Clean Code
![Page 59: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/59.jpg)
@theNeomatrix369
Predecessor to this presentation...
http://bit.ly/1lk8NDW
to improve code quality !
SonarQubetm
![Page 60: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/60.jpg)
@theNeomatrix369
Strategy (method in the madness)
[ ] Unit & Integration test coverage: EclEmma, JaCoco, IntelliJ Code Coverage check[ ] Most violated rules (Blockers, Critical, Major, Minor violations)[ ] Duplication removal - DRY[ ] Complexity (package-, file/class-, method-levels)[ ] Performance: profiling (memory, cpu, hardware)[ ] Performance: GC analysis*, JMH benchmarking** Java/JVM platforms only
![Page 61: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/61.jpg)
@theNeomatrix369
Strategy (interesting, ear-marked)
[ ] Analyse & apply Squale reports[ ] Apply SonarGraph[ ] Apply Mutation testing (i.e. PITest, Mutator)[ ] Apply generative tests (QuickCheck)[ ] Apply Mutability Detector library[ ] Analyse using JitWatch (improve JIT attempts)[ ] Analyse using Censum (improve GC)
![Page 62: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/62.jpg)
@theNeomatrix369
Quality of Music - truth tableQuality of instrument (material)
How tuned the instrument is?
Skills & experience of the performer
Quality of music(outcome)
Bad Not tuned Not skilled / Skilled Very Bad
Bad Tuned Not skilled / Skilled Bad
Medicore Not tuned Not skilled / Skilled Below Average
Good Tuned / Not tuned Not skilled / Skilled Average
Good Tuned Skilled Good
Very good Tuned Highly skilled Very good
![Page 63: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/63.jpg)
@theNeomatrix369
Novice to expert...
In the beginning, learning from past experiences, building up knowledge and experience with repetitions, finally excelling with your own efforts...
![Page 64: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/64.jpg)
@theNeomatrix369
Layers of qualityContinuous Deployment*
Continuous Integration*
Code quality
Tools & Methods
(Developing) Good Habits
![Page 65: Leaning on the two Ts](https://reader033.vdocuments.site/reader033/viewer/2022060115/557cb659d8b42ab37c8b4ac8/html5/thumbnails/65.jpg)
@theNeomatrix369
Layers of quality (contd.)Continuous Deployment*
Continuous Integration*
See what Dr. Daniel Bryant has to say about the above:http://slidesha.re/1rKdOdUhttp://slidesha.re/VwKDB0
(Devops the TDD approach)