Yet another Representative Line



  • private static String NullString = new String ("null");



  • What a piece of shit.  How can you miss localizing that?!?!1



  • .... aaaaaaaaaaaaaaand I just looked ... it is referenced ... once.

    if (dataString == null) {
    dataString = NullString;
    }



  • @C-Octothorpe said:

    What a piece of shit.  How can you miss localizing that?!?!1

    Tell the original programmers that, and they'd probably do something like:

    private static String NullString = new String ("n,ull");


  •  @zelmak said:

    @C-Octothorpe said:

    What a piece of shit.  How can you miss localizing that?!?!1

    Tell the original programmers that, and they'd probably do something like:

    private static String NullString = new String ("n,ull");
    Beyond the obvious questions of why, who in the hell ever thought this was a good idea and why is this allowed to exist, why is it static?  Shouldn't it be a const?  I mean, at least do it the Right Way (TM) when you're going to do it the wrong way...  Are they later somehow planning on changing it's value?  Are they trying to make stupidity thread-safe?


  • @C-Octothorpe said:

    Beyond the obvious questions of why, who in the hell ever thought this was a good idea and why is this allowed to exist, why is it static?  Shouldn't it be a const?

    consts are static in Java, but it needs the final keyword to be truly constant.



  • @zelmak said:

    @C-Octothorpe said:

    What a piece of shit.  How can you miss localizing that?!?!1

    Tell the original programmers that, and they'd probably do something like:

    private static String NullString = new String ("n,ull");

    +1, Hilarious



  • @morbiuswilters said:

    @C-Octothorpe said:
    Beyond the obvious questions of why, who in the hell ever thought this was a good idea and why is this allowed to exist, why is it static?  Shouldn't it be a const?
    consts are static in Java, but it needs the final keyword to be truly constant.
    How do you know it's Java?  I was assuming C#...  Either way, if it's Java, it's a bigger WTF because, well, it's Java...



  • OK, with so many of these posts I have to ask you zelmak, What did you do!?  Having to work with your code base sounds more like penance than a job.



  • @C-Octothorpe said:

    @morbiuswilters said:

    @C-Octothorpe said:
    Beyond the obvious questions of why, who in the hell ever thought this was a good idea and why is this allowed to exist, why is it static?  Shouldn't it be a const?
    consts are static in Java, but it needs the final keyword to be truly constant.
    How do you know it's Java?  I was assuming C#...  Either way, if it's Java, it's a bigger WTF because, well, it's Java...

    He probably knows due to my history of posting.

    But, yes, it is Java.

    If they were to have added the 'final' keyword, it would be better and made it a true constant. To omit the whole thing altogether would have been even better.



  • @locallunatic said:

    OK, with so many of these posts I have to ask you zelmak, What did you do!?  Having to work with your code base sounds more like penance than a job.

    I'm a contractor working on a highly specialized government system which was built by the predecessors to my current firm with the help, design and implementation of various aspects by both contractors, government civilian and even military programmers over the course of now over 12 years. It has grown quite organically ... to put it mildly. More like a fibrous tumor, if you ask me.

    Trouble is, I'm pretty good at working with this crapfest called a code base. And I'm mentoring the new breed of programmers here how NOT to do things. Kind of creating a cult, actually. Its outright scary.

    As to what I've done to deserve this?  I don't know ... I'll have to ask the missus when I get home... she knows everything.



  • @C-Octothorpe said:

    @morbiuswilters said:

    @C-Octothorpe said:
    Beyond the obvious questions of why, who in the hell ever thought this was a good idea and why is this allowed to exist, why is it static?  Shouldn't it be a const?
    consts are static in Java, but it needs the final keyword to be truly constant.
    How do you know it's Java?  I was assuming C#...  Either way, if it's Java, it's a bigger WTF because, well, it's Java...

    I knew his posting history, but I also assumed from your comment that C# had a separate keyword for consts (like PHP does) instead of using final statics like Java.



  • @C-Octothorpe said:

    How do
    you know it's Java?  I was assuming C#...  Either way, if it's Java,
    it's a bigger WTF because, well, it's Java..

    Because it uses 'String' and not 'string'.

     



  • @Severity One said:

    @C-Octothorpe said:

    How do
    you know it's Java?  I was assuming C#...  Either way, if it's Java,
    it's a bigger WTF because, well, it's Java..

    Because it uses 'String' and not 'string'.

    c# has both



  • @Severity One said:

    @C-Octothorpe said:

    How do you know it's Java?  I was assuming C#...  Either way, if it's Java, it's a bigger WTF because, well, it's Java..

    Because it uses 'String' and not 'string'.
    Right, 'string' is just an alias for the String class in C#.  Same as int to Int32, long to Int64, etc.  To be completely honest, without anybody telling you, it would be impossible to guess based solely on that line of code if it's C# or Java.



  • @morbiuswilters said:

    @C-Octothorpe said:

    @morbiuswilters said:

    @C-Octothorpe said:
    Beyond the obvious questions of why, who in the hell ever thought this was a good idea and why is this allowed to exist, why is it static?  Shouldn't it be a const?
    consts are static in Java, but it needs the final keyword to be truly constant.
    How do you know it's Java?  I was assuming C#...  Either way, if it's Java, it's a bigger WTF because, well, it's Java...

    I knew his posting history, but I also assumed from your comment that C# had a separate keyword for consts (like PHP does) instead of using final statics like Java.
    It does, but you can only use const on value types and strings in .net.  Objects (except strings) need to be declared as static readonly and initialized in either a static .ctor or at the top of the class.



  • @Severity One said:

    @C-Octothorpe said:

    How do
    you know it's Java?  I was assuming C#...  Either way, if it's Java,
    it's a bigger WTF because, well, it's Java..

    Because it uses 'String' and not 'string'.

     

    I'd go with the fact that System.String doesn't have a (System.String) constructor.



  • @pkmnfrk said:

    @Severity One said:

    @C-Octothorpe said:

    How do you know it's Java?  I was assuming C#...  Either way, if it's Java, it's a bigger WTF because, well, it's Java..

    Because it uses 'String' and not 'string'.

     

    I'd go with the fact that System.String doesn't have a (System.String) constructor.



  • @morbiuswilters said:

    consts are static in Java, but it needs the final keyword to be truly constant.

    The static final modifiers in Java do not imply a constant for objects unless the object is immutable. Static final arrays are amusingly non-constant.



  • @Thuktun said:

    @morbiuswilters said:
    consts are static in Java, but it needs the final keyword to be truly constant.

    The static final modifiers in Java do not imply a constant for objects unless the object is immutable. Static final arrays are amusingly non-constant.

    Are they constant in the sense that you can change the objects the references point to, but not the references themselves?



  • @lettucemode said:

    @Thuktun said:
    @morbiuswilters said:
    consts are static in Java, but it needs the final keyword to be truly constant.

    The static final modifiers in Java do not imply a constant for objects unless the object is immutable. Static final arrays are amusingly non-constant.

    Are they constant in the sense that you can change the objects the references point to, but not the references themselves?

    Exactly. The reference is what's constant; the stuff that reference points to is not.

    Another way of putting it is that a variable marked as final can only be assigned to once.

    The fact that Object variables store references, not values, is the thing that most confuses people who are learning Java as their first programming language. And pretty much no one teaches it properly. If someone asks you a stupid question about Java, the odds are very good that they're asking it because they don't understand the reference vs. value concept.



  • @Someone You Know said:

    @lettucemode said:
    Are they constant in the sense that you can change the objects the references point to, but not the references themselves?

    Exactly. The reference is what's constant; the stuff that reference points to is not.

    Another way of putting it is that a variable marked as final can only be assigned to once.

    The fact that Object variables store references, not values, is the thing that most confuses people who are learning Java as their first programming language. And pretty much no one teaches it properly. If someone asks you a stupid question about Java, the odds are very good that they're asking it because they don't understand the reference vs. value concept.

    That's what I thought, since I was taught about reference types vs. value types properly. I don't see how Thuktun finds them "amusingly non-constant". It's only ambiguous if you don't know how Java handles the different types.

    Does Java allow the programmer to create new types that are treated as value types? I know C# has the struct keyword for this purpose.



  • @lettucemode said:

    That's what I thought, since I was taught about reference types vs. value types properly. I don't see how Thuktun finds them "amusingly non-constant". It's only ambiguous if you don't know how Java handles the different types.

    No, it's an abuse of the word "constant" really, which implies immutability. The final keyword only talks about the assignment of something to that variable.

    @lettucemode said:

    Does Java allow the programmer to create new types that are treated as value types?

    The only "value types" in java are the primitive, unboxed types, like int, though I suppose immutable object probably act in some similar ways.



  • @lettucemode said:

    Does Java allow the programmer to create new types that are treated as value types? I know C# has the struct keyword for this purpose.

    No, nor is there any straightforward way to pass a reference by reference. Java has no direct analog to C# structs.



  • @Someone You Know said:

    No, nor is there any straightforward way to pass a reference by reference.

    Why would you want to do that?



  • @Someone You Know said:

    @lettucemode said:
    Does Java allow the programmer to create new types that are treated as value types? I know C# has the struct keyword for this purpose.
    No, nor is there any straightforward way to pass a reference by reference. Java has no direct analog to C# structs.

    Wait, what?  How is passing a reference by reference analogous to structs, or am I missing your meaning?



  • @C-Octothorpe said:

    Right, 'string' is just an alias for the String class in C#.  Same as int to Int32, long to Int64, etc.

    But... why? To have a certain amount of source code compatibility with Java?

     



  • @Sutherlands said:

    @Someone You Know said:

    @lettucemode said:
    Does Java allow the programmer to create new types that are treated as value types? I know C# has the struct keyword for this purpose.
    No, nor is there any straightforward way to pass a reference by reference. Java has no direct analog to C# structs.

    Wait, what?  How is passing a reference by reference analogous to structs, or am I missing your meaning?

    It's not. Those were two separate thoughts. I think I had a copy/paste fail there somewhere.



  • @morbiuswilters said:

    @Someone You Know said:
    No, nor is there any straightforward way to pass a reference by reference.
    Why would you want to do that?

    Hopefully, obvious troll is obvious.



  • @zelmak said:

    @morbiuswilters said:

    @Someone You Know said:
    No, nor is there any straightforward way to pass a reference by reference.
    Why would you want to do that?

    Hopefully, obvious troll is obvious.

    Yup.  I'm definitely not responding to your post.


  • @zelmak said:

    @morbiuswilters said:

    @Someone You Know said:
    No, nor is there any straightforward way to pass a reference by reference.
    Why would you want to do that?

    Hopefully, obvious troll is obvious.

    Either I missed something or I have no idea how any of that was trolling.



  • @Severity One said:

    @C-Octothorpe said:

    Right, 'string' is just an alias for the String class in C#.  Same as int to Int32, long to Int64, etc.

    But... why? To have a certain amount of source code compatibility with Java?

    Didn't you know? The whole CLR and .net framework are built on top of Java?  That's why it's so fast!

    Seriously, I would bet that it's because it makes the code look more approachable and "simpler" for developers MS is trying to get onboard the .net bandwagon.



  • if it were C#, ReSharper would probably whine at you to make it readonly.

    Also this should be front page!



  • @Someone You Know said:

    @lettucemode said:
    @Thuktun said:
    @morbiuswilters said:
    consts are static in Java, but it needs the final keyword to be truly constant.

    The static final modifiers in Java do not imply a constant for objects unless the object is immutable. Static final arrays are amusingly non-constant.

    Are they constant in the sense that you can change the objects the references point to, but not the references themselves?

    Exactly. The reference is what's constant; the stuff that reference points to is not.

    Another way of putting it is that a variable marked as final can only be assigned to once.

    The fact that Object variables store references, not values, is the thing that most confuses people who are learning Java as their first programming language. And pretty much no one teaches it properly. If someone asks you a stupid question about Java, the odds are very good that they're asking it because they don't understand the reference vs. value concept.

     

    When java was new, the first think anyone said about it something like java is better/easier/whatever because it doesn't have pointers; i even heard that same thing in a class taught around java. It was usually the only thing they knew about java. Which is only semantically correct; java renamed them reference. This notion is horrible for someone learning java, because in java everything is a reference. The no pointer buisnees really meant a pointer as implemented in C/C++; you can't do pointer math in java. You have to treat the references as opaque even if the 'handle' is really an address.



  • @morbiuswilters said:

    @zelmak said:

    @morbiuswilters said:

    @Someone You Know said:
    No, nor is there any straightforward way to pass a reference by reference.
    Why would you want to do that?

    Hopefully, obvious troll is obvious.

    Either I missed something or I have no idea how any of that was trolling.

     

    Is the troll @morbiuswilters said:

    Why would you want to do that?
    or @Someone You Know said:
    No, nor is
    there any straightforward way to pass a reference by reference.
    or @zelmak said:
    Hopefully, obvious troll is obvious.
    ?

     

    Does java not allow double indirection, like int** in C++ or ref in C#?

     



  • @esoterik said:

    Does java not allow double indirection, like int** in C++ or ref in C#?

    Not really. There is no built-in language feature for it like the ref keyword in C#. You can fake it by adding another level of abstraction yourself, e.g. by creating a class that is just a container for another object.



  • @esoterik said:

    When java was new, the first think anyone said about it something like java is better/easier/whatever because it doesn't have pointers; i even heard that same thing in a class taught around java. It was usually the only thing they knew about java. Which is only semantically correct; java renamed them reference. This notion is horrible for someone learning java, because in java everything is a reference. The no pointer buisnees really meant a pointer as implemented in C/C++; you can't do pointer math in java. You have to treat the references as opaque even if the 'handle' is really an address.

    Java got references from C++. But even more so, I hear people say all the time that references are somehow confusing. WTF is wrong with you people? Why would you need to know (or care) about the address in Java? It's a managed fucking language; you aren't supposed to know (or care) about addressing.



  • @Someone You Know said:

    @esoterik said:
    Does java not allow double indirection, like int** in C++ or ref in C#?

    Not really. There is no built-in language feature for it like the ref keyword in C#. You can fake it by adding another level of abstraction yourself, e.g. by creating a class that is just a container for another object.

    The better question is why you would need to do this in Java..



  • @morbiuswilters said:

    @esoterik said:
    When java was new, the first think anyone said about it something like java is better/easier/whatever because it doesn't have pointers; i even heard that same thing in a class taught around java. It was usually the only thing they knew about java. Which is only semantically correct; java renamed them reference. This notion is horrible for someone learning java, because in java everything is a reference. The no pointer buisnees really meant a pointer as implemented in C/C++; you can't do pointer math in java. You have to treat the references as opaque even if the 'handle' is really an address.

    Java got references from C++. But even more so, I hear people say all the time that references are somehow confusing. WTF is wrong with you people? Why would you need to know (or care) about the address in Java? It's a managed fucking language; you aren't supposed to know (or care) about addressing.

     

    whoosh



  • @esoterik said:

    @morbiuswilters said:

    @esoterik said:
    When java was new, the first think anyone said about it something like java is better/easier/whatever because it doesn't have pointers; i even heard that same thing in a class taught around java. It was usually the only thing they knew about java. Which is only semantically correct; java renamed them reference. This notion is horrible for someone learning java, because in java everything is a reference. The no pointer buisnees really meant a pointer as implemented in C/C++; you can't do pointer math in java. You have to treat the references as opaque even if the 'handle' is really an address.

    Java got references from C++. But even more so, I hear people say all the time that references are somehow confusing. WTF is wrong with you people? Why would you need to know (or care) about the address in Java? It's a managed fucking language; you aren't supposed to know (or care) about addressing.

     

    whoosh

    So.. you're saying you weren't trying to sound like a retard?



  • @morbiuswilters said:

    @esoterik said:
    ...blah blah...java...blah blah...pointers...blah blah..references...

    So.. you're saying you weren't trying to sound like a retard?

    <a href="http://comicjk.com/comic.php/306>


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.