Mercurial Tutorial

A reasonable starting point for understanding the basic concepts behind a DVCS, and Mercurial in particular.

The only thing is you have to get past the sense of ‘humour’ of the author, but the content is good.

A Mercurial Tutorial

The project I’m working on has gone with named branches for branches, and therefore one repository, rather than what seems to be the generally accepted approach of copying the repository, and then pulling changes from the old one.

The end result is basically the same, but without the ‘baggage’ of named branches. Personally, I prefer being able to see a branch with a name, and knowing what it’s associated with.

The other decision we’ve taken is to generally use rebase, rather than pulling others changes, merging them together, and then pushing. The only real reason is it keeps the number of changesets down (no merges everytime I have changes and someone else has already pushed), and also keeps the branch in the graph straighter/cleaner.

Mercurial server on windows IIS

http://vampirebasic.blogspot.com/2009/06/running-mercurial-on-windows.html

http://stackoverflow.com/questions/818571/how-to-setup-mercurial-and-hgwebdir-on-iis

Good starting point. Comments mention in order to push, have to create windows user, and add them to push list.

The Most Beautiful Seatbelt Advocacy Commercial

I know it isn’t dev related, but couldn’t help but pass this on. So many PSA commercials are terrible. Either over the top crash videos, or a droll announcer, droning on.

This one, with no words, expresses so much emotion. It’s worth the watch regardless of the message.

http://www.autoblog.com/2010/02/05/video-the-most-beautiful-seatbelt-advocacy-commercial-ever/

And if you’re one of those people that don’t wear your seatbelt, here’s a great quote from the comments on this post

You wouldn’t get on a roller coaster without a seatbelt or harness right? Why would you get on the road with a bunch of touchscreen pushin’, cell phone tweetin’, navigation glancin’ oversized SUVs without a seatbelt? Seatbelts. Wear em’.

mnmlist

A Little Groovy Goodness

Ever since attending the SpringOne 2GX conference, I’ve been intrigued by Groovy. I’ve finally had a bit of time to start working with it, and decided to share some of the niceties of Groovy. This post is a very simple example of the differences in coding between Java and Groovy, so expect to see more as time, and my knowledge permits.

The first thing I really liked about Groovy was the removal of explicit setters and getters. I’ve always hated the clutter, and especially since it makes it harder to see if any getter/setter is doing something ‘special’, or if there are methods that aren’t setters/getters.

So, a simple bean defined like so in Java to support easier setting of variables

public class Bean {
    private long numberOfCompanies;
    private long numberOfUsersPerCompany;
    private long numberOfSecureMessages;

    public long getNumberOfCompanies() {
        return numberOfCompanies;
    }
    public Bean setNumberOfCompanies(long numberOfCompanies) {
        this.numberOfCompanies = numberOfCompanies;
        return this;
    }

	// code snipped here
}	

//used like this
    growthRequest
       .setNumberOfCompanies(1L)
       .setNumberOfUsersPerCompany(1L)
       .setNumberOfSecureMessages(2L);

becomes this in Groovy

public class bean {
    long numberOfCompanies
    long numberOfUsersPerCompany
    long numberOfSecureMessages
}

 // and gets used like this
growthRequest.identity {
   numberOfCompanies = 1L
   numberOfUsersPerCompany = 1L
   numberOfSecureMessages = 2L
}

// or like this, without defining a constructor...
	GrowthRequest gr = new GrowthRequest("numberOfCompanies:1L", "numberOfSecureMessages:2L", "numberOfUsersPerCompany:1L")

Groovy also supports the concept of a read-only property. It uses the final keyword, which is a little confusing to us Java devs, as the field isn’t final in the Java sense. A getter will be defined in the public interface of the Groovy object, but the object can still modify the value internally.

Another case that is very nice is long strings, or strings that are concatenated with variables. In Java, we have

String s = "some text that is long " +
	"and some more text that goes here" +
	someVar + " more text and more";

whereas Groovy would have

String s = """some text that is long
	and some more text that goes here
	${someVar} more text and more"""

If your string is just a regular string (i.e. no variable replacement), you can use apostrophes. If you use a single quotation mark, or triple quotation marks, then Groovy will parse the string to search for replacements. So, for performance reasons, unless you need a variable replacement, use apostrophes for strings.

The heredoc format allows for much easier test string generation. For example

String s = """
	<xml>
		<entities>
			<entity>1</entity>
			<entity id="idValue">2</entity>
		</entities>
	</xml>

Keep in mind that I’m intentionally typing variables. Groovy allows for no typing as well, so the previous example could merely def s.