Ayende @ Rahien

Hi!
My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:

ayende@ayende.com

+972 52-548-6969

, @ Q c

Posts: 5,972 | Comments: 44,518

filter by tags archive

Rhino Mocks 2.8.1


Well, it looks like I’m back to making daily releases of Rhino Mocks. Royston Shufflebotham has been bombarding me with patches, this new releases contains:

  • A lot more overloads for multi mocks, including the ability to use multi mocks with partial mocks and being able to creates multi mocks with constructor arguments.
  • Can now call CallOriginalMethod() from LastCall as well as Expect.
  • A way to disambiguate between properties with the same name from different interfaces with constraints.
  • Some better debug information for those of us who debug Rhino Mocks.

A big thanks to Royston, who has been doing a lot lately to give Rhino Mocks even more great capabilities. Source and binaries are in the usual place.

Rhino Mocks Tidbits


About ten months ago I managed to put Rhino Mocks (version 2.3.3) at 100% testability. That was the last time that I checked this, and since them I had many releases.

I checked it today, out of curiosity if nothing else, and I was surprised to discover that I still got an absurdly high level of tested code, 95% of Rhino Mocks are tested. The rest of the 5% are utility methods and the like, which I’m not going to worry much about.

The last change I did involved changing the way Rhino Mocks created mocks. This is about as important a change as you can make. This amount of testing gives me the ability to make a significant change to Rhino Mocks and still be certain that I am not breaking anything when I do it.

Breaking Changes – How?


I need to make a radical change to an application. This change is basically ripping apart a major piece of the infrastructure and replacing it with another piece, which has a different API, usage and capabilities.

I’m currently thinking about how I should do it. I got tests for the code, of course, but I don’t know how I can move it to the other infrastructure with the tests intact. My worry is that I can make the move, and then break each and every tests that relies on the infrastructure to exists (~140 tests, I think). This is a big problem because I will need to change both tests and code just in order to get the code to compile again.

I’m not going to remove the tests, since they test functionality that is needed for the application, so at the end of the conversion, I know that I am at the same point that I was before I started all of this.

If anyone has any ideas, I would love to hear them.

Evaluating Enterprise Library 2.0


Because, I didn’t have an inflammatory post in nearly two days, and I’m feeling faint

Anyway, I’m working at the moment at a highly Microsoft focused client. Which means that they consider the Enterprise library as Mana From Heaven. This forced me to raise from my own pile of tools and take a look at the Enterprise Library.

I can’t say that I am overly impressed. Here is my quick summary:

Name

Opinion

Configuration

Not sure why we will need this now. There are strongly typed accessors for configuration, and they are flexible enough to do whatever I need. If I need to pull the configuration out of the database, I can do this in one line of code (using Active Record).

If I need to do complex configuration, including object graphs, I will either use a data base and Active Record, which make it a breeze, XML Serialization or just rethink what I’m trying to do.

For me, all those lengthy configuration files are death-by-XML.

Instrumentation

They mention event log, performance counters and WMI events. I’m not sure why the event log is in instrumentation, and I’m clueless with regard to WMI events, but why do we need another layer on top of performance counters?

I just did a project that required some heavy use of performance counters, and the API couldn’t really be simpler.

Object Builder

There is something very wrong in Microsoft building their own IoC container.

The Object Builder looks like a reasonable implementation of Dependency Injection and Inversion of Control container, but I don’t see any reason to use it except that it got “Microsoft” in its name.

Logging

Again, I have a problem with this, mainly because of log4net. It was there first, after all. Why do the same thing again?

Data Access

I got NHibernate, enough said

This looks like a whole lot of work to get what I have seen Oren Ellenbogen do in about five minutes and 15 LoC using delegates.

Exception Management

This one I like in concept, but not in practice. The problem that I have with this is code such as this: “if(ExceptionPolicy.HandleException(ex,”Foo”)) throw;” This presume that under some circumstance I will want to swallow an exception. This kind of stuff gives me ticks. You have no idea how big a bug-fest can get when such a thing is happening. Errors are vanished into the night, and so is sanity, soon after.

What is interesting about the exception handling is that it supposed to prevent you from leaking sensitive data to remote callers on error conditions. It is a notable goal, I just got a design problem with solving the problem this way.

Depending on the application, I would either hook an OnError event (ASP.Net) or provide a service decorator that handles this (web services / Remoting).

Beyond that, I suspect everything that has boilerplate code in it.

The real problem is that all the things that it is trying to achieve are not something that could change safely without affecting all calling code.

Caching

This one looks cool. A durable cache that survives application restarts is something very interesting. Of the top of my head, the only kind of applications that I would use this is for partially connected applications, like smart clients, etc. A cache is something that takes care & feeding, not something that you can just use without thinking about.

(Cache invalidation policies, for instance. Concurrency issues, etc. )

I would generally not bother with those issues unless I had a partially connectivity scenarios.

Cryptography

Um, why? None of the services that they offer can’t already be had from the framework in five lines of code tops.

Security

It looks nice, but I don’t know enough on the subject to talk.

 

One thing that annoys me about the Enterprise Library is that at least two of the core components are duplication of outside effort. I can think of at least two well known logging framework for .Net (log4net & NLog ), both of which existed before the Logging Application Block saw the light of day. I can’t think of all the IoC containers for .Net, and that is because there are so many of them.

I got an issue with this because it creates an artificial segmentation of the tools. As far as I can say, those tools were not created because of some need that Microsoft could not meet using the open source equivalents. Nor because of some licensing issues (like NAnt / MSBuild) since most of the IoC containers for .Net as well as log4net are free for the taking. Including for commercial use.

Rhino Mocks 2.8 Released – Multi Mocks


I said it before, but I just have to say it again. It is a big mistake to release software. Any time that I do it, I need to make a new release soon after. (And no, not a bug fix release {usually} ).

Yet I did make the mistake of releasing the most dangerous software of them all, Rhino Mocks. The moment I do something to this beast, a new feature request come up. The problem is that I’m a sucker for frequent releases, I just can’t help implement features and ship them.

This release brings one major feature to the table, Multi Mocks. What is a Multi Mock?

A Multi Mock is a mock object that implements several interfaces. For instance, you may want to test this code:

public void CleanCollection(CollectionBase collection)

{

collection.Clear();

IDisposable disposable = collection as IDisposable;

if(disposable!=null)

disposable.Dispose();

}

 

As you can see, we accept a collection, and we make sure to dispose of it if it is disposable. CollectionBase does not implements IDisposable, so this would usually force us to create a dummy class to make the MockRepository think that we need all those interfaces.

Instead, we can now do this:

[Test]

public void ClearCollectionAndDisposesIt()

{

MockRepository mocks = new MockRepository();

CollectionBase collection = (CollectionBase)mocks.CreateMultiMock(        typeof (CollectionBase), typeof (IDisposable));

collection.Clear();

((IDisposable)collection).Dispose();

 

mocks.ReplayAll();

CleanCollection(collection);

mocks.VerifyAll();

}

 

There is also a DynamicMultiMock, with the same behavior. The functionality exists with generic overloads for 2.0, of course. Oh, I also added AtLeastOnce to the default options for repeating. I was asked to do this a long time ago, and I just forgot.

You can read the feature request here. This is also very useful in Remoting scenarios.

By my calculations, it is less than 6 hours from the feature request to shipping a well tested version out the door. Take that, Test Driven Development naysayers! As usual, you can get both binaries and source here.

Thanks against for Royston Shufflebotham for presenting such a clear need.

NHibernate and XML Column Types


One of the reason that I like NHibernate so much is that it is so extensible. It took me about half an hour to allow NHibernate to understand that an XML column is a XmlDocument, and I didn’t have to use any tricks. It was very easy to do, which says quite a lot about NHibernate. Less than 30 lines of code, at the end.

The nice thing is that I am not limited to converting Xml to XmlDocument, I can very well use Xml Serialization for objects, and store them as XML in the database. There are some scenarios where this is useful, like extended properties, etc.

The scary thing is that I can feel someone in the back of my head implementing the architecture for a full blown IoC framework on top of this ability and SQL Server’ XML column type.

I put the code here.

NHibernate Generics 1.0.9


Okay, this release is to make a small fix that affected only people who were using NHibernate Generics and web services.

I’m not sure what the problem was, but I’m pretty sure that I fixed it.

If you got an error like “You must implement a default accessor on EntitySet<> because it

inherits from ICollection.”, you probably want to give it a try.

Source and binaries are here, as usual. There is a download already, and I just put it up there and in the process of writing this post, so hurry up before it runs out.

 

The Future of NHibernate.Generics

NHibernate.Generics was meant to provide a way to use generics with NHibernate, and along the way I put some smarts into the collections, which allows me to relax with regard to maintaining references between associated objects.

Now, NHibernate has a 1.2 alpha release that include generics, as well as some extensions to the collection model, which will make the work of integrating with NHibernate easier.

At the moment, I’m not sure about the status of NHibernate.Generics when version 1.2 of NHibernate is released. It is probable that I will modify the library in a breaking manner in order to make it work better with the new release. Not sure about anything yet, of course.

So, what is up with the name?


Some people are confused by the nickname that I use on the web, and I thought that I would explain what it is all about.

About six or seven years ago, I was really big Wheel of Time fan (and still am). The name Ayende Rahien comes from this series. The literal translation is “dawn of freedom”. Yes, it is silly, but in my defense, I was seventeen . I used the nickname for all my online activities, up to and including my computer’s username.

Fast forward to the beginning 2004, I was using the name Ayende Rahien so long that it became automatic. When I opened a site, it was natural to use this name. Another reason was that at the time I was at the army, and I didn’t know (nor do I know now) what is the army’s stance with regard to blogging. I know of at least one case of a soldier getting into trouble for posting a review about a TV Show in his blog.

At the moment, I got another reason to use this name. Ayende is not common, Oren is. I got a friend who tells me that there are four Oren in his team. I once checked, and at Israel alone, there are over 8,000 people with this name. There are also six or seven guys named “Oren Eini”.

The end result is that searching for Ayende will bring you to my blog, which is not something that I have been able to do had I been using my real name, which is far too common.

Rhino Mocks 2.7.2


I just got a really nice patch for Rhino Mocks from Royston Shufflebotham, which include the following new constraints:

Is.Same() constraint, when you need to do reference equality and not just equality.

Property.ValueConstraint() which allows you to specify constraints on a property value, like this:Property.Value( "X", 5 ) & Property.ValueConstraint( "Y", Text.Contains( "foo" )&!Text.Contains("bar"))

The nice thing about it is that you can chain Propety.ValueConstraint() to check an object two level deep (or more, of course).

I would like to thank to Royston for the patch, it was very well done.

As usual, you can get the source and binaries here.

Outlook’ RSS not so good


Here is an interesting observation. In most products that I beta test, there is usually Help > Report Bug / Send Feedback right there in the application.

For Microsoft applications, there never seem to be such an easy way to report bugs. And here I thought that the purpose of betas was to find bugs. I got at least three right now that I am not going to go out of my way to report because it is too hard.

After the annoyances that I detailed before, I made a concentrated effort to use Outlook at my RSS Reader, but I just don’t see it happening.

There seem to be a lot of annoying bugs there, and not a lot to suggest that it is worth taking the time to adjust. One really annoying bug is that there is no way to centrally manage all the feeds in outlook. This means, I can click this, that and that and delete them.

I had to manually delete 300 feeds. I got too many feeds that start with “T”, I can tell you that.

FUTURE POSTS

  1. Reducing parsing costs in RavenDB - 14 hours from now

There are posts all the way to Aug 04, 2015

RECENT SERIES

  1. Production postmortem (5):
    29 Jul 2015 - The evil licensing code
  2. Career planning (6):
    24 Jul 2015 - The immortal choices aren't
  3. API Design (7):
    20 Jul 2015 - We’ll let the users sort it out
  4. What is new in RavenDB 3.5 (3):
    15 Jul 2015 - Exploring data in the dark
  5. The RavenDB Comic Strip (3):
    28 May 2015 - Part III – High availability & sleeping soundly
View all series

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats