Just trying to make sense of things...

Upgrades, Upgrades,Upgrades...

Friday, 11 July 2008 08:41 by jordan.terrell

Yesterday I spent some time updating software that I use frequently:

I was a bit trepidatious about upgrading all of this software, however, all things considered it was all painless.  The first three products come with a XCOPY deployment model, and if you follow the directions it's no problem to upgrade everything this way.

I was very impressed...

Categories:   General | Programming
Actions:   E-mail | | Permalink | Comments (0) | Comment RSSRSS comment feed

Rhino Mock 3.5 Release Candidate - I Got To Help!

Monday, 30 June 2008 02:22 by jordan.terrell

Rhino Mocks 3.5 just went to release candidate.  Probably the biggest change is the new Arrange-Act-Assert (or AAA) syntax.  This now allows you to use a nearly identical approach to Moq's API.  What I like about Rhino Mocks is the fact that it uses extension methods, so you don't have to access an "Object" property to get the real mocked object.

But what is even cooler about this release, at least for me, is that I got to help with it!  I was migrating a project over to Rhino Mocks 3.5 beta, specifically because I wanted to make use of the new AAA syntax to simplify our tests, and during that process I found a pretty big bug - ordered expectations did not work with the new syntax.

To make the problem summary short, when you used the Expect() extension method, it put your mock object in Record mode, recorded the expectation, and then immediately put the mock object back in Replay mode.  Two problems with this: First, it assumed you were in Replay mode to begin with (Ayende noticed/fixed that); Second, switching back to Replay mode originally would ensure that you could not do so within the context of an Ordered() scope.  This was, I assume more to encourage proper use of the API than a real design/implementation constraint.  With the fix that I made in place, IF you were in Replay mode when you call the Expect() extension method, it now skips the check to see if you are in an Ordered() scope.  However, using the previously existing MockRepository.Replay() method still behaves the way it did before - it will throw an exception if you try to call it within an Ordered() scope.  The reason we can make an exception for the extension method is because it is an atomic action: if you were in Replay mode already, you will just be adding an expectation; you'll still end up in Replay mode.  If you were not in Replay mode, it will not try to place you in replay mode.  The API with the fix in place still protects the invariant disallowing you to enter an Ordered() scope in Record mode and switching into Replay mode before exiting the Ordered() scope.

If you want to look at my fix, it's revision 1482 in the Rhino Mocks Subversion repository.  Not a rocket science-like fix, but it's still cool that I got to contribute, and that Ayende choose to recognize my contribution when announcing the Release Candidate (thanks Ayende!).

You can bet I will be updating my project to use the Release Candidate later today...

Categories:   .NET | Programming
Actions:   E-mail | | Permalink | Comments (1) | Comment RSSRSS comment feed

Apress Books 45+% Off!!!

Tuesday, 24 June 2008 14:26 by jordan.terrell

Anyone who knows me well knows that I'm a huge book reader (mostly technical in content).  I love to learn new things, and books present, at least to me, and ideal package.  Having said that, you can imagine I get pretty excited when there is a book sale; especially when the discount exceeds 30%.

I'm normally a Borders fan, however Bookpool is having a sale on many new Apress books, all discounted at 45% or more.

I personally recommend the book entitled "Pro C# 2008 and the .NET 3.5 Platform (4th Edition)" by Andrew Troelsen.  The very first edition (based on .NET 1.0 beta) introduced me to .NET.  Since then, this book has grown to include new framework and language features all the way up to .NET 3.5 and C# 3.0 (2008).


Tags:   ,
Categories:   .NET | Programming
Actions:   E-mail | | Permalink | Comments (1) | Comment RSSRSS comment feed

IEnlistmentNotification: Implementation Nuances

Friday, 20 June 2008 11:15 by jordan.terrell

I am a big fan of System.Transactions.  It is by far one of the coolest additions to the .NET framework.  It was what introduced me to the power of ThreadStatic variables (use with caution).

Since being introduced to System.Transactions, I've been using it to create transactional business objects (volatile resources in System.Transactions lingo).  This has worked very well for me, however, I recently (read: in the past two weeks) discovered some nuances in implementing IEnlistmentNotification that might not be readily obvious or documented (as far as I could tell).

Nuance 1: Do not throw exceptions from the Prepare(PreparingEnlistment pe) method

If you need to indicate that your resource cannot prepare for the transaction to complete, you must call the ForceRollback(...) method on the PreparingEnlistment object passed into your implementation of Prepare().  If you want to include additional information on why your resource was unable to prepare for the transaction to complete, there is an overload of ForceRollback() that accepts an object that derives from System.Exception.  Once all resources have rolled back, the System.Transactions infrastructure will throw a TransactionAbortedException.  Any custom exception that you've provided to the ForceRollback() method will surface as the InnerException on the TransactionAbortedException thrown by the System.Transactions infrastructure.

You should NOT throw an exception from Prepare(), and you should wrap all code within the Prepare() method with a try/catch block - the catch block should catch all exceptions and pass them on via the ForceRollback() method.  Throwing an exception from Prepare() (or allowing one to bubble up thru Prepare()) will short-circuit the System.Transactions infrastructure from calling Rollback() on enlisted resources - not something you want to happen.

Nuance 2: Rollback() is not called on your resource if Prepare() votes to rollback

If you call ForceRollback() within your implementation of the Prepare() method, the Rollback() method will not be called on your resource.  Any clean up that typically occurs in Rollback() will need to occur within Prepare() IF your Prepare() method votes to rollback.  For example, if your Prepare() method acquired any locks (e.g. "row locks", "table locks", etcetera) you will likely want to release them in the Prepare() method right before you vote to rollback.

Moving Forward

I hope that this is useful to you - I haven't seen this behavior documented anywhere, but that could be my own fault.

I have no doubt that I will find additional implementation nuances when it comes to System.Transactions.  When I do, I'll be sure to document them here.


I'm Going To The PDC!!!

Monday, 16 June 2008 09:27 by jordan.terrell

I can't wait to see what Microsoft has cooking now!  The 2005 PDC was great because of all the LINQ-related language enhancements and WinFX content.  I'll keep you posted.



Categories:   .NET | Programming
Actions:   E-mail | | Permalink | Comments (0) | Comment RSSRSS comment feed

iSynaptic.Commons - Almost There

Wednesday, 16 April 2008 09:47 by jordan.terrell

This last weekend I hit 90% code coverage, so I'm about ready to release.  I need to update the build script to include headers at the top of the .cs files, and include the license (Artistic License 2.0) text in the distributable.  Once that's done, I will release a Community Tech Preview (CTP).

Stay tuned...

Categories:   .NET | Programming
Actions:   E-mail | | Permalink | Comments (0) | Comment RSSRSS comment feed

Book Titles

Friday, 14 March 2008 12:32 by jordan.terrell

I was reading some blog posts and I came across this one.  I really appreciate the fact that David Hayden takes the time to do these reviews - I find them very helpful, and I hope someday to follow his good example and review some books myself.

However, I have a fundamental issue with the book that was reviewed.  Well, maybe not so much the book as it is the title of the book:

Beginning C# 2008 Databases?  I didn't know the C# language had databases in it!

I'm sorry but that is just a horrible title.  Something like "ADO.NET using C# 2008" or "ADO.NET 3.5, with Examples in C# 2008" would have have been so much better.

Yes, I know - I'm being a nitpicker - but for good reason.  For example, the book "Enterprise Patterns and MDA" - absolutely an awesome book - horrible title.  I don't really know what to expect to find in that book from the title - but having read an interview of its author, I knew it was worth looking at.

Take away point:  Please, if you are going to write a book, give it a good, meaningful name!

Categories:   General | Programming
Actions:   E-mail | | Permalink | Comments (0) | Comment RSSRSS comment feed

Security Issues with Reflection.Emit

Thursday, 6 March 2008 11:41 by jordan.terrell

I was thinking through the Code Access Security (CAS) ramifications of my Cloneable<T> class, and stumbled upon a pretty useful article in the MSDN library.  It makes it clear what permissions are needed for various Reflection.Emit scenarios.

I'm sure I have more testing to do in order to find which scenarios cannot use Cloneable<T>, but I'm hoping that list is a short one.

Language Oriented Programming

Tuesday, 26 February 2008 10:05 by jordan.terrell

Unless you've been hiding under a rock inside of a cave in the middle of the desert without an Internet connection, you have undoubtedly noticed that Microsoft and other vendors are hard at work developing new and updated languages that target the .NET runtime (there are also new languages targeting native code), and the upcoming Dynamic Language Runtime, or DLR.

Here is just a few (this list just scratches the surface):

All of these seem to have surfaced within the last few years, and there appears to be added emphasis to new language concepts and languages.  If we look at the history of software development and the eras, if you will, that it has gone through, you'll see three eras that are quite prominent:

  1. Object Oriented Programming
  2. Component Oriented Programming
  3. Service Oriented Programming (or SOA)

The last one, Service Oriented Programming seems to have become fully adopted into the development culture.  There are many toolkits and frameworks that allows one to build and consume services in multiple development platforms.

With this broad acceptance of Service Oriented Programming, I'm thinking that we are beginning the next era of advancement in software development: Language Oriented Programming.  I think this is a great move by the industry and as a result I feel we will see some really expressive horizontal (general purpose) and vertical (domain specific) languages come from this shift.

However, as it was with the adoption of Object Oriented Programming, I think there is going to be a significant learning curve for many of the developers out there.  Just look at the changes to C# and VB - the addition of functional and query (set algebra) programming concepts, although very powerful (and in my personal opinion very welcomed), they present a huge learning curve to those who are more junior in their understanding of languages and software development concepts.  Those of us who "grok" it, I think now have the responsibility to train as best as we can developers who are new to all these dynamic and functional language concepts.  We need to do our best to encourage them to learn about these changes.  But, even more so, all self-proclaimed software developers need to take (at least some) time to learn about these changes and their underlying concepts - because like it or not, they are coming.

Okay, I'll get off my soap box now.  As you may have noticed in one of my recent posts, I'm working on understanding compilers and languages.  This has been an enjoyable process.  I'm reading two books to help me do this:

I've stayed away from books that are too specific or narrowly focused.  I want to get a well-rounded understanding of language and compiler design and implementation concepts, without confining it to a specific platform.

If anyone has suggestions on resources that I should check out - please do let me know!

iSynaptic.Commons - Update

Monday, 25 February 2008 11:13 by jordan.terrell

I'm learning the hard way that I should take my own advice when it comes to developing personal projects.  As a professional software consultant, I'm very consistent about writing unit tests for my production code, if not first, very shortly after (within the hour).  I've heard many a developer say "I'm busy right now, I'll come back and write those tests later."  Yeah  --  it almost never happens.

So what did I do with my Commons library?  Wrote a whole bunch of code without tests!  Now I'm paying for it - I can't bring myself to release the library without more code coverage.  Right now I'm sitting at 81% code coverage, and I'm so glad that I'm working through the tests because they have exposed a few bugs.

Let this be a lesson (mostly for myself) - don't write code without tests, even if it is for your own homegrown pet project!

Categories:   Programming
Actions:   E-mail | | Permalink | Comments (1) | Comment RSSRSS comment feed