Oren Eini

CEO of RavenDB

a NoSQL Open Source Document Database

Get in touch with me:

[email protected] +972 52-548-6969

Posts: 7,527
|
Comments: 51,163
Privacy Policy · Terms
filter by tags archive
time to read 2 min | 305 words

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.

time to read 3 min | 530 words

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.

time to read 1 min | 104 words

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.

time to read 2 min | 386 words

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.

time to read 4 min | 601 words

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>

time to read 2 min | 340 words

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. RavenDB Cloud (2):
    26 Nov 2024 - Auto scaling
  2. Challenge (75):
    01 Jul 2024 - Efficient snapshotable state
  3. Recording (14):
    19 Jun 2024 - Building a Database Engine in C# & .NET
  4. re (33):
    28 May 2024 - Secure Drop protocol
  5. Meta Blog (2):
    23 Jan 2024 - I'm a JS Developer now
View all series

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats
}