Ayende @ Rahien

Unnatural acts on source code

On RYO vs. NIH

Bil Simser has stepped into the complexity debate with this post.

This is actually on the end of Bil's post, but it deserve a special mention:

As Jeremy put it, the P&P guys are a good thing as they're out there getting the Agile word out to many more people that we can.

In that, I haven't done justice to the P&P team. Introducing Agile methodologies and best practices is something that I am very passionate about, and I failed to give them their due credit about their efforts in this direction.

Oren's defense is around the fact that he (and Jeremy) follow the guideline of evolving a framework from your application needs, not building one (like what the P&P guys have done). Okay, that's fair but at some point you have to stop building things over and over again. So when does your own work become a framework that you reuse?

After you have built one application like this, you can extract the relevant parts into a "framework", although I am not sure that I like the term. The main difference being, again, that this is something that is driven by a developer seeking to make life eaiser, not by BDUF.

The end result is often a purpose fit framework that is very easy to work with, and doesn't require years of study.

Sure, you can put together the basic needs of an IoC in half a day (half a day Bil time, 40 minutes Oren time)

Not really, the basics are deceptively simple, but then you are going to hit a lot of issues with dependencies cycles, life time issues, etc.

I would argue that if you took something like StructureMap and evolved it to handle scenarios that you're not dealing with today, that you would be starting to build your own implementation of EntLib.

Not really, I would tend to use best-of-breed stuff that I would have available, it would cut the stuff that I would need to build by 60% at least. But I would not build the EntLib by any means, I may have components that have similar functionality, but in general, it would be a set of services, not a framework. Jeff Brown had a good post about the difference between the two.

EntLib and CAB do include everything and the kitchen sink and you do need to get past the learning curve, but in the end it's a good collection of tools that you can have in your toolbox.

The first part and last parts of the sentence conflict each other, fairly badly. If they are so complex, I would get much better ROI than rolling my own, or (more likely) reusing stuff already built that isn't so complex.

Unfortunately it's not something I could introduce at a conference or User Group session and describe the entire stack in an hour, so I tend to avoid showing off applications and concepts using it as it just turns into a discussion of what [SmartPart] means instead of the main goal like describing MVP which I can do with my own code.

Don't you think that this is an issue when you can't get the basic concepts of a framework in an hour without drowning in the details? Apples to oranges, but I can show a MonoRail application that has nothing but the basics, and talk about that and the concepts underlying that. If the technology is obstructing the end goal (creating maintianable applications), how is it useful?

Perhaps but then if I choose the 3rd party elements I want and wire them together to suit my needs, what kind of Frankenstein have I built in the progress?

Well, considerring that Frankenstein was a very smart doctor, probably a good one. I think you meant something else, and I am getting tired of answerring that statement, frankly. Using several components together is neither cobbling nor frankenseining nor hobbling a solution, it is using the best attributes of each to achieve a cohesive whole. The end result of a highly componentized architecture is... good design.

I don't think Oren or Jeremy are saying the P&P guys did a bad job on in, they just choose to evolve their own solutions using a minimalist approach.

This is were all the trouble start. I am explicitly not saying that the P&P guys did a bad job, I am saying that I don't believe that the direction they are pushing is the right one.

Like I mentioned with NHibernate, I needed to deploy log4net as it needs it, even if I didn't turn on that feature. At least with EntLib, if I'm not using security for example I don't need to deploy the security module.

Bitchy: Feel free to try to deploy P&P's DAAB without Microsoft.Practices.EnterpriseLibrary.Common, when you are successful, then you can complain that NH has a dependecies.

Seriously, NHibernate.dll has dependencies on several assemblies. And it follows separation of assemblies, so if, for instance, you don't need the 2nd level cache, you don't need the MemCached assemblies deployed.

Eventually I could have a really ugly monster on my hands with copies of Castle, StructureMap, CAB, EntLib, NHibernate, log4net, and who knows what else all living (hopefully) together in happy existence. I don't want that.

You get that with everything that you use, if it bothers you, use ILMerge to make this a single DLL, and then forget about it. Disk space is cheap, and it is really not an issue. About the previous point as well, you can merge log4net into NHibernate if you so like, and get rid of the extra dependency.

Could I get the same functionality from the other alteratives? For sure, however I would probably be writing more code to wire things together than I would with CAB.

I seriously doubt it. A good collection of tools would enable you to write clean, intent expressive code. I don't think that you would end up with more code, if anything, the lack of designer generated code would reduce the amount of code that you would have to deal with.

Comments

C-J Berg
05/24/2007 11:23 PM by
C-J Berg

On NHibernate’s log4net dependency: I really think this dependency ought to be removed. Logging frameworks varies from application to application, and the decision of which one to use shouldn’t be made by any single component such as NH. Log4net’s strong name screw-up between 1.2.9 and 1.2.10 is another reason (you need to recompile NH if you have other dependencies that cannot change – not a big task, but still).

Has this been discussed by the NH team? You’re all aware of it, I’m sure. Castle has done it right, of course. Spring.NET introduced a simple lightweight logging abstraction framework to get rid of its hard-coded log4net dependency (http://netcommon.sourceforge.net/). Perhaps it could be used, especially since it wouldn’t introduce any other new dependencies? Is there any interest in doing so?

Ayende Rahien
05/24/2007 11:27 PM by
Ayende Rahien

Frankly, I am against that.

The screw-up was a big issue, I agree, but I don't see the point of abstraction for the point of abstraction, and what it wrong with another Dll.

I don't think that we are likely to see the same issue as the PK screw up, so I don't really mind the dependencies. The problem in saying that you can't take hard dependencies is that pretty soon you start to get really lost. What happen if you want to use NHibernate with Spring, NHibernate is using some Castle stuff, is this fine? If not, how are you going to replace that,etc.

C-J Berg
05/25/2007 12:18 AM by
C-J Berg

Spring vs. Castle is quite a bit different, I think. (Spring.NET uses Castle's DynamicProxy, doesn’t it? Anyway, that's not the point.) I feel you're much less likely to run into such issues, and if you do, you need to handle it differently, as you imply.

Logging, however, is a necessity of pretty much any application, and you want to be able to choose which one to use (and log4net isn't the best option out there). It might even not be your decision. And who wants to use more than one framework? (And for writing an appender to log to another framework... I'd rather not.)

I feel I shouldn't be forced to use log4net simply because I want to use NHibernate - an O/R-mapper. Those are completely different concerns. After all, isn't that why both Castle and Spring has abstracted logging?

I totally agree that you shouldn't make unnecessary abstractions, but this isn’t one of them. Sure, you shouldn’t abstract the logging in your own application code, but reusable components should, IMHO.

Chris Khoo
05/25/2007 12:42 AM by
Chris Khoo

I'm not up with the lingo - I was wondering, what's NIH?

Chris

jafin
05/25/2007 03:26 AM by
jafin

NIH = Not Invented Here ?

Steve
05/25/2007 03:47 AM by
Steve

I tried to post on that blog but I got some Community Server database unavailable error with instructions on how to set a connection string up.

lol

but, I wanted to say:

Here is the quote from the Web Client P&P Factory:

"The software factory uses the Enterprise Library for a variety of features, including exception management, logging, data access, and authorization."

Let me ask Bill and P&P:

  1. I have a DDD in place that uses NHibernate and a IRepository/DAO approach

  2. I use Windsor for some of my DI needs

  3. I have a MVP webform solution in place.

Can I plug in my approach into this 'factory'. Must I use their DAAB?

Must I use this cobble of EntLib 'features'? ie. I want to use log4net, but can I with this 'logging' feature?

It seems P&P supporters want to be critical of my approach without giving me a way to plug in my components into their architecture. It appears I must either use their system or nothing.

I don't understand this - if I have a success system that uses NHibernate or Windsor - why can't P&P create a framework that let's me use the components I use to solve business problems with?

I see effort on the OSS side to provide a way to use components. ie. Castle's 'Facilities'. Plug in a facility.

This is my issue right now - I want choice in my design. If P&P can give me that choice, I'll go use it. But if they want to bully me into a solution, where I must use a 'objectbuilder' instead of Windsor, or where I must write stored procs with 'DAAB' rather than my DAO/NHibernate solution then what is the value for me?

I could be missing the point here, but I see P&P as a hodgepodge of their own components, trying to glue them all together but not allowing anyone else's components to plug into their large bulky architecture (although they have pretty pictures on the website). I know the post said something about mastering it after a YEAR!. Whew. A year is a long time, I don't know what will be here a year from now :)

Michael Morton
05/25/2007 06:36 AM by
Michael Morton

There is absolutely nothing wrong with Frankenstein-ing or cobbling together a solution. It does not mean you are re-inventing the wheel or being in-efficient. It's more like buying a custom computer, or a custom house or a custom car. It's about you getting exactly what you want in both form and function. At the end of the day, to use the car example, both the standard car and the custom car will get you from point A to point B, but the trip could be completely different. Both types of cars have their strengths and weaknesses, but at least with the custom car, you got to choose both.

I'm not saying that everyone should only roll their own frameworks... Or only cobble together multiple frameworks... Or only use a single monolithic framework... At the end of the day, a good developer, a smart developer, will evaluate all of those options, and then some, and will choose the right solution for the task at hand. A good developer will not be biased in their decision making just because they have used a particular solution with success in the past. A good developer always re-evaluations the situation.

Casey
05/25/2007 07:11 AM by
Casey

100% in agreement ... was going to write a reply to Bill myself ... but I couldn't add much beyond what you wrote.

Steve
05/26/2007 03:51 AM by
Steve

"If you consider systems as services and the ability to plug in any service you need, then you get the best of both worlds and I don't consider any of this cobbling solutions together."

Good, because that is how I feel as well. And honestly, that is what I think we should strive for.

Choice is good.

Thanks for your followup.

Comments have been closed on this topic.