Derik Whittaker

Syndication

News


Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Learning to use Mocks and the power they provide
Up until a few months ago I had never even attempted to use mocks (NMock, RhinoMock, etc).  Every time I would read about Mocking I thought to myself, this is kinda cool, but seems to be a waste of energy.

At the time I saw Mocks as only a way to create ‘placeholders’ for business/data classes.  I did not realize that the true power of Mocks was in the ability to isolate code that is not meant to be tested.  By doing this it allows the author to write cleaner, more reliable tests.

Needless to say for the first few months of using mocks, I had to force myself to implement them.  Now, I choose to do them so that I can have better tests.  In fact, when I am writing new tests, the first thing I think of is, does any part of this test need to be Mocked?  Unfortunately for me, if the answer is yes, I tend to have to make changes to our application to allow for easier mocking (The initial design of the application did/does not allow for easy TDD/Mocking).

Another thing I have learned during my journey into Mocking bliss, is how TDD and Mocking changes your mindset when designing parts of your application.  When you are dedicated to using TDD and Mocking it forces you to attack your architecture from a totally different angle.

One of the really cool things about our profession is the ability to grow as a professional every day, if you choose to do so.  For me, learning to use Mocks is just another way I have grown into a better, more complete professional developer.


 


Posted 05-23-2007 6:54 AM by Derik Whittaker

[Advertisement]

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)