Publications

Tony Morris © 2007


HTML PDF MS Word Postscript XHTML

Why extends is not evil §

The Java extends keyword is not evil. It has never been evil; it will never be evil. What is evil is concrete behaviour inheritance, which is also known as 'implementation inheritance' or just 'concrete inheritance'. Holub sets out to prove this, but inadvertantly implies a correlation between the Java extends keyword and implementation inheritance. The fact is, this correlation does not exist. This assertion would be a mere issue of semantics and would probably not warrant this article, if it weren't for a nasty, underlying issue. more...

HTML PDF MS Word Postscript XHTML

MD5 and Speed Cameras §

There has been some recent controversy regarding speed camera photos and the use of the term MD5 seems to have been taken well out of context as a result. MD5 is what is known as a hash algorithm or one way function. It is sometimes erroneously referred to as an encryption algorithm or cipher - this is simply false. Some other absurd claims are that "MD5 is susceptible to viruses" or that "MD5 ensures cryptographic security". These statements are to be ignored as nothing more than typical media hype.

Speed camera photographs are typically associated with an MD5 hash in a flawed attempt to verify integrity of the photograph. That is to say, in transit from the camera to your letter box, integrity of the document can be (but isn't) guaranteed, since any modifications of the document would mean that a different MD5 hash is generated upon verification. First and foremost, MD5 is a weak hash algorithm, and does not even ensure document integrity in a practical sense, since it can be demonstrated to be broken. Second, any hash algorithm is mathematically proven to be breakable, which may be considered insufficient by a court.

Finally, and perhaps most amusingly, the photograph and associated hash are not digitally signed. I'm sure that anyone who has any knowledge of electronic security would find this oversight somewhat astonishing, but it must be highlighted that we are dealing with the traffic authorities in the land down under, where surprises are really just expectations. Digital signing is a way of ensuring that the entire document and hash were not modified during transit assuming that the cryptographic key is kept safe. more...


HTML PDF MS Word Postscript XHTML

How to resolve a java.lang.NullPointerException §

Every person who is learning how to use the Java 2 Programming Language will encounter a java.lang.NullPointerException during the execution of their application at some point. While this error message may appear to be cryptic to the learner, it does have a very concise meaning and there is also a systematic approach towards resolving this problem. There are also perceived solutions that aren't actually solutions. That is, a learner might have written some fix that is problematic and actually hides the original problem, not fixes it. more...

HTML PDF MS Word Postscript XHTML

Turning on the Ball and Appealing for Let §

Rules of World Singles Squash 2001. Paraphrase of Rule 9 Ball Hitting the Opponent and a Player Turning. If the striker turns on the ball, and appeals for let, the striker will be awarded a let, unless: more...

JTiger Unit Testing Framework for J2SE 1.5 §

JTiger Unit Testing Framework for Java 2 Standard Edition 1.5 is an Open Source solution that provides a robust and feature-rich abstraction to develop and execute unit test cases. Test case metadata and unit test documentation is expressed through annotations. Assertions, from the basic to the complex, can be made using the JTiger assertions package rather than having to write the logic for those assertions yourself.

JTiger includes rich assertion abilities, ranging from 'assert true' to 'assert adherence to the Object equals method contract on this type', an Apache Ant task, and reporting capabilities in HTML, XML or plain text format. For an example JTiger HTML report, see the Self Test Report. JTiger provides reassurance of being a robust unit test framework by providing its own self test fixtures that assert 100% class and 100% method coverage over the JTiger source code. more...


Assertion Extensions for JUnit on IBM alphaWorks §

Assertion Extensions for JUnit (JUnitX) is a set of assertion extensions that attempts to cover the most common test scenarios in JavaTM software development. This includes method contracts up to and including J2SE 1.5.0 and various other common features. JUnitX asserts that a success or failure assertion result is correct by including its own self-test suite with greater than 90% code coverage. The JUnitX package includes source code, unit test source code, an HTML code style report (100% adherence), an HTML unit test report (100% success), an HTML unit test coverage report (greater than 90% coverage), Javadoc documentation (100% exposed API), an HTML FAQ document, and an HTML README document. more...

Assertion Extensions for JUnit on IBM developerWorks §

Assertion Extensions for JUnit (JUnitX), an extensions package for the JUnit framework, is available for download from alphaWorks (see Resources). It provides the required implementation of many common complex assertions. Rather than write a complex JUnit test case for an assertion, you can call a JUnitX method to make that assertion from the same context -- with no additional setup. JUnitX also asserts that it functions as documented by including its own JUnit self-test suite. This reassures you that JUnitX is making its assertion according to the JUnitX documentation; if a unit test fails, you know it's the software code unit that has failed, not the JUnitX test implementation asserting a false failure.

A typical scenario in which JUnitX would be beneficial involves the contracts set out by the java.lang.Object class' equals(Object) and hashCode() methods. You're often required to adhere to these contracts in the classes you develop. Using JUnit to make the assertion that you've adhered to them would require you to develop complex unit-test cases, which are prone to error. In contrast, making the assertions using JUnitX is as simple as creating a factory implementation that returns instances of your class and calling the JUnitX assertEqualsContract and assertHashCodeContract methods from your unit-test case. more...


Java Frequently Asked Questions §

Frequently Asked Questions about the Java Language Specification and associated Java 2 API Specification and Java Virtual Machine Specification. An archive of regular questions that has been constructed over several years, which is stored in a relational database. more...

Java Trivia §

Trivia Questions about the Java Language Specification and associated Java 2 API Specification and Java Virtual Machine Specification. An archive of questions that boggle most Java developers, which is stored in a relational database. more...

Type-safe Scala Sequence Comprehensions §

On page 85 of Scala By Example, the last paragraph states the following in reference to generalising sequence (aka for) comprehensions... This type system feature being described is called higher-ranked kinds. Sadly, none of the mainstream, statically-typed languages offer this feature, which leads to enormous amounts of repetition... But in Scala you can! In other words, the paragraph quoted above is, at least from how I interpret it, false. more...

A Fling with Lazy Evaluation §

Lazy evaluation is a core topic in computer programming that is also widely misunderstood and often, erroneously trivialised. Here, I will attempt to demonstrate some of the attributes of many common mainstream programming languages; namely strict programming languages. I will also attempt to distinguish intrinsically strict languages from optionally lazy languages by focusing on what intrinsically strict means. As a note, strict evaluation (or strictness) is what lazy evaluation (or laziness) is not. more...

Idempotence versus Referential Transparency §

There is a lot of misunderstanding about the difference between idempotence and referential transparency. My plan here, is to explain the key differences without going into any specific detail about either concept. I plan to write something about referential transparency in the future and when I do, I will refer here to dispel any myths regarding idempotence. more...

The Power of Type-classes with Scala implicit defs §

A core part of Haskell's type system is that of type-classes. If you have never used type-classes, then there is a pretty good description in Yet Another Haskell Tutorial (YAHT). Haskell type-classes have been likened to Java/C# interfaces or Scala traits, but there are some significant differences.

With Scala's implicit definitions (defs), it is possible to come pretty close to emulating Haskell's type-classes. This ability can make writing certain constructs very simple and also, extremely flexible.

more...

Refunctoring §

Ask your average Java (or C#) programmer to 'write a method that takes a list of integers, adds 10 to each element, converts the result to a String, prepends *** to it and returns the resulting list'. It's quite easy and you can certainly postulate what kind of start would be made on this. Here is how I suspect most Java programmers would solve this problem: more...

ScalaCheck (committer) §

ScalaCheck is a Scala implementation of the QuickCheck Haskell library. QuickCheck/ScalaCheck are libraries for Automated Specification-Based Testing. more...