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
trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

Janin posted:

I propose a new phrase "ozark bugs", meaning a bunch of errors which combine to mostly work.

Just spent four hours disentangling a mess of this; every time I fixed one error the system stopped working because another broken part of it had (by coincidence) worked only with the previous bug.

This is why I stopped fixing things. Subtly broken implementations get broken even more when you fix them.

Adbot
ADBOT LOVES YOU

NotShadowStar
Sep 20, 2000

Tikki posted:

I think there might be some confusion, as to how the issue numbers are used.

The table is only populated once (or every time we start from a clean database in development). No numbers are being deleted in production.

We have a number of events, that people buy tickets to.
If a ticket is canceled, there is a hole in the Issue number sequence for that event.
This table is then (apparently) used to very quickly find the first hole in the sequence for the next ticket...

At least that's how a coworker explained it to me. I haven't actually gone and looked at the code... I'm not sure if I dare.

Do this: add a ticket sequence column into whatever table has the tickets.

Then show him this
Ticket.maximum(:sequence_number, :group => :event)

Now force him to explain to him what the gently caress. If he says 'the old way is faster' then get him to benchmark it or some poo poo because gently caress. I've seen some stupid loving poo poo but goddamn.

HFX
Nov 29, 2004

TRex EaterofCars posted:

This is why I stopped fixing things. Subtly broken implementations get broken even more when you fix them.

But that is 90% of the code I work on. When I recommend fixing them by fixing the design I'm told not to do it and just concentrate on getting the bug fix out for whatever looming deadline.

Kelson
Jan 23, 2005

Tikki posted:

I think there might be some confusion, as to how the issue numbers are used.

The table is only populated once (or every time we start from a clean database in development). No numbers are being deleted in production.

We have a number of events, that people buy tickets to.
If a ticket is canceled, there is a hole in the Issue number sequence for that event.
This table is then (apparently) used to very quickly find the first hole in the sequence for the next ticket...

At least that's how a coworker explained it to me. I haven't actually gone and looked at the code... I'm not sure if I dare.
None of that makes the inverted (or sparse, if you prefer) approach any less optimal... unless tons of customers routinely cancel tickets, I suppose

Lysandus
Jun 21, 2010
A guy I work with will take code like this:
code:
if( whatever )
{
    doSomething;
    doSomethingElse();
}
else
{
    doThis;
    doThat();
    doTheOther;
}
He turns it into this:
code:
if( whatever ){
    doSomething;
    doSomethingElse();}
else{
    doThis;
    doThat();
    doTheOther;}
He then commits it to the repository with the comment "Code cleanup."

He also hates to use functions because "it makes the code too hard to follow."

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
Don't you have some sort of standards wherever you work in which one of you (I'm assuming him, since I hate his style) is blatantly breaking a rule?

HFX
Nov 29, 2004

Lysandus posted:

A guy I work with will take code like this:
code:
if( whatever )
{
    doSomething;
    doSomethingElse();
}
else
{
    doThis;
    doThat();
    doTheOther;
}
He turns it into this:
code:
if( whatever ){
    doSomething;
    doSomethingElse();}
else{
    doThis;
    doThat();
    doTheOther;}
He then commits it to the repository with the comment "Code cleanup."

He also hates to use functions because "it makes the code too hard to follow."

Can I hand you a bat. Wack once a minute throughout the day until he quits.

Parantumaton
Jan 29, 2009


The OnLy ThInG
i LoVe MoRe
ThAn ChUgGiNg SeMeN
iS gEtTiNg PaId To Be A
sOcIaL MeDiA sHiLl
FoR mIcRoSoFt
AnD nOkIa

Lysandus posted:

A guy I work with will take code like this:
code:
if( whatever )
{
    doSomething;
    doSomethingElse();
}
else
{
    doThis;
    doThat();
    doTheOther;
}
He turns it into this:
code:
if( whatever ){
    doSomething;
    doSomethingElse();}
else{
    doThis;
    doThat();
    doTheOther;}
He then commits it to the repository with the comment "Code cleanup."

He also hates to use functions because "it makes the code too hard to follow."

Does he have a background in LISP?

Also rollback his commits and use as much harsh language as possible. That's just idiotic.

HFX
Nov 29, 2004

Parantumaton posted:

Does he have a background in LISP?

Also rollback his commits and use as much harsh language as possible. That's just idiotic.

A background in LISP would make him more likely to use functions, not less likely.

pixelpusherbot
Jun 3, 2009

Lysandus posted:

He then commits it to the repository with the comment "Code cleanup."
Do you have a commit quota? "Ah, developer V is doing a good job cleaning up the codebase, I count over 200 commits, making him the most active developer on the team"

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Parantumaton posted:

Does he have a background in LISP?
Given how much he wants to make the opening and closing braces as invisible as possible, Python was actually the first thing to come to mind.

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

Dijkstracula posted:

Given how much he wants to make the opening and closing braces as invisible as possible, Python was actually the first thing to come to mind.
He's violating the Python/C code standard pretty heavily there, so no, probably not a Python user.

Unless he's never used Python/C, but in that case, why are you giving little kids commit privileges?

Lysandus
Jun 21, 2010
He's gotten better at not doing that over the years, but he'll still complain about functions being hard to follow. He's actually pretty smart when it comes to some of the weird poo poo we need to figure out.

Here is another gem I found in some old networking code we have:

code:
        StringBuffer buffer = new StringBuffer( 120 );
        boolean useHTTPS = false;
 
        try
        {
            if( useHTTPS )
            {
                buffer.append( HTTPS_START );
            }
            else
            {
                buffer.append( HTTP_START );
            }

Lysandus
Jun 21, 2010

Orzo posted:

Don't you have some sort of standards wherever you work in which one of you (I'm assuming him, since I hate his style) is blatantly breaking a rule?

I'm my department yes, but he is in another department and they put up with it.

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

Lysandus posted:

He's gotten better at not doing that over the years, but he'll still complain about functions being hard to follow. He's actually pretty smart when it comes to some of the weird poo poo we need to figure out.

Here is another gem I found in some old networking code we have:

code:
        StringBuffer buffer = new StringBuffer( 120 );
        boolean useHTTPS = false;
 
        try
        {
            if( useHTTPS )
            {
                buffer.append( HTTPS_START );
            }
            else
            {
                buffer.append( HTTP_START );
            }

Presumably they were going to add a way of changing useHTTPS later? That's not a colossal horror if so.

Lysandus
Jun 21, 2010

Jonnty posted:

Presumably they were going to add a way of changing useHTTPS later? That's not a colossal horror if so.

I would hope, but by the time I inherited the code it was already 2 years old and the original programmer was long gone. I ended up rewriting most of the networking library anyway.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
Found in the Cisco AXL documentation:

code:
public XUserUserGroupUserRolesUserRole[] userRoles;
I'm all for descriptive class names, but it's quite unnecessary to put an entire namespace hierarchy in a class name.

At least I'm pretty sure it's auto-generated

BigRedDot
Mar 6, 2008

Kilson posted:

Found in the Cisco AXL documentation:

code:
public XUserUserGroupUserRolesUserRole[] userRoles;
I'm all for descriptive class names, but it's quite unnecessary to put an entire namespace hierarchy in a class name.

At least I'm pretty sure it's auto-generated
OK now I am going to make a
code:
BuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalo
class.

Fake edit: and also a
code:
BuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffaloBuffalo
class, just to add some spite.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

It's SQL and not 'code' per se but I just wacked this query together for a onetimer to get a series of strings I needed:

code:
select DISTINCT Replace(Replace(Replace((Replace((table6.ProductTitle 
+ '-' + CONVERT(varchar(16),Table1.IDProduct)),'/','-')),' ','-'),'--
','-'),'--','-') as MyString FROM
table1 INNER JOIN
(six table joins later)
The replaces are because it'll have to be communicated in a URL and I got lazy working from the inside out. The joins are because the data I need from table6 is only joined to table1 by a series of FKs distinct to each table.

SirViver
Oct 22, 2008
code:
class Foo
{
    bool UseFeatureX { get {...} }

    void SomeMethod()
    {
#if CUSTOMER_FLAG || UseFeatureX
        btnBar.Visible = true;
#else
        btnBar.Visible = false;
#endif
    }
}
Yeah, no, I don't think that's how preprocessor statements work, buddy :doh:

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
C# 3.5, so we can't have nice things like named and optional parameters.

That still doesn't excuse this:

code:
        public bool stuff(
            string command,
            string requestID,
            string couldBeAnObject,
            string request,
            string response,
            string ifThatThingWasAnObjectThisWouldntBeNecessary,
            params object[] additionalParams)
        {
            int responseCode = 202;
            string expectedRespCode = Success;
            string id = null;
            uint numberOfPendingResp = 0;
            int pendingRespInterval = 0;
            Header contentTypeHdr = ...;
            if (additionalParams != null && additionalParams.Length > 0)
            {
                int count = additionalParams.Length;
                if (count > 6)
                    count = 6;
                switch (count)
                {
                    case 6: contentTypeHdr = (Header)additionalParams[5]; goto case 5;
                    case 5: pendingRespInterval = (int)additionalParams[4]; goto case 4;
                    case 4: numberOfPendingResp = (uint)(int)additionalParams[3]; goto case 3;
                    case 3: id = (string)additionalParams[2]; goto case 2;
                    case 2: expectedRespCode = (string)additionalParams[1]; goto case 1;
                    case 1: responseCode = (int)additionalParams[0]; break;
                }
            }
:suicide:

edit: oh, and there are a ton of these.

Dessert Rose fucked around with this message at 16:56 on Jun 29, 2010

POKEMAN SAM
Jul 8, 2004

Ryouga Inverse posted:

C# 3.5, so we can't have nice things like named and optional parameters.

That still doesn't excuse this:

code:
        public bool stuff(
            string command,
            string requestID,
            string couldBeAnObject,
            string request,
            string response,
            string ifThatThingWasAnObjectThisWouldntBeNecessary,
            params object[] additionalParams)
        {
            int responseCode = 202;
            string expectedRespCode = Success;
            string id = null;
            uint numberOfPendingResp = 0;
            int pendingRespInterval = 0;
            Header contentTypeHdr = ...;
            if (additionalParams != null && additionalParams.Length > 0)
            {
                int count = additionalParams.Length;
                if (count > 6)
                    count = 6;
                switch (count)
                {
                    case 6: contentTypeHdr = (Header)additionalParams[5]; goto case 5;
                    case 5: pendingRespInterval = (int)additionalParams[4]; goto case 4;
                    case 4: numberOfPendingResp = (uint)(int)additionalParams[3]; goto case 3;
                    case 3: id = (string)additionalParams[2]; goto case 2;
                    case 2: expectedRespCode = (string)additionalParams[1]; goto case 1;
                    case 1: responseCode = (int)additionalParams[0]; break;
                }
            }
:suicide:

edit: oh, and there are a ton of these.

I was going to say that switch statement looks like it belongs in a for loop, but holy poo poo I think that version may actually be worse.

mr_jim
Oct 30, 2006

OUT OF THE DARK

I'm guessing cases don't fall through in C#? They eliminated that from C/C++, but kept goto statements?

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

mr_jim posted:

I'm guessing cases don't fall through in C#? They eliminated that from C/C++, but kept goto statements?

Correct, a case falling through is a compile error in C#. edit: except empty cases, yeah, to provide for the pattern where you want multiple cases to have the same behavior.

You can't eliminate goto, that would just be stupid. This is technically the "accepted" way to make cases fall through in C#, and the fact that you are using goto to do it is supposed to make you stop and go "Hmm, maybe I shouldn't be doing this."

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Only empty cases do.

dark_panda
Oct 25, 2004

Tikki posted:

The table only contains the numbers, it's (apparently) the fastest way of checking if an issue number is already taken.

I usually go grab some tea while it crunches. I think it takes around 10 minutes on my late-2008 MacBook.

I just realized, that the clever way to do it would to dump the table once it's done, then use that to populate it instead.

Maybe I'm really tired or something, so forgive me for asking what might be blatantly obvious but... why couldn't you just use an honest-to-God SQL SEQUENCE here? Set its starting value to whatever the current maximum value of the existing issue numbers (or 0 or 1 or whatever if you're starting from scratch) and from that point on pull the next value from the SEQUENCE. I mean, that's why they have SEQUENCEs in the SQL standard these days to begin with -- to provide a method of generating values in a safe manner, concurrent access and all.

Of course, if you're on MySQL you'd have to resort to hacks to make up for the lack of SEQUENCEs but still, it's often better knowing ahead of time that a value will be guaranteed to be unique than it is to have to check for uniqueness after the fact...

HFX
Nov 29, 2004

dark_panda posted:

Maybe I'm really tired or something, so forgive me for asking what might be blatantly obvious but... why couldn't you just use an honest-to-God SQL SEQUENCE here? Set its starting value to whatever the current maximum value of the existing issue numbers (or 0 or 1 or whatever if you're starting from scratch) and from that point on pull the next value from the SEQUENCE. I mean, that's why they have SEQUENCEs in the SQL standard these days to begin with -- to provide a method of generating values in a safe manner, concurrent access and all.

Of course, if you're on MySQL you'd have to resort to hacks to make up for the lack of SEQUENCEs but still, it's often better knowing ahead of time that a value will be guaranteed to be unique than it is to have to check for uniqueness after the fact...

MySQL still doesn't support sequencing on either of its engines? I'm doing :supaburn: :wth: :tviv:

Sprawl
Nov 21, 2005


I'm a huge retarded sperglord who can't spell, but Starfleet Dental would still take me and I love them for it!

HFX posted:

MySQL still doesn't support sequencing on either of its engines? I'm doing :supaburn: :wth: :tviv:

Yea well they are trying their hardest to eliminate it as a viable database now that oracle bought it they dont do anything useful with it now.

Tikki
Aug 13, 2007
Life is too short for... No. Life is just too short!

Sprawl posted:

Yea well they are trying their hardest to eliminate it as a viable database now that oracle bought it they dont do anything useful with it now.

Oracle owns MySQL now? :aaa:

When did that happen and why didn't I notice?

A A 2 3 5 8 K
Nov 24, 2003
Illiteracy... what does that word even mean?

Tikki posted:

Oracle owns MySQL now? :aaa:

When did that happen and why didn't I notice?

MySQL was already becoming marginalized from being owned by Sun, then Oracle acquired Sun last year without calling a lot of attention to the MySQL situation.

Preparation H67
Aug 6, 2009

Lysandus posted:

A guy I work with will take code like this:
code:
if( whatever )
{
    doSomething;
    doSomethingElse();
}
else
{
    doThis;
    doThat();
    doTheOther;
}
He turns it into this:
code:
if( whatever ){
    doSomething;
    doSomethingElse();}
else{
    doThis;
    doThat();
    doTheOther;}
He then commits it to the repository with the comment "Code cleanup."

He also hates to use functions because "it makes the code too hard to follow."

My profs and TAs would had us a bunch of code to work with that was written in this style, back asswards, which is how I quickly learned to just re-write it all myself because I'd just be sitting there editing the old code for hours so I could read it and figure out what they were trying to do.

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

Preparation H67 posted:

My profs and TAs would had us a bunch of code to work with that was written in this style, back asswards, which is how I quickly learned to just re-write it all myself because I'd just be sitting there editing the old code for hours so I could read it and figure out what they were trying to do.
http://www.gnu.org/software/indent/

wwb
Aug 17, 2004

A A 2 3 5 8 K posted:

MySQL was already becoming marginalized from being owned by Sun, then Oracle acquired Sun last year without calling a lot of attention to the MySQL situation.

Except that the homo who wrote MySql decided to try and get the EU to stop the deal because his database is a special snowflake that deserves to live.

We should loving nuke sweden.

Eggnogium
Jun 1, 2010

Never give an inch! Hnnnghhhhhh!

Preparation H67 posted:

My profs and TAs would had us a bunch of code to work with that was written in this style, back asswards, which is how I quickly learned to just re-write it all myself because I'd just be sitting there editing the old code for hours so I could read it and figure out what they were trying to do.

I think this style originally shows up programming books just to save paper and shorten long code examples. I've never seen a closing brace like that but I've seen a lot of books that use an opening brace on the same line. Unfortunately some idiots actually take it as good form and use it where it has no business being.

spiritual bypass
Feb 19, 2008

Grimey Drawer
I think OpenSolaris deserves to live, probably.

1337JiveTurkey
Feb 17, 2005

Section 1.4.4.6: Wherein we learn why referential integrity is actually bad

quote:

There are so many problems with foreign key constraints that we don't know where to start:

  • Foreign key constraints make life very complicated, because the foreign key definitions must be stored in a database and implementing them would destroy the whole ``nice approach'' of using files that can be moved, copied, and removed.
  • The speed impact is terrible for INSERT and UPDATE statements, and in this case almost all FOREIGN KEY constraint checks are useless because you usually insert records in the right tables in the right order, anyway.
  • There is also a need to hold locks on many more tables when updating one table, because the side effects can cascade through the entire database. It's MUCH faster to delete records from one table first and subsequently delete them from the other tables.
  • You can no longer restore a table by doing a full delete from the table and then restoring all records (from a new source or from a backup).
  • If you use foreign key constraints you can't dump and restore tables unless you do so in a very specific order.
  • It's very easy to do ``allowed'' circular definitions that make the tables impossible to re-create each table with a single create statement, even if the definition works and is usable.
  • It's very easy to overlook FOREIGN KEY ... ON DELETE rules when one codes an application. It's not unusual that one loses a lot of important information just because a wrong or misused ON DELETE rule.
The only nice aspect of FOREIGN KEY is that it gives ODBC and some other client programs the ability to see how a table is connected and to use this to show connection diagrams and to help in building applications.

MySQL will soon store FOREIGN KEY definitions so that a client can ask for and receive an answer about how the original connection was made. The current `.frm' file format does not have any place for it. At a later stage we will implement the foreign key constraints for application that can't easily be coded to avoid them.

Shumagorath
Jun 6, 2001

Ryouga Inverse posted:

You can't eliminate goto, that would just be stupid. This is technically the "accepted" way to make cases fall through in C#, and the fact that you are using goto to do it is supposed to make you stop and go "Hmm, maybe I shouldn't be doing this."
I've never written a line of C# but why shouldn't you do that? Is there a better mechanism that replaces case fall-through?

Who wants to bet the most frequent use of GNU-Indent is to format code in something other than GNU style?

Shumagorath fucked around with this message at 05:08 on Jul 1, 2010

Chairman Steve
Mar 9, 2007
Whiter than sour cream

A A 2 3 5 8 K posted:

MySQL was already becoming marginalized from being owned by Sun, then Oracle acquired Sun last year without calling a lot of attention to the MySQL situation.

I'm beginning to suspect that, in thirty years, the only software companies left will be Microsoft and Oracle.


Precautions against data orphaning aside, anyone who advocates against foreign keys has never had to programmatically traverse their data model. Bunch of morons.

To contribute:

Too often, in older scripts at where I work, I'll see this in scripts called by headless backend scripts:

code:
if(request->is_backend = 1)
  goto skipui
(a bunch of UI code)

#skipui

(business logic)
goto exit

(more UI code)

#exit
It's just so...upsetting to see stuff like that.

Lysandus
Jun 21, 2010
We got a new guy who's interning here until he finishes his degree. When he was sent to my department I asked him what his java experience was and he replied "Pretty extensive. I've have had 4 classes now on Java." After the usual training B.S. I let him start fixing some bugs and gave him an easy one to start with. I even told him how to fix it by extending ClassA and override MethodA, etc.

Six hours later he commits the changes which included copy and pasting ClassA to a new file calling it ClassB and changing some code in MethodA because he couldn't figure out he needed to remove "final" from ClassA.

Apparently they save the final keyword for the 5th java class. :bang:

Adbot
ADBOT LOVES YOU

Painless
Jan 9, 2005

Turn ons: frogs, small mammals, piles of compost
Turn offs: large birds, pitchforks
See you at the beach!
The way you describe it, your way of "fixing" things sounds like a coding horror in itself. Class A has a bug, so fix it by quietly removing 'final' and extending with a class that has the bug fixed?

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