The Holy Java

Building the right thing, building it right, fast

Archive for May, 2013

Most interesting links of May ’13

Posted by Jakub Holý on May 31, 2013

Recommended Readings


  • Discussion: World’s Biggest ‘Agile’ Software Project Close To Failure – what is/isn’t agile, agile vs. waterfall etc; a nice collection of all the possible opinions and misunderstandings. Some of my favorites: waste: ‘[..]An “agile” project cannot fail and cost Billions because it must always deliver runnable software with a maximum of a few weeks delay[..]’ (runnable = delivering value), separation: ‘[..] my experience has been that separating the designer/architect role from the developer role is fraught with pitfalls. The people writing the code should be the ones designing it, [..]‘, stability: ‘[..] On the successful projects that I’ve worked with in Agile, there’s strong stakeholders, good architecture keeping the vision in place and project management that keeps things well orchestrated. Without those in the mix, it’ll fail just like all software projects. [..]‘, waterfall success, people issue: ‘The problem here isn’t waterfall/agile. The problem here isn’t .Net/Linux. The problem here is the parties involved. [politicians and IT dinosaurs]‘ (learn what’s needed from drunk, bitching employees; ignore official nonsense requirements),: simplicity[..] It would probably be a lot easier if they started by making a simpler tool – instead of trying to calculate everybody’s entitlements everywhere [..]‘, agile suitability: ‘[..] You cannot use Agile to build a 100-mile canal, as the whole thing would be useless even if you completed 99 miles. [..]‘.
    Some people seem to believe that agile means no architecture and no/too little planning. Some believe that agile = hack now, fix later.

Startups etc.

Clojure Corner

  • B. Batsov’s Clojure Style Guide (based on JoC etc.) at GitHub
  • Code quaterly interview with R. Hickey (2011) – motivation behind Clojure (simplicity,..), reusability in C. (vs. Java); many valuable things
  • Clojure in the Enterprise? – about the differences between the Clojure and the enterprise java  (with heavy frameworks such as JPA, JSF, mutable state) ways and difficulties of introducing Clojure due to old-fashioned thinking, limited skills, etc. “Take away objects, mutable state, variables, loops… a lot of Java developers are immediately all at sea and have no idea how to solve even basic problems. They’ll try to bend Clojure to their OOP way of thinking and they’ll most likely fail.
    World Singles’ experience with Clojure: “We love Clojure. It’s made development a lot more fun. We’re able to solve harder problems, make changes faster, leverage multi-core concurrency more effectively, and we have a much smaller code base to maintain.
  • Replace Temp with Query in Clojure – in this post we can follow an interesting refactoring from a deeply nested if & let code to a much flatter one (featuring cond to test multiple conditions (instead of guard conditions used in imperative languages) delay to be ably to bind an expression to a local variable without evaluating it yet)
  • The Why and How of Clojure on Android (4/2013) – about the experience of using Clojure on Android, which is little slow and crazy but fun. From the author of the Nightweb app. Key components:  neko Clojure wrappers for Android and for lein-droid building w/o an IDE. Nicer than Java! (This GSoC proposal shows the limitations/future of neko.)
  • Reconstructing Clojure Macros With Speclj – a good idea to learn macros by trying to create one’s own implementation of existing Clojure macros, driven by tests that define the expected behavior of the macro (using macroexpand, macroexpand-1, macroexpand-all)
  • Advanced inspector middleware for Clojure nREPL and Emacs (nrepl-inspector on GitHub) – C-c C-i or nrepl-inspect to inspect interactively the value of a var (beware: (require ‘nrepl-inspect) fails, however calling nrepl-inspect as a function is ok). Related: Clojure Debugging ’13: Emacs, nREPL, and Ritz (May 17th) – what works, what is missing, how to set up
  • Pithering About » REPL bootstrap pimpage – neat tricks with a custom bootstrap REPL namespace – print last few commits and git branch, pre-loading common libs


Favorite Quotes

C, C#, and Java:
Applying some of the best ideas of the 1970s to the problems of today.

– Stuart Halloway in Clojure in the Field, 2013 (slide 6)

Posted in General, SW development, Tools, Top links of month | Tagged: , , , , , , | 2 Comments »

Tip: Include Context And Propose Solutions In Your Error Messages

Posted by Jakub Holý on May 23, 2013

A Puppet run has failed with an error message like this:

“No matching selector for ‘prod’ at some_puppet_file.pp:31”

If you know puppet well enough, you will immediatelly know what is wrong and how to fix it. But what if you don’t know what a ‘selector’ is? Interpreting error messages is often hard without deep knowledge of the software. Be nice to the users / fellow programmers, do not expect they know everything, and include helpful context and preferably also suggest some possible solutions. If the message read instead:

“No matching selector for ‘prod’ at some_puppet_file.pp:31; the available selectors are ‘production’, ‘test’, ‘staging’; have you forgotten to add ‘prod’ or default?”

wouldn’t it be much more clear and helpful?

Posted in General | Tagged: , | Comments Off on Tip: Include Context And Propose Solutions In Your Error Messages

Accessing An Artifact’s Maven And SCM Versions At Runtime

Posted by Jakub Holý on May 22, 2013

You can easily tell Maven to include the version of the artifact and its Git/SVN/… revision in the JAR manifest file and then access that information at runtime via getClass().getPackage.getImplementationVersion().

(All credit goes to Markus Krüger and other colleagues.)

Read the rest of this entry »

Posted in Tools | Tagged: | Comments Off on Accessing An Artifact’s Maven And SCM Versions At Runtime

Lesson Learned: Don’t Use Low-Level Lib To Test High-Level Code

Posted by Jakub Holý on May 21, 2013

Summary: Using a fake http library to test logic two levels above HTTP is unnecessarily complex and hard to understand. Fake instead the layer directly below the logic you want to test and verify the low-level HTTP interaction separately. In general: Create thin horizontal slices for unit testing, checking each slice separately with nicely focused and clear unit tests. Then create a coarse-grained vertical (integration-like) test to test across the slices.

The case: I want to test that the method login sends the right parameters and transforms the result as expected. Login invokes post-raw which calls an HTTP method. Originally I have tried to test it by using the library clj-http-fake but it proved to be unnecessarily complex. It would be much better to fake post-raw itself for testing login and test the original post-raw and its HTTP interaction separately, using that library.

Read the rest of this entry »

Posted in Testing | Tagged: , , | Comments Off on Lesson Learned: Don’t Use Low-Level Lib To Test High-Level Code

Becoming A Better Programmer Through The Study of Good And Bad Code & Design

Posted by Jakub Holý on May 19, 2013

Reading books about good design and good coding practices such as Clean Code is very helpful but it isn’t enough to become a good programmer. We need to see both good and bad code in practice, perhaps many times, to start to really understand and appreciate the principles and qualities of clean/good code. (And, of course, we must write code.) However our chances of encountering a noteworthy good or bad piece of code and realizing its qualities (or lack thereof) are limited and highly dependant on the project and people we work with. In an attempt to increase the chances and help other – especially junior – developers to encounter and evaluate more interesting pieces of code, I have started a new blog, Wonders of Code. When I encounter a code snippet lacking in some qualities, I re-implement it in a better way and publish both together with an analysis of their pros and cons and relating those to the  principles of readability, maintainability, and clean code in general.

This is an experiment and I hope to hear from the community if this is something that can really help people or not. I would also love to get contributions from other developers, to cover a broader range of opinions and examples. Comments and contributions are welcomed and appreciated!

Read the rest of this entry »

Posted in General | Tagged: | Comments Off on Becoming A Better Programmer Through The Study of Good And Bad Code & Design