If you’re a Software Developer, hopefully you understand the concept of Defensive Coding. If you’re not familiar with the term here is a quick example to explain the concept.
public string SomeMethod(string prefix, string rootWord, string suffix)
{
// Ensure Parameters contain values.
if(string.IsNullOrEmpty(prefix))
throw new ArgumentNullException("Prefix cannot be null");
if(string.IsNullOrEmpty(rootWord))
throw new ArugmentNullException("RootWord cannot be null");
if(string.IsNullOrEmpty(suffix))
throw new ArugmentNullException("Suffix cannot be null");
return string.Format("{0}{1}{2}", prefix, rootWord, suffix);
}
Defensive coding gives the benefit of ensuring that your method is being used properly by who ever is implementing your code, if the proper requirements aren’t met the code throws an exception and warns the Developer what particular parameters expects in order for the function to complete properly.
This concept has been used for years and has suited its purpose well. However there are certain things that this method doesn’t provide. Wouldn’t it be nice if these conditions could be validated by the IDE, before compiling your project? Enter Code Contracts.
Code Contracts were added to .NET 4, but are available to be used in previous versions of the .NET Framework by installing them from the Microsoft DevLabs Project Site. To use Code contracts you will have to Add a Reference to the System.Diagnostics.Contracts namespace.
Static Checking which is the feature of Code Contracts that works without explicitly compiling your code [Visual Studio Background Compilation is necessary], is unfortunately only available in Visual Studio 2010. [Aside: I use the term unfortunately here lightly, you really should Upgrade to Visual Studio 2010, Microsoft has done an amazing job, and you won’t be sorry]
To Mimic the code that I’ve shown above, however this time leveraging the Code Contracts.
public string SomeMethod(string prefix, string rootWord, string suffix)
{
// Ensure Parameters contain values.
Contract.Assert(!string.IsNullOrEmpty(prefix));
Contract.Assert(!string.IsNullOrEmpty(rootWord));
Contract.Assert(!string.IsNullOrEmpty(suffix));
return string.Format("{0}{1}{2}", prefix, rootWord, suffix);
}
As you can see the implementation is much neater and easier to read than the blocks of if statements. This is not the only functionality of Code Contracts either, you can let the contract pass the value through by using the Assume Method which assumes that the value is valid. Other Advantages include Code Based Documentation [Outlining what is expected by the method (in Code, because no one likes making XML Comments)], Business Rule Validation, Can be evaluated on TFS Gated Check-in.
Once I start using Code Contracts in more depth, I’ll be sure to start giving you more real life implementation scenarios. As always be sure to check back!
Until then, Happy Coding!
Last week I was in New Orleans, Louisiana with Sean Kearney, Mitch Garvis, John Bristowe, Damir Bersinic, Ruth Morton, Rick Claus and about 10,000 other Developers and IT Pros from across the World. We were all attending TechEd North America a four day Conference put on by Microsoft to train Developers, IT Pros and Managers about new Technologies and Best Practices while using Microsoft Software and Development Tools. I was Particularly interested in attending as many Windows Azure, Windows Phone 7, and Developer Fundamentals sessions as possible.
After watching so many keynote addresses of Microsoft Conferences online, it was quite amazing to finally be one of the live audience members on location. I didn’t get the best seat in the house, but it definitely will be an experience I will not soon forget. Outlined in the keynote were many enhancements to Windows Azure, Bing Maps, Office Communication Server, System Center as well as Power Pivot [a new feature in Excel 2010] and Pivot Viewer.

The pre-Keynote performance was by a local band which got the crowd Energized, which isn’t an easy task when your audience is full of Developers and IT Pros at 8:30am on a Monday morning.
The keynote, although not a very launch heavy address, was mind blowing. Watching a keynote via a Browser and a Silverlight video player doesn’t do justice to everything that is going on. Literally 10,000+ Developers and IT Pros mesmerized by the demos of the tools in which we use in our day to day lives.
I look forward to attending a future Microsoft Conference, as TechEd 2010 was my first large scale conference.
Some advice on attending conferences
First off, don’t schedule a block of three conferences over a span of three weeks, not only is it exhausting, but you really don’t get the chance to appreciate each conference, the somewhat blend together. Travelling between Montreal, Regina, and New Orleans was a crazy adventure, and I left little room for fault tolerance, luckily nothing went wrong.
Secondly, Make sure you leave a few hours for the Expo. The Expo is a great resource for swag and other possibly great connections. I didn’t spend nearly enough time collecting free T-shirts (I only got 7 or so), or getting demo software, but I did walk out of the Expo with some great stuff. I also managed to see a Windows Azure Data Center up close and personal, as well as getting to meet many people on the Windows Azure team [Watch for an upcoming blog post on an interview I did with David Robinson of the SQL Azure Team].
Last but not least, follow up! You’re spending a few days at a conference which is an information overload on it’s own. Be sure to note which sessions you liked, and where the resources will be posted so you are able to review the content again. Luckily Microsoft was kind enough to post the sessions publicly on the Microsoft TechEd Website.
One Last Thing

I’m in the Cloud, Everybody take a look at me!
The work life balance is something that all developers have to sort out in their own lives, and it’s not easy. There are coders that are content Developing between the hours of 9-5 when they are paid to do so. Of course there is the polar opposite, in which Developers spend time out side of their paid job learning new techniques, technologies, and possibly even new programming languages. I am not saying there is anything wrong with either group, however it all depends on where you want your career to lead you. If you want to step into a world where you work hard, but all of that hard work will pay off, this blog post is for you. If this doesn’t sound like you, leave now.
As it may be quite obvious, I enjoy developing outside of the office, not only to further my skills, but also to make a little bit of extra money. This has it’s trials and tribulations in which your brain is always on, and sometimes you start speaking in code and/or writing code in your sleep. Some times you have to make sacrifices like not playing Halo with your friends [Sorry Kyle & Anna], or missing out on attending certain social gatherings. However, there is a solid reason in which anyone would make these sacrifices and it all boils down to personal growth.
If you’re currently a developer that is doing the 9-5 life, or are currently in school and would like to Refactor your lifestyle into something that will grow your experience, and expertise here are some pieces of advice I have for you.
Goals
Just by reading the title above, you’re probably asking yourself “what is this guy going to tell me that I didn’t hear from my high school guidance councilor?” The short answer is, not much, but one thing that I can offer above and beyond your guidance councilor is that I’ve been living the life, and I am focused on the same career in which you are in or working towards.
Educational Goals
When you first jump into the “Real World” from College you hit the ground running and are probably making less money then you first expected to make and have less free time than you anticipated you would have to attend some part-time studies. Setting simple educational goals that are easy to achieve are key to keeping on top of new Technology and Trends.
Personally, I have posted a Programmer Competency Matrix on my office wall, this gives me a constant reminder that if I don’t have a specific learning objective, there is something else I can always work toward.
Here are some resources I use in order to keep up with Development trends and new Technology:
Podcasts/Vidcasts
A Podcast is normally a short 15-30 minutes of audio clip, sometimes sped up to up to 2x the speed. The short time frame gives you the ability to listen to them practically anywhere, on a run, your commute to work, or even while you’re working on some code.
A Vidcast is practically the same as a Podcast, except for the fact it is in video format. Vidcasts are a little bit harder to keep up with because of the Visual element. However with the Release of Visual Studio 2010 we might be able to play videos within the IDE which will give us the ability to code and watch at the same time.
Here are some Podcast & Vidcast sites I enjoy:
Blogs
If you found your way here, you are obviously familiar with the concept of Blogs. Blogs are a great source of information and I would have to say one of the biggest learning tools out there, all because of the magical invention of the Search Engine. You are able to find a so many of different opinions all focusing on the same topic and come up with a well informed opinion of the topic.
|
Industry Professionals
|
Local Professionals
|
|
|
|
Books/Magazines
A lot of publishers are doing their best to keep you buying books on a regular basis, take advantage of this whenever you can. E-books are great as they are often very affordable, and extremely portable. I keep a large number of books in my SkyDrive, this allows me to access them from any computer or internet capable portable devices [like an eReader]. Here are some prime places to Purchase affordable E-Books:
I also subscribe to MSDN Magazine and CoDe Magazine both of which are typically packed with incredible articles from Industry Professionals.
Forums
Forums aren’t really somewhere that you’d cruise to learn random facts about development, but they do have their place in the learning process. If you need an answer that isn’t required immediately, head on over to StackOverflow, or ASP.NET Forums to post your question.

Forums are a two way street, someone was nice enough to help you out for free-as-in-beer, pass the good cheer along and help out a follow programmer in need. The first vacation time I had ever had the chance to take, I spent the entire week on ASP.NET Forums helping out fellow developers. It made me feel great as I had the opportunity to both, help people out and learning new things that I would have had to learn eventually anyways. I’m currently a “Contributor” with 4,209 points.
Events
Find a Local User Group
If you’re a .NET Developer check out the INETA, you should be able to find a User Group near you on their site. If you are in the Greater Toronto Area [GTA] here is a list of User Groups near you:
Attend a local Code Camp
Code Camps are typically put on by User Groups but are normally a full day of learning for free. You will find content on Current, and upcoming Technology Trends from Local Speakers that you have the ability to talk to at the after party. If you do end up attending a code camp you may want to read the lessons learned by this first time code camp attendee. If you live in the GTA, definitely check out the Toronto Code Camp which is typically held on May 1st.
Keep an eye out for Development Conferences and Events
Conferences and Events are excellent resources for Networking and High Level learning. Typically Conferences and Events have a Price Tag associated with them but from time to time you can luck out and find some extraordinary content at a reasonable cost and possibly even free. I typically live off of a few resources to keep up to date on some of the conferences that are going on in my area.
Microsoft Canada has a great Events System in which you can filter the events by Online/Offline, Developer/IT Pro, and even Geographical Region.
Newsletters are also a great source of Great Events sign up for a Newsletter from Microsoft, a Third Party Control Provider, a Book Company, or a Local Consulting Company. If you aren’t a fan of getting a flood of email some providers will allow you to subscribe to an RSS feed of their event/conference announcements instead of having to get the newsletter delivered to your inbox.
If you are on a tight budget here are some great free conferences to note: Make Web Not War, ObjectSharp: At the Movies, WebCamps and Hack and Defend.
Mentors
If you are able to land a job with a mentor program consider yourself lucky. There is no easier way to gear up your development skills then having someone watch over you when you’re still green. A mentor can also give you valuable life experience advice, and narrow your development vision so you don’t get overwhelmed by trying to learn it all [insert Pokémon joke here].
If you don’t have a mentor program where you work, it would be a valuable investment for the company, so don’t be afraid to ask for one to be implemented.
If you can’t find a mentor at work, there are a few people that you can contact that may be able to help. Microsoft has a group called the Developer & Platform Evangelist [DPE] Team, it’s their job to ensure that you as a Developer have the tools you need to get the job done. If they aren’t able to help you, they will definitely know someone that will be able to give you the advise you are looking for. You can also talk to your local User Group Leader, as they are also normally quite knowledgeable or connected to others that are willing to share their knowledge with you.
Community

Community plays an important role in your Professional Development. What you know can always be expanded, who you know is something that isn’t as easily obtained unless you put yourself out there. You may have noticed that the majority of my points above tie into this theme, they all have to do with the Development Community. Each point made above builds upon the next; Starting with reading articles written by influencers within the Community, listening/watching to their shows, next you attend an event in which they are speaking, then ultimately you get the opportunity to get mentored by that individual, even if the experience is as simple as a quick chat at a technology event after party.
Expanding your network is important, so before you go to a Conference or Event, make sure to set goals as to who you wish to meet (if any), or how many people you wish to meet. Be sure to make a good connection with these people, enough that you’ll be able to recall where you met them if you are to run into them again at future events. Also be sure to be consistent, and reliable, if you make a promise be sure to follow through.
If you have the time to invest, you could become a volunteer for your local user group. Giving a helping hand at User Group meetings gives you the opportunity to continuously meet developers in your area, as well connect you with the speakers that come to present. It also gives you the opportunity to show off your talents, if you so choose to volunteer as a presenter.
Compiling a list of Best Practices
Similar to our coding habits, our lives can always be improved by putting a little bit of effort into understanding how others are implementing their solutions. In the points above I have outlined some of what I have done over the past two years. In posting these snippets of my experiences, I hope to inspire at least one Developer to refactor a part of their lifestyle.
If you have run across this post and were inspired or would like to add to the list of Best Practices, I welcome you to leave a comment below.
| Tags: |
|
refactor, life, happiness, personal growth, inspire, dream, friendship, advice, goals, software developer, programming, #tedtalks, best practices |
| Categories: |
|
General | Technology Community |
| Actions: |
|
E-mail |
del.icio.us |
Permalink |
Comments (6) |
RSS
|