Switching to Wordpress
After running this blog for some years on Serendipity, I finally switched to wordpress. All my other blogs are running on wordpress, so this was the only black sheep.
I use the Aspire theme for many of my other blogs but for this one a work/desk like theme seemed more appropriate. So I took a quick look and chose Desk Mess Mirrored.
Importing the content worked like a charm using the S9 Importer plugin.
So here we are.
For the interested here is the list of the other blogs I’m running:
97TESPK: Scoping Methods
Now that 97 things every programmer should know lies on my compass table, I’ll post my contributions here that didn’t make it into the book.
The first is “scoping methods” which I thought about while reading Uncle Bob Martin’s Clean Code. He discussed scoping variables but only about putting methods near to each other. Obviously there was a missing piece. I tried to write it down.
It has long been recommended that we should scope our variables as narrowly as possible. Why is that so?
Readability is greatly improved if the scope of a named variable is so small that you can see its declaration only a few lines above its usage.
Variables leaving scope are quickly reclaimed from the stack or collected by the garbage collector.
Invalid reuse of locally scoped variables is impossible.
Singular assignment on declaration encourages a functional style and reduces the mental overhead of keeping track of multiple assignments in different contexts
Local variables are not shared state and are therefore automatically thread safe.
But what about scoping our methods?
We try to decompose methods into smaller units of computation, each of which is easily understandable. This goes hand in hand with the principle that a method should deal only with a single level of abstraction. If the result, however, is that your class then houses too many small methods to be easily understandable, it’s time to rescope its methods. Although similar in some ways, that’s not quite the same as decomposing classes with low cohesion into different smaller classes. The class may be quite cohesive, it’s just that is spans too many levels of abstraction.
Although there are layout rules that make locality and access more significant (like putting a private method just below the first method that uses it), scoping is a cleaner way of separating cohesive parts of a class.
How do you scope methods?
Create objects that correspond to the public methods, and move the related private methods over to the method objects. If you had parameter lists for the private methods — especially long ones — you can promote these some of these parameters to instance variables of the method object.
You then have your original class declare its dependencies on these fragments and orchestrate their invocation. This keeps your original class in a coordinating role, freed from the detail of private methods. The lifetime of your method objects depends on their intended use. Mostly I create them within the scope just before being called and let them die immediately after. You may also choose to give them more significant status and have them passed in from outside the object or created by a factory.
These method objects give the newly created method scope a name and a location. They stay very narrowly focused and at a consistent level of abstraction. Often they become home for more functionality working on the state they took with them, e.g., the promoted parameters or the instance variables used by just these methods.
If you have private methods that are often reused within different other methods it’s perhaps time to accept their importance and promote them to public methods in a separate method object.
12 patterns of development
Martin Fowlers Pattern talk at #jaoo made me make this 12 patterns of development song.
Have fun
Michael
On the twelfth day of Development,
my true dev sent to me
Twelve bridges bridging,
Eleven factories making,
Ten observers observing,
Nine builders building,
Eight visitors a-visiting,
Seven composites composing,
Six iterarators iterating,
Five golden states,
Four calling proxies,
Three nice adaptors,
Two commands commanding,
And a singleton in a pair tree!
On Unicode in DSLs
Guy Steeles Talk on Fortress reminded me on the possibility of using Unicode characters in strings and identifiers in most current programming languages.
That also opens the way for using them in DSLs. Either in internal or external ones. If the special symbols have already a defined meaning in the domain (perhaps as part of a standard notation) this should make DSLs even more readable for the people with the domain knowledge.
All that came to my mind when talking with Dan North about the great new JBehave 2 BDD Framework for Java. When parsing and converting scenario step text tokens, the usage of unicode symbols could improve conciseness and readability.
From Sam Aaron I learned that a ton of unicode characters is just an (ALT-)Keystroke away on a Mac keyboard. He also showed me that in Ruby Unicode is no problem for identifiers and string content.
On Signing MacBooks
Today was the last day of this great JAOO Conference. Rickard, Emil and Irene had to leave. I’ll stay for two more days. Tomorrow some tutorials and squill hacking with Jevgeni .
I had some really great discussions over the last couple of days. The conference atmosphere is the best place to breed new ideas.
As a final gift to myself I had my MacBook Air signed by some of the speakers. I wanted to do that already when attending the QCon London in March, but back then it was to late when the idea crossed my mind.
I am happy that the following (in no particular order) people where so kind to sign my daily development tool :
Dan North, Big Dave Thomas, Dick Gabriel, Guy Steele, Martin Fowler, Ola Bini, Neal Ford, Kirk Pepperdine, Erik Meijers, Linda Rising, Jeff Sutherland, Kresten Krab Thorup, Kevlin Henney, Frank Buschmann and Bill Venners.
Becoming a PC was a very unpleasant experience for it but its still working and hasn’t shown a blue screen since.
I now just need some very resistant coating for that.
Looking forward to the next conference (QCon in March) and to the lots of interesting follow up projects in the mean time.
On Coloring Lego – Print your own
I thought about extending Lego Time Tracking to a kind of Agile story and task management. There you take the time estimated for the task and put that many bricks of the color assigned to the task away to a central location where it is clearly visible (area of stacked bricks). Everyone contributing to the task takes away the bricks he needs for tracking his work time done on this task. The count of bricks still available at the information radar visualizes the remaining estimated time needed for the task. If the bricks are used up and the task not done its obvious that the team overpromised on this task (also noticeable much earlier).
This is something XylonSextuswrote in the comments to the lifehacker post. I just recently discovered the comment.
I quickly came to the conclusion that the existing eight colors available (plus the ones on sale at the online lego shop) are by far not enough to cover the tasks for a whole iteration. When pondering it I came across the printing possibilities my friend Mattcher has available at his company.
So we did a quick prototype on printing onto lego bricks and here are the results:



I’m currently thinking about further uses of this idea besides puzzles, learning materials, additional time tracking/project management colors…
Regarding the additional colors: As you can print a color on both sides you can reuse the bricks for different task (one of the two colors).
On Boosting My IDE(A) – Jetbrains IntelliJ IDEA is fast again
Performance Problems
After struggling for some time with the performance problems with recent IDEA versions on my clients workstations, I’ve finally found a solution. After upgrading from version five the performance of IDEA began to degrade.
I had many hangs and a general sluggish feel.
The machine is a single core 3,4GHz, 4 GB RAM, Maxtor 7200 SATA drive Windows XP station that shouldn’t be that slow.
The projects I’m mostly working on contain about 7000 classes. Unfortunately some of these are quite large. But these posed no problems for former versions of IDEA.
Unsuccessful Attempts
Of course I’m always shutting down the Anti-Virus program before starting development.
I started creating a 512 RAM disk for the build process output files (.class, .jar etc).
But this didn’t improve anything for the IDE (just the build process).
There were several articles talking about IDEA optimizations. Mostly settings and JVM startup params.
10 Tips by Hamlet d’Arcy
IDEA Performance Tuning by J2EE blogger
IDEA VM options from the JetBrains blog
I played with all the JVM startup parameters available but this didn’t help either. Its currently running with
-server -ea -Xmx768m.
Following the tip of the JetBrains blog I also used DiskKeeper to optimize the MFT segment of the disk.
But none of the above had any significant impact.
IO-bound IDE
When looking at the IO Read/Write information of the task manager it is very clear that the IDE is mostly IO-bound.
Then I used sysinternal’s filemon to look which files were accessed at which times by IDEA (especially during the 3-30 second hangs I experienced regularly). These were mostly the caches, ideas own jar files and my application’s class files.
What I don’t understand is why the “operating system” is not able to cache that file information in memory as quite a lot of the available 4GB is still free.
Decision for SSD
When listening to the google talk of IDEA tech lead Dmitry Jemerov the mentioning of having 10000 rpm drives helps a lot with IDE performance was an obvious hint in the right direction. But I neither want nor need an 10k rpm drive in my workstation.
As since February I’m the proud owner of a MacBook Air with an 64gb solid state drive the solution was at hand.
Buying the SSD
I looked through serveral reviews of smaller SATA-SSD drives and decided to go for on of the fastest available. The 0 millisecond access time together with read/write rates of 120gb/80 gb respectively made it a clear favorite.

So I ordered a 16GB 2,5″ MTRON SSD Mobi 3000 from the german reseller for about 170 EUR.
Installation
After plugging it into the machine I copied the IDEA installation directories to the new drive, changed the cache location in the idea.properties file and copied my project files there as well. Next things were the JDKs and some additional libraries (potential candidates would also be the maven repository and some local libraries).
After that IDEA worked like a charm, no more hangs, no hiccups just flowing from my fingertips and not hindering me at all. That’s great feeling this again.
On Finding The Anykey
Finally I’ve found it: The mysterious “Anykey” is living under the strange name of “QuickFix” in your IDE of choice.

Pressing Alt+Enter (Cmd+Enter) in Intellij IDEA or Ctrl+1 in Eclipse enables you to program on a “per example” basis. You can do
introduction of variables, fields, classes,
renaming
changing method signatures
completing structure
surrounding code with live template
importing dependencies
and much more …

and much more just by pressing the “AnyKey” at any offending piece of code. Especially the ton (600+) of intentions of IDEA fixes almost each possible syntax problem using a single key.
Kent Beck used the AnyKey (QuickFix) when describing the Refactoring By Example.
You can find further keystroke reference cards in the help menus of your IDE.
DZone made up a nice collection of refcardz:
IntelliJ IDEA DZone Refcard
NetBeans 6.1 Refcard
On LEGO Powered Time-Tracking; My Daily Column
I’ve had troubles with time tracking my worktime for all the years. I always found this to be a tedious burden and inconvenience. So one morning in my blue hour (reading in a cafe before work) I spent the time pondering the alternatives.
I started listing software and realworld solutions to timetracking that are possible and tried to contemplate if they would (or had) worked out for me.
software:
spreadsheets
plain text files
browser based timetracking
Outlook/iCal
popup applications/widgets asking for the current task
corporeal:
sticky notes
paper
tally sheets
notebook
diary / filofax
But none of these seemed to work sufficiently for me. But the arrangement of events of a day in iCal struck me as beeing a stack of time boxes atop each other. Having played recently with my daughters legos (duplo), I quickly jumped on the thought of using them to build these stacks in the real world.

So I bought an box of 600 legos from amazon for around 19 Euros. Opening the package showed me that fortunately there was a variety of colors (white, black, brown, red, orange, yellow, green, chartreuse, blue) and lots of different sizes (lengths) and two widths (one row and two rows of studs).

As a child I hated these one-rowers as they were not useful in building stuff. But here and now they seemed a perfect fit. Small enough and in the right sizes. I chose a time partitioning of a quarter of an hour. So I can use the lengths 1,2,3,4 to build 15,30,45 and 60 minutes worth of time in a row representing an hour.
Stacking these hourly rows on top of each other builds up the whole day. I use the different colors for the projects I’m involved in (8 are just enough), putting them on the stack whenever I want and have time to do so (but mostly quite instantly).

I made up a single width column as ruler for the work hours (from at around 10 am up to 6 pm). So I can easily see whats missing and at what time I did something. For the days of the workweek I chose the rainbow color scheme (red, orange, yellow, green, blue – Monday to Friday) for the longer base row that I stack my hours on. So I can gather a whole week of time tracking until I have to enter them in some time sheet (software). I put the columns of a whole week on top of a green building plate to fix them.

You can easily see how much work you did for any given project as you recognize the colored areas rather than time ranges (8:45-11:15). Having the relative time shares as part of this setup helps as well.
You can even plan your work by prebuilding your days on temporary bases with the planned amount of time for each activity (or putting at least the estimated amount of bricks aside).
The benefits are obvious:
it works (for about 4 months now)
I have something to play with while pondering stuff
it looks great
it’s incredibly fast with no overhead
planning is possible
The single disadvantage:
coworkers coming to your place and disassembling your time tracks

I’m still looking for a great name for the whole thing. Here’s what I have collected by now:
Names:
BrickLog
Daily Column
TimeStack
TrackStack
The timeful way of building
I appreciate any suggestion for a great name.
One last thing I have been thinking about is getting these daily columns recorded automatically. So using your webcam or phone camera, you just hold the “day” in front of it. After taking the picture it is processed. The extracted information can be used in any possible way.
Update: I started writing a small java application that shall exactly do this. It’s almost finished, so stay tuned. Writing the data to iCal should pose no problem as well.
Early preview image of the scan application:

Update:
Post on Lifehacker
InfoQ follow up article.
I added a poll for the name of “Lego Time Tracking to the blog” Feel free to vote or to suggest new names.
On “The Productive Programmer” by Neal Ford
I’ve been reading Neal’s blog for a while. So I’ve been looking forward to the book. (I even accidentally ordered it twice – one was the pre-buy at amazon, which I forgot about).
I spend the last two days reading the book and found it quite helpful. There are a lot of concrete tips and examples for immediate use and daily improvement of your mechanic skills. Many of the experiences regarding the effective use of the tools at hand that he describes are well known to me. I can’t really understand how developers are not keen to improve their productivity.
Neal’s book is a good addition to the PragProgs masterpiece. It concentrates more on the mechanics and on some principles of productive software development. So the triad of values-principles-patterns got a son named mechanics.
What I missed in the book was:
- a comprehensive list of the notes at the end.
- Christopher Alexanders appearance as one of the philosophers.
- the notion of cheat sheets/refcards
- references to Martin Odersky’s Scala the scalable language
- references to Kent Becks “Implementation Patterns” (especially in the SLAP section)
As being a developer myself I was a bit disappointed by the quality of the examples (the solutions not the starting points) and a bit by the correctness of the text (typos). I spotted several errors, some bad designs and some uninformed choices even on the first read of the book. I’ll post them to the errata page.
Neals suggestion of an online repository at productiveprogrammer.com of productive programmers tools, tips and mechanics is a great idea. I’d really like to join this effort.



