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

In the time it takes to read this message you could have voted twice. Login and vote now.
Link 125489 thumbnail
User 252611 avatar

By Thierry.Lefort
via itscommonsensestupid.blogspot.com
Published: Oct 13 2008 / 17:36

Static method is much more easier to learn, and use compare to OOP and polymorphism,. But somehow it acquires a bad name in the TDD circles. Some people don't like static methods . The reason? Can't mock the static methods.
  • 11
  • 2
  • 1623
  • 0

Comments

Add your comment
User 336684 avatar

soulcutter replied ago:

0 votes Vote down Vote up Reply

I somewhat agree with his point, but his post does not present a very strong argument.

User 211643 avatar

zynasis replied ago:

1 votes Vote down Vote up Reply

what kindof blindsighted nitwit would see static methods as bad?

are java coders really becoming that naive?!

User 205573 avatar

Bryan Young replied ago:

4 votes Vote down Vote up Reply

naive? maybe. I prefer to think that people are just being lazy. Rather than trying to understand all the pros and cons of an argument and reapply the arguments to each problem, most people would rather have a dogmatic law that might apply 80-90% of the time and pretend that it's an absolute truth.

Dogma is much easier than Heuristics.. especially for people who start with a background in Math, Science or Engineering where absolute truths are much more common than other fields.

User 338269 avatar

Miloskov replied ago:

-2 votes Vote down Vote up Reply

No code samples or comparing code? bah.....

User 211643 avatar

zynasis replied ago:

0 votes Vote down Vote up Reply

surely an even mildly experienced person can think of numerous real life examples of swinging both ways on this

User 338269 avatar

Miloskov replied ago:

-1 votes Vote down Vote up Reply

Haha I know your kind they think they know everything, The elite that knows everything in their damn head, BS. That is why Im reading the article to see the author perspective but no code samples no nothing what kind of blogging or writing is this leaven the reader with own thoughts, if cant put code samples better don't blog on methodologies or programming, period.

User 211643 avatar

zynasis replied ago:

0 votes Vote down Vote up Reply

go back to ur java for dummie's book, nublet

User 186344 avatar

kunnar replied ago:

1 votes Vote down Vote up Reply

Maybe i am not experienced person then, but i would like to see in code how he exactly mocks static methods. I agree that because of missing code samples such articles about programming suck a little. But otherwise than that it was interesting post.

User 282119 avatar

Rob Signorelli replied ago:

1 votes Vote down Vote up Reply

There are times when static methods are definitely good and you don't have to sacrifice testability to get it. I'm sure just about anyone who has worked on a large project has used/written a Utils and/or StringUtils class. Nothing but static methods because frankly there's no state to maintain, so instantiation is a waste of time in those cases. And if anything, those methods are far easier to test because you *don't* have to worry about mocking your utility class. Just mock up your inputs and test.

Generally speaking if you're using statics far beyond that in an OO language, there's a good chance you're not using them correctly anyway. There's room for both without losing anything, so I don't really agree with the author's argument here.

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.