Daniel Sundman

Daniel Sundman

Random Thoughts from an Agile Developer

Test Driving JavaScript – It’s Never Been Easier

If you’re a TDD addict you know that it’s not always easy to Test Drive your JavaScript. Which testing framework should you use? How do you set your CI pipeline up? Etc…

There are quite a few frameworks out there and it seems like writing a testing framework is what everybody wants to do. I am pretty sure we don’t need any more. We just need them to be easy to use. In this post I’ll show you how incredibly easy it is these days to start using Grunt, Jasmine and PhantomJS.

read more »

RequireJS – Providing Structure Where None Exists

As JavaScript is transitioning from the dark ages as a language of ridicule to a respected language of it’s own, it is obvious that some of the rough edges need polishing.

There is no rougher edge than the global namespace issue and the difficulty providing encapsulation. Even for a seemingly trivial JavaScript application, it is no longer OK to just whip up some JavaScript files and assume that you can maintain the code base as it grows. The application now lives in the browser and the amount of code you need to maintain requires modularization.

read more »

Backbone: Orderly JavaScript

Backbones aren’t the usual fare for tech blogs, but if you’ve been following frontend development, then you’ll have heard of Backbone.js. From their site: Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions,views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface. read more »

JavaScript Development – A Year Later

As some of you may remember, a year ago I took Q3 off to focus on building a JavaScript application. I learned a lot especially about Node.js.

Yassal and I have a pet project called FeedMe that we have worked on over the years. FeedMe implements a shopping list for us to use when doing our weekly shopping. It has had many shapes over the years; it started out as a plain Java Web application; then it changed to a REST based Scala backend with a plain JavaScript front end to go back to having a Java backend again. Now there is no Java, no Scala…just JavaScript.

The application just seemed to fall into place with Node. If you want a reasonably simple modern web application, Node is perfect. By “modern” I mean a very responsive web application typically with a JavaScript fat client. As it turns out, FeedMe now has a Node backend and a Backbone based JavaScript fat client. If anything, more work went into FeedMe this summer than last, even though there was no sabbatical this time. During the Crisp Hack Summit last weekend, Yassal and I dug deep and we’re getting close to having an actual application.

Although one man’s buzz is the next man’s old news, I think we won the buzzword bingo at the Summit. FeedMe uses the following technologies.

Yassal and I will be blogging about FeedMe and the technologies involved over the next couple of months.

The source (incomplete as it may be) can be found at: https://github.com/crispab/feedme

The Compelling Case for Node.js

The basic premise of Node.js is that I/O is expensive and that, since I/O is expensive, we can’t block waiting for it to complete.

Many traditional Web Servers typically adopt a one thread per request approach, and any I/O (database, web service, file system call…) during the request blocks that thread of execution. This is inefficient in many ways because when the thread is blocked waiting for I/O to complete, it can’t respond to other requests.

read more »

The Missing Annotation

Have you ever wondered why Spring MVC supports @RequestParam but not @RequestAttribute? There are probably plenty of philosophical reasons for this – good or bad. But if your hands are tied and you’re stuck with, let’s say a CMS, that insists on passing context as request attributes what are you going to do?

As usual, Google provides some answers. It turns out I am not the only one who’s been asking for this feature and as of Spring 3 it is available albeit in a slightly different form. Instead of @RequestAttribute you would use @Value and SpEL.

@Controller
public class YourController {

	@RequestMapping("/xyz")
	public ModelAndView handle(
		@Value("#{request.getAttribute('key')}") SomeClass obj) {

		...
		return new ModelAndView(...);
	}

}

IntelliJ and nodeunit

It turns out that I’ve gotten completely side tracked…or maybe not side tracked per se, but at least not completely focused on the client side of the Application. The past couple of weeks I’ve been engulfed in Node. Trying to figure out what it is, what I can do with it and obviously how I can test drive it. I found nodeunit which seemed to be a good testing framework candidate.

read more »

TDD, JsTestDriver and YUI

As I mentioned in my previous entry, the goal of my sabbatical is to build a JavaScript Application. Notice the emphasis is on Application. That is, I don’t intend to build a JavaEE web application with plenty of JavaScript. The goal is to build an Application in the browser. It will probably (eventually), communicate with a server side component for persistent storage and synchronization but for now, that’s secondary.
read more »

A Sabbatical

It has finally started. My sabbatical. In April I decided that I needed some time to step back and try some things my own way. I told my current client that in Q3, I would not be available. A lot of Q3 has passed but, as of this Monday, summer in Sweden is over and our two daughters are back at school and daycare which means I can actually start. :-)

read more »