Another confused CS student



  • I spotted some very bad things with this code segement (commented inline, the block comments are his).

    import java.awt.;
    import java.awt.geom.
    ;
    import javax.swing.;


    class getRect extends JFrame //Not public class. getRect is what you call a method, not a class

    {
    int thisCol= 7 ;
    int thisRow= 8;
    int Rectangle; //Declared a variable with the same name as a class


       public static void main(String[] args)
       {
           getRect w = new getRect();
       w.setVisible(true); //Didn't set size of frame. Didn't ensure that process exits whenframe is closed.

       }

       Rectangle getRect() //This is not a constructor, its a method since it has a return type. Fortunatly, if no constructor is provided a no-argument public constructor that does nothing is automatically included.

       {return null; //Which is why this line is needed

           / The constuctor for this class.
           It can be left empty for now. */
       }

    //Painting in the frame directly is often discouraged. Also, method should have @Override

       public void paint(Graphics g)
       {
           Graphics2D g2 = (Graphics2D)g;
           // above: this "upgrades" the Graphics class to a Graphics2D class:
           // this has some extra methods that we'll use later on

           int w = getWidth(); //This gets the width of the frame, which includes the title bar and boarder.

           int h = getHeight();
           
           int thisRow; //And this is for??
            
           

           int r_w = getWidth()/7;

           int r_x = this.thisCol * r_w;
           int r_h = getHeight()/5;
           int r_y = this.thisRow * r_h;
           
     Rectangle r = new Rectangle();
     
            /Rectangle r =   getRect();
            g.drawRect(r_x,r_y,r_w, r_h);
    /
            
            
    Rectangle r4 = getRect(); //This returns null from your method that looks like a constructor

    g2.fillOval(r4.x, r4.y, r4.width, r4.height); //Since r4 is null, the rest of the method terminates, and an exception is printed to standard error.       
           g2.setColor(Color.blue);
           Rectangle r1 = new Rectangle(0,0,w,h);
           

       g2.fill(r1); //You just painted over the oval you painted on the screen.

    System.out.println("w is " + w + "and h is " + h);


    g2.setColor(Color.red);
       Rectangle r2 = new Rectangle(0,0,w/2,h);

       g2.fillOval(r2.x,r2.y,r2.width,r2.height);

    g2.setColor(Color.green);

    Rectangle r3 = new Rectangle(w/2,0,w/2,h);

       g2.fillOval(r3.x,r3.y,r3.width,r3.height);

       } //I assume you commented this out since you were getting an error about a duplicate method, since your "constructor" has the same decleration.

       /public Rectangle getRect()
       {  int r_w = getWidth()/7;
           int r_x = thisCol * r_w();
           int r_h = getHeight()/5;
           int r_y = thisRow * r_h;
          
           return  null;
           }
    /
       

       
    }



  •  A student making mistakes. Where is the WTF?



  • @PSWorx said:

     A student making mistakes. Where is the WTF?


    This:
    @subanark said:
    Filed under: Java

    😮



  • @subanark said:

    int Rectangle; //Declared a variable with the same name as a class

    I do that all the time. (Of course, usually the variable is the class it's named after...)



  •  @blakeyrat said:

    @subanark said:
    int Rectangle; //Declared a variable with the same name as a class

    I do that all the time. (Of course, usually the variable is the class it's named after...)

    This is fine provided that your variable starts with a lower case, and your class starts with an upper case. Also note that the variable is declared as an int, which is not a Rectangle.



  • @PSWorx said:

     A student making mistakes. Where is the WTF?
    TRWTF is @subanark said:



  •  unless that student wrote this code during an internship in a company, i see no wtf there. He just didn't undestood half of the concepts in java and will get a nice 0 for this code.



  • Certainly. It's a fail, but not a worse than failure. :p



  • @AngelSL said:

    What's the problem?



  • I think TRWTF there is that AngelSL has font smoothing disabled. The aliasing! My eyes!



  • @nexekho said:

    I think TRWTF there is that AngelSL has font smoothing disabled. The aliasing! My eyes!

    Zecc's smoothing is worse. Looks more like blurring. Edit: To clarify: In particular the "Joined..." part



  • I think that's Linux, looks too sharp to be OS X (which has the blurriest smoothing I've ever seen)



  • @derula said:

    @nexekho said:
    I think TRWTF there is that AngelSL has font smoothing disabled. The aliasing! My eyes!

    Zecc's smoothing is worse. Looks more like blurring. Edit: To clarify: In particular the "Joined..." part

    I disagree with the "is worse" part, but maybe I'm just used to the blurring. Or maybe it just looks worse on your monitor and not on mine.

    And yes, FWIW it is Linux.



  • @nexekho said:

    I think that's Linux, looks too sharp to be OS X (which has the blurriest smoothing I've ever seen)

    In my experience, both OS X and Linux have ridiculously blurry smoothing. When Apple first ported Safari to Windows, it did it's crazy OS X font smoothing right next to windows doing ClearType smoothing... it looked crazy-blurry! When all the text is the same it doesn't look as bad. The annoying part is there's no settings to change. (OS X has a checkbox "use LCD smoothing when available", but unchecking it doesn't do anything.)



  • @blakeyrat said:

    The annoying part is there's no settings to change.
     

    ?

    You can change the AA type in the preferences of Safari/Win.

    Ubuntu/Gnome has AA settings that allow for it to be smoother than the crazy-hinted Cleartype, yet not be as blurry as OSX. I like it.

    As usual, YMMV, you monitor and eyesight aren't my own, and you'll have to tweak it.



  •  Font smoothing looks like blurring to me. Even on Linux.



  • @AngelSL said:

     Font smoothing looks like blurring to me. Even on Linux.

    Do you have a CRT?

    Also I like how you said "even on Linux", when Linux has one of the *most* blurry implementations.



  • @dhromed said:

    You can change the AA type in the preferences of Safari/Win.

    Well, not in Safari in OS X.

    I'm trying to upload a screenshot, but apparently you can't FTP from a Mac for less than $24. WHAT. THE. FUCK.

    @dhromed said:

    Ubuntu/Gnome has AA settings that allow for it to be smoother than the crazy-hinted Cleartype, yet not be as blurry as OSX. I like it.

    You can do the same in Windows using the ClearType Tuner. It can be almost as blurry as OS X, if you set it that way.



  •  @blakeyrat said:

    I'm trying to upload a screenshot, but apparently you can't FTP from a Mac for less than $24. WHAT. THE. FUCK.

    http://cyberduck.ch/



  • @dstozek said:

     @blakeyrat said:

    I'm trying to upload a screenshot, but apparently you can't FTP from a Mac for less than $24. WHAT. THE. FUCK.

    http://cyberduck.ch/

    It's free from the website, but $24 from the App Store. So if you want it auto-updated, you have to shell out for it. Figure that one out!

    Anyway, I just got pissed as the feature should BE IN THE FUCKING OS WHAT THE FUCK HOW DO APPLE USERS STAND THE FACT THAT THEIR OS DOESN'T FUCKING DO ANY OF THE MOST COMMON THINGS PEOPLE WANT THEIR OS TO DO AND EVERY OTHER OS DOES! and after a short rage, I gave up.


  • Discourse touched me in a no-no place

    @blakeyrat said:

    Anyway, I just got pissed as the feature should BE IN THE FUCKING OS WHAT THE FUCK HOW DO APPLE USERS STAND THE FACT THAT THEIR OS DOESN'T FUCKING DO ANY OF THE MOST COMMON THINGS PEOPLE WANT THEIR OS TO DO AND EVERY OTHER OS DOES! and after a short rage, I gave up.
    Windows has an FTP client?  The shitty commandline one doesn't count.

    Furthermore, as far as I can tell, there's only one Windows FTP client that isn't made of utter failure - and even then, it's a huge pile of WTF.



  • @Weng said:

    @blakeyrat said:
    Anyway, I just got pissed as the feature should BE IN THE FUCKING OS WHAT THE FUCK HOW DO APPLE USERS STAND THE FACT THAT THEIR OS DOESN'T FUCKING DO ANY OF THE MOST COMMON THINGS PEOPLE WANT THEIR OS TO DO AND EVERY OTHER OS DOES! and after a short rage, I gave up.
    Windows has an FTP client?  The shitty commandline one doesn't count.

    Yeah, it's called "explorer.exe." Which is exactly where it should be-- FTP (and WebDAV) is just another type of network drive. Explorer supports it. OS X Finder doesn't, or if it does, fuck me if I can find how to use it.

    @Weng said:

    Furthermore, as far as I can tell, there's only one Windows FTP client that isn't made of utter failure - and even then, it's a huge pile of WTF.

    That's because nobody makes them, since the functionality is IN EXPLORER. How long have you been using Windows? WTF.

    Anyway, the real problem is when you're using SFTP which Explorer indeed does not support. (Not sure why... the export restrictions on encryption are gone, right?) I use WinSCP for that, and find it does a decent job.



  • OP: Context needed. Is this a first-year CS student? If so, then definitely not a WTF. (cue the cliche 'we were all newbies once')

    I'd be concerned if this was a senior or God-forbid a grad-student's code.


  • I survived the hour long Uno hand

    I've seen grad-student code that's that bad. My uni has a "conversion course" which claims that having your BA in... anything at all, they can teach you enough to give you a MSc in 2 semesters + dissertation.

    One student is passing, with my help.



  • To be honest, this looks like code that my Computer Programming I teacher wrote.

    I took Computer Programming I because absolutely nothing else was offered in the way of computers (leaving aside IT "Essentials", a class where you learn how to use lots of colors in your emails).


  • Discourse touched me in a no-no place

    @blakeyrat said:

    Yeah, it's called "explorer.exe." Which is exactly where it should be-- FTP (and WebDAV) is just another type of network drive. Explorer supports it. OS X Finder doesn't, or if it does, fuck me if I can find how to use it.

    @Weng said:

    Furthermore, as far as I can tell, there's only one Windows FTP client that isn't made of utter failure - and even then, it's a huge pile of WTF.

    That's because nobody makes them, since the functionality is IN EXPLORER. How long have you been using Windows? WTF.

    .... When the hell did that feature go in? Where the fuck was the documentation? How the hell is that supposed to be discoverable? 'Map a network drive' is a task I do a lot less (as in "I think I did it once from the GUI and 60 billion trillion times from scripts") than 'Get some shit off an FTP server'.

    At any rate, it still doesn't support SFTP or FTPS. 



  • @Weng said:

    .... When the hell did that feature go in?

    It's been there as long as I've been using Windows. (Which is to say, Windows 98.)

    @Weng said:

    Where the fuck was the documentation?

    I can't tell you where it "was". But if you open up "Help and Support" in Windows 7, and type in FTP, it pops right up.

    @Weng said:

    How the hell is that supposed to be discoverable?

    The Map Network Drive dialog has a big-ass paragraph that basically says "Map an FTP Site". If you don't use Map Network Drive, you just kind of have to know you can type a ftp:// URL into an Explorer window's URL bar. Which admittedly isn't very discoverable. (Actually they've changed the wording now to "Connect to a Web Site", presumably because it supports WebDAV as well as FTP?

    Anyway, I made no claim that it was *good*. Merely that it was *built-in*, which is where FTP functionality belongs.

    @Weng said:

    At any rate, it still doesn't support SFTP or FTPS.

    This is true, but I don't need either of those to upload images to my domain.



  • @blakeyrat said:

    Anyway, the real problem is when you're using SFTP which Explorer indeed does not support. (Not sure why... the export restrictions on encryption are gone, right?)
    I don't think Windows supports SSH out of the box - that'll be why.



  • @PJH said:

    @blakeyrat said:
    Anyway, the real problem is when you're using SFTP which Explorer indeed does not support. (Not sure why... the export restrictions on encryption are gone, right?)
    I don't think Windows supports SSH out of the box - that'll be why.

    If anybody wants the classic example of a non-answer, there it is.

    I'd wager there's some government bullshit involved. They removed the military weapons stuff around SSH (which was ridiculous anyway-- you couldn't export the compiled code, but you could the source? WTF.) But I wouldn't be surprised if the Customs people are still being asshats about it.



  • @blakeyrat said:

    If anybody wants the classic example of a non-answer, there it is.
    Your paranoia aside, it is an answer. SFTP requires SSH. Windows doesn't have SSH out of the box. Hence Explorer doesn't have SFTP available natively. (Of course, there are extensions out there that resolve this.)



  •  @blakeyrat said:

    Anyway, I just got pissed as the feature should BE IN THE FUCKING OS
    WHAT THE FUCK HOW DO APPLE USERS STAND THE FACT THAT THEIR OS DOESN'T
    FUCKING DO ANY OF THE MOST COMMON THINGS PEOPLE WANT THEIR OS TO DO AND
    EVERY OTHER OS DOES! and after a short rage, I gave up.

    At least in 10.4, the Finder has Go -> Connect to Server. If you're using iOS, though, all bets are off.



  • @PJH said:

    @blakeyrat said:
    If anybody wants the classic example of a non-answer, there it is.
    Your paranoia aside, it is an answer. SFTP requires SSH. Windows doesn't have SSH out of the box. Hence Explorer doesn't have SFTP available natively. (Of course, there are extensions out there that resolve this.)

    It's a complete non-answer. It only changes the question from, "why doesn't Windows support SFTP?" to "why doesn't Windows support SSH?" It doesn't answer the question, it just slightly changes the wording of it.

    Now if you know why Windows doesn't support SSH, then that might answer the question. But as-is, you didn't answer jack.



  • @spamcourt said:

    At least in 10.4, the Finder has Go -> Connect to Server. If you're using iOS, though, all bets are off.

    Hilarious. Yeah, that works. But the Apple super-fan, who writes fan-fiction about giving blow jobs to Steve Jobs and works at Apple, told me OS X didn't support it.

    Hilarious.



  • @blakeyrat said:

    Linux has one of the most blurry implementations.
     

    I'm going to assume this sentence means "Of all AA imps available to distros, one of them is most blurry of ALL AA imps."

    I was playing around with Ubuntu's AA, and made it significantly less blurry than OSX. It was a good balance for me.



  • @blakeyrat said:

    You can do the same in Windows using the ClearType Tuner. It can be almost as blurry as OS X, if you set it that way.
     

    Win 7?

    I'm only informed about Vista and lower, where all you can do is adjust the strength and RGB/BGR method.



  • @blakeyrat said:

    Hilarious. Yeah, that works. But the Apple super-fan, who writes
    fan-fiction about giving blow jobs to Steve Jobs and works at Apple,
    told me OS X didn't support it.

    Hilarious.

    								    </p>... uh, wow. And I've worried a lot about getting out of touch using this six-year-old PPC. A lot of OS X seems like a frontend to the crapton of ported *nix utilities, so I'd be kinda floored if they left out FTP.<p>&nbsp;(Edit) Can't friggin' quote. <br></p>


  • @blakeyrat said:

    Hilarious. Yeah, that works. But the Apple super-fan, who writes
    fan-fiction about giving blow jobs to Steve Jobs...

    								    </p><p>So I guess you could call that a ... </p><p><span style="font-style: italic;">... Steve</span> <span style="font-style: italic;">Job</span>?</p>


  • @blakeyrat said:

    @PJH said:
    @blakeyrat said:
    Anyway, the real problem is when you're using SFTP which Explorer indeed does not support. (Not sure why... the export restrictions on encryption are gone, right?)
    I don't think Windows supports SSH out of the box - that'll be why.

    If anybody wants the classic example of a non-answer, there it is.

    I'd wager there's some government bullshit involved. They removed the military weapons stuff around SSH (which was ridiculous anyway-- you couldn't export the compiled code, but you could the source? WTF.) But I wouldn't be surprised if the Customs people are still being asshats about it.

    That would be plausible if Windows didn't include any other cryptographic components, but it clearly does (e.g. IPsec and TLS).



  •  Nope. LCD.



  • @blakeyrat said:

    Anyway, I just got pissed as the feature should BE IN THE FUCKING OS WHAT THE FUCK HOW DO APPLE USERS STAND THE FACT THAT THEIR OS DOESN'T FUCKING DO ANY OF THE MOST COMMON THINGS PEOPLE WANT THEIR OS TO DO AND EVERY OTHER OS DOES!

    People wanting to send passwords in plain text are TRWTF.



  • @blakeyrat said:

    @subanark said:
    int Rectangle; //Declared a variable with the same name as a class

    I do that all the time. (Of course, usually the variable is the class it's named after...)

    I do too, but VB.NET just fucked me over on that (I'm normally a C#-er, but I'm also maintaining a legacy app in VB.NET).

    
    Public Sub SomeSub()
        ...
        Service.SomeStaticMethod()
        ...
        Dim service As Service = GetService()
    End Sub
    
    

    VB.NET complained that I can't access a method before the variable is declared, and since VB.NET is case-insensitive ($%@#$@ VB.NET), it apparently thought that Service.SomeStaticMethod() was meant to be a call to an instance method of the object declared below. There's probably some way to actually force VB.NET to realize it's supposed to be a static call, but I couldn't figure it out. I ended up renaming the instance to serviceObj (ugh).




    Fuck VB.NET.



  • @pjt33 said:

    @blakeyrat said:

    Anyway, I just got pissed as the feature should BE IN THE FUCKING OS WHAT THE FUCK HOW DO APPLE USERS STAND THE FACT THAT THEIR OS DOESN'T FUCKING DO ANY OF THE MOST COMMON THINGS PEOPLE WANT THEIR OS TO DO AND EVERY OTHER OS DOES!

    People wanting to send passwords in plain text are TRWTF.

    I don't want to send passwords in plain text. I want to upload files to my domain.

    If the geeky types who do open source OS X development think security is so great, then they should change the FTP code to do secure FTP by default... as long as the most usable way is the insecure way, you can't complain about people using the insecure way.

    Not that the geeky types who care about security also care even a small amount about usability, or they'd already have done this five years ago. They'd rather just keep pumping out unusable shit, then point and laugh when someone has a security problem-- they'd rather be snide and condescending than to fix the problem!



  • @PSWorx said:

    @blakeyrat said:

    Hilarious. Yeah, that works. But the Apple super-fan, who writes
    fan-fiction about giving blow jobs to Steve Jobs...

    								    </p><p>So I guess you could call that a ... </p><p><span style="font-style:italic;">... Steve</span> <span style="font-style:italic;">Job</span>?</p></blockquote>
    

    The other day the boss of Apple came barging into my house, went to the cupboard under the sink, ransacked the cleaning supplies, and walked out with a can of Mr Sheen. Fucking Jobs, coming over here and stealing our polish...



  • @intertravel said:

    Fucking Jobs, coming over here and stealing our polish...
     

    My life is now meaningless. I have seen perfection and I realize that I cannot possibly come close to it, let alone archieve it. I will now become a monk and spend my life in humility.



  • @blakeyrat said:

    @dstozek said:

     @blakeyrat said:

    I'm trying to upload a screenshot, but apparently you can't FTP from a Mac for less than $24. WHAT. THE. FUCK.

    http://cyberduck.ch/

    It's free from the website, but $24 from the App Store. So if you want it auto-updated, you have to shell out for it. Figure that one out!

    Anyway, I just got pissed as the feature should BE IN THE FUCKING OS WHAT THE FUCK HOW DO APPLE USERS STAND THE FACT THAT THEIR OS DOESN'T FUCKING DO ANY OF THE MOST COMMON THINGS PEOPLE WANT THEIR OS TO DO AND EVERY OTHER OS DOES! and after a short rage, I gave up.

    You don't need any of that. In the Finder, go to the "Go" menu and choose "Connect to server". When prompted for the address type "ftp://ftp.example.com/". You can also do it from terminal. You can also do it from Safari. All 3 of those are free.



  • @blakeyrat said:

    @dstozek said:

     @blakeyrat said:

    I'm trying to upload a screenshot, but apparently you can't FTP from a Mac for less than $24. WHAT. THE. FUCK.

    http://cyberduck.ch/

    It's
    free from the website, but $24 from the App Store. So if you want it
    auto-updated, you have to shell out for it. Figure that one out!

    Anyway, I just got pissed as the feature should BE IN THE FUCKING OS WHAT THE FUCK HOW DO APPLE USERS STAND THE FACT THAT THEIR OS DOESN'T FUCKING DO ANY OF THE MOST COMMON THINGS PEOPLE WANT THEIR OS TO DO AND EVERY OTHER OS DOES! and after a short rage, I gave up.



     http://www.lmgtfy.com/?q=os+x+ftp+built+in



  • @Bumble Bee Tuna said:

    http://www.lmgtfy.com/?q=os+x+ftp+built+in

    HEY! More people post this! It's already in the thread 4 times, but maybe another 5-6 will help us all understand that OS X does indeed have built-in FTP support!



  • @Weng said:

    @blakeyrat said:

    Anyway, I just got pissed as the feature should BE IN THE FUCKING OS WHAT THE FUCK HOW DO APPLE USERS STAND THE FACT THAT THEIR OS DOESN'T FUCKING DO ANY OF THE MOST COMMON THINGS PEOPLE WANT THEIR OS TO DO AND EVERY OTHER OS DOES! and after a short rage, I gave up.
    Windows has an FTP client?  The shitty commandline one doesn't count.

    Furthermore, as far as I can tell, there's only one Windows FTP client that isn't made of utter failure - and even then, it's a huge pile of WTF.

    Why not just use FileZilla?



  •  @blakeyrat said:

    @Bumble Bee Tuna said:
    http://www.lmgtfy.com/?q=os+x+ftp+built+in

    HEY! More people post this! It's already in the thread 4 times, but maybe another 5-6 will help us all understand that OS X does indeed have built-in FTP support!

    perhaps in the future you will take the time to do a 10 second google query before working yourself into a rage that the OS X UI isn't exactly the same as the Windows UI.



  • @Mason Wheeler said:

    Why not just use FileZilla?

    FileZilla is a huge pile of WTF. The only good SFTP client I've found in Windows is WinSCP. And even it's only acceptable, not great.


Log in to reply
 

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