The Artima Developer Community
Sponsored Link

Weblogs Forum
Security and the 'Final' Dilemma

23 replies on 2 pages. Most recent reply: Jan 16, 2008 8:05 AM by Vesa Karvonen

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 23 replies on 2 pages [ « | 1 2 ]
Isaac Gouy

Posts: 527
Nickname: igouy
Registered: Jul, 2003

Does JMockit solve the problems you had with unit testing and final? Posted: May 31, 2006 10:03 AM
Reply to this message Reply
Advertisement
Michael Feathers I've been playing with JMockit (mentioned above) a bit, and it is nice, but still that does not convince me that people should use final whenever possible.

Does JMockit convince you that this statement is not correct "When you use final pervasively, you make unit testing nearly impossible."?

Michael Feathers

Posts: 448
Nickname: mfeathers
Registered: Jul, 2003

Re: The problem is with nominal typing not final Posted: May 31, 2006 10:04 AM
Reply to this message Reply
> I think that this is a problem with nominal typing - not
> final. The problem is that if you are given just a final
> class (and nothing else) then you can't easily
> parameterize the client, because you need an interface for
> that. (This is in the context of Java.)
>
> With structural typing the problem doesn't exist. Type
> abstraction doesn't prevent parameterization of clients
> with test stubs.


Vesa, every time I see your posts here and on LtU I think "damn, I wish he could show me what he's talking about." This time, though, I realized that I'm in Helsinki now. You in town?

Michael Feathers

Posts: 448
Nickname: mfeathers
Registered: Jul, 2003

Re: Does JMockit solve the problems you had with unit testing and final? Posted: May 31, 2006 10:19 AM
Reply to this message Reply
> Michael Feathers I've been playing with JMockit
> (mentioned above) a bit, and it is nice, but still that
> does not convince me that people should use final whenever
> possible.

>
> Does JMockit convince you that this statement is not
> correct "When you use final pervasively, you make unit
> testing nearly impossible."?

Yes, but it's still more difficult than it has to be. ;)

Isaac, the thing you don't seem to get is that I'm a well-intentioned guy. JMockit is just now getting attention, and I expect these problems to be solved or at least dealt with in each language eventually. I also expect to make many statements which may not be correct in later light. Whatever it takes to push forward. If you have any leads on ways to easily subvert 'sealed' in .NET or automatically replace non-virtuals in C++, I'm all ears.

Isaac Gouy

Posts: 527
Nickname: igouy
Registered: Jul, 2003

Re: Does JMockit solve the problems you had with unit testing and final? Posted: May 31, 2006 2:14 PM
Reply to this message Reply
> > Does JMockit convince you that this statement is not
> > correct "When you use final pervasively, you make unit
> > testing nearly impossible."?
>
> Yes, but it's still more difficult than it has to be. ;)

What specifically is difficult about it?


> Isaac, the thing you don't seem to get is that I'm a
> well-intentioned guy.

Michael, how do you know what I get or don't get?

On forums like this I always keep in mind that comments are well intentioned and sincere.


> JMockit is just now getting
> attention, and I expect these problems to be solved or at
> least dealt with in each language eventually. I also
> expect to make many statements which may not be correct in
> later light. Whatever it takes to push forward. If you
> have any leads on ways to easily subvert 'sealed' in .NET
> or automatically replace non-virtuals in C++, I'm all
> ears.

I think it's fine that you blogged about final and testing based on your knowledge at the time - it's helped all of us to learn something, we have the opportunity to learn about JMockit.

Now, based on this new information, you've agreed that the statement you made on the object mentor blog is not correct.

Do you think it's appropriate to update the object mentor and artima blog entries with a correction so that future readers will not be misled?

Michael Feathers

Posts: 448
Nickname: mfeathers
Registered: Jul, 2003

Re: Does JMockit solve the problems you had with unit testing and final? Posted: Jun 14, 2006 5:52 AM
Reply to this message Reply
> Now, based on this new information, you've agreed that the
> statement you made on the object mentor blog is not
> correct.
>
> Do you think it's appropriate to update the object mentor
> and artima blog entries with a correction so that future
> readers will not be misled?

I'd like to, but I've been having trouble getting JMockit to run consistently on my machine. Have you tried it, Issac?

John Cowan

Posts: 36
Nickname: johnwcowan
Registered: Jul, 2006

Re: Security and the 'Final' Dilemma Posted: Jul 18, 2006 9:49 AM
Reply to this message Reply
An important aspect of "final" is that value classes really, really need to be final in Java. (.NET gets this right by marking value classes more clearly). In order to use a value class efficiently, you have to know that it's immutable, and making it final is your only guarantee of that -- some over-clever programmer can subvert the immutability otherwise.

Imagine if String had a mutable subclass! You'd never know whether it was safe to pass around a String without copying it or not. As things stand, because String is both immutable and final, you never need to copy one.

Vesa Karvonen

Posts: 116
Nickname: vkarvone
Registered: Jun, 2004

Re: The problem is with nominal typing not final Posted: Jan 16, 2008 1:18 AM
Reply to this message Reply
> Vesa, every time I see your posts here and on LtU I think
> "damn, I wish he could show me what he's talking about."
> This time, though, I realized that I'm in Helsinki now.
> . You in town?

I was close enough at the time, but unlike my inbox, I don't check your blog regularly. I noticed your message here mostly by accident.

Michael Feathers

Posts: 448
Nickname: mfeathers
Registered: Jul, 2003

Re: The problem is with nominal typing not final Posted: Jan 16, 2008 4:01 AM
Reply to this message Reply
:-) By curious coincidence, I'm there again next week.

Vesa Karvonen

Posts: 116
Nickname: vkarvone
Registered: Jun, 2004

Re: The problem is with nominal typing not final Posted: Jan 16, 2008 8:05 AM
Reply to this message Reply
Can't get over your Suomi fever, eh? ;-)

Well, if you're interested in meeting me, why don't you drop a note to my gmail inbox. My account is "vesa.a.j.k". I'm mostly available the whole week.

I noticed that you've been writing an xUnit-style testing framework for OCaml. If nothing else, I could try to bore you by discussing the design of my testing framework for Standard ML.

Flat View: This topic has 23 replies on 2 pages [ « | 1  2 ]
Topic: Security and the 'Final' Dilemma Previous Topic   Next Topic Topic: An Alternative to Closure Conversion and to Restricted Closures

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use