- 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
Ah, the basics of OOP are very hard to understand; I struggled myself for a few hours.
Addendum 2024-11-19 06:44: Just kiddin'. By first thought about C with classes was "Finally I don't have to prefix every function"; OOP is pretty much the natural thing how to order and structure interactions with data - a subject or object does an action, it ain't the other way around.
Admin
Of course the documentation says the parameter is a "group number" but the name of the parameter is just "group". I suppose referring to both of those things as an e.g. "GroupId" would be just waaaay too hard for these bozos.
Admin
Did something like this by accident once, back when I was first learning Java. Had this object representing a UI window, and I wanted to add a function to close it from some other object, named it
public void close()
, had it call thesetVisible(false)
function and tried it out. Turns out that I was using the same name as a deprecated function thatsetVisible()
was using, so it looped until the stack overflowed.Admin
This is a very lame attempt at making CPU work at full capacity, because the stack overflows way too quickly.
Please follow best practices and use timed
while
loops, which also have the added benefit of not crashing the application.Admin
FWIW: In Java a static method overloading a static method doesn't make sense, because - as you can see in the code block itself - you have to specifiy the class name, i.e. even if there is a SubGroupEntity.find(String) that particular method will end up in an endless loop.
Admin
"Antediluvian?" I haven't seen that word used in a very long time. Marvelously fitting, though.
Admin
This looks to me like someone read Donald Knuth's The Art of Computer Programming (from the 1960's and 1970's) and tried to implement his recursive algorithm for searching a tree or a sorted array - but missed both the key steps. Knuth's method was to divide the search area in two at each step and recurse into it, until it either finds the searched-for key or has narrowed the search to one item that is closest to where the key would be if it was in there.
For an example, if you have an array of structures sorted by the key you are searching for (in pseudo-c rather than the assembly language Knuth preferred):
Find(key, start_index,last_index) { If (start_index == last_index) return start_index Take the middle of the array mid_index = (start_index + last_index)/2 record = array[mid_index] If (record.key is less than key) Find(key, start_index, mid-index - 1) If (record.key is greater than key) Find(key,mid-index + 1,last_index) return mid_index }
If I was going to use this, I'd do a bit more work to make sure it doesn't
So the person who wrote that code in the original post:
Admin
@Lothar - Method overloading is when you have a method with the same name that takes different arguments. It absolutely makes sense in a static context.