Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
FSMC
Apr 27, 2003
I love to live this lie

Flobbster posted:

Not to mention the use of NSArray to store integers makes me want to scratch my eyes out, since it means you have to wrap them in NSNumbers and make everything even more verbose by boxing/unboxing them.

I refuse to actually look too closely at the code, but there's the potential for NSIndexSet to be a better fit here for a collection of integers.

I can't really tell exactly what the reason for the NSNumbers but it's likely due to using a NSMutable array which was named and made for something completely different.

Adbot
ADBOT LOVES YOU

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

Avenging Dentist posted:

Given that people make functions called doit or run in Java, yes.
public interface Doable{

thesaddestpirate
Mar 19, 2005

Avenging Dentist posted:

Given that people make functions called doit or run in Java, yes.
code:
package java.lang;

public interface Runnable {    
     public abstract void run();
}
:colbert:

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

thesaddestpirate posted:

code:
package java.lang;

public interface Runnable {    
     public abstract void run();
}
:colbert:

Um, thank you for agreeing with me that Java is horrible?

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
code:
public interface Thing{
  void doThat();
  void okDoTheRealThing();
  void helperMethod();
  void helperMethodForOkDoTheRealThing();
}

Zombywuf
Mar 29, 2008

Mustach posted:

code:
public interface AbstractThingFactory {
  AbstractThingDoer doThatFactory();
  AbstractThingDoer okDoTheRealThingFactory();
  AbstractHelper helperMethodFactory();
  AbstractHelper helperMethodForOkDoTheRealThingFactory();
}
Fixed.

fansipans
Nov 20, 2005

Internets. Serious Business.

Zombywuf posted:

Mustach posted:

code:
public interface AbstractThingFactory {
  AbstractThingDoer doThatFactory();
  AbstractThingDoer okDoTheRealThingFactory();
  AbstractHelper helperMethodFactory();
  AbstractHelper helperMethodForOkDoTheRealThingFactory();
}
Fixed.

This is actually what you get if you just keep hitting Ctrl+Space in Eclipse.

zootm
Aug 8, 2006

We used to be better friends.

thesaddestpirate posted:

code:
package java.lang;

public interface Runnable {    
     public abstract void run();
}
:colbert:
This is not a good example of bad naming in Java, and there are lots of good examples.

Volguus
Mar 3, 2009

zootm posted:

This is not a good example of bad naming in Java, and there are lots of good examples.

May I please get some? Been using it for so long, I've never had a problem with Runnable->run, Thread->start, Cloneable->clone (even tho clone is part of Object).
And I don't remember ever seeing a bad naming example in Java.

Anyhow, back to the topic, here is my code that I found in an application I was tasked to maintain (fix bugs):
code:
string cmd="del \""+myDoc.get_path()+myDoc.get_filename()+"\"";
system(cmd.c_str());
This code was in a C++ application. What kind of a monkey executes a system command to delete a file? Windows (and just about any other OS) is written in C. One could think that there MUST be a better way to delete a file, other than spawn a brand new process and the associated headache (did it succeed?if not, what was the error? what do i tell the user?,etc.)

Anyhow, the rest of the code was just as bad. I want those 2 wasted months in my life back.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Some "developers" don't know of platform agnostic interfaces to system commands...

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

rhag posted:

May I please get some? Been using it for so long, I've never had a problem with Runnable->run, Thread->start, Cloneable->clone (even tho clone is part of Object).
And I don't remember ever seeing a bad naming example in Java.

The fact that there are multiple, differently-named methods in Java that amount to "doit()" is pretty bad. For as much poo poo as operator overloading gets, at least with using the call operator, you aren't forced to come up with vague method names that vary depending on the specific usage.

As for bad naming in general, let's just go through the Javadoc alphabetically, shall we?

code:
AbstractAnnotationValueVisitor6
AbstractQueuedLongSynchronizer
AccessibleTableModelChange
AlgorithmParameterGeneratorSpi
AnnotationTypeMismatchException
AppConfigurationEntry.LoginModuleControlFlag
ArrayIndexOutOfBoundsException
AttributeChangeNotificationFilter
AuthenticationNotSupportedException
BadBinaryOpValueExpException
BasicComboBoxRenderer.UIResource
BeanContextChildComponentProxy
BeanContextServiceProviderBeanInfo
BeanContextServiceRevokedEvent
BeanContextServiceRevokedListener
BeanContextServicesSupport.BCSSServiceProvider
C14NMethodParameterSpec
CertPathTrustManagerParameters
ClientRequestInterceptorOperations
ColorChooserComponentFactory
CompositeDataInvocationHandler
ContainerOrderFocusTraversalPolicy
ContextualRenderedImageFactory
DefaultKeyboardFocusManager
DefaultStyledDocument.AttributeUndoableEdit
EnumConstantNotPresentException
FileCacheImageInputStream
FileCacheImageOutputStream
FormatFlagsConversionMismatchException
ImplicitActivationPolicyOperations
IncompatibleClassChangeError
IncompleteAnnotationException
InternalFrameFocusTraversalPolicy
InvalidTargetObjectTypeException
JFormattedTextField.AbstractFormatterFactory
JMXConnectorServerFactory
JobAttributes.MultipleDocumentHandlingType
MalformedParameterizedTypeException
MemoryCacheImageInputStream
MemoryCacheImageOutputStream
ModelMBeanNotificationBroadcaster
MouseDragGestureRecognizer
ObjectReferenceTemplateSeqHelper
ObjectReferenceTemplateSeqHolder
OpenMBeanConstructorInfoSupport
PixelInterleavedSampleModel
PortableRemoteObjectDelegate
PropertyChangeListenerProxy
ReferenceUriSchemesSupported
RelationServiceNotRegisteredException
RequestProcessingPolicyOperations
ScheduledThreadPoolExecutor
ServantAlreadyActiveHelper
ServantRetentionPolicyOperations
ServerRequestInterceptorOperations
SignatureMethodParameterSpec
SinglePixelPackedSampleModel
SQLFeatureNotSupportedException
SQLIntegrityConstraintViolationException
SQLInvalidAuthorizationSpecException
SQLNonTransientConnectionException
StringIndexOutOfBoundsException
TransformerFactoryConfigurationError
UnknownFormatConversionException

Vanadium
Jan 8, 2005

Triple Tech posted:

Some "developers" don't know of platform agnostic interfaces to system commands...

Are you suggesting that some dude is trying to avoid hardcoding a WinAPI call in order to stay portable? It is not like del is.

Edit: It appears you are, in fact, not. Carry on.

Vanadium fucked around with this message at 19:14 on May 13, 2009

ymgve
Jan 2, 2004


:dukedog:
Offensive Clock

Vanadium posted:

Are you suggesting that some dude is trying to avoid hardcoding a WinAPI call in order to stay portable? It is not like del is.

Edit: It appears you are, in fact, not. Carry on.

My guess is the dude who wrote the code doesn't know about the standard calls for deleting a file at all.

Vanadium
Jan 8, 2005

It's C++. I do not know any, either.

Seth Turtle
May 6, 2007

by Tiny Fistpump

Avenging Dentist posted:

As for bad naming in general, let's just go through the Javadoc alphabetically, shall we?

code:
AbstractAnnotationValueVisitor6
AbstractQueuedLongSynchronizer
AccessibleTableModelChange
...

It could be worse. The classes could be abbreviated to AAVV and AQLSync.

EDIT: I, of course, mean AAVV6. Don't want to confuse it with the previous five Abstract Annotation Value Visitor classes.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Vanadium posted:

It's C++. I do not know any, either.

remove()?

Vanadium
Jan 8, 2005

I could have sworn that was only POSIX. Hooray for standards. :3:

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Seth Turtle posted:

It could be worse. The classes could be abbreviated to AAVV and AQLSync.

EDIT: I, of course, mean AAVV6. Don't want to confuse it with the previous five Abstract Annotation Value Visitor classes.

Or you could use something called "namespaces" and allow people to apply using declarations to minimize verbosity. A radical idea, I know.

Volguus
Mar 3, 2009

Avenging Dentist posted:

Or you could use something called "namespaces" and allow people to apply using declarations to minimize verbosity. A radical idea, I know.

Am I weird for not finding those names...bad? I don't see the problem with a 20 character long class name. I mean, I would have had such a problem back in Borland C++ 3.1 days, but today, with today's IDE's, its all a CTRL+space away.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

rhag posted:

Am I weird for not finding those names...bad? I don't see the problem with a 20 character long class name. I mean, I would have had such a problem back in Borland C++ 3.1 days, but today, with today's IDE's, its all a CTRL+space away.

Yes. You are weird. It's not even about typing them, it's about reading them. Anything nontrivial with any of those functions (and given Java's propensity for verbosity, that's 99% of things) is going to be spread out on multiple lines or will just scroll horizontally off the screen. A good sign that your code is poo poo is when a majority of the individual statements have to wrapped to fit on the screen.

Volguus
Mar 3, 2009

Avenging Dentist posted:

Yes. You are weird. It's not even about typing them, it's about reading them. Anything nontrivial with any of those functions (and given Java's propensity for verbosity, that's 99% of things) is going to be spread out on multiple lines or will just scroll horizontally off the screen. A good sign that your code is poo poo is when a majority of the individual statements have to wrapped to fit on the screen.

Aha , I see it now. So at the end of the day its just a matter of taste.
I hate it when I see cryptic code, even if it has comments. I love it when I can "read" the code, even without comments.
And no, don't give me the 80 columns crap. Nobody nowadays has an 80 col limitation, upgrade your drat monitor if you do, so no, there is no need to wrap on multiple lines most of the statements.
If you can't upgrade your monitor and are forced to use an 80x25 screen...don't do Java. Plain and simple. Most likely the stuff you're doing (with those limitations) is not appropriate for Java.

It is just a matter of taste. Even though I program in C just as much as I do in Java, I like the Java style more. I like to comment the algorithm used, not the fact that I just wrote in one line the most complicated code ever.

So , sorry sir, those class names are fine.

shrughes
Oct 11, 2008

(call/cc call/cc)

rhag posted:

And no, don't give me the 80 columns crap. Nobody nowadays has an 80 col limitation, upgrade your drat monitor if you do, so no, there is no need to wrap on multiple lines most of the statements.

You're one of those retarded people who maximizes all their windows, aren't you.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
If you don't program with (at least) 2 columns of code side-by-side, you are not a real programmer.

rhag posted:

don't do Java

The only true statement in that entire post.

No Safe Word
Feb 26, 2005

shrughes posted:

You're one of those retarded people who maximizes all their windows, aren't you.

Hell I do and I still have an 80-column limitation.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

No Safe Word posted:

Hell I do and I still have an 80-column limitation.

Newspaper/magazine articles have short columns for a reason: it's easier to read.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Get bent, use a REAL editor with indented wrapping...

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
Oh christ, if there is any language that does not need a secret cabal of elitist programmers, it is Java.

Anyway, Java is prolix. Three root causes of this:

1. Java culture encourages it. Package names are ridiculously prolix, but at least those are usually hidden at the top of the file. Whole-word naming conventions just inevitably pile up appositional modifiers; if it's worse in Java, it's only because the language makes it so easy to over-abstract every problem.

2. The import system lacks shortened qualified import, which turns name collisions into minor catastrophes (because everyone uses prolix package names), which means you see some really silly workarounds like Swing's J prefix on every single class in the library.

3. There are several missing language features that force/encourage you to name things that don't really need names, like all the silly interfaces required by the lack of first-class functions, and the AbstractFoo variants to provide default implementations for interface functions.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

rjmccall posted:

2. The import system lacks shortened qualified import, which turns name collisions into minor catastrophes (because everyone uses prolix package names), which means you see some really silly workarounds like Swing's J prefix on every single class in the library.

This was my favorite part of reading through the Javadoc. C++ has an awful "package" management system, and even it can avoid the old-school C way of applying prefixes to identifiers to avoid name collisions.

Any language made after C just has no excuse for that.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
The really terrifying thing is the people who take this horrible name-resolution hack and apply it in their own projects as if there were some deeply legitimate design principle behind it.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

rjmccall posted:

really silly workarounds like Swing's J prefix on every single class in the library.
Correction: most classes in the library. Which makes it even worse because it's inconsistent!

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

rjmccall posted:

2. The import system lacks shortened qualified import, which turns name collisions into minor catastrophes (because everyone uses prolix package names), which means you see some really silly workarounds like Swing's J prefix on every single class in the library.

We like to complain about the long typenames in Java, but it's sad that Sun gets it wrong even when they try to use short names too:

java.util.List
java.awt.List

The only saving grace is that no method in java.awt.List seems to manipulate a java.util.List. But still, if you wanted to use both in the same compilation unit (something that could be quite likely), you're stuck fully qualifying at least one of them everywhere. Was this moronic naming (instead of something like ListBox or ListView for the UI component) just Java puffing up their chest and saying "look, packages are cool :smug:"?

Fake edit: Oh god! Since it subclasses java.awt.Component, it has a list() method that does the incredibly useless task of printing a debugging description of the component to a stream!
code:
java.awt.List list = new java.awt.List();
list.list(someStream);
:psypop:

Rottbott
Jul 27, 2006
DMC

shrughes posted:

You're one of those retarded people who maximizes all their windows, aren't you.
Who doesn't make use of all the available screen space? Unless you're working on a single monitor, which is daft.

Seth Turtle
May 6, 2007

by Tiny Fistpump

Rottbott posted:

Who doesn't make use of all the available screen space? Unless you're working on a single monitor, which is daft.

This is the proper layout of a programmer's two screens.
- SA Forums takes up 50% of the right screen.
- The other half of the right screen is two folder windows. One for your workspace, the other for your backup space, or if you've got SVN, your external harddrive.
- Half of the left side is YouTube, Hulu, or whatever.
- A quarter of the left side is a DOS window or some other command line prompt.
- The remaining quarter of the left screen is your IDE or text editor for coding.

Lexical Unit
Sep 16, 2003

Seth Turtle posted:

This is the proper layout of a programmer's two screens...

Not quite.

1. Your development machine has its screen saver up. (Who cares what windows are up on that thing?)

2. Your personal machine to your left has SA forums up with youtube hidden underneath that window in case your boss walks in.

necrobobsledder
Mar 21, 2005
Lay down your soul to the gods rock 'n roll
Nap Ghost

rjmccall posted:

2. The import system lacks shortened qualified import, which turns name collisions into minor catastrophes (because everyone uses prolix package names), which means you see some really silly workarounds like Swing's J prefix on every single class in the library.
The worst part of this all is that classpath collisions still exist all the time and we wind up with the Java equivalent of DLL hell, which sensible package names can solve on their own. For all the ridiculous identifier prefixing and suffixing schemes people concoct, I've yet to see people actually do anything reasonable like renaming packages properly so that classes don't pound on each other's namespaces like lobotomized monkeys. If I have to write another classloader because of package name idiocies, I'm sending piles of poo to Guy Steele.

shrughes
Oct 11, 2008

(call/cc call/cc)

Rottbott posted:

Who doesn't make use of all the available screen space? Unless you're working on a single monitor, which is daft.

If you have an 80 character column limit you'll have less screen area devoted to large swaths of empty space. Because you can have more files open side by side.

Brain Candy
May 18, 2006

Avenging Dentist posted:

The fact that there are multiple, differently-named methods in Java that amount to "doit()" is pretty bad. For as much poo poo as operator overloading gets, at least with using the call operator, you aren't forced to come up with vague method names that vary depending on the specific usage.

Thread is a thread, Runnable is a functor that you put in threads. Would you like ThreadFunctorActionier instead?

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Brain Candy posted:

Thread is a thread, Runnable is a functor that you put in threads. Would you like ThreadFunctorActionier instead?

Thanks for not reading what I wrote?

Brain Candy
May 18, 2006

Avenging Dentist posted:

Thanks for not reading what I wrote?

Thanks for responding with a thoughtful and/or informative post!

Adbot
ADBOT LOVES YOU

Rottbott
Jul 27, 2006
DMC

shrughes posted:

If you have an 80 character column limit you'll have less screen area devoted to large swaths of empty space. Because you can have more files open side by side.
That's why 80 character limits are out of date. I hope I never end up working somewhere with one. Anyway, I'd still have visual studio maximised but with multiple tabs visible.

Then again, without any rule people do go over the top. I just found an single line 360 columns wide:

code:
maxSteerAngle = XXDegreesToRads(((1.f - (XXPow(FROM_MPH(250.f) - speed, gAIPerCarSetup[pCar->playerId].speedSensitivity)
 / XXPow(FROM_MPH(250.f), gAIPerCarSetup[pCar->playerId].speedSensitivity)))
 * (gAIPerCarSetup[pCar->playerId].maxSteeringAngle2 - gAIPerCarSetup[pCar->playerId].maxSteeringAngle1))
 + gAIPerCarSetup[pCar->playerId].maxSteeringAngle1);
:(

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply