Showing posts with label book. Show all posts
Showing posts with label book. Show all posts

14 June 2021

The One Thing

Last year, during second lockdown, I watched a message of my guro Jakob where he proposed reading some books in the time when you are not able to practice in the dojo. He specifically recommended two books, The One Thing: The Surprisingly Simple Truth Behind Extraordinary Results and Atomic Habits: An Easy and Proven Way to Build Good Habits and Break Bad Ones. I had seen both books in my Goodreads feed and had not paid attention. But when your master asks, you better follow ;-)

FocusThe Book
The book is about extraordinary results determined by how narrow you can make your focus. Gary Keller insists that it is possible to reach any goal if you focus on it. And by focus he means that you really focus i.e. dedicate four hours of each day to your one goal. It has to be one single goal. And then, by the thousands of hours you have put into your goal, you will see results. Yes obviously, when following this approach, you will see results. In this sense, the One Thing is extraordinary and boring at the same time. I highly recommend reading it.

First I planned to summarise the book for you, and others have done a better job doing that. The book's homepage is a start and you can find many summaries of the book online, like this one on Four Minute Books. While summaries are short and save time, you will not get the benefit of the book without reading it. A book is not only about its content. Here the book is cementing its message by many times the author tells you the same thing in different words, a.k.a. repetition. The total time it takes to read the book is also time you have to reflect on the material.

Impact
Maybe my summary above is a bit lame, so let's discuss the book's impact on my life. And it had a profound impact as you will see. The first and utmost thing I remember from reading the book is the permission to drop stuff from my agenda. Like all developers I know, my daily plan was way too full: work, write a blog post like this one, release an episode of the Coderetreat Facilitation podcast, run a public Coding Dojo for the community, follow up on this cool idea I read about, finish reading SICP and get back playing with Scheme, create more exercises for workshops, keep up to date with Twitter and other feeds, work out, spend time with family, fix this next thing in the flat my wife is complaining about, fight climate change and much more. How was I supposed to allocate 4 (FOUR!) hours each day for the thing I want to do? It was impossible. Obviously Gary was crazy. ;-) Or I had to drop some tasks from my agenda. The idea of focus and dropping tasks was not new to me. I remembered J.B. Rainsberger mentioning a "Not Doing" column in his task list in 2014. I myself have put whole technologies on my blacklist - which I would ignore from this time on, but I have never dropped tasks and ideas so aggressively. I had several TODO lists of low priority where tasks went to die without being honest to myself.

The First Month
I spent the first month following the One Thing on a meta level because I did not work on anything but worked on the process itself. First I increased my focus: I deleted most icons - usually things to do or bookmarks to look at - from my desktop. I removed TODO markers in documents and on my hard drive. Then I reduced my commitments, e.g. I dropped the schedule to blog and record, stopped visiting meetups, reduced the number of learning hours and decided on the maximum number of hours I would work for each client per week. And I was OK with that. Letting go became a mental state and I had been following the Minimalists and Marie Kondo already before I started.

Suddenly I had more time - I even had some unscheduled time to play video games which I almost never did. In hindsight this was not extraordinary at all. If you drop most things you are working on, you will have more time available. It is a matter of focus. Lockdown and home office helped as I saved more than two hours every day. While some colleagues complained that they worked two hours more, I used these two hours - giving me half of my required four hours already. And I used the first month - 80 hours total - to practice the One Thing process. I started each day with a few minutes of mediation to improve my focus. I read more books about focus, e.g. Leo Babauta's book on focus and simplicity, forming habits, e.g. Atomic Habits as mentioned above and learning. I studied these books, taking notes and collecting them. I recommend all of them. I clean up my "office" and spent some time decluttering it, storing stuff in drawers or trashing it to further improve my focus during work.

Books
One example of my achievements since I started using the One Thing methods are the books I have been able to read this year. The Pragmatic Programmers once wrote that you should read at least four technical books a year and the last year I was able to follow their rule was 2016. Since then I have been struggling to read at least one technical book a year. Reading became hard, I had problems focusing and I usually fell asleep after reading a few pages. I decided to add some reading time every day to my four hours of focused work, reading on the topic of focus of course. So including the One Thing, I have read ten books in five months.

ArcherClarity
Spending four hours on focused work each day reduced the time I had available for other things. After some struggle, I had more clarity - and stopped my self-deception. For example, if I see an interesting article linked on Twitter I either read it immediately, or I forget about it. There is no point in adding it to my read-later list, because there is no read later list because there is no extra time for that. I would not read it anyway, my read-later list kept growing and growing. While I was dreaming of doing so much in the past, I have become a naysayer now. For example "this is a good idea. I might try it. (One second later.) No, not really this is not my One thing and I have no time. End of idea." This is refreshing and freeing. Clarity is one of my needs.

Crunch Time
One drawback is that I am always in crunch time. As my time is more limited, I have to prioritize harder and postpone many tasks I know I need to do. This makes me feel uneasy at times. And for the things I still want to do - not as my One thing, but from time to time, e.g. maintaining my blog - I have to live with tiny increments. For example, I was working on this blog post 15 minutes at a time for more than a month. It was a bit frustrating. Still writing and "Public Relations" are not my priority.

Sorrow
Not having time to attend meetups caused some FOMO (fear of missing out) and made me miss the people of the community I had not seen in a while. In general being unable to do things which I liked mad me sad. I have been attending every one of our local, bi-monthly Coderetreats since its inception January 2019. When I was unable to attend for the first time in more than two years, I felt very, very sad. I felt a loss, almost like mourning. Maybe this was the first time in my life when I really let something go. It is easy to let go things you are not attached to.

Crunch Time Summary
Time for a very short summary (as my latest 15 minutes increment is almost spent): Read the book. Find your One Thing. Focus on it. It is possible to allocate four hours each day to focus on your highest priority, though it might be hard to stick to it. I am half a year into the process and did not miss a single day. Keep pushing!

12 June 2020

A New Dog

Last year our dog Ruby died. We took some time to cope with the loss and now is the time for a new dog. After we loved a Great Dane once, there is no other dog we want. Here is a picture of our new puppy Ronja:

Great Dane puppy Ronja
While I chose the name of our previous dog - Ruby - my wife chose the name of this one. Ronja or Ronia is the daughter of the leader of a clan of robbers. Obviously she has little manners and does what she likes - and that is exactly the nature of our little Ronja ;-)

Raising a Puppy
Like software development, raising a puppy is a detailed process which can be improved continuously. Today we know more than ten years ago and we want to do much better. There are many misconceptions how to raise dogs and I learnt again that knowing how to handle certain situations is not enough - I have to practice them. For example, grabbing the puppy on time so it will not pee on the carpet is a skill. If you ever plan to raise a puppy I recommend to check out the books by Ian Dunbar, BEFORE You Get Your Puppy and AFTER You Get Your Puppy. These are small books, fun and easy to read. Both books are provided as e-books courtesy of simpawtico dog training in the downloads section. And even if you do not own any dogs, reading these books will help you understand why dogs behave how they do - especially if they have been trained badly.

BEFORE You Get Your Puppy book cover AFTER You Get Your Puppy book cover

22 February 2019

Flashcard Madness: The Little Schemer

On my journey into the Scheme Programming Language I am currently reading The Little Schemer (4th edition) by Daniel P. Friedman and Matthias Felleisen. I started reading because of it was recommended by different sources. It is a fun little book. Its style is quite unusual as it is written as a series of questions, which force you reflect about the content along the way. It repeats the same steps again and again - a reminder of recursive concepts - which is forcing you to practice the concepts you just read about.

The book introduces Ten Commandments and Five Laws for the Scheme style of programming. The commandments are basic rules of working with lists and the laws define the API of used functions. Ray Grasso collected all the commandments and laws in his notes. What to you do when you have a list of rules? You study them! I like using flashcards to study short facts and created a set of digital flashcards for the Ten Commandments and Five Laws. The deck is in the Anki file format (apkg), which can be used with the Anki application under Windows and Android. There is a similar application AnkiApp for Mac OS and iOS.

The deck contains questions about the rules themselves, e.g. What is the 2nd Commandment? With answer use `cons` to build lists.. Then I derived questions which are more actionable, e.g. When recurring on a list of atoms, `lat`, ask two questions about it? With answer `(null? lat)` and `else`. I am not sure these cards are useful on their own, but they definitely helped me to commit the facts I learned from the book to my memory.

Download The_Little_Schemer.apkg here.

20 December 2018

Scheme Programming Language

With the beginning of this year I "fell" into Scheme. I blame SoCraTes BE 2015 for that. (SoCraTes is a group of international unconferences focusing on Software Craft and Testing. They are about sustainable creation of useful software in a responsible way and usually run as self-organised Open Space.) During that SoCraTes I happened to enter a session where a small group worked on some Scheme code. The Scheme programming language is one of the two main dialects of Lisp and I recognise Lisp when I see it. The session was so much fun that it continued for the whole of the second day. We used available slots in the schedule of the open space, and in cases there were none, we continued coding Scheme in the hallway, the kitchen and other places. (Now such things only happen on SoCraTes and I encourage you to attend one if possible.)

SICP Exhibit, MIT Museum Includes a battered copy of SICPThis SoCraTes experience broke the ice with Scheme, i.e. it gave me enough exposure to a new language and enabled me to continue on my own. For the next two years I kept playing with Scheme, experimenting with code katas, e.g. the Bank-OCR Kata, porting well known exercises like Parrot, Gilded Rose and Game Of Life and I even solved some Project Euler problems using Scheme.

SICP
Earlier this year I started reading SICP. SICP stands for Structure and Interpretation of Computer Programs, a computer science text originally used in introductory courses taught at the MIT in the eighties. It had been on my reading list since 2010, when Uncle Bob recommended it in one of his Clean Coder videos. SICP had been recommended again and again and I was very happy to find the time and energy to read it.

SICP is one of the greatest books - if not the greatest book - I have ever read. It is fast paced and written in the style of all scientific books - too dense and hard to follow. Reading it is hard work. I used to like such books when I was studying applied mathematics many years ago - actually I was eating such books for breakfast ;-) The high density gives me new information fast. As I like to read books from cover to cover, I do not mind that the information is not accessible directly. Yes it is challenging to read. And it is very insightful. I appreciate most the skill of the authors to define abstractions. I am stunned again and again how they name their composed methods.

The Scheme Programming Language
SICP is strongly related to Scheme as it is one of the bibles of the Lisp/Scheme world. SICP uses Scheme for its code samples and exercises as Gerald Jay Sussman, one author of SICP, is also one of the creators of Scheme. Scheme is a version of Lisp and as such a divine language per se. It is a great language and unlike Lisp it follows a minimalist design philosophy. I really like its simplicity: There are no reserved words, not much syntax, just atoms, pairs and lists.
(define atom?
  (lambda (x)
    (and (not (pair? x))
         (not (null? x)))))
Atoms are numbers, strings, booleans, characters and symbols. Symbols i.e. names usually represent other atoms or functions. Maybe you do not like all the extra parenthesis, but it is compact and uniform. Because of the uniformity of the S-expression, it is easy to create parsers, embedded languages and even full featured Schemes, e.g. in Python, Haskell or any language. (To be fair, the last link contains implementations of Lisp not Scheme in 73 languages.)

History
As I said before Scheme is based on Lisp. The Lisp programming language was created 60 years ago by John McCarthy. And Lisp is very special, it seems to transcend the utilitarian criteria used to judge other languages. In 1975 Scheme was created by Gerald Jay Sussman and Guy Lewis Steele. Watch this great talk by Guy Steele about issues associated with designing a programming language.

Ancient HistoryStandards
One thing which confused me a lot when I started playing with Scheme were its versions. The Scheme language is standardised by IEEE and the de facto standard is called the Revised n Report on the Algorithmic Language Scheme (RnRS). The most widely implemented standard is R5RS from 1998. I use that mainly because the first Scheme implementation I downloaded was an R5RS compliant one. R5RS files use the .scm filename extension. The newer R6RS standard, ratified in 2007, is controversial because it departs from the minimalist philosophy. It introduces modularity which is breaking everything. Being used to the strong compatibility of Java or at least the major compatibility of Python I did not expect versions to be incompatible at all. R6RS files use the .ss, .sls and .sps filename extensions. The current standard is R7RS from 2013, a smaller version, defining a subset of the large R6RS version retaining the minimalism or earlier versions.

(Almost) Complete List of Special Forms and Functions
I did not read any tutorials or books on the Scheme language - I was exploring the language on my own. Still I wanted to know which library functions I could use. Similarly I used to list all classes available in each Java release. I searched for an exhaustive list of Scheme functions. There are many Schemes and I did not want to depend on any implementation specific extensions. In the end I decided to scrape the standards.

Scheme makes a difference between forms and functions. Function calls evaluate all arguments before control is passed to the function body. If some expressions should not be evaluated - as in if or switch (which is cond in Scheme) - a special form is needed. Special forms evaluate their arguments lazily. For more information see Why is cond a special form in Scheme.

R5RS Forms and Functions
I scraped the list of special forms and built-in functions from the R5RS HTML documents. The list is incomplete since I had to rely on formatting of the document. It misses define and the abbreviations like ' and @, but looks pretty good (to me) otherwise. Browsing the 193 forms and functions gives an idea of built in data types, i.e.
boolean
char
complex (number)
exact (number)
inexact (number)
list
number
pair
procedure
rational (number)
string
symbol
vector
as well as possible conversions between them available in any R5RS compliant Scheme.
char->integer
exact->inexact
inexact->exact
integer->char
list->string
list->vector
number->string
string->list
string->number
string->symbol
symbol->string
vector->list
The Leeds LibraryR6RS Forms and Functions
As mentioned earlier, R6RS is much larger than R5RS. It defines 630 forms and functions, most of them in the (new) libraries. The standard separates built-in forms and functions from the ones defined in libraries. (This is still very small, considering that the Java 8 core library contains 6000 public classes.) My list of forms and functions contains all, built-in and library alike. It looks complete, but I am not sure, I did not work with R6RS. From a quick glance R6RS adds bitwise and floating point operations as well as different types of byte vectors, enum-set and hashtable. When looking at my list now, I see that I should have scraped the names of the library modules as well. (I added that to my task list for 2019 ;-)

Scheme Requests for Implementation
Next to the RnRS standards, there are the SRFIs, a collection of concrete proposals and reference implementations. People implementing Scheme chose to implement SRFIs or not. Most Schemes support some of then, see Arthur A. Gleckler's report of SRFI support by Scheme implementations in 2018. Some Schemes have package managers which allow to download and instal packages. Usually some of those are SRFI implementations. I guess I also need to scrape these.

Conclusion
Scheme (Lisp) is so much fun, especially when you do not have to deliver anything. Most people I meet got in touch with Lisp during university but never followed up. Some are even afraid of it. Since 2016 I run Scheme coding sessions at every unconference or SoCraTes event I attend. I invite people to mob with me and I do all the typing. We always have a good time, and - after some warm up with Scheme - people really like it. They all enjoy the opportunity to dive into Lisp again. Will you?

28 September 2014

Advanced Personal Branding

This February I wrote three articles on personal branding for software developers. I discussed creating and strengthening your brand step by step: branding all your accounts and defining your motto, sharing and promoting yourself and maintaining a technical blog. I sorted these activities by difficulty into a kind of personal branding ladder, which will vary for different people depending on their personality. This is the final article covering advanced, that are more difficult and more time consuming branding activities.

Go Out!
Edge Conference at Google New YorkPersonal branding is - well - personal. So you need to meet people in person, interact with them. Find your local user groups or technology related meetups and attend regularly. Join the discussion and talk about the topics you are interested in. You do not need to present anything formally. Regular listeners who ask questions now and then are vital for the existence of any community. There is no way you can fail here. As long as you are authentic, people who share your enthusiasm will want to meet you and discuss your topics. You are interesting to like-minded developers, you just need to allow them to find you.

Present at a User Group
After attending the user group meetings regularly, it is time to take the next step and present something yourself. It it true that some people would rather face death than talk in front of a crowd, but the usual audience at community meetings is forgiving. Remember, most people in the audience are like you and already know you in person. They gave similar beginner talks or know that they should. First time speakers cannot be expected to give flawless talks, and that is the beauty of user groups, full of natural human beings, delivering refreshing and idiosyncratic presentations. Some communities are so successful in encouraging their members to talk, that they continuously breed world class speakers.

Nevertheless I am not saying that your talk does not need rigorous preparation and practice up front. There are several basic things that you can screw up in presentations in general, like giving a wall of text or death by power point. Do your research and read some articles on preparing content, creating slides, presentation techniques and such. There is also much content available on technical presentations in particular. In fact there is only one rule you need to keep in mind: Your presentation is not about you. It is not about you becoming a rock star speaker, it is about serving the audience. For example if you want the audience to read your code samples, make them easy to understand and write them in a large enough font. If the font is too small you are actually conveying the message that you do not care if people read it.

I gave my first presentation at the local Java user group five years ago. It worked out well and today, many presentations later, I still like to talk to smaller groups because these presentations often become conversations and large crowds make me nervous. If you have an extrovert character and like talking to people, giving regular presentations could be less cumbersome than maintaining a technical blog. Here you might change the order of steps. Anyway you need to do both!

Organise a User Group
Organising a local community is hard work. Meetings have to be scheduled, speakers contacted and so on. Usually the group leaders' work is not seen but vital for a thriving community. Step up and help the organisers, your help will be appreciated. Or maybe there is no local community for your favourite topic, then it is high time to create one. Creating new communities is easy using tools like Meetup or social media platforms. For example Aaron Cruz is a "community factory". Be created a new meetup for a topic that clearly has been missing, Clojure Vienna and organised a few meetups, which were a great success. Then he transferred the ownership of the group to the most enthusiastic member and went on to create another meetup.

Your group does not have to be local, there are good examples of virtual communities as well. For example Jonny Andersson runs a remote reading group, a small group of people sharing the interest to learn from books. Another, quite different example is the vJUG, the on-line Java User Group, which brings well known speakers on-line every month.

As I said above, being a community leader can be a lot of work. For example Peter Brachwitz of Clojure Vienna told me that he prepares a presentation if nobody else volunteers to do so. Now that is great leader spirit! Despite the effort, running an user group is a highly rewarding activity. You will be able to watch great presentations (if you organise them ;-) and have "exclusive" access to speakers and other community leaders. For example in the Java world there is an International JUG Leader's conference once a year.

Cydcor ConferencePresent at a Conference
Presenting at user groups is often informal, sometimes becoming a discussion rather than a polished presentation. The larger the audience gets, the more formal and professional your presentation needs to be. When submitting a talk to a large and well known conferences like Devoxx, you are competing with many other speakers to get accepted. Also your future talk needs much more practice. When facing 80 or 100 people for the first time, who are all looking at you in eager anticipation, your brain is likely to shut down, unless you are naturally gifted. At least mine did, and I did not even talk to really large crowds till now.

So your presentation needs more preparations, several dry runs, maybe even showing it to a colleague for feedback. This is much work, which keeps me from doing it too often, if at all. And I do not believe in talks with little or no preparation. Even if you do not mind making a fool of yourself, you are doing your audience a disservice. You are wasting their precious (and limited) learning time, when instead they could listen to great talks in parallel tracks.

At international events you might meet new people and grow your network beyond your local area. While this is already true for all attendees, the "magic" speaker badge lets you stand out. Other speakers will talk to you and regular attendees will stalk you to ask questions ;-) And speaking at international conferences can make you famous, really world-famous if you work hard. Working hard means attending at least one conference each month, all around the globe, besides your regular work. This is really tough, as veteran speakers like Dan North or Thomas Sundberg have assured me.

Organise a Conference
Did you spot the pattern? Find some event, attend, contribute and finally organise one yourself. What is true for local events is even more true for conferences. Again you can start small with local one-day conferences embedded in larger communities like Eclipse DemoCamp, Google DevFest or Code Retreat. Your event is likely relying on the infrastructure and help of a well running user group, because you cannot do everything by yourself. For example when we started Eclipse DemoCamp in Vienna five years ago, we did so with the help of the Java User Group Austria.

A much better example is GeeCON, my favourite Java conference which I attend every year. I believe its story is the following: Some guys of the Polish JUG met and complained about the lack of a great conference in Poland. They decided to create one. Already the first version of GeeCON was a huge success and over the years the conference became one of most awesome events I have ever attended. But GeeCON is also a perfect example of the hard work needed to run such an event. If the organisers are not in a hurry, e.g. to buy more wireless routers or fix some other problem, they are walking around the venue slowly, with tired, dark circled eyes. Lukasz Stachowiak, member of the GeeCON organisers, once told me that preparations for the next version of GeeCON start on the very next day after the previous one has ended. I am sure this is also true for Devoxx and all community-driven conferences.

Against Banned BooksWrite a Technical Book
Finally we reach the top of the food chain. Writing a book is probably the most time consuming activity. Tomek Kaczanowski told me that it took him two years to get his Practical Unit Testing book delivered. But the time was well spent. His book is getting more and more popular, which is nice in case of the little revenue each book gives, but much more important is the widespread reception of his book.

As I did not write any books myself, I can only refer to articles about doing so. For example Jack Shirazi's discussion if writing a technical book is worthwhile covers income vs. non-direct income vs. time spent of writing a book. It says "People are impressed by authors. If you have had a book published in a certain area, even if that book did not do particularly well, people are impressed." Since 2007 when he wrote the article, things have changed in publishing if you decide to self publish, as Tomek did. Jurgen Appelo recommends to read at least three books about self publishing before starting with it. And if you think about writing a book you should read Rand's excellent explanation how to write a book first.

It seems that writing a book is sort of making addicted. Many authors I know did write more than one book or at least think about writing another one, even if it would make their wives unhappy (again). Tomek decided to give his third book away for free. Bad Tests, Good Tests is a short book, nevertheless it took him some time to write it. Sure, giving the book away for free removes its direct income aspect, but increases its non-direct income, as more people will get it. Anyway, free or not, it is a great book and you should read it!

Thanks to all the people I used in this blog post as examples for successful branding activities, especially as I did not ask for their permission to do so.

23 November 2013

CodeCopTour Week 10

For the tenth week of my Software Craftsmanship tour RISE, the Research Industrial Systems Engineering, invited me to stay for three days and I pair-programmed with Kilian Matt. Kilian had prepared some special work items for my visit and we started refactoring some old piece of legacy code. Kilian was happy because nobody would touch that code and usually he would not have time to work on it himself, but for my visit he had "made some time". We worked together well and I was productive as soon as we sat down to code. Together we made smaller steps in the refactoring than both of us would have taken on their own and we moved forward steadily. Kilian focused on using keyboard short-cuts and I learned some of IDEA's key bindings. In the end of the day we had typed 15.000 keys and clicked 1800 times, a good ratio according to Kilian. (The recording was done with Workrave, a little tool for monitoring your work to avoid Repetitive Strain Injury.) Kilian is a true Software Craftsman and I enjoyed working with him a lot. Thank you very much and special thanks for the cheese ;-)

The third day of my visit I worked with Zeljko Brdaric, who specialized in test automation and BDD. We added a small feature to his code base, and adding the test first I worked for the first time with TestNG. It did not make any difference as the annotations and assertions looked the same as in plain old JUnit. We had an interesting discussion about using present or past tense in commit messages. I liked this attention to detail.

Pair-Programming CellThen I moved on to Dimoco, a company offering mobile payments worldwide. There I pair-programmed with Helmut Jelinek for two days. Helmut had arranged a meeting room for us so we would not disturb other colleagues in the open plan office. It was a very small meeting room, more like an aquarium ;-) I called it the "pair-programming cell", see its picture on the right. Helmut was responsible for Dimoco's reporting backend which collected events throughout the application and aggregated them for monitoring purposes and we added a small feature to its reporting backend. Helmut had a strict attitude about introducing zero defects and was very serious about checking, reviewing and retesting our changes. I have never met a person checking his or her code so closely. Obviously I liked that and will incorporate some elements of his work flow.

Remote Book Club
Besides pair-programming I finished reading Domain-Driven Design by Eric Evans in that week. I participated in a remote reading group, started by a former colleague Jonny Andersson, back in the days when I worked for IBM. Since January we have been meeting online each week and worked through 15 pages of the book each time. It took us 33 meetings in total to go through the 500 pages of the book and a few meetings were delayed due to public holidays or holiday time in general. We had many interesting discussions during the year which made reading the book more fun and the learning experience much richer. Jonny is preparing for the next reading group right now. It will start January 2014 and we are currently discussing which book to read. If you want to join us, stay in touch.

4 December 2012

Eclipse Plugin Development

My friend Piotr asked me where to start with Eclipse/RCP development. I am not an expert on Eclipse but it is the main platform of my current employer, and I collected some information while digging deeper into the topic myself. Following an advice from Scott Hanselman I write this blog post instead of an email. This is my list for developers starting with Eclipse development.Eclipse
  • The first pages to read are the Eclipse Plugin and Eclipse RCP Tutorials by Lars Vogella. These are short tutorials with good content which are highly relevant. You might want to start here.

  • Another source for tutorials is G. Prakash's Eclipse Tips, especially his top ten mistakes in Eclipse Plug-in development are highly recommended.

  • More details can be found in the book about Eclipse, Eclipse Rich Client Platform by Jeff McAffer, Jean-Michel Lemieux and Chris Aniszczyk. Throughout the book the authors build an entire application, set up the automated build, create an update site and everything else. This is a comprehensive end to end description.

  • The Eclipse website itself hosts a lot of specialized information. My favourite article is about how to use the JFace Tree Viewer. This does not only show how to use the Tree Viewer, it also explains how to "think in JFace" in general.

  • Finally a lot of articles can be found on IBM developerWorks, just search for RCP. These articles are older, mainly from 2006 to 2008, but most things discussed there are still relevant.
That should be more than enough to get you started ;-)

14 October 2012

Jakarta Commons Cookbook

This summer I finished reading the Jakarta Commons Cookbook. I bought it several years ago and it was sitting on my shelf since then. It survived the last "spring cleaning" when I gave away most of my books to the local Java user group, regardless if I had read them or not. I was not very enthusiastic about it, but felt the need to read it as it covers some of the most important Java libraries available today - the Apache Commons.

Jakarta Commons Cookbook coverReview
Timothy chose a way to organize the book around common tasks, so the book is in the usual cookbook/recipes style. To me the cookbook style is rather verbose and there are many examples on minute details which make the book suitable for beginners. If you are experienced and have used Apache Commons before, the book is a quick read.

Although the book covers a lot of material, it is just a glimpse of the whole Apache Commons universe. An extensive description of all the Commons projects is impossible so squeeze into a book. Still Timothy wrote about the most important projects like Lang, Collections, IO, Math as well as about some Apache top-level projects like Velocity and Lucene.

The cookbook has been published in 2004 and shows its age. A few Apache projects described in it have retired in the meantime and some parts of the shown APIs are deprecated. Still only a few changes were needed to compile all examples against the newest versions of Commons libraries. So the content in the book is still relevant.

Examples
I wanted to keep all the source code of the book as a quick reference and as a source to copy from. Unfortunately O'Reilly did not provide the code for download or I just did not find it. So I extracted the code samples and expected output from the eBook based on their markup. My script parsed the eBook and saved the Java examples into packages derived from the chapter names and classes derived from the section names. It added a main method and appended the expected output as a comment after the code. For example the extracted code for recipe 1.11 about finding items in an array looked like that
package com.discursive.jccook.supplements;

import org.apache.commons.lang.ArrayUtils;

public class FindingItemsInArray {

   public static void main(String[] args) {
      String[] stringArray = { "Red", "Orange", "Blue", "Brown", "Red" };

      boolean containsBlue = ArrayUtils.contains(stringArray, "Blue");
      int indexOfRed = ArrayUtils.indexOf(stringArray, "Red");
      int lastIndexOfRed = ArrayUtils.lastIndexOf(stringArray, "Red");

      System.out.println("Array contains 'Blue'? " + containsBlue);
      System.out.println("Index of 'Red'? " + indexOfRed);
      System.out.println("Last Index of 'Red'? " + lastIndexOfRed);
   }

   // Array contains 'Blue'? true
   // Index of 'Red'? 0
   // Last Index of 'Red'? 4

}
And then I went overboard with this little project. For a week I worked to have all examples compile and run. This was hard work because the examples contained many syntax errors like missing semicolons or typos in variable names. These mistakes were no problem for human readers, but the compiler complained a lot. For some examples I had to second guess the code not shown, e.g. used Java beans or factory methods which had been omitted for brevity. In hindsight it was a stupid idea, but after successfully cleaning up more than half of the examples, I just had to finish the work. Remember, I am a completionist ;-)

In the end I won and now all the examples are mine! I would like to share them with you, but O'Reilly does not allow that. The examples are distributed under some special "fair use" license that prohibits "reproducing a significant portion of the code".

26 April 2012

JUnit Tutorials

I prepared a short list of tips and links for some colleagues to get started with JUnit.
  • A good start for an absolute beginner is the JUnit Cookbook.
  • JUnit is integrated in Eclipse. Lars Vogel's JUnit Tutorial shows how to write and execute tests using Eclipse. Talking about Eclipse, I always use the keyboard short-cut ALT-SHIFT-X and then key T to launch the test open in the editor window. After that I use the keyboard short-cut CTRL-F11, which runs the last launched test or application, to re-run my JUnit test until it succeeds.
  • JUnit comes pre-packaged with Hamcrest, a framework for writing matcher objects. These matchers improve the readability of tests and provide better failure messages. Consider writing a custom Matcher if you need to compare large objects with one another based on complex state.
  • A mistake that I see quite often is the handling of expected exceptions in tests. Szczepan Faber has written down five rules how to do that and to avoid any problems.
  • To explore more advanced topics of JUnit see my presentation on Practical Unit Testing (June 2009).
  • Also make sure that your tests are deterministic. Non-deterministic tests are a serious threat to the discipline of unit testing.

Ventanas Rotas. Broken WindowsAll these links focus on using the JUnit technology, but do not explain how to write good tests. If you have some spare time and would like to know more about JUnit and unit testing in general I recommend the book Pragmatic Unit Testing in Java with JUnit.

Behaviour - the "New" Way
By the rise of BDD the common understanding of unit tests has changed. Even if you do not do TDD or BDD these things apply to any unit test.
  • They are now called Micro tests to distinguish them from traditional unit tests. Tests with a larger scope, e.g. integration or end-to-end tests, are no unit tests even if they make use of JUnit.
  • Further the names of test methods should be full sentences focusing on behaviour. JUnit 4.x removes the need to prefix test methods with test, and usually the sentence of the expected behaviour starts with the word should.
  • The test methods should be created using the Arrange-Act-Assert or even better the Given-When-Then pattern.

Recommended Watching
Finally I highly recommend the recording of The Deep Synergy Between Testability and Good Design by Michael Feathers. It's an excellent talk examining relationship among test-pains, code smells and design principles. Go, watch it!

9 February 2012

Required Reading: Clean Code

Here is an email that I wrote to my team earlier this year. The team members are able to deliver new features on time but do not care for code quality (at least not as much as I do ;-). This is going to change.

Raising the bar. (1)

Clean Code AssetsDear team,
as mentioned in the kick-off, we need to get into the right attitude for the upcoming refactoring effort. Many items on our code clean-up list are ongoing changes, e.g.
  • use proper names for fields and methods
  • clean up magic numbers
  • split large classes
  • add JavaDoc to core classes
  • fix compiler warnings
  • remove duplicated code
  • remove dead code
  • add JUnit tests
All of these changes are in fact rules how to produce code that is easy to read and maintain. All these rules are part of a coding style sometimes called "clean code".

The Pragmatic Programmers once wrote that you should read at least four technical books a year to stay sharp and relevant in our fast paced industry. Remember that the half-life of our technical knowledge in only 18 months. (Heinz Kabutz) So as first technical book to read in 2012 I highly recommend Clean Code by Bob Martin. It's a great book and has raised a new wave of code-consciousness. Read one of its reviews if you do not believe me.

Sooner or later you will have to read it, so why not start now? Go ahead, buy it, read it! Or at least browse it and see what is inside. We cannot afford to have any more cryptic variable names or huge classes.

Regards,
Code Cop

Lowering the bar.

Of course I did not attach the PDF of the book. That would have been illegal but it might lower the bar to get my colleagues into reading it. I know that not many of the team will read it. I would consider my email successful if one of two read the table of contents or browse a chapter.

(1) "Raising the bar" is the subtitle of the Software Craftsmanship Manifesto.

15 January 2012

Literature for Java Developers

Jonny Andersson asked for a list of good books that one needs to read to learn how to create proper and useful Java code. He knew a few reasonable books, like the SCJP (Sun Certified Programmer) Study Guide, and I immediately came up with some recommendations. Still he encouraged me to share more literature tips in a discussion thread because as he said, there are so many books on Java development and software engineering available that it is impossible to know them all. We cannot afford to waste time on other books than the best ones and have to relay on recommendations. My last reading list is a bit outdated so I decided to repost my recommendations here.

Reading in the roundFirst I would like to differentiate the topic of Java into three phases: First learn how to program, second learn how to program in an object oriented way and only then learn whatever framework you like. Unfortunately I see that most junior developers have serious deficiencies in the first two areas, whereas frameworks are well known. I met developers who knew the Spring Framework pretty well, but had never heard of Test Driven Development and had no idea what the Java keywords volatile or transient are supposed to do.

For the first phase I refer to the most influential book every programmer should read. There you see that the most important book (as seen by the StackOverflow community) is Code Complete. The second important book is The Pragmatic Programmer. I think it's even more important than Code Complete. This book is the base of all development work. I'm sure you will like it. It has around 350 pages and for an experienced developer only a few chapters will be new. But on the other hand, I still meet people that do not use version control or build automation. That's one reason that everybody has to read it. Now go, read it! Even if you are an expert, just go and read it! ;-)

The SCJP Study Guide is a good start for Java. There is no way around knowing operator precedence and other low level details of the language. Another book on Java basics like TIJ (Thinking in Java) is necessary to deepen the knowledge after the SCJP guide, which is just focusing on the very basics. Then I highly recommend Java Generics and Collections to comprehend Java Generics. Of course no list of Java books is complete without Effective Java which is also very important. To round up the basic Java knowledge I recommend the Java Language Specification. It's a specification but it's not that bad to read.

After the basics I would definitely add Kent's Beck Test Driven Development by Example, which is a short and excellent introduction to JUnit and TDD. And of course you must read Design Patterns, Refactoring, Clean Code - argh, more and more books get piling up. Think about it, you will not become a professional (Java) developer by reading three books, you probably need more than that, maybe 30 ;-) So if you feel like more books, just check out my Goodreads reading list. All books I've read are rated and tagged accordingly. I encourage to have a look. I'm looking forward to see your recommendations.

19 October 2011

Awesome Book Marks

Since the beginning of code-cop.org I have put strong emphasis on my personal branding. Till now I have created various t-shirts, business cards and buttons. I use these buttons to award conference speakers who delivered good presentations and to thank contributors who helped during Hackergarten. But now my mother-in-law excelled all of them. See my new hand embroidered book marks:

Awesome code-cop.org Book Marks
These are some awesome masterpieces! Thank you Lidia.

23 March 2009

Resources to Start Scala

The Scala Programming Language has been around some time and started getting popular in 2007. A good place to start are the tutorials included in the distribution, which are also available online: A Scala Tutorial (very short 15 pages), Scala By Example (already 145 pages) and The Scala Language Specification (full 180 pages).

Early multimedia resources that picked my interest were Martin Odersky's talk, The Scala Experience at JavaOne 2007 and the 62th episode from Software Engineering Radio. Further Martin Odersky gave another talk at JavaOne 2008 and JAX'08.

In January 2008 Ted Neward began his busy Java developer's guide to Scala, which started with stuff from the Scala Tutorial but went into greater detail later. Another blogger that is definitely worth mentioning is Daniel Spiewak, who wrote the nice Scala for Java Refugees as well as on some special topics like Integrating Scala into JRuby. Another piece worth recommending is Dean Wampler's blog titled the The Seductions of Scala. James Iry has to be mentioned for exploring more theoretical stuff in nice little chunks.

After spending some time with Scala, I went for the only book available, Programming in Scala, a comprehensive step-by-step guide with massive 754 pages. Unfortunately it did not ship for almost 9 (!) months and I do not like ebooks. (I know - I should have read the whole page when ordering; that it was not printed, not even finished back then.) However, now it's printed. Since January it's standing on my book shelf and torturing my conscience.

I have to pull myself together and finally start reading it!

11 December 2008

New in Java 6

Java 6 New Features coverIt has been two years since Java 6 was released, so it's really high time to get to know it better.

Book about new features
Earlier this year I read Java 6 New Features by Budi Kurniawan to get an idea of the new features. I liked the book a lot because it is really unique. All the other books you find for Java 6 are general Java books that more or less cover the new features of Mustang. I do not want to read about the methods of java.lang.Object or the Collections Framework again. Budi Kurniawan does an excellent job focusing only on the new stuff. If you want to know what is new in release 6, go for this book!

List of all new classes in Mustang
Then I updated my list of all classes included in the runtime of Java, similar to what I did two years ago. I used Sun's Java 1.6.0_11 and created the updated list of all runtime environment classes in Java 1.6. Let's see what I found: Java 6 added only 74 new types in the java. name-space,
java.awt.Desktop
java.awt.font.LayoutPath
java.awt.geom.Path2D
java.awt.GridBagLayoutInfo
java.awt.LinearGradientPaint
java.awt.MultipleGradientPaint
java.awt.RadialGradientPaint
java.awt.SplashScreen
java.awt.SystemTray
java.awt.TrayIcon
java.beans.ConstructorProperties
java.io.Console
java.io.IOError
java.lang.management.LockInfo
java.lang.management.MonitorInfo
java.net.CookieManager
java.net.CookiePolicy
java.net.CookieStore
java.net.HttpCookie
java.net.IDN
java.net.InterfaceAddress
java.security.PolicySpi
java.security.URIParameter
java.sql.ClientInfoStatus
java.sql.NClob
java.sql.RowId
java.sql.RowIdLifetime
java.sql.SQLClientInfoException
java.sql.SQLDataException
java.sql.SQLFeatureNotSupportedException
java.sql.SQLIntegrityConstraintViolationException
java.sql.SQLInvalidAuthorizationSpecException
java.sql.SQLNonTransientConnectionException
java.sql.SQLNonTransientException
java.sql.SQLRecoverableException
java.sql.SQLSyntaxErrorException
java.sql.SQLTimeoutException
java.sql.SQLTransactionRollbackException
java.sql.SQLTransientConnectionException
java.sql.SQLTransientException
java.sql.SQLXML
java.sql.Wrapper
java.text.Normalizer
java.text.spi.BreakIteratorProvider
java.text.spi.CollatorProvider
java.text.spi.DateFormatProvider
java.text.spi.DateFormatSymbolsProvider
java.text.spi.DecimalFormatSymbolsProvider
java.text.spi.NumberFormatProvider
java.util.ArrayDeque
java.util.concurrent.BlockingDeque
java.util.concurrent.ConcurrentNavigableMap
java.util.concurrent.ConcurrentSkipListMap
java.util.concurrent.ConcurrentSkipListSet
java.util.concurrent.LinkedBlockingDeque
java.util.concurrent.locks.AbstractOwnableSynchronizer
java.util.concurrent.locks.AbstractQueuedLongSynchronizer
java.util.concurrent.RunnableFuture
java.util.concurrent.RunnableScheduledFuture
java.util.Deque
java.util.NavigableMap
java.util.NavigableSet
java.util.ServiceConfigurationError
java.util.ServiceLoader
java.util.spi.CurrencyNameProvider
java.util.spi.LocaleNameProvider
java.util.spi.LocaleServiceProvider
java.util.spi.TimeZoneNameProvider
java.util.zip.DeflaterInputStream
java.util.zip.InflaterOutputStream
java.util.zip.ZipError
and around 400 in javax. packages,
javax.activation
javax.annotation
javax.jws
javax.lang.model
javax.script
javax.smartcardio
javax.tools
javax.xml.bind
javax.xml.crypto
javax.xml.soap
javax.xml.stream
javax.xml.transform.stax
javax.xml.ws
mainly the Java Activation Framework, some extended annotations and the model of the Java language. Further there are the new Scripting (JSR 223) and Compiler (JSR 199) APIs. More than half of the new classes are XML related, including XML Binding/JAXB 2.0 (JSR 222), XML signatures (JSR 105), Streaming API 4 XML/StaX (JSR 175) and XML based Web Services/JAX-WS 2.0 (JSR 224).

The need for a better tool
Till now I used some ugly shell scripts to extract the needed information about the classes in rt.jar. With the growth of the JRE the repeated call of javap -public %class% for each class took more and more time. I needed something else to determine the accessibility of each class. I remembered that there was a field that determined various attributes of a class. I wanted to load the class file's bytes, jump to the offset of this field and read the package/public flag. The Java class file format is simple, but unfortunately not that simple. In order to read the access_flags, one needs to understand the whole constant pool because the access flag is stored afterwards and the constant pool is of variable length. So I started disassembling the class files. I do not know why, but I happened to write the new script in Ruby:
# Unpack HI-LO byte orders contained in the String.
class String
  # Return the _index_ 'th and the next element as unsigned word.
  def u2(index)
    self[index..index+1].unpack('n')[0]
  end
end

class JavaClassHeader

  # Parse the binary _data_ from the class file.
  def initialize(data)

    # u4 magic;
    # u2 minor_version;
    # u2 major_version;

    # u2 constant_pool_count;
    # cp_info constant_pool[constant_pool_count-1];

    constant_pool_count = data.u2(8)
    pos = 10
    cnt = 1
    while cnt <= constant_pool_count - 1
      case data.u1(pos) # cp_info_tag
        when 7
          pos += 3
        when 9
          pos += 5
        when 10
          pos += 5
        when 11
          pos += 5
        when 8
          pos += 3
        when 3
          pos += 5
        when 4
          pos += 5
        when 5
          pos += 9
          cnt += 1
        when 6
          pos += 9
          cnt += 1
        when 12
          pos += 5
        when 1
          length = data.u2(pos+1)
          pos += 3 + length
        else
          raise "const ##{cnt} unknown tag #{data[pos]}"
      end
      cnt += 1
    end

    # u2 access_flags;
    @access_flags = data.u2(pos)
  end
After (sort of) parsing the class file, the check if a class is public or only package accessible was straight forward to implement.
  ACC_PUBLIC = 0x0001

  # Return +true+ if the class is public.
  def accessible?
   (@access_flags & ACC_PUBLIC) != 0
  end
This improved performance a lot and I am looking forward to the release of Java 7 to use my new ClassList script again.

(Download the list of all classes in Mustang.)

Update 14 Mar 2009

javaclass-rb Project Initiated

The ClassList script was fun and made me want to play more with class files. Based on the source code above, I created javaclass-rb, a parser and disassembler for Java class files, similar to the javap command. The initial version reads the class file version and the package/public flag of a class as well as the constant pool. Expect updates soon!

30 August 2006

Java Bookshelf

On this page you will find what I think are the most valuable resources for Java developers available. First a list of books every Java software developer should know (no excuses). It's amazing how old some of these are and still there are people around not knowing them. Next are my favourite newsletters (electronic journals), which I read regularly. Last I give you a (probably subjective) list of some of the best development tools available, which are all free.

Books
Books on the Java Language
Newsletters and Sites
Tools