Loading ...
Sorry, an error occurred while loading the content.

Re: [XP] Re: Testing strongly-typed collections into existence TDD and strong typed

Expand Messages
  • Chris Dollin
    ... Problem is (I think) over-stating it rather. ... As the first test you write for it will surely reveal. ... I don t think I ve *ever* had a problem in
    Message 1 of 17 , Jul 28, 2005
    • 0 Attachment
      On Thursday 28 July 2005 10:54, Andrew McDonagh wrote:

      > Its worth remembering thought, that we have this problem in languages
      > like Java as well.

      "Problem" is (I think) over-stating it rather.

      > Its easy for a class member variable to be 'eclipsed' by a local
      > variable within a method.
      > A very simple example...
      > public class EclipsedMember {
      > private String name;
      > public EclipsedMember(String theName) {
      > name = theName;
      > }
      > public void addSurname(String surname) {
      > String name = null;
      > name = name + surname;
      > }
      > }
      > Now this compiles fine but because addSurname is using a local variable
      > 'name' the method is not going to do what we think it is.

      As the first test you write for it will surely reveal.

      > Luckily a lot of IDEs can generate warnings for this situation.

      I don't think I've *ever* had a problem in Java with shadowing;
      if I have, it's been caught by the next test run. I've had a
      shadowing problem /once/ in C; it didn't take long to track down,
      and had I understood how to use tests effectively at that time,
      it wouldn't have survived more than about ten minutes.

      Which is why I'm interested in problems people have actually
      /had/ with lexical scope shadowing, rather than speculation;
      I can do speculation on my own.

      Chris "electric hedgehog" Dollin
      predicting self-predictors' predictions is predictably unpredictable.
    Your message has been successfully submitted and would be delivered to recipients shortly.