Ayende @ Rahien

It's a girl

Phone shots

I just discovered the usb cable that allows me to connect the cellular phone to the computer, so I am going through the pictures I have taken. The end result is that I am about to subject you to several pictures I have taken in the last six months or so.

 From the Agile FDD Talk

CowShot.png

I assume that I am Herd because "I am legion" :-) This gets really funny when taken out of context.

From the store

LiverDeath.png

Click on the link to see, it is a Tube of Vodka. Instant Liven Transplant is required after consuming this.

From Microsoft

MsBob.png

Do you need an introduction?

Back from the Microsoft Developers Academy

I gave my IoC talk, and I got some good feedback. I have a hard time evaluating myself in this matter, there was a lot more power point that I usually like, and not enough code. I did get some involvement from the crowd, including some fairly interesting quetsions. I'll wait to get the official feedbacks.

I also took part in a couple of panels, and just because I could, some OSS work when I had free time. I liked the irony :-).

I'm dead tired, so this is probably going to be it today, to everyone that mailed me with patches, bugs, etc. I saw it, but I probably won't respond until the weekend.

 

Tags:

Published at

Is Linq For Mortals?

Mike Taulty has posted about Linq syntax, at the end, he shows a simple way to do joins and then aggregation between two collections. The code looks like this:

var a = products.Join(
      
sales,
        p => p.Id,
        s => s.ProductId,
      (p,s) => new { Country=s.Country, Sales=s.Sales, Product=p.Name })
.GroupBy( p => new { p.Country, p.Product })
.Select( gp => new { gp.Key, TotalSales = gp.Sum(s => s.Sales) });

I am sorry, but I cant read this. I can't even understand what this is meant to do. Now, I am the first to admit that my knowledge of Linq is weak at best, but still... Assume that I have a bug in such a code, how do I debug it?

That is a much bigger concern to me, I am not worried about learning the new stuff, I am worried about what I need to do when they break. I have some experiance in debugging applications via Reflector, and that is not nice. Especially if the compiler is doing funky magic and you are left reading the IL.

NHibernate In Action

Looks like Ben Scheirman have found the big secret.

Just one question, what is this picture or?

Aside from that, I can say that Hibernate in Action is a the best for anyone developing NHibernate. With the advent of NHibernate in Action, it is going to be even easier (no need to mentally translate from Java and EJBs anymore).

I am looking forward to July 1th, when this book is coming out.

Coding Metrics

Take a look at those:

Castle: (removed image)

Rhino Tools: (removed image)

I run Ohloh before, but this time it is for my own stuff, and it looks like my Rhino Tools projects is over 70,000 Lines of code, and is worth close to 1 million dollars. I find it interesting that it is valued at 17 man years, though :-)

If you can't see the metrics below, your client doesn't allow javascript, go to the website and you'll be able to see them.

Microsoft Academy Insights

Since I am giving a talk, I also have access to all the presentations ahead of time, and I spent some time going through them. Some people has clearly spent a lot of time trying to turn Power Point into Maya 3D. Anyway, I am seeing some really cool stuff there, things that make me want to start coding.

I am giving a talk and participating in two panels, so I probably won't be able to see the talks (will have to wait for the videos), but it certainly makes sure that I would need some spare time after this is over to go over some of those talks.

Tags:

Published at

The Zen Of Python

I opened the python shell and entered "import this", here is what came out:

The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

I like it. ;-)

My Debugger is Broken

I started to get errors like this recently, and the whole debugging experiance has gone to the toilet ever since.

DebuggerBroken.png

Specifically, it looks like it is not able to do break on exception now. And I can't figure out what it the issue. It happens just when I am using TestDriven.Net, and not when I am attach to a different process. Right now it seems to have fixed itself, but it drove me mad.

Googling doesn't find anything useful :-(

Tags:

Published at

On Hiring Bloggers and Open Source Developers

Phil Haack has a post On Hiring Bloggers and Open Source Developers. I guess that I have no choice but to +1.

And if you get the joke, I would like to hire you.

In a recent inteview I had a candidate that had serious issues with:

  • Writing an INSERT statement
  • Reversing a string
  • Searching google*

* That is a skill that you need to have. If you are searching for Reversing a String in C# and you manages to go to the only example I C in the page, that is a major minor point.

Tags:

Published at

From SQLite to SQL Server Compact Edition

I am giving up on SQLite as my embedded DB of choice. The reason for this is very simple. I really want to be able to use the in memory features (and other nice stuff it has to offer), but it has the worst support for date/time manipulations that I have seen. I am trying to formulate a query that should be along the lines of:

select  *

from    blogs,

        posts

where   posts.blogId = blogs.id

        and ( posts.date + blogs.maxDaysInFeed ) <= getdate() ;

As much as I dislike dates, I tend to work with them in complex ways quite a bit, and I really need a database that can work with me in this regard. I just finished moving my in memory infrastructure to using SQL Server Compact Edition. This means that my tests will have to touch the disk, but I am willing to make this compromise.

In favor of Sql CE are the following:

  • Embedded DB, so it is faster (nor RPC call)
  • It has a behavior that is very similar to SQL Server, so I can test on Sql CE and then move to use SQL Server with worrying about the differences.
  • I can use Management Studio to query it! Killer feature to say the least.

 

Can Microsoft's Developer Division Compete?

Mike Schinkel has a couple of posts about Microsoft development division that makes for an interesting read:

Be sure to check the comments, Eric Lippert has responded with some very interesting insight. And there is some very interesting discussion beyond that.

My own comment to that is that OSS projects has far less cost of change than most commercial projects. They are structured to enable change (otherwise they die), most commerical projects require a lot of extra baggage to move. If we will take NHibernate vs. the ADO.Net Entity Framework, I can make a change in NHibernate and not consider the affect it will be on the UI that Visual Studio needs to present to the user. Just this can make a world of difference in my ability to add features or fix bugs.

 

Castle Igloo

Castle Igloo (ppt) is a very interesting experiment in bringing more MVC goodness into the WebForms. I have to say that when I dove into the code, the ideas that Gilles Bayon (no blog :-( ) had there blew my mind away. I always believed that trying to do MVC in ASP.Net was possible, but fairly awkward.

My main issue with this was always that I always had to do extra work in both the view and the controller in order to make this work, and I never felt that I really got the flexibility that I can get in MonoRail. Here is an implementation of MVP from Phil Haack, as an example. The problem here is that I still have the following problems:

  • I need to define an interface for the view, which will likely contains a lot of data passing parameters.
  • My controller is dependant of that interface, if I want to test that, I need to mock/fake the interface before I can use it, not a big deal, but not as trivial as just dowing new MyController() in the test.
  • My view implementation is dependant on the controller, and is actually responsible for creating it.

I may be spoiled by the pure MVC that I can get in MonoRail, but I really want that back. As I said, I didn't believe that I could get nearly the same experiance, but Gilles has proven me wrong. [Forehead still hurting from that smack]. You can get the code here, I suggest taking a look and seeing what is in there.

Here is a small part of the controller:

public class PatientController : BaseController

{

 

    [Inject(Name = "doctor")]

    public Doctor Doctor

    {

        set { _doctor = value; }

    }

 

    [Inject]

    public IList<Patient> Patients

    {

        set { _patients = value; }

    }

}

And another small part of the view the view:

public partial class Index : Page

{

    [Inject]

    public IList<Patient> Patients

    {

        set { _patients = value; }

    }

}

Notice that the controller doesn't care about the view at all. How does it works? Well, there is some magic behind the scenes, but basically, the controller can register an object in a registry, and when it is done, that object is populated to the view transperantly. Here is the method on the controller that gets the list of patients.

public virtual IList<Patient> RetrievePatients()

{

    IList<Patient> patients = _patientService.RetrievePatients(Doctor);

 

    Scope["Patients"] = patients;

 

    return patients;

}

The view can either call this directly, or rely on getting the value from the scope:

protected void Page_Load(object sender, EventArgs e)

{

     if (!IsPostBack)

     {

            GridViewBlog.DataSource = PatientController.RetrievePatients();

            GridViewBlog.DataBind();

     }

     else

     {

            GridViewBlog.DataSource = Patients;

            GridViewBlog.DataBind();

     }

}

In the second case, we got the value from the scope automatically.

What we gained:

  • No need to define an interface for the view.
  • Controller completely seperated from the view, easier testability.
  • The view is still tied to the controller (since it needs to let it know about things such as button clicks, etc), but trying to avoid that is something that isn't really possible with WebForms (but you are welcome to prove me wrong).
  • Strongly typed support for passing items from controller to view :-)

I fear that I am not really doing much justice to Igloo, mainly because I am still in the process of grokking it. There are still several things there that I need to figure out. There is an automatic navigation part that I am doubtful about (I don't see the usecase, actually). I think that I will try and get a small sample with just the bijection support (the automatic injection and outjection of properties from both controller and view), just to see how I can make this work.

FeedDemon? +1

I am moving from RssBandit, mainly because the new UI really annoys me now. It doesn't respond properly to scrolling, and other minor annoyances. The big thing is that it has start to consume way more CPU than it should.

I installed Omea Reader for a while, and while I really like it, I keep getting the same old items in many feeds. I am not quite sure why. I also have problems with defining newspaper view vs. normal view, and it rememberring a post that I read three days ago and keep returning to that in a feed that is constantly refreshing. To summarize, Omea Reader doesn't work the way I expect it to, I find it to be very polished, but I am pretty set in the way that I read RSS, and I couldn't figure out how to configure it the way I wanted.

I am testing FeedDemon at the moment, and after a few hours where I had the same feeling of "but I don't want it to work like this", I am starting to get used to it. Just the usage stats alone are looking like a killer feature for me. Why am I posting this?

FeedDemon just made me smile, and that means that it is 99% a keeper. It made me smile by doing what I expected it to do, and doing it in a nice way. I like it.

From the IM logs

After the fact, I think it is funny:

Ayende Rahien says:

 Real development for me means that I can use .Net
Ayende Rahien says:
 
And that means that I got to have R#,
Ayende Rahien says:
 
that means that I got to have VS.Net
Ayende Rahien says:
 
:-(

JetBrains, can we please get an IDE from you?

How much a hypothesis weight?

Well, roughly 6Gb. That is the download that I had to go through to get Orcas. And I am not even that interested in Orcas itself at the moment. I just want to test a crazy idea that I had.

At any rate, I got the answer that I was looking for. The code below is not legal:

public class Foo
{
    [IsValid( x => x==null )]
    public string Name;
}
public class IsValidAttribute : Attribute
{
    public IsValidAttribute(Expression<StringPredicate> expr)
    {
    }
}

The errors are:

Error 1 The best overloaded method match for 'ConsoleApplication1.IsValidAttribute.IsValidAttribute(System.Linq.Expressions.Expression<ConsoleApplication1.StringPredicate>)' has some invalid arguments C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs 19 10 ConsoleApplication1

Error 2 Argument '1': cannot convert from 'lambda expression' to 'System.Linq.Expressions.Expression<ConsoleApplication1.StringPredicate>' C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs 19 19 ConsoleApplication1

:-( :-( :-( :-( :-( :-( :-( :-(

I was really hopeful this time, there isn't any technical reason why this can't be done. The compiler is going to turn the lambda expression into Expression<T> anyway, so it is certainly should be possible to take that and put it in the attribute declaration, thus satisfying the requirement that the values will always be constants.

This is actually harder than it seems, because it probably requires a change in the attributes spec, but I think that this is worth it.

At any rate, I opened up a suggestion at Connect, so please go and vote for it.

RML: Refactoring Modeling Language

I need to show an iterative apporach to a problem. How I move from a coupled design to a highly de-coupled design. I run into a problem when trying to show that. At the moment, all the tools that I have to visualize a system assume a static state. It is very difficult to try and explain a change in the system, because you have no way of doing this in a clean fashion. What I ended up doing was to create two diagrams of the systems and animate them, but that takes a lot of time and a lot of explaining when it goes on.

What I really would like to see is a way to show a diagram of a change in the system. This can be a refactoring, moving from one architecture to another, versioning, etc.

 

Tags:

Published at

The cost of clean sources

I just run Clean Sources on the two main directories I use for projects (Work and OSS). Running it on my Work projects gave me back 450Mb of space, and running it on my OSS projects gave me back over 900Mb. That is just removing the bin/obj/setup directories.

Talking in DevTeach

I am going to give several talks in DevTeach on May. The topics are:

  • Interaction based testing With Rhino Mocks
  • Rapid (maintainable) web development with MonoRail
  • Advanced usages of Inversion of Control containers

I am very excited about it.

The part that I really like is the "Advanced usages..." part of the last name. It means that I can assumes that you know what IoC is and I can blow their minds with the interesting stuff (Binsor, Auto Transaction, Bijection, AoP, Generic Specializing Decorators, Scoped Containers, etc). I am now working on a lecture about IoC for developers that doesn't neccesarily knows what it is, and I am frustrated that I can't get to the really cool stuff.

Cruel And Unusual Punishment (or, how I Practice)

I was working on the talk I am going to give in the Microsoft Academy next week, and I really needed to practice saying everything. I quickly gathered some family memebers and subjected them to a high level lecture of IoC. Interesting what you can learn from the amount of glazing in their eyes. :-)

I did the same to some co-workers today, and got even more good feedback (the best piece of advice was from our QA guy, which is certainly not the target audiance). I am starting to get a good feeling about this lecture, even though it is going to be very different from the one I did about Active Record.

That one was basically all code, with a presentation there just to keep me from shooting off in some obscure directions and getting all excited that [HasManyAndBelongToMany] can now do a better job inferring what I mean. This is a more of an overview of the pattern and what advantages it can give me (I have to assume that a significant part of the audiance will be facing this concepts for the first time).

All the ways to beat a dead horse

This had be laughing out load:

In business we often try other strategies with dead horses, including the
following:

Buying a stronger whip.

Read the rest, it is funny.

Tags:

Published at

Code Review Tools

I am searching for a tool to help with code reviews. This is something that is done after the fact, not before commits, by the way. Specifically, what I am thinking about is a tool that let me browse checkins into the source control, select one for review, add comments to it, etc.

I wrote the above sentence, and then went to Trac, and took a look at the Timeline view. It seems to be that this may be a way to do it, while handling the code reviews as tickets in Trac as well.

At any rate, I would like to be able to get a tool that says what has changed and needs reviews, or able to give me a diff over more than a single commit. I just thought of a new thing that I would like, something along the line of getting all the changes in this directory from last time that I reviewed it. I can get a diff from subversion, but attempting to understand something with just a diff is non trivial.

Any recommendatiosn about tools for doing this?

Tags:

Published at

Bum

That is what Microsoft thinks that I am ;-) Take a look at this horrifying video, detailing how I was reduced to begging in order to get to the event. At least I end up arriving in style :-)

At least I wasn't turtored, thrown off a plane, sent to space or Telenovelled.

Seriously, that is nearly 5 hours of my life, compressed into 40 seconds. For those of you who aren't Hebrew speaking, those are teaser videos for the Microsoft Academy Event at the end of the month.