Ad-Hockery

ad-hockery: /ad·hok'@r·ee/, n.
Gratuitous assumptions... which lead to the appearance of semi-intelligent behavior but are in fact entirely arbitrary. Jargon File

Static analysis and strictness

Let me be clear – static analysis tools like Checkstyle and Codenarc are useful tools. But…

I don’t think you should have overly strict enforcement. There is a small class of static analysis rules that are unambiguous – you’re not using that import, that if block doesn’t have braces – but there is a large class of rules that exist in a grey area. Is that method really unused or is it invoked reflectively somewhere? Yes, generally we should declare constants for magic numbers but is it really necessary for the prime seed of a hash code method?

Read more…

Decoupling from the DOM with Angular

One piece of advice you’ll run into pretty soon when working with Angular is that you should never touch the DOM outside of a directive. Especially when test-driving your components this is pretty wise. The great strength of Angular is the declarative way in which the view (HTML) works with the view model (Angular controllers). It’s almost absurd how easy it is to unit test Angular controllers. Controller functions tend to act on $scope properties, trigger or respond to events and all those things are straightforward to replicate in unit tests.

Read more…

Unit testing Angular directives that use controller and templateUrl

I spent an hour or so this morning figuring out how to unit test an Angular directive that uses a controller and a template loaded from a file (as opposed to inline). There’s a useful example in the ng-directive-testing repository but I thought a quick summary would be useful (as much to remind me the next time I have to do it as anything). Also the examples there test by interacting with DOM elements rather than directly with the directive’s scope.

Read more…



Semantic color names in LESS and Sass stylesheets

Most people using Sass or LESS will define variables for the palette of colors in their page. Something like:

$blackish: #231f20;
$purple: #561e31;
$pink: #da2770;
$off-white: #efefef;

.header {
    background-color: $blackish;
    color: $off-white;
}

a {
    color: $purple;
    &:hover, &:active {
        color: $pink;
    }
}

blockquote {
    background-color: $blackish;
    color: $purple;
}

This is good as far as it goes. Tweaking colors in the page is pretty easy as they only have to be changed in the variable definition.

That said, I think there are a couple of problems here.

Read more…


Using SASS and Compass with Gradle

I recently started helping with the Ratpack website. It is (or will be) a Ratpack app & built with Gradle. I started prototyping with a simple webapp created with Yeoman and using SASS and Compass for authoring CSS. When I migrated the work-in-progress into the ratpack-site application I initially used Ted Naleid’s method of calling Yeoman’s Grunt tasks from Gradle. Unfortunately this meant there were rather a lot of build dependencies. In order to build the app you would need Node.js, Ruby and the Compass gem installed. Peter Ledbrook pointed out this could frustrate potential contributors & Marcin Erdmann proved an example of what he meant. Clearly I needed to simplify.

Read more…


Web Statistics