Ayende @ Rahien

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

ayende@ayende.com

@

Posts: 5,949 | Comments: 44,547

filter by tags archive

Disconnected Mode Change Tracking


There is some interesting discussion going on right now about dealing with change tracking in disconnected mode. The whole discussion started when Andres complained that this making writing diconnected updates much harder than it should. You can check the links to see the whole discussion, what I am interested at is Udi's second reply, in which he suggest doing something like this:

void IBus.Send(params IMessage[] messages);

With the client code looking like this:

myBus.Send(addOrderLineMsg, delOrderLineMsg);

I am not sure that I agree with the choice of names (specifically, IMessage to me in an infrastructure level idea, IOrderMessage is something that would have a meaningful business sense), but I really like the idea. Then I started to think about it. Sending the server a bunch of changes, so it could execute them in a single transaction, thus reducing the chattiness of the conversation, I am pretty sure that I heard it before. Indeed, it is my favoriate pattern, Unit Of Work, expanded to include a multi layered, service based architecture. 

I really like this approach.

ASP.Net WTF?! (sorry, blog was down)


All of a sudden, I get an email telling me that my blog is down. I go and check it out, and it is indeed down. With the following error message.

Server Error in '/Blog' Application.


Could not load file or assembly 'App_Web_g5ujsn49, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'App_Web_g5ujsn49, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

I tried restarting the appication by renaming web.config, but it didn't work. The only thing that worked was changing the compilation debug mode from false to true, and then to false again.

Search for the error brought this post, and it looks like there my be a hotfix avialable.  The problem is that my scenario doesn't match the conditions on the hotfix, so I really don't know what to think. I am going to ping my host and check if there is anything that can cause file locks on the server (anti virus, indexing service, etc), although I would have expect this kind of error to occur much earlier if that was the case.

WantedMethodMissing


I am listening to this webcast, talking about dynamic dispatch on the JVM, and 19:30 it starts to get really interesting. The JVM is getting support for MethodMissing. As far as I understand, this is most relevant for compiler writers, but it is something that I really would like to have on the CLR (and exposed for C# & VB).

The reason for wanting this is very simple, it lets me handle advance scenarios very easily. Take a look at Boo's duck typing capabilities to see some of the stuff that can be done with it.

The missing Linq: Stateful extentions methods


It seems to me that right now there is a lot of exploring going on with extention methods. People are doing some really cool stuff with them.

What I am afraid of is that this exploration is going to hit glass wall the moment people are going to try to do the interesting stuff with them. The reason for this is that beyond the simplest cases, I would really want to have some sort of a state between method calls.

Here is a code sample that demonstrate the issue:

object myRandomObj = new object();
myRandomObject.Tag("Linq ExtentionMethods");
myRandomObject.GetTags();

Tag() and GetTags() are extention methods. The problem is that as it stands now, there isn't really a way to implement this functionality using Linq. You need to keep the tags associated with the object, which usually means that you will use a hash table. This seems like a solution, but it runs into the issue of breaking the GC, since I would like to have the state freed by the GC when the object goes out of scope.

Hashtable based on WeakReference are one solution to this, but this is quite a bit more complex than it sounds, and you needs to scavengar that table every now and then, which means that you can either suffer wasted memory(bad) or have a separate thread that will clean the table (bad).

I can see two solutions to this problem. Either adding another field to System.Object "IDictionary ExtendedProperties" or supplying a weak hashtable implementation that ties into the GC in the same manner that WeakReference is there. The first solution is the simplest, but it is tying object into IDictionary, as well as increasing the size of System.Object significantly. The second solution is more complex, but it is much prefered, since it doesn't affect anything else. 

The problem is that both of those requires support at the framework level, it is not something that can be done externally.

MonoRail With SubSonic


In the Castle forums, it was asked if it is possible to use SubSonic as the DAL for a MonoRail application. The answer is absolutely yes.

You will usually see MonoRail samples with either Active Record or NHibernate, simply beacuse this is what most of the users of MonoRail are using, but MonoRail has no data access preference. (There are extention to MonoRail that make it work better with Active Record and NHibernate, but those are just that, extentions, the core is completely data layer agnostic).

So, how would you go about using SubSonic with MonoRail?

Here is the controller:

public class ProductsController
{
 public void List()
 {
  ProductCollection products = new ProductCollection();
  products.Load(); 
  PropertyBag["products] = products;
 }
}

And here is the view:

<ul>

<% for product in products: %>

<li> ${product.Name} </li>

<% end %>

</ul>

Query Objects vs. Methods On The Repository


Udi Dahan is talking about Query Objects vs. Methods On The Repository and raises some interesting ideas.

I am somewhere in the middle, since I am doing almost all queries directly on the repository, but I am passing it a query object. The main idea is that I don't really deal with the query object, it just happens behind the scenes:

return Repository<Customer>.FindAll( Where.Customer.City == "London" );

One important case for query objects is when you have complex searching, as I said, Querying is a Business Concern. The traditional case is for a search screen, where you may have several dozens criteria (and I don't kid about the several dozens) that you need to search for. But there are many cases where in order to perform a business operation, you need to perform a non trivial query. Those are often dynamic queries, changing according to business logic and the state of the moon.

In those cases, I generally tend to separate those out into explicit query objects, using [UseCaseName]Finder, which can then be use:

CustomersInDebtFinder finder= new CustomersInDebtFinder( CurrentEmployee )
     .DebtIsLessThan(CurrentEmployee.MaxDebtAllowedToHandle)
     .DebtIsOverDueAt( AppContext.CurrentApplicationDate );
if(CurrentEmployee.IsManager && shouldShowSubordinateItems )
    finder.FindCustomersWithDebtOverSubordinatesMaxDebt( CurrentEmployee );
return finder.Find();

The mechanics of the query is fairly complex, and a query object allows me to express them in a way that is much more intent revealing.

FUTURE POSTS

No future posts left, oh my!

RECENT SERIES

  1. The RavenDB Comic Strip (3):
    28 May 2015 - Part III – High availability & sleeping soundly
  2. Special Offer (2):
    27 May 2015 - 29% discount for all our products
  3. RavenDB Sharding (3):
    22 May 2015 - Adding a new shard to an existing cluster, splitting the shard
  4. Challenge (45):
    28 Apr 2015 - What is the meaning of this change?
  5. Interview question (2):
    30 Mar 2015 - fix the index
View all series

RECENT COMMENTS

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats