Devlico.Us
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @devlicious

Tim Barcz

Why use nails when a screw is the more reversible choice?
  • Developer Book Club - Recommendations Needed

    Today I tossed the idea of a developer book club out to the rest of my team.  They all seemed to be on board with varying degrees of enthusiasm.  I know that we won't be the first to try this and so I'm hoping some of you out there can share some stories/ideas of what worked for your team.

    The goals are three-fold:

    • Team/community building
    • Common knowledge
    • Knowledge building/sharing

    Specifically I'm looking for three things:

    • What books would be on your short list?  Which book should we start with?
    • What works well to keep people excited/enthusiastic?
    • What are the things we should absolutely stay away from, whether they be specific books or implementation details?

    So let me have it, what advice can you share?  What can we do to make our book club a success?

    Posted Nov 18 2008, 07:37 PM by Tim Barcz with 21 comment(s)
    Filed under:
  • Windsor Components, the ASP.NET MVC Framework, and Bug Verification Tests

    Shhh...don't tell anyone but we don't unit test all of our code.  We're striving to get all developers and managers on board with unit testing but we're not there yet.  Despite our delinquency in writing tests one thing we do try our very best to do is keep mistakes from happening again.  If we find a bug in the system, before fixing it, we go and write a unit test for that problem.  We verify the test fails, the go and write the code that fixes it.  This recognizes that bugs will appear in the system, but once fixed we'll insulate ourselves from that bug happening again.

    We had one such case last week.  We were getting a yellow-screen error after a bunch of commits by developers.  The error stemmed from a component in Windsor that did not have all of it's dependencies met.  In other words, we registered a component which relied on another component which was not registered.  We already had written a test to compile and test our Windsor configuration, however that test was not mature enough and needed some tweaking. 

    In our application we leverage the new ASP.Net MVC.  We also take advantage of the ability to leverage an IoC container, Windsor, to create controller instances when a web request comes in.  When the application starts, we register all of the controllers in the application into Windsor using reflection.  Therefore our Windsor configuration at runtime is made up of two things, the XML configuration and the controllers which are registered on startup.  The "bug" here was that one of our controllers had a dependency on it that was not registered in Windsor.  When you ran the test by itself, the test would pass, since it was only loading up the components from the Windsor configuration.

    Wanting to protect us in the future, we acknowledged there was something missing from our test and set out to find it.  To create the failing test was relatively simple.  All that we needed to do replicate in our test what we were doing at runtime.  Therefore we needed to register all implementers of IController, just like we do on application startup.  Below I've

    Before:

       1: IWindsorContainer container = new WindsorContainer("windsor.config.xml");
       2:  
       3: foreach (var handler in container.Kernel.GetAssignableHandlers(typeof(object)))
       4: {
       5:     Console.WriteLine("{0}\n\t- {1}", handler.ComponentModel.Service, handler.ComponentModel.Implementation);
       6:     container.Resolve(handler.ComponentModel.Service);
       7: }

    After:

       1: IWindsorContainer container = new WindsorContainer("windsor.config.xml");
       2:  
       3: var assm = new HomeController(null).GetType().Assembly;
       4: //add all controllers
       5: foreach (Type type in assm.GetTypes())
       6: {
       7:     if (typeof(IController).IsAssignableFrom(type) && !type.IsAbstract)
       8:     {
       9:         container.AddComponent(type.Name.ToLower(), type);
      10:     }
      11: }
      12:  
      13: foreach (var handler in container.Kernel.GetAssignableHandlers(typeof(object)))
      14: {
      15:     Console.WriteLine("{0}\n\t- {1}", handler.ComponentModel.Service, handler.ComponentModel.Implementation);
      16:     container.Resolve(handler.ComponentModel.Service);
      17: }

    Now that this test is in place, I am much more confident that we won't see the error we were seeing in product again, we've got a test which warns us if something isn't quite right.  Our initial test didn't quite get it all right.  Mistakes/bugs in code will happen, hopefully few and far between, but when a bug does show up, go write a test that verifies the bug before going off an fixing it.  Then make the test pass, which should fix the bug.

  • How To Approach Development

    I don't typically link blog and I do my best to write substantive original material, but the following is too good to pass up.  It's how I feel and how I've approach work in the last year or so.  From Ayende's Reducing The Cost Of Change blog post this morning:

    That mindset, at least for me, starts from the first line of code. I treat each piece of the project as utterly disposable. Since I don't really care how each individual piece works, I am able to roughly sketch a fair amount of the application very rapidly, and then focus on each of the items in isolation, and replace that with a much better implementation. I think that I stated before that I tend to rewrite most of my application core at least two or three times before I am happy with them.

    When you have disposable pieces, it is no big deal if you mess up and need to start over, because the whole project is structured in a way that allows you to do so. Going back to using my current project as an example, the algorithm used for the core part of the system is crap. I thought it up while being on a coffee break, and it is enough to demonstrate what the software is supposed to be doing. I don't really care, because the moment that I do need the real algorithm, I can drop it in (need to change the implementation of a single method).

    I can't improve on that, so I won't try.

    Posted Nov 13 2008, 09:50 AM by Tim Barcz with 3 comment(s)
    Filed under:
  • Iowa Code Camp 2 - In Review

    image This past weekend in West Des Moines, Iowa I attended the Iowa Code Camp.  This was the second such event this year and it amazes me how well these events have gone given they are in their infancy.  The leadership deserves a huge round of kudos for pulling off such a great event.

    Recap:

    This was a big day as I was leading four session, two by myself, and two fishbowl type sessions.  Below is my recounting of an awesome day!

    Open Source Tools for the .NET Developer

    This was my only open session where I was not helping or giving the talk.  So this was a good time to soak in some knowledge.  Javier Lozano did a great job introducing some of the open source tools that he considers a must.  I use everything he was saying, so I was hoping to catch a nugget here or there that I could take back to work with me.  In general I think this was a very good talk.  Covered a lot of ground in a short amount of time but attendees could see by the interaction from a few in the crowd that many of these tools are mature and being used quite heavily with a lot of confidence by other attendees.

    Fishbowl Session(s)

    Chris Sutton has had a vision of bringing open discussion to the Iowa Code Camp since the last go around in May.  He tapped Nick Parker and myself to facilitate.  We weren't sure how the idea of dynamic selection of topics for group discussion would go, but we were very surprised and pleased with the outcome.  We had two of these "sessions" during the day and both of the discussions were very good.

    Easing Your Testing With Rhino Mocks

    This was my talk.  I've given this talk before internally but I was a little skeptical of how the talk would go given that I didn't know who would attend, their familiarity with testing and/or mocking, and what they're knowledge level was in general.  I had struggled with where to take people.  In preparation my talk went from "way too much" to "too trivial" at times.  By Friday night I felt like I had the kinks worked out.  Overall though I think this talk went very well.  I first introduced code that does not lend itself to be easily tested.  I wanted to address testability as a design time idea.  After going through what made this code not easily testable we refactored the code to allow us to get in there are test what we wanted.  We created some stubs and mocks by hand to test both state and interactions.  After showing you could test by writing your own mocks I wanted to show that it's much easier to leverage a framework.  Given the amount and type of questions, I feel pretty good that the attendees understood why you would want to mock and how you would do so.  I'm confident attendees walked away with something they could take to their jobs on Monday morning.

    TDD: A Workshop in Driving Your Design with Tests

    This was my second, self-led session of the day.  I'm not a TDD expert by any means.  Quite frankly, like many out there, I too am learning what it means.  As I've learned and studied, I find that many people classify TDD wrongly.  I often hear something like, "We write unit tests and do TDD" or "We add tests to our code using TDD", which seem to blur the lines between TDD and unit-tests.  I wanted to clear the air and share what I knew.  Rather than doing a talk where I stood up in front of the group and they watched me do something, I wanted to get them involved.  TDD is hard, and I wanted to people to get a true sense of what TDD feels like and how it takes discipline to accomplish.  The idea for this was to have a workshop and as a group solve a problem using TDD.  I think the the knowledge transfer was good and people saw what TDD really is.  The downside was getting people to get out of their seats and code.  The idea was to have a person write a failing test, then someone else write the code to make it pass.  Out of a very good crowd of about 30, only about 7 were willing to interact which was somewhat disappointing.  I think the idea of an interactive workshop is still a good one, however, as someone suggested, I would structure it quite differently, possibly keeping someone at the computer for a few minutes at a time.

    Conclusion

    Overall the day was awesome and I look forward to the next.  If you have access to a code camp they really are a great way to learn.  Imagine trying to learn something new and having someone right there begging you to ask them a question.  I look forward to the next Iowa Code Camp, which will be next spring.  Leading four sessions was a lot but come May I will probably be pushing myself to present again as much, ever hoping to help someone be better than they were the day before.

  • Exercise Caution When Using Floating Point Numbers

    I understand floating point numbers can be somewhat imprecise but I'm a bit bothered today when I see the following evaluates to false:

       1: float f = .16f;
       2: double d = .16d;
       3:  
       4: Assert.That(f, Is.EqualTo(d))

    Annoyingly I wanted to see what the two values are:

       1: Console.WriteLine((double)f)
       2: Console.WriteLine(d);

    produces the following respectively:

    .159999996423721

    .16

    What bothers me about this, and I'm hoping someone can eloquently explain this, the MSDN docs say this should be implicitly converted.  From the MSDN doc article on implicit numeric conversions:

    • From float to double.

    Float is 32-bit and double is 64-bit, so why can't the float fit nicely inside the address space for the double?

    Hell, if you're not going to respect the integrity of the number what's the point of the implicit conversion?

    Posted Nov 05 2008, 02:13 PM by Tim Barcz with 10 comment(s)
    Filed under: ,
  • Test First or Test Driven, Who Cares?

    image This past weekend I attended the Continuous Improvement in Software Development Conference in Austin, Texas.  This conference brought together many brilliant minds in the .NET community for the expressed purpose of continuous improvement.  The conference was very good, but some of the best chances for learning happened outside the conference sessions at dinner or sitting around a table at the hotel bar.  One such discussion seemed to point out one problem we have in our community, minutiae.

    I will preface the remainder of this post by saying I tend to be a purist at times and must always remind myself what the ultimate goal is.  Acknowledging my tunnel vision, sometimes purists, can miss the point if we're not careful.  One evening a few of us got on the discussion of test-driven development.  Someone at the table used the phrase test-first development in the conversation.  That person was quickly halted by others at the table because the terms, in their opinion are quite different and should not be used interchangeably.  If I were to ask you define both, could you adequately define the difference?  Should you be able to?  Does it really matter?

    I would say that for the development community out there that the differences, if in fact they do exist, don't matter.  A quick and informal poll revealed that 8 of 10 developers I know aren't unit testing at all.  I readily admit that my sampling is probably an inaccurate representation of the total developer population.  I don't think though that my sample poll is off by an enormous amount.  Think of the developers you know; are they testing at all?  I'm not talking TDD, but plain old unit tests?  Chances are good that you know a few that aren't testing at all.  Are they served by the bantering back and forth about differences between TDD and TFD?  Absolutely not.

    The important thing to remember is that fundamentally the TDD and the TFD practitioner believe the same thing, that is, you need to be testing your code. They may disagree about small things, but those small things should take a back seat to the fundamentals.  We don't have to look far to see another example of this type of behavior.  Think of two Christian denominations, both of which are trying to convert nonbelievers to Christianity, bickering among themselves about whether children should be baptized or not.  The debate becomes so ardent, that neither camp accomplishes their original goal or converting nonbelievers because they're too focused on each other.  I fear the same outcome will befall those of us preaching testing.  We get so religious about the non-essential aspects of testing that we miss the people we intended to target, the people who aren't testing their code at all.

    I think we could all take a page from St. Augustine who had it right over 1600 years ago: "In essentials, unity; in non-essentials, liberty; in all things, charity."

  • Alt.NET Austin - Workshops Day 2, Conference Day 1

    Yesterday was the first day of the pre-conference workshops at the Kaizen Continuous Improvement Conference.  Day two was a bit more invigorating for me since I attended two topics (Opinionated MVC and Fluent API's with C#) which got my head spinning nearly immediately.  Both talks were very good and rather than writing my own thoughts on the subject I'll defer to Derik Whittaker and his thoughts on the day.

    Posted Nov 01 2008, 03:52 PM by Tim Barcz with no comments
    Filed under:
  • Alt.NET Austin - Workshops Day 1

    I'm in Austin, Texas for the Kaizen Continuous Improvement Conference this weekend.  One of the very cool things the organizers did for this event was offer two days of workshops before the conference.  While I'm excited for the conference itself, much of my excitement for the conference stemmed from these pre-conference workshops.  Yesterday I went to two workshops, both of which should be online at some point.

    Advanced NHibernate - with Ayende Rahien

    I was a little leery of this one given our seemingly trivial usage of NHibernate.  I was pleasantly surprised to see how much of this was perfectly timed for where we are at.  Oren went into great detail on various parts of the NHibernate and it's contributing projects.  He spoke a bit on caching and performance optimizations/pitfalls that you generally have to watch out for.  Quite possibly the coolest feature was getting to see NHibernate profiling application that Oren is working on.  This won't be a free tool but the price from what I've heard from Oren will be very reasonable (I am not saying the price since it may change).  With NHProfiler you can see all the queries that get executed from you application.  It even has alerts built in, such that if it detects a problem (ie. Select N+1) it will let you know.  Without hesitation, if you're using NHibernate, buy NHProfiler when it comes out, it is easily worth it.

    The most important concept that I got from this session is how powerful NHibernate is.  People can fight ORM, roll their own solution, or write their own T-SQL but when you see what NHibernate has to offer it seems ridiculous to choose any of those options.  Two little known NHibernate features you may not have known about that I've found very cool:

    • NHibernate Search : Leverages the open source Lucene.NET implementation and keeps allows you to do search which have performed poorly in the database against a very fast Lucene index.
    • NHibernate Shards : Written by Google this allows you to scale across a number of databases. I won't delve into sharding here but you can read up on it on wikipedia.

    DDD Chalk Talk - David Laribee

    I was very interested in this chalk talk since the name seemed to indicate we'd get a chance to have an open discussion about DDD and how one would approach DDD in their domain.  This talk seemed to have peaks and valleys.  It was no fault of anyone in the talk, but DDD seems to be one of those topics where it becomes extremely tough to follow once you get outside of what you know.  The topic of aggregate roots and contexts were quite helpful.  I found it encouraging that ideas that I have interpreted from the book seem in line with what David Laribee demonstrated on the white board.  I'm only a few chapters into the book and am absorbing as much of the DDD concepts from those who are ahead of me on this path.  I'm encouraged to see where others have taken it, the value they have found in it, and what it could mean for our application(s) in the future.  Just have to keep reading and learning.

    Quite a lot for only the first day of a multi-day conference.  For those of you who aren't here in Austin but wish you were, keep an eye out for videos of the many presentations that my pop up.  I will update this blog if/when I see them appear online.  There was a lot of good content coming out of these workshops and it'd be a shame to have the content limited only to those in attendance.

  • Mass Transit - Part 2 of N

    Last week I posted the first in a series on Mass Transit, an open source enterprise messaging system.  This series is my public exploration into messaging for our eCommerce application.  In this post I'm going to dig in to see an actual working example.  I like to see something work, then dig in to figure out how it's all put together.  We'll take a look at a simple publish subscribe example to see the messaging in action.  In later posts we'll dig in deeper into the guts of MassTransit.  That said, let's see some MassTransit in action!

    Getting Started

    I've downloaded the MassTransit source from the Google Code repository and am going to run one of the samples provided with the source.  We'll look at their "PublishSubscribe" sample.

    image

    Project Structure

    image Opening the solution reveals nine projects, a few more than what I would consider a simple sample, however don't let the solution scare you away.  It turns out that you can for the most part ignore five of the projects, the mass transit infrastructure projects.

    There are four parts to this solution that are relevant and we'll focus on those:

    • Client - The client represents the application that wishes to leverage messaging.  It plays the role of publisher in this example.  It is worth noting however that in this example, as we'll see, this project is also a subscriber.
    • Security Messages - This is a pretty simple project as it should be.  This project encapsulates the strongly typed messages that will be passed throughout the system.  By having the messages in their own light-weight assembly we can keep our messages separate for their consumers.
    • Server - This project acts as the subscriber.  In a normal scenario this server may be sending out emails or logging particularly interesting things as messages come through or whatever else you may have a need for.  Like the client project, we'll see that this project also plays dual roles, the subscriber as mentioned and also a publisher.
    • SubMgr - The subscription manager, is quite a mystery to me.  It may not be obvious, but the subscription manager is needed to get everything to work.  As Dru explains it to me, it is the glue.  In my first go around with MassTransit, I created a client and server and was frustrated when nothing was working.  Talking with Dru, he quickly pointed out my error, I had no Subscription manager.  In the following posts I hope to clear up some of the mystery for myself around the subscription manager.  My understanding at this point of the subscription manager, which may be a bit simplistic, is that it pushes the messages to each of the queues which are interested in the message.  A publisher publishes a message, the subscription manager is the one that ensures that it ends up in the appropriate queue(s) for consumption by various subscribers.

    Getting Setup

    image In order to get this sample going you first have to create the MSMQ queues that this sample expects:

    • mt_client
    • mt_pubsub
    • mt_server

    You can create these queues in the Message Queuing area of the Services and Applications snap-in in the computer management area on your computer.

    Seeing Is Believing

    Now that we've got the project set up let's fire it up and see what we get.  Since we need all three applications running at once, the client, server, and subscription manager we can take advantage of a cool feature in Visual Studio, multi-project startup.

    With multi-project startup you start any number of projects in your solution.  From the properties dialog for the solution we can choose which projects we want to kick off.  (It is worth noting the order in which I have these projects launching.)

    image

    What's Going On

    When you run this example, the client application will ask you to enter a new password.  When you type in a new password  you will get a nearly instantaneous response letting you know the password was updated.

    image 

    The thing to bear in mind here is that at the point you hit the <enter> key submitting your new password, the client publishes a message and then it is done.  It appears instantaneous but you'll want to keep in mind that it is asynchronous.

    The Flow Of It All

    image The diagram to the right illustrates what is going on once you hit the <enter> key.

    1. The client publishes a RequestPasswordUpdate message (see the Security Messages project in the solution for this message object).
    2. The server in this case consumes the RequestPasswordUpdate message.  When it is notified of the message, it logs the new password, then...
    3. The Server publishes a new PasswordUpdateComplete message.
    4. The client consumes the PasswordUpdateComplete message and in so doing writes to the console that the password update is complete.

    It is worth noting here that the client knows nothing of the server and the server knows nothing of the client.  Our example could easily expand to have multiple clients (think for example a windows app or multiple web servers in a farm).  Likewise there could be multiple server instance, each consuming different messages.  In other words, we are very loosely coupled, which is a good thing.

    Conclusion

    I hope this introduction to the MassTransit was beneficial.  Now that we've seen the example working, in the next post I'll revisit the idea of durability.  We'll augment this example and simulate a breakdown in infrastructure and see what durability really means, which is really at the heart of this fantastic open source library.

  • Continuous Improvement - One Developers Journey

    When I started my current position six months ago I was brought in to help with development of their new website application. Whether my boss knew it or not, that meant that I would be bringing a host of baggage with me. When I came I brought along of ideas and practices that were new to the development team. The usage of an IoC container (Windsor), ORM (NHibernate), a build server, unit-testing to name a few.

    These tools and practices are often discussed both here on this blog and in the larger .NET blogosphere. Getting up to speed on them can surely be a daunting task. I’ve asked a lot of the guys I work with in terms of learning new tools and implementing better development practices. I wanted to take the opportunity to interview one of them and let him speak about his experience learning all of these ideas.

    Chris is a developer with a few years of experience with .NET. His exposure and experience to the tools mentioned above begins six months ago, when I joined the team. He approaches development as a student and one of the things I appreciate about him is his openness to the ideas I’m bringing to the table.

    I asked Chris to answer a few questions about his experiences over the last few months. The goal is to give some of you some insight into one developer’s journey to writing better software.

    What has been the biggest change?

    The biggest change is probably the learning curve that was involved in the new software, for example, using Subversion instead of Visual Source Safe. I had to learn new software, but once I felt comfortable in Subversion I realized that I really like it; unlike Visual Source Safe, which was a pain. I always treated it as a necessary evil.

    Has it been difficult?

    Some of it has been. Things like trying to figure out why NHibernate mappings are failing and why Windsor can't resolve a type. These are just things that you have to practice and familiarize yourself with to understand how they can break. It can get frustrating at times.

    What's been the hardest part?

    The hardest part is sticking with it and not going back to the "old ways". There have been times where I was puzzled with some unit tests and mocking and wanted to just give up; it seemed like the best option. More than once I asked myself, "Why do we have to do all this all at once?!?!" When that happens, I just step back, calm myself down and try again. There is always a solution, it just might take some time to figure out why I'm doing it wrong and fix it. Once fixed, it's great and I'm glad I didn't give up. If you're learning several new techniques and patterns at the same time, they can pile up and begin to overwhelm you. Patience is the best medicine in that case.

    What's been the easiest, if anything?

    I'm always amazed how much easier it is to integrate with other colleagues' code. Pulling a latest version from source safe and compiling, then pushing the code manually to the test server was a pain and caused countless headaches and stress. Not only the continuous integration, but the concepts promoting better abstraction really lend themselves to working with each other, not against each other.

    Do you feel like this is the correct path?  In other words are you writing better applications?

    I think this path is very conducive to writing better code. It's visible by the unit tests and code coverage. To me these are readily identifiable measurements to the quality of the code. I know code coverage can be 100% even on bad code, but confidence in my tests creates confidence in my code overall. I now have little confidence in code without unit tests.

    Any advice to someone who is reading this article?

    I have a personal trait to never accept anything as a good enough answer. This is sometimes a good, and sometimes a bad trait of mine. I think in this aspect, development, it's a good thing. For instance, you could be comfortable with drag-and-drop web forms controls, they work. Are they the best way to build web applications? One could argue for them, but I would argue a resounding no. There are a lot of solutions to problems out there and just because you know it as the best approach, doesn't necessarily mean it is the best. Do some research; learn some new techniques and you'll surprise yourself how many great ideas there are out there.

    I want to thank Chris for sharing his experiences here on this blog.  You can check out Chris' blog at http://www.dumpsterdoggy.com.

  • Mass Transit - Part 1 of N

    This post is the first in a series of posts I plan to do about MassTransit, an open source messaging system written by Dru Sellers (blog) and Chris Patterson.  I plan on blogging my observations as I explore both the implementation and the source code.  Before I dig into MassTransit specifically, I want first touch on a few introductory items.

    What Is Messaging?

    Messaging quite simply is a type of notification.  In the real-world we deal with this everyday.  Consider meeting someone for the first time and you say, "Hello, my name is <your name>."  You've published a message.  If the person on the end is polite, they will have "subscribed" to your message and choose to publish one back, for example, "Nice to meet you <your name>, my name is <their name>."  Another example is someone shouting, "FIRE!" in a crowded theatre.  That is a type of message, albeit an important one.

    In code, some messages are rigidly defined, such as when an event is raised.  Many messages, however are more loosely defined.  Consider for example the creation of a string, a log message if you will, that is stored in an in-memory queue.

    Can I Benefit From Messaging?

    Maybe, maybe not.  Once upon a time I worked for a company that offered a CMS product as part of it's product offerings.  This system started small but gradually had increased demands in the form of new features clients wanted added.  Pretty soon, when you clicked the save button multiple things were happening; a database row would be updated, an email would be sent, a new file would be written, another status file would be updated.  These were all executed when the user clicked the button, therefore every action was a blocking action, the server couldn't move on until it was done servicing that particular request.  Performance degradation wasn't a problem when only one or two things were happening but as users demanded more features performance suffered, which manifested itself in long page loads.

    In this example many of the things the application did after the user clicked the save button could have been moved to an asynchronous processing mechanism.  This is where messaging comes in handy, instead of doing all of those tasks in a blocking form you end up instead publishing messages and let some other process come along and do the work for you, asynchronously.  This provides for a much quicker and scalable system.  For example:

       1: public void Save(Entity entity)
       2: {
       3:     EntityRepository.Save(entity);
       4:     
       5:     Publish(ShouldSendEmailMessage);
       6:     
       7:     Publish(WriteFileMessage);
       8:     
       9:     Publish(UpdateStatusFileMessage);
      10: }

    What Makes MassTransit different?

    MassTransit is based on the idea of durability.  To explain durability I will point you to the title of an MSDN article by Udi Dahan named "Build Scalable Systems That Handle Failure Without Losing Data".  Durable messages means that the message can survive some outside event, such as a server reboot or a process recycling.  Imagine my in-memory queue scenario above.  Image the queue has 50 messages when the server reboots. Where do the messages go?  Since the messages were stored in-memory until they were handled, they are now lost.  In other words, these messages were not durable, data was lost.

    Poor Man's Durable Messaging

    I recently came across an application that chose to write the properties of an email to a database table rather than attempt to send the email real-time (for performance reasons).  In this particular instance there was another simple .NET console application that ran every few minutes that would look at the database table and see if there was anything in it, if there was it would pull the records and loop through each one sending an emailing and deleting the record after the email was sent.

    Durable, yes.  Scalable. No.

    Tell Me Why I Need It?

    I can hear you now, you're probably thinking, "Hey that database table idea is pretty slick.  I'm doing the same thing in my app and it works fine.  Why do I need a whole new framework to do this?"  The problem that MassTransit seeks to solve is that of scalability.  The database table for emails works well if all you have to do is send emails.  The more messages you want to handle the more database tables you have to add.  Want to add a row to an audit database whenever an action happens, you have set up the database table to hold the information you want the consuming application to handle.  In other words for N types of messages you have to do N things; and that's bad when you want to scale.

    Why MassTransit and not NServiceBus?

    The reasons I chose to explore MassTransit and not NServiceBus are not scientific at all.  You may not agree with them, and that is fine, but I'm providing them here so you know why:

    • Familiar and Friendly Authors - Dru Seller is one of the nicest guys I met while in Seattle at Alt.NET.  If I have questions or comments about MassTransit, I just pick of the phone and give Dru a call.  Granted not all of you have that ability, but again, I said these were my reasons.  If you are friends with Udi Dahan, I'd strongly suggest you take a look at NServiceBus.
    • Familiar Commonality - MassTransit uses and integrates with other frameworks/libraries that I use, most notably it's integration with Windsor/MicroKernel and secondly NHibernate.
    • Relatively Small - MassTransit is small, yet powerful, and covers the functionality I need.  Being small and young, it is easier for me to go through the project and it's history.
  • Tornado Update - Your Help Is Needed

    I'm sorry this is not a tech related post, but rather a call for your help.

    image Many of you won't know this but my wife's home town of Parkersburg, Iowa was struck by a tornado back in May.  My in-laws lost everything.  All that was left of their house was the basement, literally.  The tornado destroyed every building on their farm and killed nearly all of the livestock.  Worst of all Sarah's aunt was one of six people killed in the tornado.  The town is rebuilding and is in a unique position, please see the email below originating from my wife:

    As many of you know, my High School was destroyed with the EF5 tornado that went through Parkersburg, May 25th. Aplington-Parkersburg High School has been selected as a finalist in the contest listed below. Please take time to read the email and vote for A-P everyday. The contest runs Oct. 6th (today) - October 19th. This would be such a blessing to the school and community. I would really appreciate if you took the time to do this for the next couple weeks, it is an easy way to show your support and help out. 

    VOTE TODAY! AND EVEN BETTER, FORWARD THIS ON TO ALL YOU KNOW AND HELP ME SPREAD THE WORD!!! Also, if you have more than one email address, I encourage you to vote from both as any valid email address counts as a vote!

    Thanks!

    Sarah Barcz

    Please take a few minutes and vote for Aplington-Parkersburg at http://www.henkelhelps.com

    If you're concerned about your address ending up in some database I completely understand, but you can vote and protect your email/inbox, remember I showed you how to do that.

    If you do vote, please leave a comment below and let me know that you voted for Aplington-Parkersburg.

    Posted Oct 09 2008, 03:49 PM by Tim Barcz with 9 comment(s)
    Filed under:
  • Frictionless Subversion Updates

    Friend and fellow blogger Chris Sutton wrote a post the other day about updating source code with batch file.  I found it quite helpful given the number of open source projects I follow (or attempt to) and the different repositories we have at work.  A simple click and all projects registered in the batch file were updated.  The only problem is that any time I download a new project, I'm going to have to crack open the file and add in another project.

    Chris' solution reduces friction, I'm wanting to provide a solution that reduces it further:

    New Solution

    This new solution will traverse a directory and find all directories that contains the ".svn" directory which indicates the directory is under source control.  If the directory is under source control then the batch file issues an update command to bring the source up to date.

    File System Structure

    image

    The Batch File Source

       1: @ECHO OFF
       2: FOR /D %%a IN ("*") DO CALL :SvnCheck %%~dpa %%a
       3: PAUSE
       4: GOTO :eof
       5:  
       6: :SvnCheck
       7: set sourcedir=%1%2
       8: set dir=%2
       9: set svndir=%sourcedir%\.svn
      10: echo "%sourcedir%"
      11: CD %dir%
      12: IF EXIST %svndir% svn up
      13: CD ..
      14:  
      15: :eof

    Without getting into all of the details of the batch file syntax, the basics of what is going on here is that there is a for loop, looping through each directory.  If the directory has the ".svn" directory then the "svn up" command is issued.

    Happy updating (now with less friction)

    Update

    After reading some of the comments, particularly some by "Chris", I've went back and made this simpler.  Thank you Chris

       1: @ECHO OFF
       2: FOR /D %%a IN ("*") DO IF EXIST %%~dpa%%a\.svn svn update %%~dpa%%a
       3: PAUSE
    That's it, small, concise, and for all practical purposes down to one line.
  • Iowa Code Camp - November 8

    image

    I want to invite any of you who are within a few hours of Des Moines, Iowa to attend the second Iowa Code Camp on November 8th.  The first Iowa Code Camp back in May was a huge success. From Derik's write-up:

    Yesterdays event was awesome.  They had about 125-150 people show up for the first ever Code Camp in Iowa.  The venue could not have been any nicer and setup any better.

    I will be giving one presentation on using RhinoMocks and one workshop on TDD.  Below are the abstracts.  If you have the chance, take part, and register today.

    TDD: A Workshop in Driving Your Design with Tests

    If you've heard about Test Driven Development (TDD) and wondered what it was or how to do it, then this workshop is for you.  We'll take a practical, introductory approach to getting started with TDD.  We'll introduce fundamental object-oriented design principles including separation of concerns, dependency injection/inversion, and more.  This will be a hands on lab, so bring your laptops and a copy of Visual Studio 2008 and expect to learn.

    Easing your Testing With RhinoMocks

    When learning about testing you'll see trivial examples illustrating how to write tests. However most production code is non-trivial, making calls to configuration files or to a database which makes testing in isolation hard.  The use of mock objects allows you to isolate code you want to test by providing fake objects to your methods, allowing you to set up complex scenarios to test specific conditions.  In this session we'll first dig into some code that is not very testable and refactor it to make it more testable.  After the refactoring we'll use and explore RhinoMocks to see how we can test different scenarios in our code and verify our code is working as it should.

  • Rhino Mocks 3.5 RTM

    Yesterday Oren announced the release of RhinoMocks 3.5.  While the RC version has been out for a bit the RTM release fixes a few bugs.  You can read all about the enhancements and features in Oren's post

    The feature that excites me the most about the new RhinoMocks release is the AAA Syntax (Arrange-Act-Assert).  One thing I've always struggled with when explaining mocking to people is the record replay model.  The new syntax seems to be more natural.  I have no empirical evidence to back that last statement up, only anecdotal evidence from observing fellow employees interact with the new syntax.

    A close second in terms of changes is the deprecations of CreateMock().  In all the features, patches, improvements, and bug fixes this is the only item Oren bolded, which shows it's importance:

    CreateMock() is deprecated and marked with the [Obsolete] attribute. Use StrictMock() instead.

    This one is great for beginners who instinctively pick up the binaries and see the method CreateMock() and end up later with brittle tests.  Brad Abrams talks about the "Pit of Success" and quotes Rico Mariani:

    The Pit of Success: in stark contrast to a summit, a peak, or a journey across a desert to find victory through many trials and surprises, we want our customers to simply fall into winning practices by using our platform and frameworks. To the extent that we make it easy to get into trouble we fail.

    In earlier versions of Rhino it was too easy to use CreateMock() when DynamicMock() is what you wanted.  New mockers were often using the wrong method (I was one of these CreateMock() abusers/users).  The warning when using CreateMock, and the other enhancements/changes, make falling into the pit of success (with mocking) a much more likely reality.

    You can download the bits from Oren's download area.  When you download, I would encourage you to make a donation to Oren's open source efforts.

More Posts Next page »

Our Sponsors

Red-Gate!