Monday, March 19, 2012

Who broke the build massacre

Recently it's becoming more and more popular to create gadgets that "attack" or "shame" the one that broke the build on Jenkins. Some of them are really creative and funny!

This doesn't change the fact that it is outrageous and completely unprofessional that such "tools" are even needed. All that under the assumption that the person that did break the build (or even made it unstable) couldn't care less about it.

So my advice to you: do care about the stability of your work! Or else don't do software development - it's out of your league! You don't fit in!

Saturday, March 17, 2012

REST Service - the two words that make no sense

It's been bothering me for like ages and I finally decided to put a blog post about it. Let's start with a couple of definitions:

WebService - a way of servicing someone (like "giveMeSomething" sort of way) over the web

REST - Representational state transfer. We're transferring a representation of the state (of someone) - not servicing anybody.

To see why is this so damn important first let's see what classic SOAP web services look like in practice. They consist of 3 things:

1. WSDL / XSD (description)
2. Endpoint (URL)
3. XML (data)

In fact there's one most important thing to note: the "endpoint" is/has usually a verb: "go get some flowers", "fetch history", "make me pretty" - you get the idea, right?

Now on the other hand REST has nothing to do with verbs - REST deals with nouns: people, cars, addresses, gasoline, money... So how do you make a person give money for gasoline for their car to allow them to get to a certain address they are heading?

WebService: MySuperDuperWebService.makeHimPay(Double money)
REST      : GET /person/54623445/account/1/balance (get the current balance)
            PUT /person/54623445/account/1/balance + current balance

The difference here is you're not giving a REST place orders other than update, delete, retrieve.

So the next time you'll be tempted to say REST service please bear in mind there's no such thing. What is however named as a "REST service" is a URL, that responds (usually) to POST (cuz that's so damn easier to pass data to) that has no predefined schema (usually..) and that instead of giving you back XML hands you over JSON (possibly using JSONP). That my friends is a definition of a JSON Service and has nothing, absolutely nothing to do with REST whatsoever. Even worse is the term RESTful web service. My God is that a horrible thing to say. It seems like the service being referred to rusts in peace and should never ever be called.

Make the world better for a change!

Monday, March 12, 2012

ExtJS inheritance strategy

I've been struggling for quite some time to come up with a strategy for writing ExtJS code so that no matter what kind of class I'm extending everything looks the same. Today I've finally ended up with what I wanted :). In this case I'm working with Ext 2.0.2 but it should apply without any changes to all versions of this wonderful library.

Challenges


I've set a goal to be as follows:
  1. Instances will have proper class names and not some generated names
  2. Declarations will present themselves in the code exactly the same way regardless of the base type
  3. The code will look understandable

The template

First we need a namespace so that the global one doesn't get polluted:

Then we need to define the constructor (this will give the actual name for the class later on:

And finally we'll implement some public methods:

This way the actual class is "Namespace.ClassName" and not some wierdo, public methods are cleanly separated and default configuration is in one place.

As a bonus this pattern works for every single class - no matter if it is a component (GridPanel, Window) or not (ie. Store)

I hope this will make someone's coding adventure a little bit less messy :)


Have a nice day!

Thursday, February 16, 2012

IBM download manager

This post is just to make a stand against corporations like IBM that think we're so stupid and ugly we can't download and run a simple exe from the net.

Well, guess what: we can! Stop the damn reinforcement to give you all the personal information you don't need! It's against everything - not just the European data privacy laws.

And above all: come on guys! Do you really feel it is necessary these days to force the user to use a Java-based download agent? Ain't it simpler to finally enable HTTP resume on your server? Or can't you do that?


What a damn shame that the big ones can't keep up...

Wednesday, February 15, 2012

Grails, documentation and images

A quick tip of the day:

if you're creating a Grails project and want to provide documentation for it it might stand a chance you'll need to include images in that documentation. Unfortunately the official documentation is very sparse in this regard showing you only the syntax for including external images. As it turns out it is possible to have images that come specifically with the docs. All you need is to specify
grails.doc.images = new File("src/docs/images")
and then include them in the docs as usual but without a URL
!my-image.png!
Thanks to Lauro Becker for that hint!

Wednesday, February 8, 2012

Grails, Bootstrap and a pile of crap

Today we're going to pick on a good idea gone bad. The good idea being the ability to kickstart a Grails application with Bootstrap from Twitter. What's gone wrong is the actual implementation. But let's start from the beginning.

Create a new application

grails create-app example
You've seen this over and over again, right? Nothing new here. Let's install the kickstart-with-bootstrap plugin. For that in Grails 2 we'll modify the grails-app/conf/BuildConfig.groovy's plugins file like this:
plugins {
    runtime ":hibernate:$grailsVersion"
    runtime ":jquery:1.7.1"
    runtime ":resources:1.1.5"

    build ":tomcat:$grailsVersion"

    compile ":kickstart-with-bootstrap:0.5"
}
Easy enough. Let's compile the application first (grails compile) for the build system to fetch all the plugins and do its other bits. After that we'll execute grails kickstart-with-bootstrap (the one that just came about with the kickstart-with-bootstrap plugin), answer all questions positive and we're done. At this point you can create a domain class and a controller but that's not really the point of this blog. The point here is to pick on the way the master kickstart layout looks like.

The good part

Well... the appearance is really great! But let's face it: it's so because Bootstrap looks great. It has all the usual stuff, the top bar, nicely looking fonts, the layout is floating. That's all nice and dandy...

The ughly

Let's open the newly created grails-app/views/layouts/kickstart.gsp. Here are a few points I'd like to make:
<%--  <div class="container">--%>
What for the love of god was going through the author's mind to leave commented out code in official release? And believe me this is not a single place. There are actually 21 of those!

But that's as long as purity goes - let's try to find something scarier:
   <g:if test="${ params.controller != null
      && params.controller != ''
      && params.controller != 'home'
      && params.controller != 'login'
   }">
I mean what the heck is this?! We're in a reusable layout! Ok, you might think I'm bitching about one place in the layout... Well actually no. There is more:
class="${ params.action == "list" ? 'active' : '' }"
class="${ params.action == "create" ? 'active' : '' }"
So a list should be shown, right? Or maybe we're actually creating an entity... Hm,... What was going through the author's mind at this point???

Does it by any chance belong in a reusable layout?!

Summary

I personally think that such a plugin is a blessing for someone that starts a new project now and then. The original Bootstrap plugin just doesn't cut it. But for the love of God do it right! By providing such a half-done tool to others you're actually doing more harm than good.

I'd love to get in touch with the original author to straighten things out. I love the idea of having a plugin that supplies a set of scaffolding templates and a layout to get me started with a nice look and feel quickly. Never mind the fact that it doesn't use the resources plugin. I actually like it. But it needs to be done the proper way, the way it is reusable!

Thursday, February 2, 2012

Hosting Git like a professional - Gitorious!

I've been struggling over the past months to find a way to install Gitorious on my private network to have the same kind of power in hosting repositories as GitHub or BitBucket. For sure Gitorious is not as powerful as those guys but it is more than enough for in-house development.

And tada! Here it is: the automated process of installing Gitorious on a fresh Ubuntu or Debian machine.

Here are the main components being installed:

1. Ruby 1.8.7 - enterprise edition
2. MySQL 5.1
3. Stomp server
4. Apache HTTP server with Passenger module
5. Lots of supporting utilities
6. Last but not least: The Gitorious application.

The procedure to install using this script is as follows:

1. Make sure you do have sudo installed (on Debian you need to install it manually!!!)
2. wget the script from GitHub in raw form.
3. Edit configuration options found at the very top of the file
4. Launch bash (_NOT_ just sh!!!) with this script (bash install.sh)
5. Press enter when asked

One note: if the script seems to be hanging mid air (especially at the end of the installation where ruby interpreter is being invoked to add admin user and so on) press Enter. After pressing Enter the script will continue almost immediately.

Now this is a very basic installation of Gitorious. For example there's not Git over HTTP support available. But all the rest should be working just fine :)

Give it a shot! Give it a shot even if you don't need it :) Gitorious is an amazing piece of software and can help you out in Git administration like no other software will.