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
dc3k
Feb 18, 2003

what.

Biowarfare posted:

Not really bad code per se, but who the gently caress indents like this????

That is really strange...generally I would do it like this, as I imagine most would:

code:
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72"   href="ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed"                 href="ico/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon"                                href="ico/favicon.png">

Adbot
ADBOT LOVES YOU

dc3k
Feb 18, 2003

what.

Dicky B posted:

I know it's pointless and annoying to maintain for anybody who doesn't have some kind of editor plugin

How?

dc3k
Feb 18, 2003

what.

geonetix posted:

Just ran into something that's always pretty sad (it's coldfusion, but the comments make it worse):

code:
// If the thread is still running.
if (redactedThread.status == 'RUNNING') {
	// Trace a message.
	trace(text="Waiting for redacted");
}
Every single line of code in this file has a comment. It wasn't there some revisions ago. Somebody actually spent time adding it.

x++; //increment the x variable

dc3k
Feb 18, 2003

what.

QuarkJets posted:

What kind of poo poo class requires physical printouts of code for homework submission? Classes in the early 90s, perhaps

My intro to OOP class was like this. I had to print out 30+ pages of code for each assignment. Prof's reasoning? "So the TA can make comments in the margins"

...

Right. That happened maybe five times total outside of them writing my grade on the paper, which was useless because our grades were online anyways. Why couldn't the TA just add comments to our code with a text editor and return it to us that way? Or give us a document back telling us which lines the mistakes were on? But no, we had to waste our loving money printing out code and not using the online submission system that every other loving course used.

This is the same prof who would dock marks on exams in second and third year courses for missing semicolons and handwritten code not being perfectly indented in the tiny space given to us on the exam sheet.

dc3k
Feb 18, 2003

what.
Found this in some code the other day and while it isn't the worst thing in the world, it annoyed me because there's no reason to do it and it sort of kills readability.

code:
self.someProperty.booleanProperty = self.someOtherProperty.hidden = self.someOtherPropertyAgain.booleanProperty = self.yetAnotherProperty = self.heyLookSomethingElse = NO;
I tried to explain that it was a dumb thing to do, but he was having none of it. "What's wrong with that? It's fine."


Sacrificing readability to reduce 4 lines of code is dumb.
:(

dc3k
Feb 18, 2003

what.

Crosscontaminant posted:

True. I assume it is on the basis of self.

Sorry, forgot to mention it's Objective-C.

dc3k
Feb 18, 2003

what.

substitute posted:

PHP code:
function register()
{
    if (!empty($_POST)) {
        $msg = '';
        if ($_POST['user_name']) {
            if ($_POST['user_password_new']) {
                if ($_POST['user_password_new'] === $_POST['user_password_repeat']) {
                    if (strlen($_POST['user_password_new']) > 5) {
                        if (strlen($_POST['user_name']) < 65 && strlen($_POST['user_name']) > 1) {
                            if (preg_match('/^[a-z\d]{2,64}$/i', $_POST['user_name'])) {
                                $user = read_user($_POST['user_name']);
                                if (!isset($user['user_name'])) {
                                    if ($_POST['user_email']) {
                                        if (strlen($_POST['user_email']) < 65) {
                                            if (filter_var($_POST['user_email'], FILTER_VALIDATE_EMAIL)) {
                                                create_user();
                                                $_SESSION['msg'] = 'You are now registered so please login';
                                                header('Location: ' . $_SERVER['PHP_SELF']);
                                                exit();
                                            } else $msg = 'You must provide a valid email address';
                                        } else $msg = 'Email must be less than 64 characters';
                                    } else $msg = 'Email cannot be empty';
                                } else $msg = 'Username already exists';
                            } else $msg = 'Username must be only a-z, A-Z, 0-9';
                        } else $msg = 'Username must be between 2 and 64 characters';
                    } else $msg = 'Password must be at least 6 characters';
                } else $msg = 'Passwords do not match';
            } else $msg = 'Empty Password';
        } else $msg = 'Empty Username';
        $_SESSION['msg'] = $msg;
    }
    return register_form();
}

I call it the crocodile clause.

dc3k
Feb 18, 2003

what.
This is the kind of poo poo you come across frequently in the hobbyist (Arduino) community. Everything is an unreadable unmaintainable poorly formatted loving mess.

code:
    //DRAW THE INPUT
    boolean drawLine=true;
    stroke(255,0,0);
    int Y1 = InputData[i];
    int Y2 = InputData[i+1];

    y1Above = (Y1>inputHeight);                     // if both points are outside 
    y1Below = (Y1<0);                               // the min or max, don't draw the 
    y2Above = (Y2>inputHeight);                     // line.  if only one point is 
    y2Below = (Y2<0);                               // outside constrain it to the limit, 
    if(y1Above)                                     // and leave the other one untouched.
    {                                               //
      if(y2Above) drawLine=false;                   //
      else if(y2Below) {                            //
        Y1 = (int)inputHeight;                      //
        Y2 = 0;                                     //
      }                                             //
      else Y1 = (int)inputHeight;                   //
    }                                               //
    else if(y1Below)                                //
    {                                               //
      if(y2Below) drawLine=false;                   //
      else if(y2Above) {                            //
        Y1 = 0;                                     //
        Y2 = (int)inputHeight;                      //
      }                                             //
      else Y1 = 0;                                  //
    }                                               //
    else                                            //
    {                                               //
      if(y2Below) Y2 = 0;                           //
      else if(y2Above) Y2 = (int)inputHeight;       //
    }                                               //

    if(drawLine)
    {
      line(X1,Y1+inputTop, X2, Y2+inputTop);
    }
Seriously, who the gently caress puts comments like this? Any change to the code (to fix the horrendous style or to make changes) makes it even worse than it already is...

dc3k
Feb 18, 2003

what.

EntranceJew posted:

Looks like someone was brought up on assembly.

Even in assembly I don't often see large chunks of code with ; and no actual comment after it though.

dc3k
Feb 18, 2003

what.

pokeyman posted:

I'm not defending this particular style, but it looks like the empty comments signify the code described by the nonempty comment at the top. Like #region in C#.

Yeah, that's definitely the reason. Could have gone about it a bit better though.

dc3k
Feb 18, 2003

what.
I'm working on a mobile app right now. Our engineers have been working with the client and a few of their engineers for the past year or so on this product. We were trying to figure out why scrolling performance on a particularly complicated part of the app had suddenly gone from "pretty good to very good" on most devices to "complete poo poo and dropping assloads of frames even on the most powerful phones"

It turns out our client's developer committed some fixes to a custom text label we had implemented as part of a feature he had implemented. The basic functionality of this custom label is to include clickable links within the text. When the label is configured, some code gets run that detects whether or not a link exists in the plain text, and, if so, magics it into a clickable link that will push to another part of the app or a web view if necessary. It's a fairly expensive operation, and the cost can add up quickly when scrolling fast. So clearly it should be called as little as possible - ie, only when the text changes.

Client dev decided to override almost every label method to call super, then call the code that checks for links. This included setting the font, changing the text colour, changing the background colour, adding an attribute to the text (which actually resulted in it being called twice).

So, when the view was configured with new text, the minimum of the following was happening:

set text
set text background colour
set text font
set text font colour

On top of running the same expensive operation four times in a row for no loving reason, each time it was run it was creating a new instance of the object that we use to check if the links exist rather than just creating it once and keeping it around for the lifetime of the label. This happened for each instance of this label. Of which there were many being recycled and re-configured as the view scrolled. We ripped out all of his lovely overridden methods and stopped recreating the same object over and over and magically the code is 700 billion times faster and nothing broke because changing the font doesn't change the goddamn text so why the gently caress would I need to check for links embedded in the text unless changing the text itself!?!?as;lkgdfhasdjlg

Ugh.

dc3k
Feb 18, 2003

what.
Haha, that would be nice. We're too far in to re-factor that much (they're still too busy shoving features down our throats for us to do any maintenance) and they wouldn't let us do it anyways because reasons. Scrolling is pretty close to where I would reasonably expect it to be while doing all UI on main, so I'm not too upset now that this particular fuckup is fixed.

dc3k
Feb 18, 2003

what.
My friend sent me this today:

code:
private void startLoginCrap(){
        TelephonyManager d = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
        String Device=d.getDeviceId();
    if (Device == null){
        WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
        WifiInfo wInfo = wifiManager.getConnectionInfo();
        String c = wInfo.getMacAddress();
        //Log.w("StringC", Device);
        Log.w("MacAddress", wInfo.getMacAddress());
    }else{
        c = d.getDeviceId();
        Log.w("DeviceID", c);
    }
   
    u = etUser.getText().toString();
    p = etPassword.getText().toString();
    a = "?action=login";
    b = "?action=SetDeviceID";
    mLogin = "false";
    dLogin = "false";
    //Log.w("DeviceID", c);
    urlLogin= (KEY_LOGIN_URL + a + "&user=" + u + "&pass=" + p);
    devLogin= (KEY_LOGIN_URL + b + "&user=" + u + "&device=" + c);
    new VerifyLogin().execute(urlLogin);
    //Log.w("LoginStatus", mLogin);
    new setDeviceID().execute(devLogin);
    Log.w("DeviceStatus", devLogin);
 
}
http://pastebin.com/gaKDH8WA

:downs:

dc3k
Feb 18, 2003

what.

EpicCodeMonkey posted:

>$5000/seat compiler

These are a thing?

dc3k
Feb 18, 2003

what.

shodanjr_gr posted:

Is the horror the break; statement instead of "return" or "return rc"? Is it the spelling mistake in the trace statement? Is it me?

e: Probably copy-pasted from a while(true){} wrapped initialization code-segment?

http://code.metager.de/source/xref/QubesOS/qubes-r2/vmm-xen-windows-pvdrivers/xenpci/gntmem_device_interface.c#733

?

dc3k
Feb 18, 2003

what.

NihilCredo posted:

So, I gather that the perfect version of this code should have no mutation, a single return statement, and two braces for every if block.

Well, the solution seems blindingly obvious to me. I don't know, maybe you're all bad? :confused:


i hate you

dc3k
Feb 18, 2003

what.

Ika posted:

While tracking down the source of a newly introduced error I found this beauty

code:
	[...]
	if(item1st)
		this->doActivateItem(item1st);
	else
		if(itemlst)
			this->doActivateItem(itemlst);
At first glance it looks like it just has a useless if / else, but those are actually two different variables.

This reminds me...
I hate it when people type stupid idiot poo poo like "lst" instead of just spelling the mother loving word properly. JUST TYPE THE FULL WORD. USING VOWELS WILL NOT CAUSE YOUR COMPILER TO EMIT DEMONS. THE loving IDE WILL AUTOCOMPLETE IT FOR YOU FROM THAT POINT ON. YOU'RE NOT SAVING ANY TIME YOU STUPID rear end in a top hat

I had an intern once that called a bunch of UIButtons in an iOS project btn1, btn2, btn3, etc and I wanted to stab him in the face.

dc3k
Feb 18, 2003

what.

Suspicious Dish posted:

half rant / half question: does anybody hate the "programmers are introverted, we must be alone, in our own offices, to prevent ~*~ breaking the flow ~*~" meme thing

i feel like some of the most productive programming i've ever done has been paired up with somebody in a room with a whiteboard. because the rest is basically busywork of typing it all into the computer -- the hard stuff is problem solving, and if i have a problem with what i'm typing into a computer, it's a lot better to let other people know and try to solve it together (also, it probably affects their busywork as well)

for stuff like debugging, even when i have nobody to collaborate with and simply need to power through something, if someone asks me a question, i can just say "in the middle of something, come back later."

i swear i wish people would come interrupt me for five minutes when they have a question about my code and how i solved these problems than try to get "in the zone" and waste a bunch of time trying to understand it.

I did pair programming full time for over two years. It's really good for what you describe. There are some downsides of course, but I found it significantly helped productivity.

dc3k
Feb 18, 2003

what.

Hollow Talk posted:

code:
(let ([list (list a b c)])
  (list list d))
vs.
code:
(let ([lst (list a b c)])
  (list lst d))
There is a reason, sometimes.

use better variable names

dc3k
Feb 18, 2003

what.

FamDav posted:

Can this be the new thread title.

Please yes. That is terrifying.

dc3k
Feb 18, 2003

what.

Absurd Alhazred posted:

This is a horror I made myself. See if you can spot the error:

C# code:
for (int i = n-1; i > 0; i--)
{
        y [i] = x [i] - x [i = 1];
}
:shepface:

you put a space before your square bracket you loving monster

dc3k
Feb 18, 2003

what.

more falafel please posted:

Lol, blueprint doesn't compile to native, it compiles to UnrealScript bytecode. UnrealScript was the scripting language they used through UE3, and it's not even close to native. Blueprint is useful for simple stuff (designers rigging up level triggers, etc) but in a full production game you don't want any tight loops in Blueprint, because it's very slow.

the nativization docs say it can be compiled into native c++. is that not actually true, or are you speaking specifically about the default setting?

https://docs.unrealengine.com/4.27/en-US/ProgrammingAndScripting/Blueprints/TechnicalGuide/NativizingBlueprints/

dc3k
Feb 18, 2003

what.
returning dates in both incorrect unix timestamps and that dumbass start and end format instead of a single proper iso8601 string for the start and end (or proper unix timestamps...just anything but the current two wrong formats) is the real horror here

dc3k fucked around with this message at 07:20 on Aug 15, 2023

dc3k
Feb 18, 2003

what.

Falcon2001 posted:

The sheer virtriol in this thread is absolutely hilarious / baffling / horrifying to me.

it's par for the course when dealing with gamers, tbh. minor inconveniences to the typical reddit/r/gaming (or whatever subreddit is the main one) users become life altering disasters that require constant commenting and complaining. most gaming subs are generally unusable due to the constant whining every time a patch/update comes out

Adbot
ADBOT LOVES YOU

dc3k
Feb 18, 2003

what.
everything in linux is a file
everything in javascript is a god drat nightmare

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