RPN Calc Part 9 – State and Commands in Clojure

In my last post, I started porting the RPN calculator example from Java to Clojure, moving a functional program into a functional language. In this post, I finish the work and show how the Clojure calculator models both state and calculator commands.

Continue Reading…

Two Cheers for Manual Testing (Functional Test Automation, part 3)

If you’ve never played it before, a hand of manual testing misery poker plays out something like this:

“It took six of us eight weeks to plow through a three and a half foot stack of system test scripts”

“That’s nothing.  Our site acceptance testing alone took fifteen of us three months for a six-foot stack.”

“But were yours double sided?”

“Erm, no”

“Then what took you so long?”

“Screenshots every step”

“Oh.  I fold.”

We automate functional testing for a reason: the alternative is tedious, resource-intensive, and expensive.  So why do test suites still comprise so many manual tests? Continue Reading…

RPN Calc Part 8 – Moving to Clojure

So far in this series, I’ve taken a basic calculator written in Java and transformed it from a command-oriented procedural design into a more functional style. In some ways, this has made for simpler code:
calculator state is better encapsulated in value objects, and explicit control flow structures have been replaced with domain-specific higher order functions. Unfortunately, Java wasn’t designed to be a functional language, so the notation has become progressively more cumbersome and lengthy. 151 lines of idiomatic Java is now 327 lines of inner classes, custom iterators, and inverted control flow patterns. It should be difficult to get this kind of code through a serious Java code review.

Despite this difficulty, there is value in the functional design approach; What we need is a new notation. To show what I mean, this article switches gears and ports the latest version of the calculator from Java to Clojure. This reduces the size of the code from 327 lines down to a more reasonable-for-the-functionality 82. More importantly, the new notation opens up new opportunities for better expressiveness and further optimization. Building on the Clojure port, I’ll ultimately build out a version of the calculator that uses eval for legitimate purposes, and compiles calculator macros and can run them almost as fast as code written directly in Java.

Continue Reading…

Functional Test Automation, Part 2: The Subject, the Standard, and the Evidence

In my last post I wrote that the reality of automated functional testing has so far failed to live up to my expectations. In this post I’ll define what I mean by functional testing. What follows might not be the definition you’re familiar with, and I don’t mean to suggest that this is the only valid definition. It is certainly influenced by the industries I work with, where:

  • The subject of functional testing is a black box
  • The standard of functional testing is the set of functional requirements
  • The evidence of functional testing formally links test cases to those requirements they test

Continue Reading…

Functional Test Automation, Part 1: Room for Improvement

From my first encounter with HTMLUnit over ten years ago, I had high hopes for automated functional testing for web applications. Comprehensive test suites would run continuously and unattended, and notify us promptly of incipient problems. We would dazzle our customers and quality auditors with slick, comprehensive, and electronically signed hypertext reports. We would dispense with hundreds of person-hours of manual testing, and pass the cost savings on to our customers. We would retire waist-high piles of paper test scripts and reports to long term storage and, after the obligatory retention period, dance around the bonfire where they burned. Continue Reading…

Integrating Joda-Time and Freemarker

One nice aspect of the Freemarker template engine is the way that it intelligently displays typed model data. Dates, for example, are presented in a human-readable format which can be controlled in the view using Freemarker builtins. This works well, and is good for helping view concerns stay in the view code. However, one difficulty with this feature is that Freemarker doesn’t understand all domain types out of the box. joda-time DateTime objects are a good example, and this article shows how to teach Freemarker how to render that type of value.

Continue Reading…

Details in Java Code: Error Reporting and Loop Control Variables

Sometimes, it’s easy to focus so much on the architecture of a system that the details of its implementation get lost. While it’s true that inattention to architectural concerns can cause a system to fail, it’s also true that poor attention to the details can undermine even the best overall system design. This post covers a few minor details of code structure that I’ve found to be useful in my work:

Continue Reading…

Sencha Package Management Using Sonatype Nexus

In this post I will explain how to use Sonatype Nexus Repository Manager as your Sencha Package repository.

If you use Sencha Touch or ExtJS for development, Sencha has provided a tool called Sencha Cmd which “is a cross-platform command line tool that provides many automated tasks around the full life-cycle of your applications from generating a new project to deploying an application to production.” One of the new features is the ability to have “packages”. If you come from the Java world like I do a package is the equivalent to a JAR library file. A re-usable block of code that can be versioned and stored for others to use. Sencha Package Manager is designed to solve two basic problems: consumption and distribution.

Continue Reading…

Clojure: lazy-seq and the StackOverflowException

I’ll get back to rpncalc shortly, but before I do, I wanted to take a post to talk about a surprising problem I recently had with lazy sequences. As part of my day job, I am developing a Clojure based system for accumulating and displaying time series data on a web page. One of the core algorithms in my
implementation is a incremental merge sort. I have a function that takes two seq’s, both ordered by time, and produces a lazy result seq with all values from both inputs, also in time order. Every few seconds, as new input values are read from their sources, the program uses the ordered merge function to integrate the new values into a seq that contains a complete history of all values. It’s a straightforward and flexible design, and initially, it appeared to work quite well. The problems only started to arise after several hours of run time: traversing the history list would then immediately result in stack overflow exceptions.

Continue Reading…

Securing ExtJS Using Java

While trying to teach myself Sencha ExtJS MVC framework, I decided to use Java as the server side language for the REST services that would support the application.   I also thought it would be a good time to exercise what I have learned from working with other web frameworks and try and apply those same principles.  Much to my surprise, when looking around for articles on ‘Securing ExtJS’ I could not find exactly what I was looking for.

Continue Reading…

Page 2 of 5«12345»