Subscribe: hammett - Weblog
http://feeds.feedburner.com/Hammett-Weblog
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
activerecord  castle  code  components  create  java  monorail  net  new  people  ruby  things  time  transaction  view 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: hammett - Weblog

hammett - Weblog



hamilton *hammett* verissimo's Weblog



Last Build Date: Sat, 28 Jul 2007 14:23:36 -0400

Copyright: Copyright 2007
 



This blog is closed for business

Wed, 25 Jan 2006 18:15:15 -0500


As I‘m sick and tired of the unrestricted access of spammers, I‘ve moved to geeks with blogs. So long, and thanks for all the fish.




Drunk and Retired II

Tue, 3 Jan 2006 19:40:40 -0500


I revoke what I have said on the previous post. These guys should study more (taking advantage of the retireness)


There are three episodes on ‘why Ruby on Rails is not enterprise ready‘ and while I agree that it‘s definitely not enterprise ready - and by that I mean that it's not ready to integrated with other application, lack of support to different transactional resources (transactions that goes further than database) and RoR's AR is quite simplistic - the argument that it should keep one instance per database row is plain stupid. It‘s the way Entity Beans work and leads to several deadlocks (unless you model your transactions up-front which is rarely done). C‘mon, the guys arguments are exactly what I expect from Java developers that can‘t see much further than that.


On the other episode, supposely about state machines, there‘s a clear lack of theory in their brains. At least they dont seem able to distinguish a parser from a lexical analyser, and they should before trying to talk about state machines and giving compiler parsers as example (!).


Or maybe I‘m being shallow and pedantic.




Drunk and Retired

Tue, 3 Jan 2006 08:57:20 -0500

If you want to laugh and yet say 'that makes sense' then check http://drunkandretired.com/podcast




Castle: New release, new web site, new documents, same old bugs

Mon, 2 Jan 2006 06:32:12 -0500

The Castle team is proud to announce the Jan' First release. This one is the most stable release we ever done, being the result of months eating our own dog food.

Visual Studio integration (for 2003 and 2005)

You can now use wizards to create MonoRail and ActiveRecord projects. The integration idea is to make Castle more accessible and simpler to MS world developers.

ActiveRecord

  • Added FindAllByProperty, FindFirst and FindOne
  • Added support for composite keys
  • Introduced DifferentDatabaseScope

Click here for the complete ActiveRecord release notes

MonoRail

Click here for the complete MonoRail release notes

MicroKernel/Windsor

Thanks

Thanks for the valuable contribution from committers and non-commmiters. Thanks indeed!




DC is cool

Mon, 12 Dec 2005 21:55:34 -0500


I accepted the suggestion from the people at work and decided to visit Washington DC last weekend. Quite an easy task. Took a cab, went to Shady Grove station, froze my nose for 20 minutes, took the train. After about 14 stations it was Metro Center. I couldnt help noticing that the underground stations are quite dark, perfect scenario for a Silent Hill game. Well, as a matter of fact they have used that in SH 4 - the room. Anyway, went to the Blue Line and took the train ‘til Farragut West station which happened to be a stupid decision, but I didnt know atm…


Outside the station I was completely clueless, just wanted to visit Lincoln Memorial but there was no indications on how to get there. Finding a cab on a saturday morning wasnt easy too, but after a several minutes I could find one. Interesting comment from the cab driver “oh man, brazilian women are pretty pretty pretty”. Who am I to disagree?


Five minutes later and 10 box less I was in the Lincoln Memorial. Took my camera off the coat, pointed to the it and the battery light blinked saying “goodbye”. Damn! Anyway, what a view! US capital is really a beautiful place. I wish I could enjoy the view a little more but in three minutes I was asked a bunch of times to take pictures from lots of people (including two nice blondies that would make lots of brazilian women envy)


Decided to chase the holy batteries, but again totally clueless. Picked up a random street and start walking, IIRC it was the 27th street. Pharmacists institute, State department, George Washington University and half mile later a metro station. Nearby some street shops that happened to have batteries. Can you believe it? I couldnt!


Armed with my recharged camera went down the street again, all the way to the memorial. The wall with the names of Vietnam soldiers makes you think… Finally I took all the pictures I could and walked the 27th street again to the metro station (Foggy Bottom station – what kind of name is that? I wonder if there‘s a equivalent Cloudy Buttocks underground station in UK)


Back in Shady Grove took a cab to Rio Mall, have some cool lunch and went to Barnes & Nobles. Could find several titles from Noam Chomski that are hard to find in Brazil. I‘m currently reading 9–11, the man has a really interesting perception on things. From the bookstore decided to walk to the hotel, man that was not a wise decision, but I‘m alive. Fortunatelly every decision about making a left or a right turned out to be the right one (for an unexplainable reason). Otherwise I would have appeared on the news: frozen brazilian man found on a side walk surrounded by noam chomski‘s books (image) alt=title=":-D" />

Btw I've published the pictures on flickr, cheers!




Some pictures

Thu, 8 Dec 2005 19:13:44 -0500


That‘s the my temporary desktop set up in the hotel. Yes, it is Seinfeld on the television.


(image)


And fortunatelly the snow is finally melting. Although it‘s gonna snow more tonight, so they say.


(image)


As you can see I‘m buying and reading some rubbish (image) alt=title=":-D" />


(image)




Getting older

Wed, 7 Dec 2005 19:05:54 -0500


Just turn 26 today. Bunch of crap e-mails from companies – as if I didnt know they have a impersonal system service just to send all that spam. No gifts, by the way. Well, one of the damn companies sent a few coupons.


Anyway, time for reflection. Accomplishes: hmm., improved my english, even if you don‘t believe me, it used to be worse. Joined university, which from my standpoint is not adding much, but I need to finish it before I get even older.


Meaningfull accomplishes: none
Hope things get better from now on, though.


Every year is getting shorter, never seem to find the time

Plans that either come to naught or half a page of scribbled lines

Hanging on in a quiet desperation is the English way

The time is gone, the song is over, thought I‘d something more to say





And now for something completely different: a new Castle release

Tue, 6 Dec 2005 19:59:16 -0500


...and I need to learn to keep track of the changes from version to version. But anyway, this release is not about super new cool features, instead it‘s just maturation of the existing ones. Grab your copy.


What‘s in our short term plans:

for ActiveRecord

  • Composite keys support: currently we force people to use surrogate keys and this is not nice

  • More validators

for MonoRail

  • Caching support

  • Exception/Error Pipeline (categorize exceptions, e-mailing and logging them, etc)

  • ExceptionRescue: associate an exception with a specific rescue

  • Scaffolding with Ajax

  • Pagination support

for MicroKernel

  • ComponentBurden: this is something I've postponed for too long

  • More documents, tutorials


Something that puzzles me is how people are so interested in MonoRail, ActiveRecord or Aspect# but just “don‘t get” inversion of control, how the MicroKernel works and how its extensibility points could help them. I'd bet that if the same solution were availble for Java, more people would have seen its value (image) alt=title=":-D" />


If you are one of those I‘m refering to, have you seen this article? If you still not conviced, can you share your fears, questions, doubts?




Off to the US - part III

Fri, 2 Dec 2005 18:04:49 -0500


This time I‘m gonna stay two weeks. If you‘re in Washington, DC area, drop me a line and we might catch up next weekend, if you dont, then probably I will be able to release the next version of castle package as I‘ll be grounded in a hotel room (image)




Interesting conversation on a forum

Tue, 29 Nov 2005 10:04:39 -0500

Just bumped into this, and it's not one of my multiples personalities, promise

http://www.castleproject.org/index.php/MonoRail
has anybody tried this? it's an alternative web framework to ASP.NET. it's sort of like Ruby on Rails which is the rave of many Java/Ruby developers around the world...


looking at the documentation it seems ridiculously easy :)
one thing though (they recommend against using Web Forms because (according to them) it is not a controller-aware approach to web development). they actually recommend using the NVelocity templating engine (adapted from the popular Velocity engine for Java) or using the "Brail" Boo-based templating system (Boo is an open source .NET language that's based on Python).
interesting stuff, eh :) looks like i might decide to dump asp.net for .NET web development :P


hey 'dre ... not to start on anything but i am curious ... are you using all these open source techs that you encounter in current projects? there seems to be too many OSS stuff that you know about and i havent even known some of them and mostly, those that i know are just things that i read on the web or through your posts. Iba na talaga ang magaleng! :) i feel inferior everytime i see you post on somethign else new in the OSS world.


haven't used it yet...but it looks interesting, i definitely will look at it.
i think that one thing that makes .NET devs different from Java devs is that most .NET devs rely only on things that are made or endorsed by Microsoft while most Java devs are "breaking away" from Sun's stuff like EJB and embracing simpler, more agile frameworks. it's time we .NET devs open our minds to what's out there, especially if it's LGPL or BSD licensed since we can freely use them even on closed-source systems... NUnit is cool and i use it regularly. the MonoRail/NHibernate/NVelocity thing is next on my list of stuff to learn and so is Castle.Windsor (which seems to be much simpler than the ported-from-Java Spring.NET) :)


Cool or what?!




Book recommendation: Ajax in action

Sat, 26 Nov 2005 11:37:53 -0500


Wow, it‘s been a hell of week. But I really dont want to talk about it. Accordingly to the book The seven sins of the memory if you want to forget something you shouldn‘t talk about it.



Anyway, the first book on my wish list arrived this week: Ajax in action. I must tell you that I usually dont give much credit for books being released about the hype of the month, trying to ride the tide, but so far this book has been terrific.



First, the concept of transient and sovereign applications struck those “why I havent thought about this before?” moments.



One thing, though, that caused certain impact was when he mentioned: “hey, now your application is on the browser, so carry all your paradigms and beliefs and discipline to the javascript code too“. I confess I never paid much attention to any “scripting” language, and javascript developers on the companies I worked for were, well, ok, we made fun of them. (I know he‘s reading this, so I apologize (image) )



But it‘s never too late, right?




Google talk

Sat, 19 Nov 2005 10:10:04 -0500


Kinda cool. Download a copy at http://www.google.com/talk




Two major mistakes

Sat, 19 Nov 2005 10:07:49 -0500


I knew it was something I shouldnt have done. But I did anyway, now I regret. So much. But it‘s sronger than me. I try and I try to fight against it, but once you‘re there, there‘s no way out. And now my life is wasted, it‘s worthless…


If you can‘t read between lines I say it loud and clear: I bought a xbox. That was my first mistake. Then after landing in Brazil I bought Splinter Cell Chaos Theory, second mistake. Since last friday night I couldn‘t take my eyes from the TV…


Well, now I need to complete the big apple mission. Wish me luck.




Planning and building a MSI file (or a day in hell)

Sat, 19 Nov 2005 10:07:39 -0500


Lots of people have been asking for a MSI (standard) distribution of Castle, and I completely agree with them. As a lazy average person I happen to download more MSI files from sourceforge than any other format, so fair enough, let‘s play the game.



After bringing the subject to Castle PMC, Craig mentioned that nantcontrib has a msi task. Had a cursory look and it looked good. Last night then I decided to create the first setup script. The docs for the tasks are quite good. My advice however is that you download the Installer SDK from MS web site and read the chm doc to get at least a gist of how it works.


Created a nice script in 20 minutes, but executing it was another story. Seems that the msi nant task documentation is outdated and the schema that validates it is flawed. I just couldn‘t use the nodes that the xsd inherited. When I downloaded the code from NantContrib CVS urging to find the bug and fix it I realised it went too far. Gave up.


Next attempt: using the Orca with Nant msi template. If you can‘t have enough aggravation in your life I strongly advise you to try this. The Orca is a msi “editor” that comes with Installer SDK. The damn thing seems that was created by a trainee who was late for his lunch (which also happened to be its deadline). I compare using Orca for something serious as collecting stamps in a wind tunnel. Gave up.


When I was about to download Installshield I googled for alternatives. Ant has an external project called antinstaller that seems to do what I wanted, but the documentation was kinda dodgy. I bumped into WiX later and read the tutorial. Aside from the standard UI that it generates, I like the tool. You can always create your own UI anyway…


So in a few hours I had a standard setup done with a hierarchy of items to be selected:

Castle Project
  Binaries
    MonoRail
    ActiveRecord
    Aspect#
    ...
  Source Code
  Documentation
  Samples

But now I‘m facing the shared assemblies problem. Yes, as one of the MSI‘s rules of thumb is: “a file cannot be shared among components” which leads me to a problem (at least while my creativity doesnt come up with a decent solution). For example: the Ioc package has a Castle.Model.dll, but ActiveRecord also requires this. What if the user wants to install ActiveRecord but not IoC package? The same is true for the dependency on NHibernate. Both ActiveRecord and NHibernate Facility use them.


I have some ideas to solve it, but in the meantime I‘m going to watch that Constantine movie again, this time til the end. Awful, awful! But it features Rachel Weisz!


Btw this is a good selection of resources for those interested in MSI.




Another interesting Open source side effect

Sat, 19 Nov 2005 10:07:24 -0500


A Castle user appeared on the user list asking for a kinda complex sample on using ActiveRecord and MonoRail to achieve some specific functionality. He also offered a small “bounty”, which is a word completely unknown to me, btw.


Anyway, if there‘s something I can‘t accept is when people get stucked using my pieces of code. I experimented the feeling of embracing things and bump into bugs that werent easy to find, or simply didnt have enough knowledge to get round it, or at least in a nice neat way. It‘s the kind of moment that you curse all the open source movement and buy a XP Professional box… Yes, then you bump into another problem and curse Microsoft and the thing goes on and on. (image) alt=title=":-)" />


But I digress. The fact is that I coded the sample in a few minutes and committed to Castle‘s SVN. Instead of money I‘d rather have a few books and a damn A/C adapter to use my laptop during long flights, so I created a nice and long Amazon Wish List. What was my surprise? 90% of the list were purchased and dispatched already. Man, that‘s so cool!


So, if you reading this post also thinks I somehow made your life a little better, or at least now you code less and have more time to spend with your wife, girlfriend, dog, etc, feel free to buy me one of these things (image) alt=title=":-P" />


And Spring guys, I know you so please dont waste your time sending me any packages as I will forward them to the bomb squad.


Seriously, even though things like this unexpected gift may happen, it does show how documentation on castle side is poor, and documentation is a must for any serious open source project. MonoRail for instance has so many undocumented features that I feel like crying… Bear with us, we‘re working on that anyway. New site, new layout, new content, new setup. Things are improving, promise.



This blog started to pop up ads and I don‘t know where they are coming from. I really hate them, and if you have a clue, leave a comment, please.




The joys of Castle.Services.Transaction

Sat, 19 Nov 2005 10:06:07 -0500

This is an important piece of Castle project that unfortunatelly does not receive the attention it deserves. I‘ll try to depict how it was design, the purpose and how you can interact with it. Castle.Services This piece of Castle was created to offer standard and base APIs, independent of how their are going to be used. It would be cool if we could offer something like JCP does, but I‘m not so pretentious :-) Currently we have: Castle.Services.Transaction Castle.Services.Logging The idea is that these are base, core API, that all others projects under Castle (and even outside) can refer and extend. Castle.Services.Transaction The transaction infrastructure under castle was shameless based on Java Transaction API. Yes, I‘ve said this before and I repeat: I love the JTA/JCA design! Castle.Services.Transaction is simpler, though, and yet provides all you need in order to solve your problems for complex scenarios. However it wasn‘t design for 2PC or to integrate with COM+. As a matter of fact it would be possible to integrate with COM+, specially version 1.5. But this is a subject for another post. Oh well, what‘s under Castle.Services.Transaction? – ITransactionManager – ITransaction – IResource – ISynchronization It also provides the TransactionalAttribute and TransactionAttribute. The former denotes that a class has transactional semantic and the latter that a method has a transaction associated. The flow is very simple. You want a transaction? Grab an ITransactionManager instance and create a new ITransaction. You can then register resources on it, or synchronization objects. Do your work and commit or rollback the transaction. That‘s it. For lots of cases, when entering a transactional method, we can safely assume that: – a transaction must be created – if an unhandled exception goes out the method boundary the transaction is rolled back – otherwise, the transaction is committed Enters AutomaticTransactionFacility AutomaticTransactionFacility The role of this facility is coordinate the automatic creation and destruction of transaction applying the rules stated above. Simple, eh? AutomaticTransactionFacility has no idea about what‘s you underlying resource (database, filesystem, kitchen sink) as long as you implement correctly the protocol, then everything is fine. The AutomaticTransactionFacility works by registering an contributor that inspect registered components. If a component is marked with the Transactional attribute, it associates an interceptor to it. The interceptor role is to create a transaction when a method marked with TransactionAttribute is invoked. It takes less than a hundred lines of code to accomplish this. If you dont believe me, check for yourself: http://svn.castleproject.org/svn/castle/trunk/Facilities/AutomaticTransactionManagement/ Interacting You can always register an implementation of ITransactionManager and interact directly with it and thus have a fine grained control over what‘s happening. In fact the default implementation (DefaultTransactionManager.cs) is good enough for almost all scenarios. My earlier strategies were to customize the DefaultTransactionManager for each integration I wanted to provide. For example, have a custom implementation for NHibernate and other for iBatis. It turned out to be a stupid approach. The IResource interface is all you need in most cases. So integrating it with your project is just a matter of coding an adapter. More on that later, first le[...]



Castle's Factory Facility

Fri, 18 Nov 2005 10:28:33 -0500

So the java spring developers, addicted to “xml programming“ as well (or numbed), that are now on the .net land are bashing Castle ‘cause it “does not provide a powerful configuration support” and completely loses the point. This is intentional as I have chosen to develop something extensible rather than a swiss army knife. Nevertheless I think the support for singletons and external factories were something that we should have provide long time ago (through a facility) as I see its value (although I never really need it I‘m aware that people dealing with existing code will inevitably need it). When asked on the forum and on the mailing list I said that a new facility for that would require a couple of lines of code. If they didnt believe me, well, I‘ve just coded it. Here‘s the new facility: public class FactorySupportFacility : AbstractFacility { protected override void Init() { Kernel.ComponentModelCreated += new ComponentModelDelegate(Kernel_ComponentModelCreated); } private void Kernel_ComponentModelCreated(ComponentModel model) { String instanceAccessor = model.Configuration.Attributes[“instance-accessor“]; String factoryId = model.Configuration.Attributes[“factoryId“]; String factoryCreate = model.Configuration.Attributes[“factoryCreate“]; if ((factoryId != null && factoryCreate == null) || (factoryId == null && factoryCreate != null)) { String message = String.Format(“When a factoryId is specified, you must specify “ + “the factoryCreate (which is the method to be called) as well – component {0}“, model.Name); throw new FacilityException(message); } if (instanceAccessor != null) { model.ExtendedProperties.Add( “instance.accessor“, instanceAccessor ); model.CustomComponentActivator = typeof(AccessorActivator); } else if (factoryId != null) { model.ExtendedProperties.Add( “factoryId“, factoryId ); model.ExtendedProperties.Add( “factoryCreate”, factoryCreate ); model.CustomComponentActivator = typeof(FactoryActivator); } } } So this facility checks for a few attributes on the configuration associated with a component: instance-accessor: this is used when you have a singleton and exposes a public static property to obtain its instance factoryId: links a component to a factory (which is another registered component) factoryCreate: specify the method (instance or static) that should be invoked to obtain the component instance The following are both valid uses. The former uses the instance-accessor and the latter uses the factory attributes. public class SingletonWithAccessor { private static readonly SingletonWithAccessor instance = new SingletonWithAccessor(); private SingletonWithAccessor() { } public static SingletonWithAccessor Instance { get { return instance; } } } public class MyCompFactory { public MyCompFactory() { } public MyComp Create() { return new MyComp(); } }



I've never been so spoiled

Thu, 17 Nov 2005 04:38:11 -0500


So I‘m here in Maryland and so far it‘s been a great time. Well, the flight was kinda hell, AA is really committed to make you suffer, and this time they have set up a connection flight that was just impossible to make. I‘ve land to Miami at 6:50 AM and the flight to Boston started boarding at 7:10 AM. Alright. Had to wait ‘til 11:30 to the next flight to Boston, which surprise surprise was late.



Anyway, the consultancy had booked a room in Hilton Boston Logan, pretty cool hotel. The fanciest I‘ve ever been. I‘ve met the consultancy people few minutes later, went dinner in the Hilton restaurant and was able try everything I wanted from the menu I felt like when I was nine years old in a restaurant with my parents. Btw the consultancy people are very nice. Good work with such cool people! Boston was really rainy and I was damn tired, so didnt make the promised phone calls and didnt have a chance to sighseeing. My plan included a fast trip to NYC, but, well, maybe next time.... (image) ("" title=""> alt=title=":-(" />


Next morning waked at 5 AM to catch the 7:45 flight to Washington/Reagan, and took a cab to Rockville, Maryland (yup, they convinced me to not rent a car!). Rockville is a peacefully and beautifull small place with lots of technology companies and delicious restaurants, (oh that pancake house will be in my dreams for the next 10 years)


Today was my first official day at the company. The final spoling: they arranged me an office that is almost as big as my flat in Sao Paulo, and a brand new Dell Xeon 3.20ghz DUAL with 3G RAM. My laptop is now with serious identity problems, the poor guy… Oh, shopping was also great: iPod nano, XBOX, DVDs, books books books! Wow!


I‘m also enjoying how we‘re brainstorming some cool ideas for Castle that is going to make our users really really productive. I‘d rather not disclose the ideas right now, but guys, I‘m positive you gonna enjoy what we are up to (image)




Off to the US, again...

Thu, 17 Nov 2005 04:37:45 -0500


I‘ve been hired for a few months to provide some customization and even improvements on Castle towards the requirements from a specific company, which from the NDA I‘ve signed few days ago and the nature of their business (finance, investments), I can‘t tell whether I‘m allowed to disclose its name.


Anyway, I‘m flying to Boston next friday, gonna spend just one day there and gonna fly to Washington, DC. Then I‘m gonna hire a car and drive for a few hours, or several hours as I‘m highly skilled in getting lost; so I‘m very excited about getting lost thousands of miles away from home.


But the coolest thing is that this whole experience proves how Castle is being embraced by serious people who share our values, and companies pushing it to complex, mission critical, systems.


This is definitely an extra motivation to keep up the good work knowing that there are lots of silent users around the world who approves our work.


Congrats Castle community!




Small brain exercise

Thu, 17 Nov 2005 04:25:04 -0500


Andrew has a nice post on testing iterations. While the article is interesting, I was more attracted to the problem being solved: a kind of instr function. Andrew‘s approach uses a nested for, which made me forget about the rest of the article and think about how I would solve the same problem with a better performance. My code:

#include 

int instr(const char* target, const char* tosearch)
{
if (target  0 || tosearch  0) return -1;

size_t targetlen = strlen(target);
size_t searchlen = strlen(tosearch);

int matchindex = 0;
int initialFound = -1;

for(int i=0; i < targetlen; i++)
{
if (target[i] == tosearch[matchindex])
{
if (initialFound == -1) initialFound = i;

matchindex++;

if (searchlen == (i - initialFound + 1))
return initialFound;
}
else
{
matchindex = 0; initialFound = -1;
}
}

return initialFound;
}


And my “test cases”

void tmain(int argc, TCHAR* argv[])
{
assert( instr("", "") == -1 );
assert( instr("", NULL) == -1 );
assert( instr(NULL, NULL) == -1 );
assert( instr("aa", "a") == 0 );
assert( instr("1aa2", "aa") == 1 );
assert( instr("1aabbabdabc2", "abc") == 8 );
assert( instr("1aabbabdabz", "abc")  == -1 );
}


The book The practice of programming has some very interesting stuff on testing. The thing that I distinctly remember is to always test boundaries which are the points likely to fail.


With that in mind, which tests are missing? Can the algorithm be made any simpler? There‘s also at least one optimization that could be made, it‘s blinking! What would that be? Your call.




Java Connection'05 - The final post

Thu, 17 Nov 2005 04:24:53 -0500


For those still interested in listening what actually has being said on the event, be my guest. Now compare to what that dull guy said about it.




Is foo Better Than ...?

Thu, 17 Nov 2005 04:24:05 -0500


Dave Thomas just hit the nail with his wonderfull post "Is Ruby Better than ...?"


Personally I don‘t understand why companies (and people) have to embrace just one technology/plataform. Real geeks passionate about their job would certainly appreciate experiencing something different from time to time.


So why use a full stack J2EE solution for a web application where the user can browse through five static pages and subcribe for a newsletter? Why use Ruby and RoR if you have multiple transactional resources involved? Instead, search for a balance. If Java or .Net is the only thing you know, you might be in trouble. But the bottom line is: do your home work and choose the appropriate solution for the given scenario. As we all know there‘s no silver bullet out there, our common sense should drive us towards the best choice.


And what am I doing about all that? Hmm. I‘ve worked with Visual Basic for several years (yeah, I‘m not proud of, that‘s for sure), then C++, then java for a few years (love it), currently working with .net (love it). Have used Ruby on Rails (love it) to construct a real product for a few months last november and I‘ve tried python, but my heart belongs to Ruby (image) alt=title=":-P" /> I'd love to buy a Mac someday, but in Brazil it's just too f... expensive. (image) alt=title=":-(" />




Who visits this blog?

Fri, 23 Sep 2005 00:22:23 -0400


I‘ve always been curious about people that actually waste their time reading all the nonsense stuff I write here whenever I have time to waste. So I signed up with webstats4u and always observe from where and how people are accessing this small, confused but comfy space I have.



So let‘s analise together just two snippets of yesterday traffic



(image)



Ukraine, Brazil, US, France internet providers and what? NASA? Guys, please don‘t use Castle neither in a rocket nor on a navigation system, it‘s beta yet! I have no responsability if a satellitle crashes with a “unsatisfied dependency found: aborting” exception.


Then about a couple of hours later…


(image)



Library of Congress?



Isn‘t that Lockheed-Martin Corporation the company that appears in Bowling for Columbine? Are they planning to use the coordinates on my blog map (on the right) to bomb my house? Well, if I suddenly disappear, you will know what happened! (image)


Btw, you can use google map or virtual earth with these coordinates to see the flat I live in: 23.5419248374, 46.6969187018.



And Microsoft, that‘s an easy one. The MS Patterns and practices team is still trying to figure out what Castle is all about. “How come they have so little dependency on xml? It cannot be a serious framework!“ “What if a little guy in a small island wants to change some obscure configuration?“ “infering things instead of configuring, give me a break, mate!”





Hope people understand this is a joke, just to forget for a second the abnormal pressure to finish some highly complex code in no time :‘-(




Castle new release is inevitable

Sun, 11 Sep 2005 17:03:04 -0400

Henry and I used this weekend to solve pending JIRA issues, it was a bugs and improments fest. I'm damn tired and monday is there, so I need to learn to use my weekends to actually rest, but nevermind, it payed off. It's also nice to see people solving opened jira issues by themselves. Unfortunatelly this only happens when jupiter is aligned to the third moon of an unnamed planet outside solar system :-) ActiveRecord First, a few additions to ActiveRecord 'How To' section: How to configure ActiveRecord on web applications How to enable Session Scope per request so you can use lazy collection without major headaches How to create simple test cases How to enable second level cache Facilities I've completed the Facilities documentation at last, now everything is documented!! That's our currently facility list: EnterpriseLibrary: Provides integration with MS' Enterprise Library Configuration package EventWiring: Allow subscribers to connect to events exposed by publishers FactorySupport: Allow your application to use external factories ActiveRecord: Take care of configuring and starting ActiveRecord AspectSharp: Enable AOP capabilities for components Prevalence: Manages the prevalence of an object model db4o: Enables the usage of db4o by your components Automatic Transaction Management: Perform automatic transaction management for your classes through interception NHibernate: Enables the usage of NHibernate O/R framework for your components iBatis.Net: Enables the usage of iBatis O/R framework for your components Batch Registration: Registers components based on configuration instructions TypedFactory: Given a factory interface, automatic implement it delegating creation to the container Startable: Implements the startable semantic for components Remoting and logging facilities are under way! MicroKernel Daniel has added a new event (DependencyResolving) so you can know when a dependency is being resolved and act on it. I've also documented how type conversion works on MicroKernel, how primitives, list, arrays and dictionaries can be externally configured. Check Reference Documentation MonoRail MonoRail also has being improved. With the introduction of ControllerDescriptor we dramatically reduced the ammount of reflection involved on each request. Now even the test cases are faster. I'm not sure if I mentioned that Brail was also officially added as an view engine. Welcome aboard!! Last but not least the concept of ViewComponent was introduced. Follows a small explanation of what it is: ViewComponent Rationale To have UI components, responsible for pieces of view, and usually reused among controllers - maybe among projects? How it works Simply create a class that extends ViewComponent or SmartViewComponent. You can override the Initialize and the Render methods. If you don't override the render method it will try to render a default view (more on this later) MR's default behavior is to inspect the assembly (for controllers and now for components) and register them into ViewComponentFactory. If Windsor integration is enabled, then it assumes that all view components come from the container. NVelocity integration NVelocity allows you to create your own directives, so that's how we introduced components to it. Basically you can use // for inline components #component(Component[...]



Re: MonoRail makes life boring...

Sun, 4 Sep 2005 05:57:05 -0400

That's a wonderful post from Ayende about MonoRail. Quoting:

What I do see as MonoRail biggest weakness is the inability (my inability, that is) to explain the benefits to someone who only did ASP.Net [Web Forms] programming and doesn't see how it seperating the view & the controller [& Model] can help you in making the application. I tried several times this past week, and I just couldn't make them get it.

And he is absolutely right, we at castle lack any marketing ability (which from my personal perspective is good, I'm gonna straight to heaven when I die). And even worse, half of .net developers just don't know castle exists as they'd never seen a link to it on MSDN. The other half is aware of it, but just won't adopt it 'cause we are not endorsed by MS, so they rather embrace those Application Blocks.

But all is not lost. We have more than 90 subscribers on the dev list, more than 800 posts on our forum so probably there are a couple of developers using it on real world projects right now :-)




Implementing MonoRail-based Autocompletion

Sat, 3 Sep 2005 20:43:13 -0400


Michael Dubakov shows in his blog how to achieve auto-completion using Ajax.Net library. I don't have anything against Ajax.Net but looking at the support that others offer, Ajax.Net is very simplistic. But again, I'm not bashing anyone nor anything, I just have the right to show how the same thing can be achieved using MonoRail (image) alt=title=":-)" />


So, first of all, create a new project. The generator can help ya on that. Also, create a new controller. I've created an AccountController

public class AccountController : SmartDispatcherController
{
public void Index()
{
}

public void GetSearchItems(String name)
{
IList items = GetRecords();
IList matchItems = new ArrayList();

name = name.ToLower();

foreach (string item in items)
{
if (item.ToLower().StartsWith(name))
{
matchItems.Add(item);
}
}

PropertyBag.Add("items", matchItems);

RenderView("partialmatchlist");
}

private IList GetRecords()
{
ArrayList items = new ArrayList();

items.Add("Ted");
items.Add("Teddy");
items.Add("Mark");
items.Add("Alfred");

return items;
}
}


Then a view – yes, using NVelocity. Follows the index.vm



$AjaxHelper2.GetJavascriptFunctions()
$Effects2Helper.GetJavascriptFunctions()







Some static content and yada yada yada

Auto completion: $AjaxHelper2.InputTextWithAutoCompletion( "name", "getsearchitems.rails", null, null )


But it‘s not completed yet. There‘s a small view to render the items. Follows the partialmatchlist.vm

    #foreach($item in $items)
  • $item
  • #end


And that‘s it. Now compare to how much code Michael had to write to achieve the same thing.


For those interested, here is the code for download.

Btw kudos to these smart talented guys:




Castle ActiveRecord, web apps and performance tips

Thu, 1 Sep 2005 22:32:52 -0400


Castle‘s ActiveRecord combined with ActiveRecord Integration Facility and Automatic Transaction Facility was a huge time saver for the project I‘m working on. However I‘ve learned a thing or two about things I should do and the things I shouldn‘t. The items will probably apply to people that use pure NHibernate too.


  • Don't try to have on your object model all interconnections with others objects just for the pleasure of having a uniform model and hoping that someday that property or collection will be useful, that's a performance killer which doesn't pay off
  • Use lazy loading for all collections that won't be usually used when the object is loaded or when you're dealing with a big set of data. That dramatically increases the performance
  • Create a SessionScope for the request lifetime. That will ensure that all lazy collections will be available whenever you use them. You also benefit from first level cache, so several Find()'s for the same id will return the same object
  • Consider carefully what objects are likely to be immutable, so you can mark them with Cache=CacheEnum.ReadOnly and enable second level caching
  • Operations on collections, specially with big sets, should be converted to HQL. For instance I had lots of usages like mySurvey.Questions.Count == somethingElse which result in queries being generated, sent to db, instances created, being populated, just to get the count (dumb!). I converted them to pure HQL (select count(q.id) from Survey s join s.Question q where ...)




Castle's Factory Facility - Take 3

Thu, 1 Sep 2005 22:12:21 -0400


Now I‘m happy with it!









MyStore


item1
item2








As you can see the parameters node lies on the component instead of the factory. That was the flaw on the earlier implementation.




Castle's Factory Facility - Take 2

Tue, 30 Aug 2005 23:51:56 -0400

As kindly requested here see below I've added support to method parameters to the Factory Facility, meaning that now the container is able to resolve the method arguments, using the same principle that applies to all other components, and then invoke the factory creation method with the correct arguments or failing if it can‘t.

For example, here's a factory:

public class MyCompFactory2
{
public MyComp Create(String storeName, IDictionary props)
{
return new MyComp(storeName, props);
}
}

And another one:

public class MyCompFactory3
{
public MyComp Create(IMyService service)
{
return new MyComp(service);
}
}


The facility will try to resolve the arguments using the resolver
so you just need to provide a parameters node in the xml, as usual.






MyStore


item1
item2













Things to say when you're losing a technical argument

Sun, 28 Aug 2005 10:30:22 -0400

Things to say when you're losing a technical argument

The Ruby on Rails' people should come up with a revised version. I bet they listen to similar falacies every day :-)

Speaking of Ruby, has anyone glimpsed at Ruby.Net code by any chance? If you didn't, well, don't. Unless you're really fan of crappy code. It's even worse than IronPython code... It's a shame that usually compiler people can't produce nice, clean, readable code.




Controller logic and view logic

Wed, 24 Aug 2005 22:34:57 -0400

There has been some discussion on castle list about MonoRail and its view engines. There are people that think NVelocity is too much and fails as view engine; others think that StringTemplate won?t be powerful enough to create decent views. On my side, I think NVelocity is the perfect solution for a view engine that follows the Rails philosophy and enforces separation of concerns. My biased view of the perfect world for web application at least is somewhat explained through this code samples: [Layout("default")] public class AccountController : SmartDispatcherController { private readonly AccountService accountService; public AccountController(AccountService accountService) { this.accountService = accountService; } public void Index() { } public void New() { PropertyBag.Add( "countries", Country.FindAll() ); PropertyBag.Add( "languages", Language.FindAll() ); RenderView("new"); // Only necessary 'cause Create can call us too! } public void Create(String name, int countryid, int languageid, String email) { // Suppose there's no client-side validation if (name null || email null) { Flash.Add("error", "Sorry but you must supply a name and an e-mail"); New(); return; } Account newAccount = new Account( name, email, countryid, languageid ); accountService.Create( newAccount ); Redirect( "home", "index" ); } } This code demonstrates how controllers can be totally agnostic about what happens in the views. There‘s no antecipation, no pre-processment, no chewing. Just make the data available to the view. So the controller is all about Flow Validation Populating entities with form data Dispatching the real work to more intelligent layers (in this case the AccountService) The service can perform checks, but checks that relates to business constraints. With this approach in mind is even easy to foresee this very controller being used for say a desktop application: the data flow would be the same, the consistencies checks would be the same and also the dispatching. Now, on the view side of the coin: The index.vm would present some information about how it‘s important to create a proper account. Nothing to discuss here. The New.vm would just present a form, it may or may not use validation, it may or may not contain some cool javascript/effects or something like that, but it will populate selects, it may be a view that can be reused for an Edit operation (some ifs will be necessary) We would use a layout but it‘s just plain html. Nothing to discuss too. - So what sort of "programming" happens on the view side? ifs, loops, method invocations Why? It should be just a view you may add. It‘s view and a view may have its logic and flow as well. Why methods? Just for the sake of simplicity and DRY principle. Instead of always coding the same things, use helpers. What are helpers? Just ordinary classes with a bunch of methods to easy the burden to couple with web/html development. Helpers play an important role when dealing with validation, ajax, repetitive or complex html construction. A realistic example: $AjaxHelper2.GetJavascriptFunctions() $ValidationHelper.InstallScripts() #set ($validatorForm = "return (validateForm[...]



hammett's being bashed by .net community - COOL!

Wed, 24 Aug 2005 14:43:26 -0400

Suddently I became the center of hatred from all brazilians .net‘ers. I find this extremelly funnny but need to reply to the author that reviewed my participantion at Java Connection (see below). Unfortunatelly I‘m gonna break the standards and post this in portuguese. Hope you non-portuguese speakers readers dont mind Lamentável ... é o que eu posso dizer por enquanto, fiquei tão nervoso com o cidadão que "defendeu" o .NET ... Primeiro erro: o proposito do painel era apresentar os problemas de cada plataforma. O objetivo final era mostrar que nenhuma delas é perfeita e tentar trazer fim a polaridade. Eu nao fui para defender .net, plataforma que gosto muito ou nao teria investido tanto tempo no Aspect# e no Castle Project como um todo. Primeiro O cara mal trabalha com .NET, está focado em projetos opensource e trabalha (se não me engano) pra uma empresa que presta serviços p/ APACHE Segundo erro: mexo com .net desde a versao PDC. Sou MCAD Charter member, trabalhei profissionalmente com .net na vesta, na cimcorp e atualmente na Lucida. Sou committer e membro do PMC da APACHE sim, e a Apache tem projetos em .net (logging.apache.org e ibatis.apache.org). Trabalho atualmente como arquiteto num projeto para Hay Group e usando .net. O moderador lançou vários tópicos, aí cada um colocava seu ponto de vista sobre a sua tecnologia. Fui especificamente para o debate e me decepcionei, o Hamilton simplesmente não sabia o que ele estava fazendo ali. Sem base nenhuma, mal falou do frameWork.NET e só apoiou o tempo todo o Rodrigo, que por sua vez fez muito bem o seu trabalho (defender o JAVA). Dando nome aos bois: o Rodrigo era o moderador, o Phillip estava la para falar de Java e para falar mal e foi o que ele fez. Falou sobre como essa ideia de portabilidade é um misleading, falou sobre EJB/J2EE e todos seus problemas, falou sobre a terrivel estrategia de criar uma tecnologia complexa e depois tentar simplicar com IDE. Ele foi muito bom nas suas criticas à plataforma Java. Eu fiz minha parte. Critiquei a API de collections, critiquei a IDE, e principalmente os profissionais. Em um dos questionamentos, o Moderador pediu para que cada um falasse sobre alguma deficiencia de sua tecnologia. O Rodrigo falou muito bem dos problemas que encontra quando desenvolve em JAVA, principalmente da curva de aprendizado que um programador JAVA precisa ter para aprender a tecnologia. O Hamilton por sua vez disse que sente falta de collections ordenáveis ... é molé será que ele já ouvir falar de ArrayList ou HashTable lamentável ... um cara que não sabe isso nunca poderia defender uma tecnologia em um evento de universidade onde pessoas estão dependendo daquilo para definir qual caminho tomar. Alexandre, voce é uma prova viva do que eu disse na palestra: vc nao tem conceitos fundamentais de estrutura de dados. 1. ArrayList nao é ordenavel. Ele nao recebe um IComparator, nao tem essa opcao. 2. Hashtable, por sua propria definicao, nao tem como ser ordenavel. Sera que vc realmente entende o que eu digo quando digo “ordenavel”? Veja a API do Java, o mais proximo que .net tem é o SortedList. Ainda assim faltam Linke[...]



Conexao Java'05

Sun, 21 Aug 2005 12:40:14 -0400


Conexao Java is Java event roughly translated to Java Connection organized by one of the biggest java community groups here in Brazil. I was invited to speak in a panel about Java vs .Net (.net side). However the focus was inverted: instead of saying how .net is superior to Java or vice-versa. we talked about severals plataform aspects and it‘s problems. Even the strategic differences from MS and Sun and how it might impact our lives – from developer to developer.


I must say that it did work! The questions from the audience were great and the same from the signs of concordance on some polemic subjects. At the end I was surrounded by a bunch of people with more questions, looking for advice with their university projects and even asking why something wasnt working with their .net projects.


It wasn‘t my first talk, but it was by far the easiest. We that spoke on the panel were interviewed too. My first interview, really cool (image) Gonna publish some pictures as soon as I get them.


And if you‘re wondering, well, wonder no more: I mentioned castle and told how life is easy to cope with if you use it :-p




Finally something interesting on my CS course

Wed, 3 Aug 2005 23:51:20 -0400


We were required to think about any usefull project, design and implement it or at least pieces of it in C or C++. While most of my colleages have chosen restaurant apps, video stores, I asked my professor for something more academic. I brought three ideas:

  1. Use ART (Adaptive Resonance Theory) to build a knowledge base of buying habits and suggest things that make sense for the customer OR build a KB of symptom/disease so it could infer the disease based on a set of sympton (even with some error/noise) and learn from mistakes
  2. Use Agents to check for errors/possible issues in an online application. This can be quite complex as the agents may have to learn the consistence rules (given a learning time span) or I could write a small rule definition language and then parse/interpret..
  3. Build a math expression evaluator. This is simple and would force me to code a lexer, parser and interpreter from the scratch. More importantly it will force me to learn every intrisic detail to calculate limits, linear equations and so on.


My teacher was interested in the first one. I think the second one would be valuable in real business project – I‘d LOVE to have something like that for the project I‘m working on currently. Anyway, the final decision is up to me.


Suggestions?




Book: Programming Language Pragmatics

Sun, 31 Jul 2005 17:59:14 -0400

I've just finished reading this book - thanks to my commute time - and it's just awesome! I wish I had read it years ago. It's not only for people interested on compilers, or CS students, it's about programming languages - which is the major tool for programmer - how different languages allow you to express your code, how they evolved, the small differences, the rights and wrongs. The most impressive chapter, at least to me, was the one dedicated to functional/logical languages, as I'm clearly not familiar with them, it's was kind hard to grasp. Definitely it was the best technical book I ever read.. this year. The top of the list still The Pragmatic Programmer

After that I decided to restart Rook - one more time. This is what it's doing by now:

(image)

Not impressive, I know, but now it's just a matter of adapt adopt improve :-)




PicoContainer is also using Castle.DynamicProxy

Sat, 23 Jul 2005 20:23:48 -0400


The .net ports of PicoContainer and NanoContainer are using Castle.DynamicProxy

Great! But starting shameless plug if you are looking for a container in .net land, check also this (image)




MonoRail on Portland Code Camp

Mon, 18 Jul 2005 12:42:05 -0400


Phil Weber is presenting a session about MonoRail at Portland Code Camp. Here‘s the session description:


Web developers everywhere are abuzz about Ruby on Rails, a Model-View-Controller (MVC) framework for Ruby. Why should Ruby programmers have all the fun? In this session you‘ll learn about MonoRail, an open-source re-imagining of Rails for ASP.NET. You‘ll see how MonoRail improves maintainability by segregating business logic, data access and presentation layer code. And perhaps more importantly, you‘ll learn how MonoRail can increase your productivity by dramatically reducing the amount of code you must write.


For more check http://pacwest.ms/codecamp/pdx/1/sessions.html


Gosh, I wish I was there. I also know a thing or two about MonoRail myself (image)




Negative ad?

Fri, 15 Jul 2005 18:24:26 -0400

http://manuals.rubyonrails.com/

Application error

Rails application failed to start properly



I‘m sure there are a bunch of people right now saying that in J2EE apps things like that never happens.




What makes Castle.MicroKernel a cool thing?

Fri, 15 Jul 2005 00:25:18 -0400

In my first experiences with .net I was totally attribute-crazy. I wanted to use metadata for everything afterall, in C++ and java I didn't have anything similar to play with. So one of the things I remember I've created for the company framework was the ability to decorate the properties with validation attributes (btw, I'm not proud of it) public class Product { ... [RequiredField] public String Name { { get / set ... } } } After that I created a small infrastructure to commands (similar to transaction scripts). A command could be transactional or not. [Serializable, Transactional] public class CreateCompanyCommand : ICommand { // properties ... // The real business work: public object Execute() { ... lots of work ... return (newly created object); } } The transactional or nontransactional attribute were used by the framework to create the proper environment for the command execution. The transactional command was executed from a ServicedComponent. (By the way that is another design I'm not proud of. With commands you end up with too much repetitive code, not to mention the copy and paste syndrome, but I digress) I left this project and few weeks ago I saw it again - small world! Few other small frameworks were created, but clearly they do no cooperate. For example, if they wanted to introduce logging, even though by using a small framework and trying to keep things non intrusive, they would dig some code and do some dirty work. This is were Castle.MicroKernel can make things simpler. By serving as a rendezvous you can code your small infrastructure - enter Facility - to serve your application and they _will_ be independent and cooperate (without realizing this fact). Then, just register the components on the container and expose them to your application nicely. By nicely I mean: without references to the container, so you keep things reversible. How to do that? There are plenty of ways, as design is always a matter of taste and Castle never imposes anything: With the TypedFactory Facility you can code factory interfaces and use them to obtain instances of your component. By properly designing layers - think separation of concerns - you can have hard references to the container only to instantiate the first layer (the entry point). The remaining comes automagically with the auto-wiring. By using a framework like MonoRail and its integration with Windsor, your first layer would be the controllers, and them just need to put on the constructor the services it needs. Again, no references to the container You can also use the Windsor adapter to System.ComponentModel.IServiceContainer, so you're application can replace the container implementation and only depends on the standard .net API (if it makes you feel more comfortable) ;-) If you still can't see the benefits, then I think your abilities as a developer/architect are a bit er..hmm.. questionable :-p [...]



Container Reference documentation

Tue, 12 Jul 2005 12:20:18 -0400


Finally I reserved some time to put together a decent documentation:



Containers Reference Documentation



Hopefully it will shed some light on the inner-workings of Castle.MicroKernel.




Re: Microsoft to chase phantom Ajax scientists

Thu, 7 Jul 2005 21:21:03 -0400


It‘s so sad that the .Net community still has much to learn about being educated, discuss things decently or just keep the mouth shut when appropriated.


I was reading DHH blog long time since my last visit and some of the comments were quite stupid. One of them refering to MonoRail:



Challenge by Anomman on June 30, 6:55

MonoRail is staying on the heals of Ruby on Rails for .NET (AJAX Helpers, a near completed ActiveRecord implementation, and Scaffolding support). The distinct advantages of Ruby on Rails are slowly being killed. With the new dynamic Ruby like language, Rook, being developed to run on .NET, David will have a tough time providing a completing advantage for those to switch platforms in the Rapid Application development field.




If that is the message Castle, MonoRail and its community are sending now to Open source community, I‘d rather pull the plug right now.


I‘ve worked on a product using the earlier versions of Ruby on Rails, I just loved the damn thing. I realised that I couldn't work with my old model again, but given the common political, strategic, you name it, reasons, companies around here just wouldn't ALLOW me to use Ruby in any projects. This is my reality and I truly hope someday things are going to be different.


That‘s why I kick off MonoRail, I wanted a pleasant web framework and yet pay my bills. It‘s not meant to compete. People, listen: we‘re not competing.


I‘ve stated this before, and I‘m gonna say again: I may disagree with some of DHH‘s moves, but he did created a wonderfull framework, with things that I‘ve never seen before, a paradigm shift to simplicity. If MonoRail is a success, kudos to him.




My best wishes to London

Thu, 7 Jul 2005 20:21:43 -0400


Last september I spent a month in London studying english at St Gilles Intl. Met lots of people, my teacher, Alexandra, was terrific, and that british humor sauce is really adorable. I‘ve also made some intl friends and some people from thoughtwork‘s geek nights.


When I wake up this morning and see the news, my thoughts related to the healthy of those people. Russel square is about 300m from the St Gilles school. It‘s also somewhat near TW. Kings Cross and Moorgate were the station I used to get to the technical lunch with TW people.


Fortunatelly all emails I‘ve sent were answered, everyone is fine. London is a superb city with a terrific people. There‘s no other place in the world I feel so comfortable. My sincere best wishes to them.




Castle - new releases

Sat, 2 Jul 2005 17:14:16 -0400

Castle has some good news: DynamicProxy 1.1.5 Phew! Thanks for the patches. There were some nasty bugs related to indexers, constructors and deserialization. Fixed now. ActiveRecord beta 1 AR had its inner workings rewritten. However the changes shouldn‘t impact on people who are using it. We improved error messages and added support for table hierarchies using discriminators or joined tables. Inversion of control package beta 3 Seems that this is the most stable piece under Castle umbrella. Almost no bugs reported. MonoRail beta 3 Now this is where the biggest juicy improvements are. Lots of contributions, patches, suggestions! Routing support If you want pretty urls like: http://site/blog/posts/2005/07/07/ just register a module: And add your path rewriting rules: ... (/blog/posts/)(\d+)/(\d+)/(.)*$ (/news/)(\d+)/(\d+)/(.)*$ ` PS: CDATA was necessary ‘cause .Net xml parser for the configuration seems to be a simplified and even bugged version of the official parser :-\ DataBind Now you can populate objects based on form parameters (thanks to CobraLord!): public class AccountController : SmartDispatcherController { public void Update([DataBind] Account account) { } } If you‘re using MonoRail and ActiveRecord, things get even better alt=title=":-D" /> public class AccountController : SmartDispatcherController { public void Edit([DataBind] Account account) { PropertyBag["account"] = account; RenderView("edit"); // Not necessary, but clearer } public void Update([DataBind] Account account) { if (!account.IsValid()) { Context.Flash["errors"] = account.ValidationErrorMessages; Edit(account); } else { account.Update(); List(); } } } You can even have multiple databinds: public void Update([DataBind] Account account, [DataBind] User user) { } But to avoid collisions, it‘s a good idea to use a prefix: public void Update([DataBind] Account account, [DataBind(Prefix="user")] User user) { } Resources Also thanks to CobraLord – you can associate resources with a controller: [Resource("Validation", "My.Namespace.Javascript.Validation")] public sealed class MyController : Controller The resource entries will be automatically added to the property bag. Localization I dont even have to explain this one! alt=title=":-D" /> Again: thanks to CobraLord [LocalizationFilter( RequestStor[...]



Damn sick

Fri, 1 Jul 2005 17:30:05 -0400

Gosh, I just can't remember the last time I've been so sick. Headache, backache, fever, allucinations (this is the only cool part).

But the leason was learned. You get what you've paid for. Eating in cheap places has a price...

The funny part is reading the messages on castle mailing list and forum. It takes me a while to understand what the guy is talking about. btw what's castle anyway?




Finally Mr Fowler understood IoC

Wed, 29 Jun 2005 08:23:34 -0400

Quoting his post:

"There is some confusion these days over the meaning of inversion of control due to the rise of IoC containers; some people confuse the general principle here with the specific styles of inversion of control (such as dependency injection) that these containers use."

Aha! He should blame himself. But that's OK. Finally he said how inversion of control is a broader concept, how does it differ frameworks from libraries/api and that even EJB containers use it.

Thanks, uncle fowler! :-P




Castle ActiveRecord Documentation

Sun, 19 Jun 2005 19:14:00 -0400


Finally I put together a partial documentation.


Check http://www.castleproject.org/index.php/ActiveRecord:Reference_Documentation




Presentation on IoC, Castle and NanoContainer

Fri, 17 Jun 2005 17:23:17 -0400

In PDF and PPT. Nice work, although not very accurate. Castle supports constructor, setter and whatever else you may want to implement - like Avalon's ServiceManager.

This presentation also point out some similarities between Castle and NanoContainer/PicoContainer. Well, if they only analysed the API, it might have some similarities, but that's it - althought I have great respect for Joe Walnes' work. He's an incredible smart guy.




My kingdom for a decent Winforms API

Mon, 13 Jun 2005 22:12:36 -0400

I'm working on a proof-of-concept to validate an object model and the database structure behind it. Decided to do it using Winforms to save some time. What a dumb!

Winforms seems perfect – even awesome – for someone that worked with Visual Basic for the past ten years – nothing against VB programmers, btw – but as I’ve played with Swing and JFace, I can see Winforms' faults, specially in the sense of lack of an API for people that looks for a decent design in Windows plataform – rare thing?

Being concrete in my complain:

Combox: Now the Combox has a Items property, so you can just add your objects (whatever object) and the even use the DisplayMember and ValueMember so the control can use reflection to populate itself accordingly. Nice for simple cases.

But I’d like to have some better textual representations of my contents without relying on owner draw. Yeah, just a

ItemParent 
--Child Item 
--Child Item 

would do the trick. No way.. Unless I override the ToString on my classes to give them this inteligence – which is completely unacceptable.

I’m not asking MS to drop the current API, but to offer one extra way. For example:

comboBox1.SourceProvider = new MyItemsProvider();
comboBox1.LabelProvider = new MyLabelProvider();

Just like JFace. Soooo nice!

class MyLabelProvider : ILabelProvider
{
  String ILabelProvider.GetLabelFor(object item)
  { 
     ... work work …
     return String.Format(”{0}{1}”, ident, itemName);
  }
}

ListItems: Same thing. You have to live with something that was just ported from VB controls.

Why not

listView1.ContentProvider = new MyNewContentProvider();

listView1.LabelProvider = new StandardLabelProvider(); // Uses whatever is the default logic to gather item’s label

It would be so easy to reuse UI logic…

TreeView.Nodes Oh, c’mon!

I wonder if Avalon will save the day. Hopefully.




If US wants to watch/reinforce democracy in south america...

Tue, 7 Jun 2005 13:36:02 -0400


...then who is going to watch US? The american people? They don‘t seem to be doing a very good job at all.




Beard

Sun, 5 Jun 2005 04:05:39 -0400

Why, WHY!, we do we have beard? Is it any good? I understand that a few centuries ago it might have had some importance, but it's damn useless now.

I believe in a near future where male pre-adolescents will have to choose between the red or blue pill, signaling the non-beard mode to their body... I have a dream!