Re: Is 'Final' for classes and methods a good feature or something that should be eliminated?



rmoldskr+usenet@xxxxxxxxx wrote:
Michael Feathers <mfeathers@xxxxxxxxxxxxxxxx> wrote:


Final gets in the way of both of those. Really, there are very few alternatives at the unit level.


I hardly ever use either of those methods when I write unit tests, so
I don't see how that can be true. After all, you're testing the code
that uses the final-ed object, and not the final-ed code itself.

Sure, it's sometimes _convenient_ to be able to proxy an library object by inheritance and overloading, but I can't really see any
situration where it's _necessary_ for writing an Unit test.

What about the cases that I mentioned.. when there is a side effect that you wouldn't want to have occur when your testing the code that uses the final-ed object?

Could be anything from hitting the database, to sending mail or launching cruise missiles.


----
Michael Feathers
http://www.objectmentor.com
http://michaelfeathers.typepad.com
author of: Working Effectively with Legacy Code (Prentice Hall 2005)
.



Relevant Pages

  • Re: Is Final for classes and methods a good feature or something that should be eliminated?
    ... alternatives at the unit level. ... I hardly ever use either of those methods when I write unit tests, ... that uses the final-ed object, and not the final-ed code itself. ...
    (comp.object)
  • Re: A critique of test-first...
    ... writing the tests before writing the code. ... Test Driven Development (write one test, ... Development is a design technique first, ... of unit tests that come out of TDD is not the same as a professional ...
    (comp.programming)
  • Re: The design is the code?
    ... >I dont use unit tests either. ... >write code and have it execute correctly first time out. ... I achieve the same goal by writing tiny ... >defects per year with zero production defects ...
    (comp.object)
  • Re: Tracing the execution of scripts?
    ... Write unit tests for your code. ... Keep writing unit tests until you have ... further development, write the tests first, then implement the code that ... As far as programming goes, I have done minor things with it, and web ...
    (comp.lang.python)
  • Re: OOA, OOD, design all first, how to go about it all?
    ... we write a suite of unit tests that: ... you must stop writing it as soon as some part of it fails. ... * You are not allowed to write any more production code than is ...
    (comp.object)