Thursday, August 09, 2007

Blue October - August 4th

Me, My wife, and daughter went to go see Blue October play at the Sam Houston Race Park.  It was my 2nd time to see the band (the first being at a venue that only held 300 people).  There were a few thousand people there and it was really great to see how big the band has gotten.

Me and my baby at the Race Track before the concert
Me and my baby

My 2 favorite girls…
IMG_5490

Rocking out before the concert…
IMG_5509

Goofing around…
IMG_5512

No, I’m not stoned in this picture…
My JP Boodhoo Pose

We’re Hungry…
IMG_5554

Finally, they arrive…
IMG_5570

They played mostly songs from their new album, Foiled (which is my least favorite to be honest).  I much prefer The Answers or Consent to Treatment.

IMG_5603

 

Blue October always puts on such a great show.  The band is full of energy and Justin’s vocals seem to never end.  I don’t know how he does it… I was singing along all night and nearly lost my voice.  I guess I can let go of my hopes of being a rock god .  Well, there’s always Guitar Hero.

Wednesday, August 08, 2007

HTML 5 Sneak Peek

Check out the article over at IBM on New Elements in HTML 5.

Everyone who knows me knows that I loathe using tables for layout.  My biggest beef with it (there are many) are that it usually renders an unnecessary amount of markup for simple things.  Good CSS design reduces this drastically but there are occasions when you have a layout that ends up being as bloated as using tables.

If you need to style two sections of divs that have a similar or convoluted hierarchy, you usually have to resort to adding classes.  Classes add to the visual weight of the HTML, so I generally prefer not to use them if I can select the element using CSS.

New tags in HTML 5 will help with this even further.  These are all semantic structural tags that encourage proper design using HTML:

  • section
  • header
  • footer
  • nav
  • article

A <section> element will denote regions of the page that can easily be selected. Who knows, <section> might even replace <div>.

You’ll also notice a trend where tags have no visual representation at all.  They might be styled differently by CSS, but that’s not the point.  a <time> element could be used for programs to easily distinguish the time of a post, or the time that the page was last rendered, for example.

Check out the article, it is worth a read.  These changes are long overdue and will help raise the bar on web standards usage even further.  Let’s just hope IE plays nice this time (I think they will).

Professional Gender Transmogriphier

The other day, my cube-mate Peter Seale, posed the following question:

Do you ever wonder why the Experts Exchange website url has a dash in it?

Well, no I didn't before... but I now I am... why? (at this moment I pause for a second and think about what the url would be... )

expertsexchange dot com

That just might send the wrong message... whaddyathink?

e Goes Gold

My favorite text editor for HTML, CSS, JavaScript, Ruby/Rails, etc development just announced its 1.0 stable release.  The beta versions were very good and I rarely ran into issues.

If you aren’t using e, you should check it out:

e

If you’re like me and jealous of the Mac crowd who gets to use TextMate ( /drool ) then this is the best alternative for Windows.  (I hear there is a Linux version coming soon).

But if you’re not privy to what coolness awaits you, allow me to tantalize you with some e-excellence:

  • Keep looking up the exact doctype syntax?  Type doctype<TAB> and a context menu appears allowing you to select your doctype (XHTML 1.0 Transitional for example).   (And you should be using a doctype header).
  • Type head<TAB>, it creates the header section for you, places the cursor right where you put the title, press <TAB> again and you're ready to enter scripts and style sheets.
  • Want more? Try link, style, body, div, table, ul li ... the list goes on.

These are just the HTML bundles. There are a crap-ton of bundles that already exist for TextMate, and they are supported with e.

So head on over to http://www.e-texteditor.com and pick up a trial copy. If you like it, consider buying it. The time you save will surpass the measly $35 you spent in no time. time.

Tags:
Monday, August 06, 2007

Dear VSTS Test: I Hate You

I cannot even count the ways that VSTS Test is inferior to NUnit (or MbUnit).

I’ve been running my tests via TestDriven.NET (right-click, Run Test) and it has been working just fine.  The tests run, I get my results.  The reason I do this is because the built-in test runner sucks leaves something to be desired.

I went to a teammates machine the other day and he ran the test suite and most of the tests failed.  In fact, any test that hit the database failed.  All of them had the same error message: 

ConfigurationException:  Could not load the configSource ‘local-connectionStrings.config’.

This file is copied (via pre-build event) from a root location, to the output directory.  This file is, by nature, different for each developer.  It contains connection strings that are specific to the machine.

Using FileMon I was able to see that the VSTS Test Runner was looking in the ..\..\TestResults\{TIMESTAMP FOLDER HERE}\Out\ directory.  The VSTS product team claims that this is for remote running of tests, but I suspect that it is just a poor solution to the problem.  Anyway, there is no way that I can (via a batch file) copy the config file to this folder.  So Pre-Build events are out.

I read up on the issue and find that it is possible to have items copied to the Test Results folder.  You have to add this attribute to a test method:

[DeployItem(“local-connectionStrings.config”)]

…and yes, I said to a test method.  It will not work on a [TestInitialize] or [TestClass].  So basically if I want to use this feature, I have to retro fit around 80 tests to include this attribute, then tell my whole team to do it as well.  No thank you.

You can also add the Deployment Item to the localtestrun.testrunconfig file (under Solution Items).  This file says “local” but it is checked into source control, so it is not clear if this change will be applied to everyone’s working copy or my own.

This is a stupid, hacky solution to a problem that doesn’t even exist with the other unit test frameworks.  Since we aren’t really using any TFS test features yet (Web Tests will come) —I’m tempted to just rewrite them all for NUnit.  Of course I will get pushback from management, but these little issues are becoming a hinderance. 

If it is cumbersome to test, developers won’t write unit tests.

(Oh, and JetBrains:  when will you release support for the VSTS Tests?  I’m dying over here!)

Friday, August 03, 2007

Decorator - The Cool Pattern with the Stupid Name

So I have a logging class that is implementation agnostic.  Under the hood it uses an Adapter for Enterprise Library Logging, however we could easily switch it out for log4net if needed without changing the code.

So you can imagine that I have an interface that looks like this:

public interface ILogger

{

    void Write(string text);

    void Warn(string text);

    void Error(string text, Exception msg);

}

… and there is currently an implementation of this class called EntLibLogger:

public class EntLibLogger : ILogger

{       

    public void Write(string text)

    {

        //ent. lib write log entry

    }

 

    public void Warn(string text)

    {

        //ent. lib warn

    }

 

    public void Error(string text, Exception msg)

    {

        //ent. lib error

    }       

}

The specific logger that is used is abstracted behind a factory of course.  However, some of the applications that use this component will not have the logging configuration.  It is perfectly feasible to ignore logging in this scenario (ie: swallow exceptions) however this is something that any logging component would do.  I don’t want to add it to each and every implementation of ILogger.

So here’s where the decorator comes in.  This pattern could really use a better name, but I can’t think of one, so I’ll leave that up to you.

A Decorator implements the same interface, however it wraps each method with its own behavior before deferring the call to an inner implementation.  Wow, that doesn’t really make much sense, so how about an example…

public class SilentlyFailLoggingDecorator : ILogger

{

    private readonly ILogger _innerLogger;

 

    public SilentlyFailLoggingDecorator(ILogger innerLogger)

    {

        _innerLogger = innerLogger;

    }

 

    public void Write(string text)

    {

        try

        {

            _innerLogger.Write(text);

        }

        catch

        {

            //swallow exception

        }

    }

 

    public void Warn(string text)

    {

        try

        {           

            _innerLogger.Warn(text);               

        }

        catch

        {

            //swallow exception           

        }

    }

 

    public void Error(string text, Exception exc)

    {

        try

        {

            _innerLogger.Error(text, exc);

        }

        catch

        {

            //swallow

        }

    }

 

}

All of the actual implementation comes from whatever ILogger is sent via the constructor.  All this class does is “decorate” the method calls with additional behavior.  (This time, we’re choosing to silently ignore errors rather than throw exceptions that cause the program to stop)

To wire this up, wherever the factory method resides that creates the actual logger, you’d write…

public static ILogger GetLogger()

{

    //via IoC or just hard-coding

    return new SilentlyFailLoggingDecorator(

         new EntLibLogger()

    );

}

So there you have it!  The decorator pattern can do all kinds of Aspect-Oriented things such as Log a message each time a method is called, or possibly massage parameters before sending them to an inner class.

ReSharper Coolness - Move Methods

Every once and a while I come across a new feature that just makes me stop and think “ReSharper, I love you MAN!”

If you have your cursor on a method, press CTRL+ALT+SHIFT  and the Up or Down arrow keys.

Here it is in action:

Resharper:  move method

Thursday, August 02, 2007

How Does YouTube Handle It?

I ran across an excellent read about how YouTube's architecture handles so much bandwidth and traffic.

The core of it is:

  • SuSe Linux
  • Apache + lighttpd (for videos only)
  • Python + C extensions for expensive operations
  • Lots of caching

Many more points to read, but a great reference indeed.  Check it out here:  http://highscalability.com/youtube-architecture.

Excellent Advice from a Hibernate Expert

I just stumbled on this list of 10 Things I Learned About Using Hibernate Successfully.

It is excellent advice for anyone using Hibernate or NHibernate.  I fully agree with each point on this list.

http://www.spenceruresk.com/2007/07/27/10-things-i-learned-about-using-hibernatejpa-successfully/

Wednesday, August 01, 2007

Robert Martin at AgileHouston Last Night

I just got home after attending a talk by Robert Martin on Code Quality.  It was really great to meet him after reading his book, to which I gave an excellent review.

Bob (that’s what people call him when you know him, kind of like Bob De Niro, though I don’t know him at all — what was I saying?) is very animated and pretty weird.  He pulled out his geek card a few times which was funny.  He even acted out a scene from Star Trek 2 where he was Ricardo Monteban.  Yeah.

Anyway, the talk was very much like his book and enjoyed it thoroughly.  It was also good to see other folks in the room interested in agility from around Houston.  Most of them were .NET developers.

Robert Martin will be in town again next month giving a similar (but different) talk about clean code, possibly with Ruby.  Hopefully I will be able to attend that as well.

I’ll leave you with some R.M. quotes…

“Not cleaning up your code is like not doing the dishes after dinner.  The longer you wait, the more the mess piles up.  Eventually it impedes you so much that you can’t even work”

Having management dictate a specific code coverage percentage is madness.  Code Coverage is a great tool for developer feedback, but mandating it will not provide value.”

The great redesign in the sky fails — always.”

So you want to clean up some code but it is just a mess?  Uh [snickering] do you have tests?  No?  Your pretty much screwed.. [smiles]” — after which the book Working Effectivly with Legacy Code was recommended.

“Professionals write tests — first”

Sunday, July 29, 2007

My Presentation at OKCodeCamp - DDD with NHibernate

I presented a talk on Domain Driven Design with NHibernate at the OKC code camp yesterday.

It started out a bit rough because I had some missing references and some confusing exceptions, however once I got the ball rolling I think it went pretty well.

I ran way short on time, however, and I promised the crowd that I would post the completed files on my blog tonight .

So, here is the powerpoint, demo applications, and all of the referenced dlls from my presentation.  Let me hear your feedback in the comments!

File Attachment: ddd with nhibernate.zip (7694 KB)

(the file is large because I have the complete references to specific versions of NHibernate and NUnit, so you shouldn’t have to worry about references at all.)

To get the sample running, change the app.config to point to an actual database.  The database should be empty.

OKC Code Camp - After Thoughts

I’m in the airport now awaiting my flight home.  The code camp was a blast!  I was very glad to meet a bunch of very smart folks and pick their brains.  I also miss my family, so I’m glad to be going home.

Being surrounded by like-minded people really validates that the things that we are doing are of value, and I really think that the industry is poised for a change as a whole.  At the code camp there was an Agile Experts Panel (which I was a part of somehow  )  — anyway, there was only one guy up there that was questioning the things that we were talking about.  In my experience the agile ones are the outnumbered ones.  There were a number of .NET newcomers who were just getting into development, and it was really good to recommend some solid books and blogs to get them started.

It was fun to listen to Scott Bellware not pull any punches and be incredibly blunt about what he believes about agile. 

A couple of my favorite quotes of the day:

  • “God forbid we ask our developers to LEARN…” – Scott Bellware
  • “When you fire up the debugger to verify something and then click stop, the ‘test’ that you just performed goes into the ether.  Every time someone does that, God kills a kitten…” – Dave Laribee

I can’t wait to get together with these guys again at the ALT.NET open spaces conference in October.

(oh — I’m working on finishing the example from my presentation, so I’ll post the files for that as soon as I finish)

Wednesday, July 25, 2007

The Results are In!

Our little dasBlog theme contest has ended.

Here are the votes:

drum roll please…

Dandelion: 6 votes
Expression: 2 votes
Funky: 1 vote
Lizard Lounge: 2 votes (even though I told them not to vote for it :P )

So, Tim Sherrill, your $100 Amazon Gift Card is forthcoming, and thank you!

Thanks also to the others who submitted their themes.  Maybe we can do a larger contest in the future.

Dandelion DasBlog Theme

Homeowner Loan - Renegade motorhomes - New York Hotels - Debt Help