if ( document.comments_form.url ) { document.comments_form.url.value = getCookie("mtcmthome"); } Otaku, Cedric's weblog: January 2004 Archives

January 29, 2004

More on super and inheritance

There were quite a few interesting comments on my previous entry, both on my weblog and on TheServerSide thread.  I will address them in turn and I'll take this opportunity to clarify my position on inheritance.

Howard writes:

I tend to make as many of my methods private as possible. I occasionally even use final on non-private methods (but rarely).

This is a very good practice.  Interestingly, it's a lesson that we learned from C++, where the community actually took it one step further.  Back then, I remember reading an article by a C++ guru actually recommending to maximize the number of static methods in your code.  This article caused quite a stir as you can guess since a lot of developers equate static methods to global variables.  Nevertheless, the author mentioned that static methods are the most decoupled methods you can have in your code. Something to think about.

Vincent says:

I personnally try not to extend specialized TestCase. I prefer to work with Suites. I think this is the "official" way to extend JUnit

I don't know how official it is, but point taken, Vincent.  I think I'll head this way as well, maybe it will decrease the amount of frustration I have with JUnit :-)

Hristo is more radical:

Yes inheritance IS EVIL and should almost always be replaced with compositions (or AOP introductions).

I disagree with this, which is too radical in my taste.  Neither inheritance nor delegation/composition/introduction are silver bullets.  I am not going to run an exhaustive list of their pros and cons, but I think one of the salient points that should make you choose one over the other is that of Typing.  When you extend, your subclass can be substituted for its parent class (also referred to as the Liskov Substitution Principle).  There are quite a few cases when such a property is not only convenient:  it is the only sound design choice.  On the other hand, delegation is more flexible and more dynamic.  This is also something that can be a requirement.

Hristo also uses this interview of James Gosling to bash inheritance, whereas Gosling seems actually to be quite fond of inheritance:

I personally tend to use inheritance more often than anything else.

Then Hani sets the debate back on track with his usual lucid observation:

Inheritance isn't evil, people who don't understand it or design for it are.

Which is pretty much what I said in the paragraph above, although in different terms since I couldn't dream of ever reaching Hani's mastery of concision and punch-packing.

Bo notices:

Um, as far as I can tell, you haven't made a case against not calling super you've made a case about why you should put initialization logic in constructors. (Hint: base class constructors always get called).

Right, constructors are always called and the invocation of super in their code is enforced by the compiler, which is why I made them an exception in my original article ("whenever you feel the need to call super inside a method that is not a constructor, it's a code smell").   And I agree that initialization logic should be in constructors, but it's not always achievable.  Sometimes, extra initialization has to happen after the object is created.

It's too bad that java doesn't have an overrides keyword yet (1.5 will introduce @Overrides)

This keyword won't change anything to the problem at hand, except that the compiler might be able to notice a typo.  But there will certainly be no implicit call to super.

IMO calling super should be the first thing you do when you override a method

In my experience, close to none of the code I work with or read ever does that.  Most of the methods that override a parent method simply replace the logic of the overridden method.  You might call that misuse of inheritance, and I won't necessarily disagree with you, but this is a different topic.

 

Posted by cedric at 10:15 AM | Comments (12)

January 28, 2004

Don't call super

Okay, I found why my DBUnit tests were not working:  I was overriding setUp() but not calling its parent version.

The fix was simply to invoke super.setUp() in my own setUp():

public void setUp() {
  try {
    Class.forName(JDBC_DRIVER).newInstance();
    super.setUp();
  ...

Note that the order of these two instructions is important, or DatabaseTestCase will be unable to locate your driver.  Seems obvious, but I didn't get it right the first time.

Now, all this makes me angry for a lot of reasons.

First of all, this is the kind of design flaws that has been around since the C++ days.  I weblogged about it a while ago:

This kind of pattern is similar to seeing methods invoke their super counterpart, a definite code smell in my book (if you override the said method and forget to call super, everything breaks).

I'll restate my point:  whenever you feel the need to call super inside a method that is not a constructor, it's a code smell.  If on top of that, this method can be overridden by subclasses, you absolutely need to get rid of that constraint because I guarantee you that someone (a user or even yourself) will break that contract.

How do you solve this problem?  With a technique called "hooks".

In this particular example, DatabaseTestCase.setUp() performs some very important initialization logic.  If this code is not run, then DBUnit breaks.  As simple as that.  The problem is that subclasses are very likely to override setUp(), since it's the recommended and documented way to set up your tests in JUnit.

When you face such a situation, you should consider moving the vital code in a private method that cannot be subclassed, and then have this method invoke one or several "hooks".  The hook would be, in that case "onSetUp()".  This way, subclasses can be notified when the setUp() is happening but they won't override the important initialization that's happening in it.

Admittedly, this technique has limits when the hierarchy of subclasses deepens, and there is no easy way to achieve that, so DBUnit is not completely to blame.

The real culprit is JUnit which was designed without realizing that subclasses of TestCase can be either more specialized parent test classes or real tests, and that subclassing rules should be different depending on which class you are implementing.

The more I work with JUnit, the more angry <blam> I <blam> get.

 

Posted by cedric at 10:01 AM | Comments (25)

January 27, 2004

Another game

For all of you bored with hitting penguins, here is another little game (HTML + Javascript).  Quite simple and addictive.  My record is about 26 seconds.  I recommend IE to run it, Mozilla seems to experience a few glitches with this code.

 

Posted by cedric at 01:53 PM | Comments (30)

January 26, 2004

Major spam attack

I have just been the target of a massive spam comment attack. In the night of January 23rd, my weblog received about two hundred and fifty (250!) spam comments.  The sheer size of it is not the only thing that worries me:  it's the way it was done.

Usually, MT-Blacklist makes it trivial to get rid of such spam and it also allows you to despam your weblog retroactively (i.e. not just the comment that was just posted and for which you just received an email notification). The problem in this particular attack is that these 250 comments

  • All came with a different email address.
     
  • Were posted all across my weblog, not just on one entry (they commented on about thirty posts).
     
  • But worst of all, they advertised a wide range of web sites, not just one.

This last point is the reason why MT-Blacklist was a little less effective at getting rid of that spam than it usually is, since MT-Blacklist despams based on the URL of the poster or its IP address (most of the time useless). Ideally, I would have liked MT-Blacklist to have an option "Add the websites contained in the last 250 comments to my blacklist and despam my entire weblog", but since this is not supported, I had to do some manual work.

Basically, I went through my Inbox and blacklisted the domains one by one. Once I thought I had found most of them (going through 30-40 emails), I asked MT-Blacklist to despam my entire weblog.  Then I repeated this procedure until the last comment posted on my welcome page was a legitimate comment again.  Total time, about a half hour.  Not too bad.

Now, all this made me think a little bit about the spam comment phenomenon. Obviously, the blacklist method will not scale for much longer, so how could I stop the problem at its source: preventing spammers from posting in the first place?

This is obviously impossible, so maybe I could push the reasoning one step further and make sure they don't find my weblog in the first place... The question now is: how did they find my weblog?

If I were a spammer and I were looking for weblogs to comment, I would start by determining what seems to be the de facto weblogging software. Movable Type is an easy choice. Then I would take a look at the source and find how comments are posted. I would quickly find out that the main entry point is called "mt-comments.cgi" and I would google it.

So I did this, and... holy smurf on a snowboard! My weblog appears in sixth position!!!  Now things are slowly falling into place. I think the first measure I will take is to rename mt-comments.cgi to something different (how about vxtyzb.cgi?) and I will patch my installation of Movable Type to use this new page. Hopefully, this shouldn't be too hard.

I have a few other ideas to make these bastards' lives harder but it will be for a next entry.

Update:  I made the change.  It's a simple matter of modifying mt.cfg, renaming the script and rebuilding the whole site.  I am very happy to report that if you click on the link shown by the google request above, it will now 404.  Yeah.

 

Posted by cedric at 08:42 AM | Comments (15)

January 24, 2004

Trace wizardry

Indeed, Cameron's trick is pretty cool.  I have been using a similar trick for a while now, except that when I wrote it, we didn't have StackFrame support, so it was all about dirty manual parsing of the stack trace.

However, my technique is different from Cameron's in the following ways:

  • I don't print the name of the variable.  Most of the time, I'm not tracing a variable (could be an array or the result of a method) and anyway, the name of the variable is not that important.
     
  • However, I use the trick to print the name of the class.  This is the most important part, in my opinion.  I can't count the number of times where I painfully looked for a particular trace in my source code in order to remove it.  IDE's make it a little easier to do that now, but they also have limits (like when the text happens to be i18n'ed and therefore, nowhere to be found in your *.java files).
     
  • And finally, I give my trace functions a very identifiable name, for a reason related to the previous point.  Using a name like "trace()" or "p()" makes it challenging to find all the places where you invoke the trace, so I typically use "ppp()".  You can't type this by accident :-)

All that being said, IDE's make this kind of hack almost useless these days.  For example, I have a template called "ppp" and all I need to do is type "ppp<space>" at any moment to have the trace method automatically implemented with the class name and everything else in it.

But it's nowhere near as elegant as the trace walking.

 

Posted by cedric at 02:24 PM | Comments (1)

January 23, 2004

More DBUnit woes

By an interesting coincidence, DBUnit released version 2.0 yesterday, so I immediately installed it.  The good news is that it didn't require any change in my code (probably because I am still in the early experimentation stage at this point, but I understand that some major configuration changes have been made).

That being said, my first contact with version 2.0 is not good at all.  For example, I made a typo in my XML dataset and misspelled a column name:

<PERSON last_nam = "Molinier" first_name = "David" middle_name = "L" />

With DBUnit 1.5.6, the punishment is immediate:

java.sql.SQLException: General error, message from server: "Column 'last_name' cannot be null"

(Note that the error is not that the column name is incorrect, which is already not looking good).

But with DBUnit 2.0, the error is silently discarded and I end up with an inconsistent database:

+-----------+------------+-------------+
| last_name | first_name | middle_name |
+-----------+------------+-------------+
|           | David      | NULL        |
+-----------+------------+-------------+

Second, I can't seem to be able to initialize the middle_name column, neither with 1.5.6 nor with 2.0.  No error message, no indication whatsoever of what went wrong.  Of course, I am pretty confident the spelling is right.

Strike three for DBUnit.  Very disappointed.

 

Posted by cedric at 04:30 PM | Comments (7)

DBUnit doubts

I was looking forward to converting my database tests to DBUnit, created by Manuel Laflamme.  The idea of being able to specify my test data in an external file was appealing, as was the fact that DBUnit is a thin layer on top of JUnit, so I was confident I would feel comfortable with the product.

Unfortunately, things turned out differently.

First of all, I still haven't been able to get it to work.  For some strange reason, my getConnection() never gets invoked.  I am not extremely worried about that, I know I will eventually figure it out, but why is it that every single open-source product that I try never works as advertised out of the box?  Why do I always have to become much more intimate with their source base than I would like to?

Another sadly typical thing in open-source projects is that if you go to DBUnit's home page, there is no obvious link to the documentation.  I give them points for putting the Download link on top, but if I am trying to evaluate your product, why would I care so much for Changes, FAQ, Getting Support, Source or JavaDocs?  Just point me to a simple white paper of a few pages explaining why I should care about your product.  To make matter worse, the only page that provides some assistance tells you that the documentation can be found in the release.  Come on, now, just make the darn thing available online and make sure it sits right up next to the Download link.

Anyway.

The real problem is the idea behind DBUnit.  I started realizing that specifying the test data in an external file didn't make that much sense after all.  If you are going to modify the said data, you will be modifying your Java code as well, so the maintenance cost is pretty much the same in both cases.  Except that if you initialize your test data in the code, you get an additional way of testing your database code, and you are also probably closer to the way your users will initialize their own database.

Another hint on the questionable premise of DBUnit can be read in the author's own comments.  He initially started with a generic XML format to describe the data that your database should be initialized with.  Then, in the next version, he makes the following observation:

The FlatXmlDataSet class has been introduced in version 1.2. I found that generic XML datasets were hard to write and to maintain. This was particularly painful for tables having a lot of columns.

This new XML format is more generic but also dependent on your database schema.  It's a progress over the first iteration, but it's a pity that Manuel didn't push this realization to its conclusion:  you are trying to model relational data, XML is not a good way to do that because it is hierarchical.  From a practical standpoint, I see very little difference in verbosity between FlatXmlDataSet and plain Java code.  I would argue that a dumb properties file would probably be the easiest choice:

person.row0 = "Beust", "Cedric", ""
person.row1 = "Purdy", "Harold", "C"

I really want to like DBUnit, but at this point, I see very little added value compared to writing my own framework on top of JUnit.

Can someone convince me otherwise?

 

Posted by cedric at 10:12 AM | Comments (8)

January 22, 2004

Hit the penguin!

Note:  the title has nothing to do with my previous entry ;-)

Stressed?  Try this little game.  Quite fun (my record is 321).  Hint:  you can control both speed and angle of the swing.

Posted by cedric at 02:26 PM | Comments (149)

2004 the year of Linux? I don't think so

It's quite amusing to see various pundits predicting that 2004 will be "the year of Linux" (including Linus himself, but this shouldn't come as a surprise).  Never mind the fact that the past eight years have all been predicted as the "year of Linux", there are quite a few signs that make me think that if anything, this year will be the year of Windows.

If Linux ever had a chance, I would evaluate it at two or three years ago.  But now, in 2004, what do we see?  An increasing loss of market shares for Sun, the herald of UNIX if there is any still alive these days, casting a grim shadow on the entire UNIX industry.  Red Hat's recent withdrawals and reversal of fortunes are not helping, nor is the inability of the Linux community to agree on one user interface (I remember making this exact remark to coworkers in 1995 about Linux, and in1990 about UNIX in general).

It's quite ironic that the only major user-oriented advance in the UNIX world has been made by Apple, who single-handedly made UNIX credible for Joe-type users.  But with their faltering 2% market share of personal desktops, I can't see how it really helps the cause that much.

On the flipside, Windows has never been so present.  First of all, the existing offers (Windows 2000 and XP) are going stronger than ever to a point where even die-hard Linux fans find it quite acceptable to work on these two operating systems.

The "next generation" operating systems are still far away (Windows 2003 is kind of here already and who can tell when Longhorn will actually be ready), but they promise innovative features that get the developer community drooling (WinFS and Indigo come to mind).

But if you look past the desktop, Microsoft appears as a more credible player every day, especially in the mobile space.  Windows cell phones are making shy but firm entries in our lives and Windows-based PDA's are increasingly becoming a force to reckon with.

I have read some articles saying that 2004 will make or break Linux.  I am predicting that nothing such will happen.  Linux will keep the niche place it has had for years now and 99% of computer users will simply and quietly keep not caring about it.

 

Posted by cedric at 10:04 AM | Comments (15)

January 15, 2004

Ioc types

I am a bit puzzled by Martin Fowler's description of the difference between IoC type 1 (interface injection):

class MovieLister implements InjectFinder...
  private MovieFinder finder;
  public void injectFinder(MovieFinder finder) {
    this.finder = finder;
  }

and IoC type 2 (setter injection):

class MovieLister...
private MovieFinder finder;
public void setFinder(MovieFinder finder) {
  this.finder = finder;
}

These two methods look exactly the same to me, except for the name of the method the initializes the component and the interface implemented by the first component (the second component could implement an interface as well).

Am I missing something?

 

Posted by cedric at 04:14 PM | Comments (15)

January 14, 2004

Book list

I added my latest book purchases to the book list. As you can see, I am in a SQL frenzy these days.

Posted by cedric at 10:48 AM | Comments (3)

January 11, 2004

It's about the content, not the author

I can't really agree with Rick's statements on the importance of knowing who a blogger is.  Rick writes:

I simply disregard blogs that give me no way to identify the blogger. Life is too short to be wasting it trying to decide whether someone's message is worthy regardless of their failure to have enough self-respect and courage to identify themselves as the speaker of the message.

Far from me the idea to defend what Saunders is doing, but I have to say I don't agree with the above statement at all.

Why is it so important to know the real identity of weblogger?

We work in a domain where it's pretty easy (almost scientific) to determine the validity of articles and posts.  I don't care if the article was written by a twelve-year old, a software guru with thirty years of experience or some marketing shill serving a hidden agenda.  I can decide for myself if this person is posting something that I find
interesting.

Granted, knowing the employer of such a person might possibly be relevant but I don't even need that to decide if I want to subscribe to that person's weblog.

Rick's recent posting is equally misguided.  Obviously, you can't hold a weblogger to the same standard you would expect from a nation leader or a journalist.  Let's try and keep things in perspective.

The bottom line is:  if you don't know the author of an article or of a blog entry, it is your duty to apply maximal skepticism and use your judgment before forming an opinion.

Posted by cedric at 05:40 PM | Comments (7)

January 07, 2004

Spam, spam, spam

Like everybody else, I am subjected to various forms of spam every day. At the top of the list, email, of course, which pretty much everyone reading this weblog probably endures every day. But I also receive more unusual forms of spam that only a smaller portion of the online community ever has to deal with.

As the owner of a relatively big mailing-list (EJBGen, 620 members as of today), I am a regular target for both untargetted (sex, loans, etc...) and targetted (recruiting firms) spam. I have always been reluctant to make my mailing-lists moderated, because my time is limited but also because I want posters to feel free to email whenever they feel like it. Then I realized that Yahoogroups offers two very effective ways to prevent spamming without resorting to full-length moderation.

First of all, I receive an email every time a new member joins. Mailing-list spammers are not very clever at making out fake names, so their email address is usually a dead give away (cheap_loans@yahoo.com, etc...). I don't expect this trend to last much longer, but it allows me to preemptively remove and ban the person quickly.

The second feature that I recently turned on is that first posters get moderated when they send their first message. This is extremely effective and it will force the spammers to send at least one on-topic message on the list before being able to unload their crap on my subscribers, something which I don't think will be worth their time.

Then, there is weblog comment spam.

Most weblogs allow readers to leave a comment, optionally allowing them to leave an email address and a Web site. It didn't take long to spammers to figure out that this was a cheap way to have many self-created links to their own Web site, thereby artificially inflating their Google ranking.

What baffles me with this kind of spam is that it strikes me as an extremely inefficient way to boost your ranking. First of all, you need to go through a form to file a spam, and while it is theoretically possible to automate pretty much any kind of interaction with a browser, I suspect most of these spams are made by hand. Leaving a comment on a weblog is an expensive process, aggravated by the variety in weblogs and procedures needed to achieve that result. Another thing to keep in mind is that this kind of spam is only effective if the comments are displayed prominently on the weblog, or at least, that they are reachable by a GoogleBot, another thing that is not a guarantee.

So I am really shocked to see that despite these facts, spammers take the time to leave fake comments in weblogs. Which is pretty alarming since it confirms that these guys have a lot of resources and money to be able to finance this kind of grunt work.

So far, I was just deleting the comments manually, one by one, which is pretty easy since I receive an email every time a comment is left on my Weblog. However, I received my first "full scale" attack a few days ago and a spammer left over thirty spam comments spread over that many entries. So I decided to install MT-Blacklist, which is now up and running and working great. Spammers can now be blocked right away if the content of their comment matches a black list, but in case they work around this first measure, I still receive the comment in email and the bottom of that email contains a link allowing me to eradicate and blacklist the offender in one fell click. Quite a relief.

I wonder what spammers will come up with next...

Posted by cedric at 11:32 AM | Comments (5)

January 06, 2004

iPod Mini

Well, Steve finally gave the scoop on the new iPod. It's 5 Gb (1000 songs says Steve, adjust with the Jobs distortion factor accordingly), thinner and lighter than the competition. It's priced at $250, $50 more than the average MP3 Flash players.

It sounds good except that Jobs also announced that the entry-level iPod was switching from 10 Gb to 15 Gb, while keeping its original price of $299.

Maybe there are people who will want to save $50 at the expense of 67% of capacity but I really doubt they will be legion. It seems to me the iPod Mini is hitting exactly in the middle of the two sweet spots: either lower the capacity and the price or bring it closer to the regular iPod. I predict disappointing sales for that very reason, but time will tell...

Posted by cedric at 11:19 AM | Comments (7)

January 04, 2004

A trip back with father Tiresias

I am just back from France where I spent the holiday break with my family, split between Paris and Deauville (my home town). I only go back once a year and it's always an interesting experience. In many ways, I have the feeling that things don't change a bit back home. Same old faces on the television, same people in politics, same strikes, same scandals, same artists.

Every year, I go through the same puzzling experience: I feel like a total stranger in France but I am surprised by my ability at not only understanding the language but actually being able to blend in. Believe it or not, but I can really pass as a native. This probably sounds funny to you but it's constant rediscovery for me. The only giveaway of my expat status is not that I use English words in my French (I love the French language and I do my best to always look for the right French words, even if English words tend to come up more easily), but rather that my sentences and my words sometimes have an American intonation to them. Also, my absolute ignorance of certain events and famous personalities would probably be a dead give away.

Like every year, I am impressed by the amount of SMS messages that French exchange every day. I heard that on January 1st, four million text messages were exchanged between midnight and fifteen past midnight. By 8 o'clock, the number had reached twenty million, to which you need to add SMS messages exchanged on private networks (so 30-40 million is probably a more accurate estimate). The state of affairs in the United States is pathetic compared to Europeans. Hardly anyone even knows what SMS is, much less use it at all.

That being said, I am happy to report that for the first time in three-four years, America seems to have caught up in terms of cell phones: form factor and functionalities are now on par with what French use.

Another thing that is always a wonderful rediscovery is the breadth of French TV news. You need to see it for yourself to realize how much Europe is a reality there. There is not a single TV newscast that doesn't include at least 30 if not 50% of news from all over Europe. This is something that the US needs to learn very fast. Even San Francisco, probably one of the most varied city in America in terms of ethnic representations, is very much guilty of "nombrilisme" (the act of staring at one's navel). TV or newspaper, it's really really hard to find any kind of non-American news.

I also used this time to catch up on French movies. Big disappointment there, I found pretty much all the movies I watched very boring or even pathetic, even those that received reviews from the critics, such as "Le Placard" (which was shown in San Francisco for a while, featuring Depardieu, Daniel Auteuil, Jean Rochefort and many other top-notch French actors). I can't say I even smiled once watching it. I was also exposed to Michel Vaillant on the plane (a comic strip I used to love when I was a kid, and which, even though the script was written by Luc Besson, turns out to be a ridiculously pompous and ludicrous movie). Maybe I watched the wrong movies but it seems to me French screenplay writers are in desperate need of an imagination fix.

I did come back home with a few French DVD's though (my DVD player is region-free): "L'integrale des Nuls" (a group of French comedians who can be compared to Saturday Night Live and who unfortunately stopped their comic work a few years ago) and "les Inconnus" (same thing). I am looking forward to watching these and my only regret is that I can't really share them with my non French-speaking friends.

Another thing very unique to France compared to America is Bandes Dessinees. I could translate this to "comic strip" but it's really not doing this genre justice. First of all, bandes dessinees are sold in hard cover, but also the attention to the scenario and the drawing makes it a full-fledged art, right up there with books and movies. I learned to read with bandes dessinees when I was four years old, so it comes as little surprise that I'm still fascinated by this genre. Throughout the years, I do my best to keep my collection current and I also take every opportunity possible to discover new authors and new heroes.

My recurring purchases are typically Blake and Mortimer, Thorgal, XIII, Largo Wynch, and Yoko Tsuno among others, but I also recently discovered the Aldebaran cycle and also AquaBlue. As for novels, I didn't have much time to shop around and 95% of my reading is in English anyway, but I did buy Bernard Werber's latest two novels. Werber is the author of the fascinating "Ants" (and its two sequels). If you think that a fiction novel about ants cannot be interesting, I urge you to read at least the first book, which is available in English if I'm not mistaken.

But Werber didn't stop there and he wrote riveting novels after that, one of my favorites being the "Thanatonautes", about near-death experiments. Very recommended, it will make you see things in a very different way. I am very much looking forward to reading my two recent purchases.

I don't keep up much with French music but I never fail to see if Mylene Farmer or Jean-Jacques Goldman have released any new album. Goldman is a French version of Mark Knopfler (and as a die-hard Dire Straits fan, it's not a compliment I make easily). He is an outstanding guitarist (actually he also plays the violine and many other instruments), composer and singer. He also wrote countless songs for dozens of famous singers such as Celine Dion. His recent album seems to be very influenced by Irish traditional songs but I need to listen to it more to decide. If you would like to discover this amazing and yet simple guy, I strongly recommend his masterpiece album "Entre gris clair et gris fonce".

All in all, I enjoyed my trip and nothing can explain what it tastes like to eat French food even at the simplest "troquet du coin". You need to experience it for yourself.

Happy new year to you all.

Posted by cedric at 06:17 PM | Comments (16)

January 02, 2004

Pico-puzzled

Okay Carlos, thanks for the attempt to explain why you like PicoContainer, but I'm still not convinced.

You are saying that Pico forces you to structure your classes better by avoiding getters and setters. First of all, I don't believe in this kind of generalization and while I do agree that the practice you recommend improves your code quite a bit, I argue that in real life, things are not so easy. Even your simple BankAccount example would become much more complicated in the real world and I challenge you to stick to the rule "no setters/getters" then.

But for the sake of argument, let's assume you can indeed "normalize" any Java class by removing all setters and getters and by initializing your object only with constructors. Well, in that case, what you are telling me is that PicoContainer has made you think differently. It's changed the way you program and has made you a better programmer, but it still doesn't make the use of PicoContainer mandatory. It's a bit like learning about Aspect-Oriented Programming and realizing the importance of separation of concerns. But you can apply such technique without any AOP framework.

I really want to like PicoContainer, but so far, I am still unconvinced why I should adopt it. I went through the source code of the ten-or-so projects that use it and I haven't found one very obvious usage which would be hard to achieve without it.

Carlos, can you try again?

Posted by cedric at 05:09 AM | Comments (8)