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
Malcolm XML
Aug 8, 2009

I always knew it would end like this.
LMAO at people who have few enough servers that names matter

Or aren't just creating and destroying them as needed with stateless clones of services

Adbot
ADBOT LOVES YOU

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Malcolm XML posted:

Or aren't just creating and destroying them as needed with stateless clones of services

Most places I see are just coming out of the dark ages and aren't anywhere near mature enough for doing something like that. It's a good thing to aspire to, though.

The idea of CI builds and automated tests are still mind-bogglingly modern to them.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



The nutbar that used to be the senior admin around here likes to use disaster names and rather presciently picked tsunami in November 2004. Wouldn't be so bad but the idiot didn't rename it before calling in for tech support in early January the next year to getting something set up. Tech support was, of course, in Indonesia.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Munkeymon posted:

The nutbar that used to be the senior admin around here likes to use disaster names and rather presciently picked tsunami in November 2004. Wouldn't be so bad but the idiot didn't rename it before calling in for tech support in early January the next year to getting something set up. Tech support was, of course, in Indonesia.

Congratulations (?), you have managed to get the server-name derail back on topic.

Soricidus
Oct 21, 2010
freedom-hating statist shill
Also I ran into some servers named after my little ponies today and I think I want to kill someone.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Soricidus posted:

Congratulations (?), you have managed to get the server-name derail back on topic.

:tipshat:

The best server names I've come across were when someone st the college's IT department set up the four mac servers (they used to make actual servers!) with the names of the four horsemen. Logging into death was often the highlight of my day.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



But seriously, don't be annoying. Just name your machines (front,app,dev,db) plus a number if there are multiple.

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

Ithaqua posted:

Most places I see are just coming out of the dark ages and aren't anywhere near mature enough for doing something like that. It's a good thing to aspire to, though.

The idea of CI builds and automated tests are still mind-bogglingly modern to them.

INSTANCE_018 is down? Issue a reboot command and call me in the morning.

like honestly there is no other way to build a large distributed application architecture

CI and automated tests are orthogonal to this


the one server where we broke this law is the one that's causing us the most pain, natch

beuges
Jul 4, 2005
fluffy bunny butterfly broomstick
One of my clients has a system that serves media content for off-site advertising displays. Different types of content get put into different media playlists which the displays then cycle through.
Some of the content is loaded manually, some pulled automatically, e.g. from a facebook feed or so. So a task runs every 30 seconds to check if any content for any playlist has changed, and if so, create a new playlist. All reasonable and straightforward.

So I've been asked by their IT guy to investigate why their datacentre has sent them a bill for 5TB of traffic between their front-end server and db server. It turns out that the contractor who wrote all of this chained Linq queries in a dumb way, so instead of just returning the latest playlist entry from the db to compare against, it returns all playlist entries, and then takes the latest one from that. Over 12000 rows in the playlist table. Total table data size is around 96MB. So, it generates around 100MB of traffic from the db every 30 seconds, instead of around 500KB.

And that's not all. While going through the code to see what's going on, I come across the following:


C# code:
           var mediaIds = MediaGroupManager.MediaGroupMan.GetActiveMediasByGroupId(groupId);
            var mediaValues = "";
            var sep = "";
            foreach (int t in mediaIds)
            {
                mediaValues += sep + t;
                sep = ",";
            }
            xml += GetMessageXml(mediaValues);
mediaIds is a List<int>.

Then, we have this:

C# code:
        private static string GetMessageXml(string mediaIds)
        {
            var list = mediaIds.Split(new char[] { ',' });
            var mediaIdValues = (from s in list where s != "" select int.Parse(s)).ToArray();
e: that mediaValues csv string also gets passed to another method after the call to GetMessageXml, which also splits it back into an array of ints. The only place that it's used is when it's passed to these two methods.

beuges fucked around with this message at 11:04 on Nov 11, 2014

David Pratt
Apr 21, 2001

Malcolm XML posted:

INSTANCE_018 is down? Issue a reboot command and call me in the morning.

like honestly there is no other way to build a large distributed application architecture

Agreed. Servers are cattle, not pets.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Welcome to my hell.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

:eyepop: what the gently caress is that? Did someone lose a bet?

Hiowf
Jun 28, 2013

We don't do .DOC in my cave.

Looks like a standard vendor supplied driver to me. You are really hosed because of this:

RESET_HDMI_PHY();
RESET_HDMI_PHY();
RESET_HDMI_PHY();

i.e. the hardware is just a broken piece of poo poo.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
I already know that.

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.
I had one of these Pivos XIOS DS boxes for a while, I think they were running Amlogic M1? It was not too horrible all in all, but it was never stable. Everytime they merged in some new Amlogic drivers *something* would be broken in some way.

FlapYoJacks
Feb 12, 2009
Overly complex drivers for hardware not made correctly? Sounds like a embedded Linux project to me! :allears:

That's not the worst I have seen either. At least it's readable.

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av
I name all of my machines after stars. Aldebaran was the first, then I had Deneb, Mizar, Polaris, Fomalhaut... My first dual-core machine was Sirius (a double star), now I have a netbook called Procyon. Well, actually nowadays I'm lazy and I name my systems "thing": my iPhone is iThing, my work computer (MacBook) is ThingBook, etc.

omeg posted:

I loving hate Windows security API. So many ways to get poo poo wrong.
You rang? :tipshat:

e: I swear I'm answering your PM tonight :sweatdrop:

hackbunny fucked around with this message at 18:08 on Nov 13, 2014

Illusive Fuck Man
Jul 5, 2004
RIP John McCain feel better xoxo 💋 ðŸ™Â
Taco Defender
i just loving hate all the code this guy writes. loving full of
C code:
#include <log.h>                                // for logging functions
C code:
    int i = 0;												// simple counter
he doesn't use for loops at all. always (if i'm lucky)
C code:
i = 0;
while (i < MAX) {
    ...
    i++
}
he also never deletes code. If something is no longer used, it gets #if 0'd out, even if we could never conceivably need that code again.

Everything is a mixture of spaces and tabs. Or no spacing. I once saw like a 100 character line of code full of un-necessary casts and pointer arithmetic without a single space.

C code:
x=*(uint8_t*)((uint32_t*)buf+5))+sizeof(somefuckingthing)<<4
I can't even finish trying to make up an example because its so horrific

Illusive Fuck Man fucked around with this message at 21:43 on Nov 13, 2014

lord funk
Feb 16, 2004

I may suck at coding, but I'm glad I suck at coding alone.

_aaron
Jul 24, 2007
The underscore is silent.

Illusive gently caress Man posted:

i just loving hate all the code this guy writes. loving full of
C code:
#include <log.h>                                // for logging functions
C code:
    int i = 0;												// simple counter
I cannot stand poo poo like this. I know it's not even a big deal, it's just irrationally annoying.

NFX
Jun 2, 2008

Fun Shoe

Illusive gently caress Man posted:


C code:
x=*(uint8_t*)((uint32_t*)buf+5))+sizeof(somefuckingthing)<<4
I can't even finish trying to make up an example because its so horrific

I don't get stuff like this. Are people allergic to whitespace or something? You need to let those variables get some air, man. Otherwise the code will get moldy.

raminasi
Jan 25, 2005

a last drink with no ice
C code:
    for (i = 0; i < NUMOTYPE; i++)
        if (ofun[i].funame[0] == ofname[0] && !strcmp(ofun[i].funame, ofname))
            return(i);
:raise:

Corla Plankun
May 8, 2007

improve the lives of everyone

_aaron posted:

I cannot stand poo poo like this. I know it's not even a big deal, it's just irrationally annoying.

Ok, I give up. Why are the first two lines bad? Is it because of the inconsistent whitespace? The names? What?

It seems like not enough context to convey anything terrible to me, so I am getting really worried about not being able to tell whats wrong.

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

Corla Plankun posted:

Ok, I give up. Why are the first two lines bad? Is it because of the inconsistent whitespace? The names? What?

It seems like not enough context to convey anything terrible to me, so I am getting really worried about not being able to tell whats wrong.

The comments are both useless. You can already tell exactly what log.h is for, and i = 0 is overwhelmingly used as a counter. They're both cases where a comment would have been better if the lines were doing anything but what they are doing.

dwazegek
Feb 11, 2005

WE CAN USE THIS :byodood:
A colleague of mine does something similar. He'll first outline the different steps a method has to do in comments, then write the code. Which, in general is fine, except he leaves all the comments in, and never adds any actually useful comments. So all his code looks like this:
code:

//Create bar for foo
CreateBar(foo);

//Set foo active
SetActive(foo);

It's not the worst thing in the world, but it's utterly pointless, and it's everywhere.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

I'm still going through it, but you guys probably noticed Microsoft open-sourced a bunch of .NET stuff yesterday:
https://github.com/dotnet/corefx

Haven't found any horrors yet, but mostly I've been trying to find funny comments or something. Not much so far.

DimpledChad
May 14, 2002
Rigging elections since '87.
That's actually something advocated by Steve McConnell in Code Complete. He calls it the Pseudocode Programming Process. In the linked article, Jeff Atwood explains why he doesn't like it. Anyway, I agree that it's a pretty dumb way to write comments, but at least your colleague isn't totally crazy.

omeg
Sep 3, 2012

hackbunny posted:

e: I swear I'm answering your PM tonight :sweatdrop:

Don't sweat, I'm in no hurry :)

Hot Dog Day #42
Jun 17, 2001

Egbert B. Gebstadter

carry on then posted:

You can already tell exactly what log.h is for

Maybe it's for taking logarithms :smug:

Kazinsal
Dec 13, 2011


There's a line in zlib's adler32.c that reads /* the derivation of this formula is left as an exercise for the reader */.

gently caress you, Mark Adler. The job of a comment is not to tell the reader to figure it out himself.

ExcessBLarg!
Sep 1, 2001

Corla Plankun posted:

Ok, I give up. Why are the first two lines bad?
At best it doubles the amount of text that has to be read because the code is essentially written twice.

But that style of commenting quickly becomes a headache when a group of people have to maintain that code. When the code changes, the comments have to be updated to reflect the changes, otherwise they become inaccurate. Or someone has to make the decision to delete the superfluous comments, which is extra work and might offend someone.

It's also kind of defeating. The purpose of comments is to call attention to portions of code that are counterintuitive or whose purpose is not obvious. Basically a comment says "pay attention here" to the reader. If everything's commented, things that actually need to be called out are lost in the noise. Also, generally speaking, well written code should be fairly clear and unambiguous in meaning most of the time, so excessive commenting is a sign that someone is not comfortable with their ability to write clear code.

Of course, it's a fine thing to do on a toy project if you're just starting to learn a language/platform and it aids in the learning process.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Illusive gently caress Man posted:

i just loving hate all the code this guy writes. loving full of
C code:
#include <log.h>                                // for logging functions
C code:
    int i = 0;												// simple counter
he doesn't use for loops at all. always (if i'm lucky)
C code:
i = 0;
while (i < MAX) {
    ...
    i++
}
he also never deletes code. If something is no longer used, it gets #if 0'd out, even if we could never conceivably need that code again.

Everything is a mixture of spaces and tabs. Or no spacing. I once saw like a 100 character line of code full of un-necessary casts and pointer arithmetic without a single space.

C code:
x=*(uint8_t*)((uint32_t*)buf+5))+sizeof(somefuckingthing)<<4
I can't even finish trying to make up an example because its so horrific

You sound like you desperately need to institute mandatory code reviews gating your source contrahahaha you just code directly in prod don't you.

necrotic
Aug 2, 2005
I owe my brother big time for this!

Kazinsal posted:

There's a line in zlib's adler32.c that reads /* the derivation of this formula is left as an exercise for the reader */.

gently caress you, Mark Adler. The job of a comment is not to tell the reader to figure it out himself.

But how else will you learn?

Illusive Fuck Man
Jul 5, 2004
RIP John McCain feel better xoxo 💋 ðŸ™Â
Taco Defender

Volmarias posted:

You sound like you desperately need to institute mandatory code reviews gating your source contrahahaha you just code directly in prod don't you.

Tbqh there is no 'prod' because this is kind of a proof of concept project. it's a 4 person team and when it works someone just tags the commit 'it works' but the plan is somehow that we will be able to demonstrate and let people use this in a few months?

I would love some kind of code review or automated testing but that would be like a whole job for somebody to set up and organize and none of us even know how to set up Jenkins sooo

gently caress

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Kazinsal posted:

There's a line in zlib's adler32.c that reads /* the derivation of this formula is left as an exercise for the reader */.

gently caress you, Mark Adler. The job of a comment is not to tell the reader to figure it out himself.

Mark Adler is a mathematician, not a programmer.

raminasi
Jan 25, 2005

a last drink with no ice

Kazinsal posted:

There's a line in zlib's adler32.c that reads /* the derivation of this formula is left as an exercise for the reader */.

gently caress you, Mark Adler. The job of a comment is not to tell the reader to figure it out himself.

If I saw that I'd assume it was a tongue-in-cheek way to say "I have no idea how I came up with this poo poo"

vOv
Feb 8, 2014

The canonical unhelpful-yet-accurate comment is of course // what the gently caress?.

Don Mega
Nov 26, 2005

vOv posted:

The canonical unhelpful-yet-accurate comment is of course // what the gently caress?.
I always loved this

Don Mega fucked around with this message at 09:18 on Nov 14, 2014

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...
Since this is the coding horrors thread, I'm sure most of you know about Duff's device already.

But have you seen Stroustrup's device (PDF)?
C++ code:
typedef decltype(x) T;
static std::unordered map<T,size t> jump_targets;

switch (size t& jump_to = jump_targets[x]) {

default:
  if (P1(x)) {
    if (P2 (x)) {
      if (P4(x)) { jump_to = 4; case 4: s4;} else
      if (P5(x)) { jump_to = 5; case 5: s5;}
      jump_to = 2; case 2: s2;
    } else
    if (P3(x)) {
      if (P6(x)) { jump_to = 6; case 6: s6;} else
      if (P7(x)) { jump_to = 7; case 7: s7;}
      jump_to = 3; case 3: s3;
    }
    jump_to = 1; case 1: s1;
  } else { jump_to = 0; case 0: ; }
}

Adbot
ADBOT LOVES YOU

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

GrumpyDoctor posted:

C code:

    for (i = 0; i < NUMOTYPE; i++)
        if (ofun[i].funame[0] == ofname[0] && !strcmp(ofun[i].funame, ofname))
            return(i);
:raise:

Looks like an early-out optimization to avoid a function call to strcmp in the presumably-common case where first chars differ. Usually means "strcmp prolog/epilog showed up in a profile once" (possibly on a previous project, and is carried forward superstitiously).

Often an unnecessary optimization, but I wouldn't say it was a horror.

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