Tuesday, September 16, 2008

GITting Around

I've been very busy for the last 3 months or so, but now can start to blog again.

A few things have changed. One of them is source control. GIT is working out really well. I highly recommend people drop SVN in favour of it. You can get an overview and tutorial from many places, so I won't bother repeating any of that. For folks developing in a windows environment, I can help a bit with some specific issues one might run into with the switch.

1. Upon installing MSysGIT, the AutoCRLF setting should be set to false before you do anything unless you are writing a multi-platform app. If you don't, you run into the danger of having your CRLFs changed to LFs in the repository. Then GIT will report file changes where there are none.

2. Stop all that typing (unless you want to strictly use the GUI via git gui):

git config --global alias.st status
git config --global alias.co checkout
git config --global alias.ci commit
git config --global alias.br branch
git config --global alias.me merge
git config --global alias.cl clean
git config --global alias.ps push
git config --global alias.pl pull
git config --global alias.rt reset
git config --global alias.rb rebase

If you want to configure bash on your machine, you could make aliases at that level - such as gci for "git commit".

3. Unless your SVN repo followed a strick trunk, branch, tag structure, don't bother with the standard layout option for cloning SVN with git svn. This leads to more headaches in the end. It's a long running process, so get it right the first time. Use --follow-parent to track moves, copies and renames.

4. Get hosting. Unfuddle is great as a free host environment. Don't get scared about the 200MB limit on the repository. GIT is very efficient and will take 1/30th the space that a SVN repo took. Unfuddle will email you when there are commits. It parses commit messages as well, so you can close an issue (tracked in unfuddle) with something like "closes #435". A commit with that message will close issue 435 in unfuddle. For $9/month you can get more users, 500MB limit and file attachments. The file attachment is a waste. I use www.drop.io to host files.

5. Setup your remote branches so you can simply "git ps" and "git pl" to send commits and receive commits from the remote repo. If you have a remote repo for the remote team over in India, you could set up something like this in the .git/config file for an "india" branch:

[remote "india"]
    url = git@mycompany.unfuddle.com:mycompany/outsourced.git
    fetch = +refs/heads/india:refs/remotes/india/master
    push = india:master
[branch "india"]
    remote = india
    merge = refs/heads/master

6. Read up on GIT. It's quite different from SVN.

Tuesday, August 19, 2008

Messaging Update

Seems more multithreading was the culprit.

with on thread one:
lock (dictionary) { dictionary.Add("bum", "a homeless person");}

and seven seconds later on another thread:
lock (dictionary) { if (dictionary.Contains("bum")) C.Out("defined"); }

... Contains returned false!

FTW??

... or was it IIS.

*** UPDATE Sept 16 ***

It was IIS. After adding tons of logging and tracking thread IDs, app domain IDs and process IDs, it was apparent that IIS would load up more than 1 either app domain or process for the app.

The long term solution was to house the app in a windows service that communicated over WCF. It was a quick refactor and opens the door for using WCF to push to clients. The new question is, does WCF hold threads? Or can you have 100,000 seldomly active clients for, say, a chat application?

Don't Give Up on Messaging

Today at work the dreaded words were uttered: "Well if it's not working by the end of the day lets just go for the pull every 1 second solution."

After implementing all of the long running processes to a pub/sub model, it was not pleasant to hear that. I wasn't going to just give up on that much energy poured into the current (and best) approach.

After adding tons of logging and hammering the server to see where the leaks sprung up, I cornered the culprit. If you are pulling from MSMQ ad nauseum, and you are in a multithreaded environment, you need to protect yourself from the thread unsafe methods "Send" and "Receive" on your MSMQ object - usually done by creating the MSMQ object for just long enough to do 1 operation.

The place where this was being done was not a multithreaded scenario, so I got rid of the creation and disposal of the MSMQ object between receives.

That did it.

The other lesson here is to be careful when you do have a multithreaded app pulling from MSMQ. You may see same messages go missing. I know there are other MSMQ features that guarantee delivery, etc, but I expect this integrity out-of-the-box.

Sunday, August 17, 2008

Alt.NET Canada

Too bad I had to miss this due to work. Here is Greg Young's Domain Driven Design presentation:

Tuesday, August 12, 2008

Project Management and Command/Query Separation

Just like we have issues mixing command and query when writing software, we run into similar issues when it comes to project management.

Say you have a project manager that is very technical. You would think that you could do no better. But alas, you will have bottlenecked his potential by requiring him to service the "queries" he has to provide for management (such as status reports, etc).

In the opposite corner, you can have a non-technical PM giving "commands" to the developers without the proper knowledge of the consequences of his actions.

Even in the well balanced scenario, you can overload a PM with a week or more worth of "queries"... or ask for too much direction.

So, can you scale your PM? If the role is clearly defined and we have a separation of command and query, yes you can.

Thoughts?

Monday, August 11, 2008

DDD and the Too Many Aggregate Roots Design Smell

This usually comes about from forcing a DDD solution where one would really needs a simple forms over data type app with ORM thrown in for speed.

Don't even bother with TDD for the most part.

Thoughts?

Monday, April 28, 2008

Spec# Needs a lot of Love form Microsoft

I was disappointed at how little $$ was being thrown at something as good as Spec# by Microsoft. Considering the millions that have been flushed down the toilet trying to make drag and drop do what it was not meant to do, it's a crying shame. Hopefully the tide is slowly turning and great endeavors like this will be supported properly by Microsoft in the future.

As a token, I'm adding a little I <3 Spec# on my blog.

Do check out spec#!