|
 Friday, June 20, 2008

Recommended Reading

Every now and then I have people who want to know what books I recommend in regards to IT and Software. My list tends to change over time, so I plan on keeping this up to date. I'll be posting this link on the home page, so feel free to check back any time. 

PatternsOfEntAppArchi

Patterns of Enterprise Application Architecture  - Martin Fowler

Great book with great patterns for enterprise architecture. 

head-first-design-patterns-book-cover

Head First Design Patterns

Good intro to design patterns.

PragmaticProgrammer The Pragmatic Programmer

Great book for those who like to program but what some more direction on the ways of great software development.
RefactoringToPatterns Refactoring to Patterns

Learn how to refactor your code into patterns.
WorkingEffectivelyWithLegacyCode Working Effectively With Legacy Code

New to unit testing? Having problems with how to understand and test old code? READ THIS BOOK. This book helps any developer understand "hand-me-down" code. :)
AgilePatternsAndPRacticesinCS Agile Principles, Patterns and Practices in C#

Can't be a book written by Robert C. Martin like this one. All around goodness.
xUnitTestPatterns xUnit Test Patterns

You know how to unit test? But what about all of these edge cases? How about testing sending emails? How to test file handling?
FrameworkDesignGuidelines Framework Design Guidelines

A great resource for someone who is attempting to write a framework for a team. This is not the end-all-be-all, but it is a good resource.
CodeComplete2_thumb Code Complete 2

A must read for any developer.
AgileSoftwareDevelopmentWithScrum Agile Software Development with Scrum

Get a grip on the development process with Scrum.
SoftwareEstimation Software Estimation

Another classic from McConnell. If you need to learn how to estimate better, pick up this bad-boy. If you're agile or waterfall, this can help.
releaseit Release It!

Having trouble getting things out the door? This book will help guide you. Completely mind altering book.
PracticesOfAnAgileProgrammer Practices of an Agile Developer

Excellent book on agile development.
LearningWCF
Learning WCF

If you're interested in SOA, then you need to learn WCF. This book helps you ramp up and get dirty quick.
rAgileWebDevelopmentWithrails Agile Web Development With Rails

Again, in my quest to learn new languages, I decided to whip up some web apps with Rails. Very slick, very nice. If you want to learn how to build web apps with Ruby check out this book.
EverydayScriptingWithruby Everyday Scripting with Ruby

In my quest to learn a new language every year, I picked up a copy of this book. It has been outstanding in helping a .NET architect become a dynamic language convert.
#    Comments [2] |
 Friday, June 13, 2008

GMail = Dog Slow

I've been using GMail since it first came out. I remember getting it and having TWO invites to send to friends. This is back when Gmail invites were going for $100.00 a pop.

Through the years its been a great service and I've love every single second of it. Its truly the best at keeping track of conversations, and this works wonders for insanely active groups like ALT.NET.

Over the last couple of months its seemed that Gmail has gotten progressively slower and slower. Through using Fiddler I was able to determine that larger chunks of JavaScript was coming down the wire. The amount of AJAX and DHTML going on behind the scenes brings Gmail to a crawl.

How to overcome it?

On the top right hand side of your page, click "Older Version".

image

This will load the UI without all the bells and whistles and its about 5 times as fast in regards to response times.

Unfortunately there is not an option in the preferences to make this stick. As soon as I log in, I immediately click "Older Version". Alternatively you can also switch to "Standard HTML View" at the bottom. But with this, you don't get any smooth AJAX. Its regular HTML page post backs.

#    Comments [0] |
 Monday, June 09, 2008

I Took The ASP.NET 3.5 Beta Exam, and then the red pill

At Tech-Ed last week they offered the ASP.NET 3.5 Beta Exam. The beta exam is not available in Phoenix, so I decided to give it a whirl on Thursday. I didn't plan to take the test so I didn't have a lot of time to review (maybe 30 minutes of review) and I just dove in and took it.

Normally MS Exams have about ~40 questions and they take a couple of hours for me to complete. I was expecting the same from this one...

Nope. This exam had 70 questions. Wowza. I'm assuming the reason for this is one of these scenarios:

  • This is a beta exam and they need to weed out some questions
  • They have bumped up the number of questions in the exam

So how hard was it?

Well ... it's a little harder than the 2.0 version. A lot of it is repeated from 2.0, but this new beta exam threw me for a loop in a few areas.

The areas that threw me for a loop were:

  • WCF Integration Questions (I'm very well vested in WCF, but I just was not expecting it in this exam - there's a WCF exam for that!)
  • Deep AJAX Questions (Don't do much AJAX stuff, lets be honest... JavaScript is not my favorite language)
  • Miscellaneous Mobile Questions

The main thing about MS exams is that they are LONG and tricky. Sometimes you'll get asked a question and all four answers look right. LOOK VERY CLOSE. You'll see that maybe one word is spelled wrong, or the line's are swapped, etc. They will confuse you. But the main thing to do is be alert. The test will wear on you, its long. By the 2.5 hours in, you'll get tired of the test and you'll want to just hurry through it, don't. Just take your time.

 

So How Did I do?

Since its a beta exam, I won't know for about 2-3 weeks. They send your results in the mail. I feel like I passed, but we'll see when the results come in.

... and no, I didn't take any pills before or after... :) I'm just joshin' ya'll.

#    Comments [0] |
 Tuesday, June 03, 2008

Resources from Desert Code Camp

This past weekend I presented the topic "Intro to Dependency Injection and Inversion of Control" at the Phoenix Desert Code Camp. A big thank you goes out to everyone who attended. It was such a popular topic that it actually moved up to the largest room in the conference location, the Theater at UAT! Thanks again everyone!

At the bottom of this post are the resources from this presentation.

 

Resolution from Error During the Presentation

For those of you were present when I ran into an issue with this "DynamicMethod" error, I have figured out the issue. It's a bug in Unity. It looks like its been fixed and should be available in the next release.

image

I was able to work around this issue by moving the Dependency attribute into the Interface. I have updated the code in the download below to reflect this.

 

Presentation Resource Download

 

Full Solution Download (900K)

PowerPoint Presentation

You can also view the presentation online - located here.

#    Comments [0] |
 Sunday, May 25, 2008

Intro to Microsoft Unity - Dependency Injection Container

 

Note: A full solution is supplied at the bottom of this post if you would like to download it and run it.

A couple of days ago Matt wrote about the new Unity Application Block. The Unity MSDN article describes Unity as:

The Unity Application Block (Unity) is a lightweight, extensible dependency injection container. It facilitates building loosely coupled applications and provides developers with the following advantages:

  • Simplified object creation, especially for hierarchical object structures and dependencies
  • Abstraction of requirements; this allows developers to specify dependencies at run time or in configuration and simplify management of crosscutting concerns
  • Increased flexibility by deferring component configuration to the container
  • Service location capability; this allows clients to store or cache the container

Designing a software system architecture with loosely coupled components makes life easier in the long run. A few of the benefits of loose coupling are : maximizing testability, modularizing components, and increase the maintainability of the code.

This is a simple introduction into Unity that exemplifies the simplicity of the container setup. I will cover two options for type registration:

  1. Manual Method based type Registration
  2. Configuration file (XML Based) type Registration

 

The Example Application

The application that is included at the bottom of this post is visualized via the class diagram below. This simple application utilizes very simple implementations of the repository, mapper, domain model, data transfer object (DTO) and service layer patterns for example purposes.

The application follows a very simple flow as shown below:

image

 

The console application calls into the Service layer which calls into the repository to get the data which calls into the DB. A domain object is created from the Repository call, which is passed up to the service layer. The Service layer returns a DTO via the DTO Mapper to the parent caller (the console app) and then the console app displays the customer name via a write line call.

None of these layers have any inter-dependent dependencies coded inside of them. I'm using constructor injection to inject dependencies into the calling object.

Once unity is set up, it will find the dependencies and supply them to the program at runtime. Therefore, if I need a ICustomerRepository for the service layer to work properly, Unity will give the Service layer a CustomerRepository instance. Since CustomerRepository inherits from ICustomerRepository Unity is able to make this link (once you've set it up) and supply the proper instance.

Class Diagram

image

 

The Setup & Code

The easiest way to see HOW Unity works is to get into the code. My recommendation is to download the sample below, fire it up in Visual Studio and set some break points to see how the code is interacting. Seeing is believing!

Before Unity can supply your application types at runtime, you have to tell Unity WHAT you want it to supply and where to find it. This can be done multiple ways as described here. Today we will go over manual configuration inside of the console app, and xml configuration.

Manual Configuration

image

The manual configuration that I've utilized here utilizes the fluent interface of the container.

Explanation of code: Here we are telling Unity to register a type. We're saying "If someone requests ICustomerRepository, give them an instance of CustomerRepository. If someone requests ICustomerDTOMapper, then give them an instance of CustomerDTOMapper. ..." and so on.

 

 

Using the Container From Manual Configuration

After you've set up the types of objects the container should resolve, you can then ask the container for a instance of "ICustomerService" and then invoke a method call on it. At this very point in time Unity will give you the CustomerService, and then when the customer service needs a repository Unity will then give it a instance of CustomerRepository, etc. At this point in time, everything is mapped for you behind the scenes. The only thing you have to do is ask for the first object and Unity will walk the dependency graph and fill in the blanks for you (if as long as you've given Unity the proper types it needs).

Here's how to do this in the code:

image

 

 

 

XML Configuration

XML configuration utilizes an external XML file (app.config/web.config) to create its dependency graph. This allows for a lot more freedom in what you would like to do with your app. If you're not happy with a certain version of "ICustomerRepository" you can create a new one, drop the DLL in the bin folder and change this config file to point to the new one and you're done. No recompiling!

In this implementation I'm using the app.config file because this is a Console App for example purposes. The full schema for XML configuration can be found here on the MSDN.

To utilize the XML configuration you'll need to utilize a custom config section. You can do this by placing this code into your config section of your app.config file:

image

Next, you'll need to add the container and type definition as shown below (this is just a snippet, full code is included at the bottom of the post):

image

The container gets its types from the config file at runtime.

Each type is declared in the config file as the "type" of object to find and the "mapTo" defines which object to return when the "type" is requested.

The type definitions are declared as type, assembly.

 

 

 

 

 

 

Using the Container From XML Configuration

To force Unity to use the XML Configuration you have to perform few extra set up steps in the application code as shown below. Essentially you're telling Unity that it's configuration/mappings are stored in a config file. The config section configures the container for you, as shown below.

image

To have Unity resolve an instance, its the same as the manual configuration option above. Here is the same image from above that displays how to do this:

image

 

 

 

 

Conclusion

Overall, using Unity as quite simple for this example. The docs on MSDN were pretty good, however I didn't really like the examples that were contained with the download because they did not show you how to utilize XML configuration as I wanted to. It didn't take but a few minutes to figure out what I needed to do. I think Unity is a decent solution at this time. I plan to investigate further into the depths of Unity to see if it may possibly be an alternative for my favorite container tool, Windsor Container.

 

Download The Code For This Post

FooTheory.UnityExample.zip (~477K)

#    Comments [2] |