BIRT 3.7
Written by: Michael Williams
Featured Refcardz: Top Refcardz:
  1. Scrum
  2. Apache Maven 2
  3. Essential MySQL
  4. Node.js
  5. Groovy
  1. jQuery Selectors
  2. Ajax
  3. Java
  4. Spring Config.
  5. Java Concurrency

Link Details

Link 56333 thumbnail
User 111696 avatar

By bloid
via weblogs.java.net
Published: Dec 09 2007 / 22:45

I've blogged just a few days ago about the Java Day in Rome, talking about the event in general. Now I'd like to focus about what probably was the best talk of the conference.
  • 13
  • 19
  • 3309
  • 0

Comments

Add your comment
User 220443 avatar

seanhussey replied ago:

0 votes Vote down Vote up Reply

Informative post, but I disagree with the content. Is there a neutral vote? :)

User 230306 avatar

Eric Burke replied ago:

1 votes Vote down Vote up Reply

"if" makes code more complex? Give me a break. Sounds like dogma.

User 179375 avatar

Ricky Clarkson replied ago:

0 votes Vote down Vote up Reply

The blogger didn't give enough detail. He said the talk was really about if and for. If you're using a for loop and an if statement inside it to find all items in a list that have a certain property, you are effectively hand-coding something like this:

list.filter(hasPropertyX)

Not only that but you're likely doing it eagerly, which means that you're creating a new copy of the elements in the list when you create the list, rather than lazily. The above filter code may not necessarily be lazy, but we've decoupled whether it's lazy from the calling code.

User 249616 avatar

robse replied ago:

0 votes Vote down Vote up Reply

Patternoholics.
English link was 404.

User 254835 avatar

wittgen replied ago:

0 votes Vote down Vote up Reply

actually I do feel a little dirty whenever I use an "if". weird.

User 233461 avatar

antych replied ago:

3 votes Vote down Vote up Reply

It makes kinda sense, polymorphism is your friend. Too many conditional statements in OO code usually mean the author has no clue. Of course there's no point in getting religious about it. You can end up with rally messed up code if you try avoiding them no matter what.

User 244565 avatar

palsforpals replied ago:

0 votes Vote down Vote up Reply

I voted up because it provides a completely new perspective, eventhough I have to say a little weird observation....

User 209464 avatar

willcode4beer replied ago:

1 votes Vote down Vote up Reply

I think one of the bigger points is what I like to call "logic reduction".
Basically, this means, "is there a more simple way to do it?"

Often while refactoring code, I try to eliminate conditionals and loops, not as dogma, but as a way to simplify the code. Often, complex logic is created to make something simply work. Upon refactoring, the complex logic can be reduced and simplified. Performance gains are often a side effect. Maintainability and stability are the major goals.

User 196387 avatar

Jevgeni Kabanov replied ago:

0 votes Vote down Vote up Reply

This is just stupid. I agree with the sentiments ("if" and "for" are too low level constructs for every use), but not the solution. OO is not meant to replace control flow structures, it's for higher level organization. Functional languages have great facilities for higher order data manipulation, which is what you need (i.e. they want map and filter and try to emulate it in OO, that's been done before a 100 times, always unsuccessfully). The word they are looking for is Scala, not Java :)

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.