Showing posts with label Clean Code. Show all posts
Showing posts with label Clean Code. Show all posts

Thursday, January 23, 2014

HLSL Unit Testing

Es gibt schon krasse Sachen! Tim Jones hat HLSL Unit veröffentlicht. Dabei handelt es sich um ein Framework zum Testen von Shadern. Dies spielt z.B. in Geo4T eine große Rolle da dort vergleichsweise viel Logik auf die GPU "out-ge-sourced" wurde. Entsprechend wichtig sind da automatisierte Tests. Einen entsprechenden Spike habe ich unter Hello.HLSLUnit angelegt.

Wednesday, December 4, 2013

"No Experience Required!"

Der Blogpost No Experience Required! stellt die Ergebnisse von empirischen Studien zusammen die insgesamt über 30 Jahre abdecken. Erstaunliches Ergebnis: Es konnte absolut gar keine Korrelation zwischen der Erfahrenheit eines Programmierers (in Jahren) und der von ihm produzierten Codequalität festgestellt werden. Das stimmt nachdenklich, oder?

Wednesday, October 9, 2013

Klockwork Insight: ReSharper für C++?

Über eine Meldung auf Heise DeveloperHeute bin ich auf Klocwork Insight aufmerksam geworden. Dabei handelt es sich um ein Werkzeug zur automatischen Analyse und Refactoring von C++ Code. Das Demo-Video welches typische Handgriffe in der Visual Studio Integration zeigt erinnert stark an Jetbrains ReSharper (für .NET). Kein anderes Tool hat mein Arbeiten so stark verändert. Daher könnte ich mir gut vorstellen dass das Insight vielleicht was für unsere C++ Ritter ist. Was meint ihr?

Thursday, September 26, 2013

New Programming Jargon:"Reptile Code"



With New Programming Jargon Jeff Atwood added all the modern programming metaphors to the  Jargon File. With Reptile Code i would like to propose one myself.

In "The Science of Discworld (1)" [1], chapter Mammals on the Make, biologist Jack Cohen elaborates on of one of science's remarkable misjudgments. At this time, the concept of DNA was often referred to as Blueprint of life. And it still is today:



It seemed to be a natural conclusion to approximate a species' level of evolution or its complexity by the length of its DNA strand, i.e. the longer the DNA code the more sophisticated the species.

This intuitively made sense. By analogy, the engineering blueprint of Jumbo Jet is a lot longer than that of a simple paraglider.


The embarassing result: Empirically, the DNA of a frog is much longer than the human DNA. Confusion took hold. Could it be that God considered simple reptiles higher than his flagship creation, man?

Later, it was found that human DNA is so much shorter because it is organized better [2].
Put simply, frog DNA contains a variety of contingency plans for environmental changes that accumulated in the course of evolution as lots of code patchwork. For instance,
if temperature between -14° und -7° do this,
else if between -7° and 0° do that,
else if ... etc.
Warmbloods like man escape this complexity through the elegant statement
set internal temperature to 36°.
Especially for developers, i find this view very accessible, because they very well know about metrics like Lines of Code (LoC) oder Cyclomatic Complexity (McCabe) from their own experience [3].

Hitting such code, you could probably say in Mr.Spock voice:
Fascinating! This component is likely to be hard to maintain: The average cyclomatic complexity of their methods differ with 57.63 significantly from that of the World Code Health Organization (WCHO) which recommended a maximum 20.
Compared to Mr. Spock just stating
Woah! Reptile Code!
really hits home and feels more natural.

Footnotes:
  1. As a teenager i loved reading Terry Prattchet Discworld-novels, especially the series Science of Discworld which were written together with co-authors Ian Stewart und Jack Cohen and which uniquely prescribes the wonderful cosmology of Roundworld and is amongst the best introductory works on evolution after Richard Dawkins.

  2. Later, it turned out that DNA-Code at times can "reorganize" and shift to a whole new organizational level of abstraction. It seems, evolution knows the concept of "refactoring" but she is a lot more cautious on eliminating "dead code" (perhaps of the deep coupling of SCM and the code itself).

  3. In general, long codes with a high McCabe-Complexity are a lot harder to maintaint, cf.:

Links:

Monday, September 9, 2013

Code Metrics in VS2012

Gerade gestern hat mich ein Artikel unseres alten Scrum-Trainers Markus Gärtner erneut auf die Cyclomatic Complexity-Metrik aufmerksam gemacht. Diese ist besonders praktisch weil sie zu einer Methode direkt sagt wie viele Unit Tests man dafür haben sollte.

Auch in aktuellen Sprints haben wir viele Fehler erst wieder sehr spät beim manuellen Testen bemerkt, sodass wir Schwierigkeiten hatten die angedachten Szenarios bis zum Termin überhaupt einmal durchzuspielen. Die meisten der dazugehörigen Bugs waren schwer zu finden da sie sich gut in teils sehr langen Methoden mit vielen if-else-Verschachtelungen versteckten (d.h. hohe Cyclomatic Complexity). Die entsprechenden Code-Pfade waren vom Entwickler wohl kaum - wenn überhaupt - durchlaufen worden.

Grund genug für mich den Dachboden meiner grauen Zellen zu durchforsten.

Wednesday, July 10, 2013

What's in a Good Commit?

Repost The Morning Brew:
What's in a good commit? & What's in a good commit? - Timo Mihaljov and Jaco Pretorius discuss best practices for what should go in a commit when developing, with Timo giving the initial list of 5 best practices and Jaco responding to these sharing his opinions.
Lesenswert.

There's only one rule when it comes to committing commented-out code ;-)
Should I commit old commented-out code?