Home

Add a comment

 

Re: JSR-299 & @Produces

Hi Anonymous (-/62.91.33.77),

I thought for a while about whether I would approve your comment, because frankly, it's tone is very aggressive. The fact you haven't left your name didn't help. In the future, please be a little nicer :-)

I won't comment on all your points, but some are interesting.

1) The snippets are not mine, rather copied mostly from the spec. Your tip on injecting on setters rather than injecting on fields is a good one.

2) Login Bean - I didn't explicitly say that I prefer injecting a login bean or current user bean. I might indeed prefer injecting a bean which contains my entire model... All of these conform to Demeter to some degree, which according to Wikipedia is summarised as:

"each unit should have only limited knowledge about other units: only units closely related to the current unit" - no problem here, as the "backing" bean is related to a model bean;

"Each unit should only talk to its friends; don't talk to strangers" - again, no problem here;
"Only talk to your immediate friends" - yup, again, no problem here.

Maybe you need to lookup what Demeter is about, before telling me I am wrong. My world isn't as black and white as yours.

"About qualifiers..." - Yes, I do understand them, you don't need to explain them. Thanks anyway.

"For me, the name of the variable providers the information about what the hell that thing is. For readability, you need as little noise as possible"

I guess we will just have to disagree here. Something I can add is this: I have spent years maintaining large systems where we are often hunting for potential bugs. If I want to find the implementation of say an EJB which the class I am investigating references, it is easy to do. In standard Eclipse, I put my cursor on the interface class, hit ctrl+t and Eclipse shows me all the implementations. If I have a variable with "@Random" and "int" in it definition, and nothing else, I have no idea where to start looking. Well I guess I have to look for where the @Random qualifier is implemented. In the end, in my experience, I will spend more time looking.

"I consider the latter much more expressive and meaningful" - and I don't, I guess we will just have to differ on our opinions.

You go on to give some good examples of when @Produces would be really useful (non-beans, implementation is dynamic at runtime). So good, @Produces does have it's uses. But none of the examples I have seen restrict the @Produces annotation to such cases, rather over enthusiastic people get carried away, and inject random ints...

"Generally, I consider this post complete rubbish full of FUD. You seem not to get the basic ideas of DI, certain OO principles and just don't get CDI yet. Don't worry, comes with experience. Normally, I don't answer, but as I saw it on JavaLobby, I had to." - I might not get the point of @Produces, but come on seriously, insulting me on my own blog like this? I fully understand DI, OO and I am pretty sure I get CDI. This posting was simply a rant about my opinion that @Produces is mostly unnecessary. Why are you so angry in your comments?

Please be a little more polite in the future.

Ant

Re: JSR-299 & @Produces


Title
Body
HTML : b, strong, i, em, blockquote, br, p, pre, a href="", ul, ol, li, sub, sup
Name
E-mail address
Website
Remember me Yes  No 

E-mail addresses are not publicly displayed, so please only leave your e-mail address if you would like to be notified when new comments are added to this blog entry (you can opt-out later).