- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Admin
Who said he passed the class?
Admin
In what way does Runtime.getRuntime() make sense? Do you enter a house to find the house? Why have a class that represents something of which there is only one instance (i.e. is not a class)? And why do you have to call a function to get it? Next thing you'll be calling
Admin
This shows the problem with being stupid. If you can't distinguish between "object-oriented programming" and "one language's way of doing object-oriented programming" you're pretty much disqualified from further discussion. Now go sit in the corner.
No, first get me another cup of coffee, then go sit in the corner.
Admin
Fuck off; that corner is mine. Piss off to the basement or something.
Oh, and mine has milk, no sugar.
Admin
No, the basement is where I'm building the robot, I don't want him fucking with that. Put him in the attic.
And mine is cream and sugar, and don't forget the bourbon.
Admin
2)Runtime is a singleton. Therefore you wouldn't new up a new runtime
Admin
I routinely write code like:
Sure, it sounds repetitious. But I'm not writing a poem: I'm writing a program. I don't care how it sounds: I want it to work and to be clear to the reader.
As to the second part: A class is not an instance, so we are not "going into a house to find a house". Rather, we are thinking about the general idea of a house to find a specific house. I think it makes perfect sense to say, "Let's think of the general idea of houses. Now, within that idea, let's find a house that meets such-and-such condition." Like House.findHouseOwnedBy(person).
I suppose you could make a case that Runtime.getRuntime is an imprecise name because it doesn't tell us what Runtime we're getting. Perhaps a better name would be Runtime.getCurrentRuntime. But so what? Read the docs and you'll know what it means.
What's the logical fallacy in the idea of a class of which there is only one instance? In set theory, there's nothing absurd or even particularly special about a set with only one member. Even in common English, we have the phrase "in a class by itself", meaning something that is the only member of its class. If a class with 2, 3, 4, or 1000 members is legitimate, why not a class with only 1 member?
The whole point of classes in OOP languages is that a class is a container for data and functions related to some logical entity. There is no reason why something that there is only one of would not have data and functions related to it. Like, in the context of a given system, there might be only one server. But that server might still have all sorts of data about it that we want to keep, like when it last booted, its network address, amount of free memory, etc. If we accepted some definition of "class" that says there must be more than one, then we'd have to make up some other kind of construct for the things of which there are only one, and they'd have to do many of the same things classes do. If it worked exactly the same but had a different name, why bother to have two names? If it accomplished the same purpose but worked differently, wouldn't that be a lot of extra complexity for no benefit?
Admin
In modern Java,
But that assumes that the thing is a useful resource and not just a waste of space that will get cleaned up by garbage collection.
Admin
Good rant.
And however you may feel about OOP and singletons and whatnot, don't ever fucking write a goddamned fucking constructor that is only fucking called to initialize some goddamned static variables. Seriously, that shit makes no sense.
(Got at least two motherfuckers who do that all through their code.)
Admin
I see you've never tried alcohol before.
Admin
You're right, you don't initialize static variables in a constructor. That would be stupid - why would you want to "initialize" something every time an instance is created? In Java you'd use a static initializer block.
What does this have to do with anything? And where's my goddamn coffee?
(can't get a good intern these days for love or money)
Admin
You'd like that think that would get through to people, wouldn't you. Sadly, I once worked with someone who had to be "asked to leave" after I had to revert two giant commits he did.
Admin
The "door close" button in the elevators in Japan work as intended. People don't want to wait 5 seconds to watch a door close when they know no one else is getting on or off. (If the person was wrong, there is a "door open" button that still works when the doors are closing).
Admin
Admin
Admin
Oh, your SCM doesn't allow that?
Admin
Can nobody see the WTF?
I can see the WTF here. You should write your commit messages in present tense:
Also the period is superfluous in the summary line.
Admin
TRWTF is no code reviews.
Admin
Coffee is a mission critical component. I only let competent members of my team make mine.
Admin
it's newhire.job.delete();
newhire.freeJob() just returns the number of employment openings. =)
Admin
Yeah, too many companies see that as a waste of time. Personally, I've always seen it as a great mentoring opportunity. I've learned a lot from my code reviews.
Admin
Yes, I was about to point that out myself - it's not a directive to force the JVM to run collection immediately, it's a suggestion that now would be an appropriate time (e.g because you've just released references to a large amount of memory). In a container environment (e.g a web server), there's a good chance it won't do anything.
Admin
TRWTF functions called freeMemory() instead of getFreeMemory()
Admin
If Hire was properly implemented you could....so this reflects back to a bug in the Hire implementation.
Admin
Admin
Admin
Admin
TRWTF: method names that are unclear about whether they represent an action or a piece of data. By Java conventions, shouldn't it be getFreeMemory()?
Oh, and where's the babushka of type boxes, factories and decorators around it? This can't be correct Java.
Admin
Admin
I think he knew exactly what freeMemory does....
That is, I think he understood that it doesn't freeMemory but just has a look at how much spare mem is available - 'cause everyone knows if the computer has peeked at the memory then it can more efficiently allocate it later...
Admin
Admin
Admin
I don't really understand why people think freeing memory is a performance enhancement - unless you're using way more memory than you've got. But even then, freeing some probably won't make the world a happier place performance-wise.
Admin
Admin
Admin
Without searching, what would people expect the following German words to mean? Gift, Objektiv, Artist, Kriminale, gross, herb
Assumption is the mother of all fuckups.
Admin
Buffalo buffalo = BUFFALO Buffalo(); Buffalo.buffalowBuffalo().buffalowBuffaloBuffalo();
Admin
Admin
Admin
Java is a part of Indonesia.
In some parts of the world, the "door close" button in the elevator actually does close the door, even on passenger elevators.
Incredably annoying when you then go to country where the "Door Close" button is not connected to anything, and you can stand there punching it and nothing happens.
Admin
And yet every piece of unportable bloated crap I end up running that causes my workstation to bog to a crawl turns out to be Java. For what should be a simple TK widget interfacing with the server. Just how does Java end up being so slow on modern hardware? Why is that? Could it be because the system isn't actually as smart as its authors thinks it is? Or does Sun/Oracle just want to sell more hardware to throw at the problem that should be fixed by a few hundred lines of TK? Or does Java just attract crap developers that are so abstracted from reality and who have no idea what the bare metal is doing underneath?
Software was better back in the days when people had to care about memory allocations. Higher entry bars and all that.
Admin
WFM in .au too. But then again, you do have to know when pressing the button will make a difference - no use pressing it while the door is still opening, because the microcontroller is still busy opening the door and will ignore you.
And in a building with 4 lifts, you have to know which one it is where the door close button actually acts as an emergency stop and open the door and get off at this floor button and the door open button acts as a door open button. It seems there's no configuration management in lift controllers.
(actually, I'm most amused by our below ground floor lifts where despite the floor buttons not being counters or toggles, they've still implemented de-bounce circuits in analogue, and they've been slowly degrading over time so that now you sometimes have to hold the button down for 3 seconds before it will latch. And they've implemented a different buzzer for every individual button. And some of the LEDs are dimmed or don't work at all once latched (but do work when pressing the button). All this in lifts that are less than 10 years old. TRWTF is lifts that haven't been fully virtualised yet. Damn real world)
Admin
The problem (as so often is the case) is that these languages are often designed to guard against fuck ups. The problem is, that the harder you make something to fuck up, the more people will claim qualification in it simply because they haven't broken anything. Yes, Garbage Collection and automatic memory management is a very convenient thing, but that doesn't necessarily make it good.
More people want to be programmers, and languages are evolving and being created to both simplify things sufficiently for everyone to live the dream and to guard against (accidental or otherwise) stupidity. The problem (as MS should have found out by now) is that when you build things for morons, you tend to turn people into morons.
Make a language any moron can use, and any moron will use it and some just-above moron people will degrade to morons. Make a language the average person can use, and the avergae person will use it - and the people on the cusp of being average will either sink to average or rise to average. Make a language that requires understanding, and you'll attract mainly the people with the understanding (and some just-above average types who put the work in to learn).
In an ideal world, we want to keep thinks complex when they have to be - to ensure that there's not too many monkeys about, right? Well, actually, no. When we become too specialised, we see that there are small numbers of awesome people trying to fill a market demand for large numbers. This is why we need languages that idiots can use - because whether we like it or not, there are simply not enough people floating around capable of understanding what is going on to sustain the world's demand.
Admin
I had one where a guy was opening IE instance "WebBrowser" in a tight loop and then throwing them away.
WebBrowser web = new WebBrowser(); // Not using this web = _browser;
7 senior developers couldn't find the performance bug.
Admin
Yeah but that only returned the number of new hires that were about to be fired. It didn't actually fire any one.
Admin
Doing something idiotic...and failing at it because you can't read the doc: Priceless!
Admin
Get to about item 5 and Knuth says something like "see, I told you to read ALL the instructions first, in step 2 you overwrote a critical file that you need next". After swearing and starting again from scratch, you get to item 10 and the same thing happens AGAIN!
I know damn well (well, I assume :-) he set it up that way on purpose, just to catch us out. But twice!? Evil man.
Admin
Not to mention Jetty (way too many dangling streams), or even socket connections that create 4 streams for every opened connection, but don't explicitly close them when you explicitly call closeConnection()! ;-( Why bother having a close() method?
This is actually a case where periodically/dynamically calling the garbage collector was the only way to help prevent web requests failing under load due to having too many open file handles.
Admin
...and this is probably because of an IDE's autocompletion. That's why, if I really ain't in a hurry, I like to program in something like GNU Emacs. It makes repetitive tasks easier with the appropriate functions, but at least before typing a function call I don't know about, I have to read the documentation.
And before you go into the "Emacs isn't used in enterprise, every professional who knows his/her craft uses an IDE" tantrum, go take a tour of Google or Red Hat.