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
Golbez
Oct 9, 2002

1 2 3!
If you want to take a shot at me get in line, line
1 2 3!
Baby, I've had all my shots and I'm fine
I have never had more of a :catstare: face than I do after reading that post.

Adbot
ADBOT LOVES YOU

csammis
Aug 26, 2003

Mental Institution
It's horrible interview etiquette to get up and walk out on them right there but man I would have been tempted if that had been sprung on me.

What does it do in the larger scope of the product?

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Kim Jong III posted:

And this is what they wanted me to maintain. :fuckoff:

And the problem with codebases like that is that no decent developer will want to maintain it, so they'll never get quality developers, and the cycle of horrors will continue.

ErikTheRed
Mar 12, 2007

My name is Deckard Cain and I've come on out to greet ya, so sit your ass and listen or I'm gonna have to beat ya.
Indian code is the best. I might have multiple posts today considering the quality of this codebase.

code:
ArrayList lGblReturnList = new ArrayList();
String pPostWhereClause;
String pGblWhereClause = null;
Statement lStatement = null;
ResultSet lResultSet = null;
DBRegistry lGBLDBRegistry = Applications.getInstance().getDefaultDatabaseConfiguration();

try {
	// lConnection =
	// lGBLDBRegistry.getDatabaseConnection().getConnection(pRequestStorage);
	lStatement = lGBLDBRegistry.getDatabaseConnection().getConnection(
		pRequestStorage).createStatement();
	String lQuery = " select * from gblusrug where uugrowstate != -1 and uugugid = "
		+ Constants.ADMIN_USERGROUP
		+ " and uugusrid = "
		+ lLoggedInUser.getId()
		+ " and uugorgid = "
		+ lLoggedInUser.getOrganizationId()
		+ " order by uugugid";
	lResultSet = lStatement.executeQuery(lQuery);
	mLogger.info("lQuery is: " + lQuery);

	while (lResultSet.next()) {
		lGblReturnList.add("1");
	}
	mLogger.info("lGblReturnList.size: " + lGblReturnList.size());
} catch (SQLException e) {
	mLogger.info("Error::::" + e.toString());
} catch (Exception e) {
	mLogger.info("Error::::" + e.toString());
} finally {
	try {
		if (lResultSet != null) {
			lResultSet.close();
		}
		if (lStatement != null) {
			lStatement.close();
		}
	} catch (SQLException e) {
		mLogger.info("Error::::" + e.toString());
	}
}
My favorite part is our friend lGblReturnList

Johnny Cache Hit
Oct 17, 2011
e: ^^^^^ oh goody, my favorite exception handling (anti)pattern.

csammis posted:

It's horrible interview etiquette to get up and walk out on them right there but man I would have been tempted if that had been sprung on me.

What does it do in the larger scope of the product?

I never figured it out, to be honest. Every time I try part of my brain just shuts down.

I ended up taking the job because they promised me a team lead position on the rewrite of that product & and a senior developer salary. As frightening as that code was, I figured, hey, I can come in and do the rewrite well.

They came through with the salary & I started on a Monday. I started meeting the team & planning out the rewrite, but on Thursday they decided they didn't have enough programmers to rewrite that application. Then the fun really started. On Friday, they told me I was going to be a C# developer doing some embedded work. Over the weekend they decided "nah, we don't want to make him learn C#", so on Monday they decided to have me lead a rewrite on a smaller application. But then by Tuesday they realized they didn't have the resources to do even that, and everyone was going to be doing maintenance on their primary horror because some huge fire broke out.

Ithaqua posted:

And the problem with codebases like that is that no decent developer will want to maintain it, so they'll never get quality developers, and the cycle of horrors will continue.

I had a job across town as a Ruby developer by that Thursday. Came in, gave their CIO my most diplomatic "this simply will not work", and was out. One week and four days... shortest employment term by far.

But you're absolutely right. I polled the people that were there - their senior developer had 3 years of experience, two other guys had a year or so, and the other ~15 people were straight out of school. I would've entered the place as the most experienced programmer by a handful of years.

Turnover was described as "a problem" by their CIO. Can you imagine? :allears:

Johnny Cache Hit fucked around with this message at 16:09 on Jun 14, 2012

Zorro KingOfEngland
May 7, 2008

ErikTheRed posted:

Indian code is the best. I might have multiple posts today considering the quality of this codebase.

code:
mLogger.info("Error::::" + e.toString());

Why is this a thing? It's all over my codebase too. Including the four (or more) unnecessary colons.

Opinion Haver
Apr 9, 2007

Hammerite posted:

I guess I'm not going to persuade you on the privilege name thing. It makes perfect sense to me to identify privileges by the names they're referred to in code.

So if you decide to refer to your privilege table elsewhere by primary key, you're OK with having to update that table too if you decide to rename your privileges?

KaneTW
Dec 2, 2011

Zorro KingOfEngland posted:

Why is this a thing? It's all over my codebase too. Including the four (or more) unnecessary colons.

It's a pretty bad practice to catch(Exception e) { /* log and/or do nothing */ }

Zhentar
Sep 28, 2003

Brilliant Master Genius

Zorro KingOfEngland posted:

Why is this a thing? It's all over my codebase too. Including the four (or more) unnecessary colons.

Probably to make the error messages more visually distinct (and easier to Ctrl+F) amidst the huge mass of meaningless log entries.

ErikTheRed
Mar 12, 2007

My name is Deckard Cain and I've come on out to greet ya, so sit your ass and listen or I'm gonna have to beat ya.

Zhentar posted:

Probably to make the error messages more visually distinct (and easier to Ctrl+F) amidst the huge mass of meaningless log entries.

Amongst the huge mass of other entries using "Error" + some number of colons

Johnny Cache Hit
Oct 17, 2011

Zorro KingOfEngland posted:

Why is this a thing? It's all over my codebase too. Including the four (or more) unnecessary colons.

Because all programs should have really loud and noisy error messages :v:

Really it's a thing because of terrible programmers fighting checked exceptions. Checked exceptions can be a good thing because you have to think about & deal with the exceptions you might encounter, but it leads to far too many programmers catching & eating it immediately rather than letting it bubble upward & catching it centrally. This is beyond terrible.

The absolute worse thing you can do is

code:
catch Exception {
 // gently caress right off
 pass;
}
I hope there's a special ring in hell for programmers who do that.

VVVV oh, wow, yeah, didn't even catch that. Who needs a logger? Real programmers just dump text somewhere :shepface:

Zorro KingOfEngland
May 7, 2008

quote:

Amongst the huge mass of other entries using "Error" + some number of colons
...being logged in the info level rather than the error level.

epswing
Nov 4, 2003

Soiled Meat

Zorro KingOfEngland posted:

Why is this a thing? It's all over my codebase too. Including the four (or more) unnecessary colons.

Possibly because their log is full of noise, and indenting certain amount helps one visually parse the wall of text?

E: wow beaten badly :argh:

epswing fucked around with this message at 18:03 on Jun 14, 2012

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

yaoi prophet posted:

So if you decide to refer to your privilege table elsewhere by primary key, you're OK with having to update that table too if you decide to rename your privileges?

on update cascade

Sneaking Mission
Nov 11, 2008

grandma plus plus

McGlockenshire
Dec 16, 2005

GOLLOCKS!

Kim Jong III posted:

The new senior developer then proceeded to tell me that the database tables were pretty similar, and to illustrate, showed me the most important table in the database. It contained 55 columns, all of them VARCHAR(45), and the first three that I saw were named "AAAA", "AAAAA", and "AAAAB".

And this is what they wanted me to maintain. :fuckoff:

The proper response to this one is "my salary requirements just went up."

Zamujasa
Oct 27, 2010



Bread Liar

Kim Jong III posted:

This was code I was asked to critique during an interview. See if you can figure out what it does.

I have been trying to figure out what the hell that code does for five minutes and just :psypop: It clearly does something involving dates but augh. The more I look at it the worse of a headache I get.

I wouldn't be able to run away faster. Out of sheer curiosity how much was your salary requirement for that one?

ErikTheRed
Mar 12, 2007

My name is Deckard Cain and I've come on out to greet ya, so sit your ass and listen or I'm gonna have to beat ya.
Well, here's some more:

code:
public static String convertDateFormat(String origDate) {
	// String origString = "31-08-2009";
	char buf[] = new char[10];
	origDate.getChars(0, 2, buf, 8); // copy dd
	origDate.getChars(2, 6, buf, 4); // copy -mm-
	origDate.getChars(6, 10, buf, 0); // yyyy
	String convertDate = new String(buf);
	return convertDate; // converted string is ConverDate = "2009-08-31"
}

Munkeymon
Aug 14, 2003

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



It fills two arrays with hour names (like '11am') for each hour in the day. $grandma is the 24-hour hour, somehow.

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

Munkeymon posted:

It fills two arrays with hour names (like '11am') for each hour in the day. $grandma is the 24-hour hour, somehow.
When can you start?

xarph
Jun 18, 2001


Munkeymon posted:

I'm assuming the bank's data service (you didn't think Mint logged into their web site and scraped it did you?)

Log into mint.com and refresh.

Log into bank.

"Last access: Windows 2000, IE 5.0"

Munkeymon
Aug 14, 2003

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



xarph posted:

Log into mint.com and refresh.

Log into bank.

"Last access: Windows 2000, IE 5.0"

I can't replicate that because my friendly local megabank doesn't tell me stuff like that, but it does weird me out a bit.

Look Around You
Jan 19, 2009

Hammerite posted:

on update cascade

With a primary key? :psyduck:

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Kim Jong III posted:

php:
<?
$grandma = 0;
    for($y="000000", $x="005959"; $y<="230000", $x<="235959";)
    {
        $tima[$grandma] = date("ga", strtotime("$y"));
        $paser = date("ga", strtotime("$y"));
        $bima[$paser] = 0;
        $y = $y + 10000;$x = $x + 10000;
        if(strlen($y) <= "5"){$y = "0$y";}if(strlen($x) <= "5"){$y = "0$x";}
        $grandma++;
    }

echo '$x:', "\n";
var_dump($x);
echo "\n", '$y:', "\n";
var_dump($y);
echo "\n", '$grandma:', "\n";
var_dump($grandma);
echo "\n", '$paser:', "\n";
var_dump($paser);
echo "\n", '$tima:', "\n";
var_dump($tima);
echo "\n", '$bima:', "\n";
var_dump($bima);
?>

code:
$x:
int(245959)

$y:
int(245959)

$grandma:
int(24)

$paser:
string(4) "11pm"

$tima:
array(24) {
  [0]=>
  string(4) "12am"
  [1]=>
  string(3) "1am"
  [2]=>
  string(3) "2am"
  [3]=>
  string(3) "3am"
  [4]=>
  string(3) "4am"
  [5]=>
  string(3) "5am"
  [6]=>
  string(3) "6am"
  [7]=>
  string(3) "7am"
  [8]=>
  string(3) "8am"
  [9]=>
  string(3) "9am"
  [10]=>
  string(4) "10am"
  [11]=>
  string(4) "11am"
  [12]=>
  string(4) "12pm"
  [13]=>
  string(3) "1pm"
  [14]=>
  string(3) "2pm"
  [15]=>
  string(3) "3pm"
  [16]=>
  string(3) "4pm"
  [17]=>
  string(3) "5pm"
  [18]=>
  string(3) "6pm"
  [19]=>
  string(3) "7pm"
  [20]=>
  string(3) "8pm"
  [21]=>
  string(3) "9pm"
  [22]=>
  string(4) "10pm"
  [23]=>
  string(4) "11pm"
}

$bima:
array(24) {
  ["12am"]=>
  int(0)
  ["1am"]=>
  int(0)
  ["2am"]=>
  int(0)
  ["3am"]=>
  int(0)
  ["4am"]=>
  int(0)
  ["5am"]=>
  int(0)
  ["6am"]=>
  int(0)
  ["7am"]=>
  int(0)
  ["8am"]=>
  int(0)
  ["9am"]=>
  int(0)
  ["10am"]=>
  int(0)
  ["11am"]=>
  int(0)
  ["12pm"]=>
  int(0)
  ["1pm"]=>
  int(0)
  ["2pm"]=>
  int(0)
  ["3pm"]=>
  int(0)
  ["4pm"]=>
  int(0)
  ["5pm"]=>
  int(0)
  ["6pm"]=>
  int(0)
  ["7pm"]=>
  int(0)
  ["8pm"]=>
  int(0)
  ["9pm"]=>
  int(0)
  ["10pm"]=>
  int(0)
  ["11pm"]=>
  int(0)
}
$grandma
          why

Zombywuf
Mar 29, 2008

Today in MySQL: http://stackoverflow.com/questions/9819271/why-is-mysql-innodb-insert-so-slow

That's about 300 rows per second.

Johnny Cache Hit
Oct 17, 2011

Zamujasa posted:

Out of sheer curiosity how much was your salary requirement for that one?

I negotiated in the $60k range, which is on the starting end for senior level salaries in this area. But I was a starting senior developer, so hey, worked for me.

I don't think I could've negotiated a sanity-preserving salary at that place.

Doctor w-rw-rw-
Jun 24, 2008

xarph posted:

Log into mint.com and refresh.

Log into bank.

"Last access: Windows 2000, IE 5.0"

Maybe it's a safe default so most banks degrade their experience to the one with the fewest bells and whistles?

Strong Sauce
Jul 2, 2003

You know I am not really your father.





The best part about that horrible code is that rather than considering just hardcoding the arrays with the 24 values he just decides to dynamically create them in the worst horrible way. I guess this is just in case we decide to stretch our days into 26 hours cycles?

I mean there is just so much wrong in there yet someone thought this was OK to put into production. I mean it has a little bit of everything you shouldn't do programming wise.

Munkeymon
Aug 14, 2003

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



Strong Sauce posted:

The best part about that horrible code is that rather than considering just hardcoding the arrays with the 24 values he just decides to dynamically create them in the worst horrible way. I guess this is just in case we decide to stretch our days into 26 hours cycles?

I mean there is just so much wrong in there yet someone thought this was OK to put into production. I mean it has a little bit of everything you shouldn't do programming wise.

If he had used strftime instead of date, setting the locale before running that loop would produce localized strings, but then if he were competent enough to know that, he'd have done it right, so I got nothin :eng99:

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

In InnoDB, the primary key is also used as a clustering key.

Someone familiar with MySQL might realize that this makes using strings as primary keys a bad idea :ssh:

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Jabor posted:

In InnoDB, the primary key is also used as a clustering key.

Someone familiar with MySQL might realize that this makes using strings as primary keys a bad idea :ssh:

Another issue is that strings are not a motherfucking data type in SQL. I actually have no idea if he was talking about text or varchar.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

hieronymus posted:

Another issue is that strings are not a motherfucking data type in SQL. I actually have no idea if he was talking about text or varchar.

The conversation started off as being about character sets, which is a notion that applies to all string types in SQL. That is why I was not especially rigorous in differentiating between different string types. However, if you'd read my posts I think it is actually clear enough that as far as the indexes thing is concerned I'm talking about short CHAR (or I suppose in principle VARCHAR) columns.

And I am perfectly familiar with the way InnoDB table structure works and the fact that long primary keys are disadvantageous!

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Hammerite posted:

And I am perfectly familiar with the way InnoDB table structure works and the fact that long primary keys are disadvantageous!

Well I was more talking about the fact that inserting your primary key in unsorted order is substantially slower than having a synthetic ordered primary key, but yes long primary keys are also bad.

sturgeon general
Jun 27, 2005

Smells like sushi.
On average, what are the odds that any given "PHP Developer" opening is to fix a production application with all VARCHAR columns in an unindexed MySQL table, queries written with no concept of table joins, and tons of coded-by-exception if statements?

Sinestro
Oct 31, 2010

The perfect day needs the perfect set of wheels.

sniperchance posted:

On average, what are the odds that any given "PHP Developer" opening is to fix a production application with all VARCHAR columns in an unindexed MySQL table, queries written with no concept of table joins, and tons of coded-by-exception if statements?

103%, because there will be many other horrors as well.

Johnny Cache Hit
Oct 17, 2011

sniperchance posted:

On average, what are the odds that any given "PHP Developer" opening is to fix a production application with all VARCHAR columns in an unindexed MySQL table, queries written with no concept of table joins, and tons of coded-by-exception if statements?

Pretty much what Sinestro said, you're almost guaranteed to stumble into a viper's pit of hellish practices. There's just something special about PHP that brings out the worst in people.

If you want to be a mercenary you really can make decent money doing that type of maintenance work, especially when a business becomes sufficiently desperate for good help. I have a friend that has built a nice little business 1099 contracting from company to company, sweeping up messes & billing major bucks.

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Kim Jong III posted:

Pretty much what Sinestro said, you're almost guaranteed to stumble into a viper's pit of hellish practices. There's just something special about PHP that brings out the worst in people.

If you want to be a mercenary you really can make decent money doing that type of maintenance work, especially when a business becomes sufficiently desperate for good help. I have a friend that has built a nice little business 1099 contracting from company to company, sweeping up messes & billing major bucks.
I don't think mercenary is the term you want to use. I think they're more like the guys who do Crime Scene Cleanup. They're paid a lot of money to touch poo poo no one else wants to.

Chuu
Sep 11, 2004

Grimey Drawer
Trying to add nice error handling to some stored procedures I wrote, I cannot believe how ugly error handling is in MS SQL Server. Pre-2005 before TRY/CATCH blocks, you literally wrapped every statement that could cause a problem in an ugly boilerplate. According to MSDN in 2008R2 this is considered best practices for robust error handling:

code:
  begin try
    declare @hasOuterTransaction bit = case when @@trancount > 0 then 1 else 0 end;
    declare @rollbackPoint nchar(32) = replace(convert(nchar(36), newid()), N'-', N'');
   
    if @hasOuterTransaction = 1
    begin      
      save transaction @rollbackPoint;
    end
    else
    begin
      begin transaction @rollbackPoint;
    end;

    Do work;

    if @hasOuterTransaction = 0
    begin
      commit transaction;
    end;
  end try
  begin catch
    if xact_state() = 1
    begin
      rollback transaction @rollbackPoint;
    end;

    execute Standard module error handler;

    return -error_number();
  end catch;
end;
That "Standard module error handler" is where RAISE_ERROR lives, which in and of itself is a bit of a horror because before SQL Server 2012 you could not re-throw errors, which meant using RAISE_ERROR and more ugly boilerplate for reporting.

Are all databases this terrible for developing robust stored procs?

Beef
Jul 26, 2004
Every once in a while, when I wonder what I'm still doing in academia, I check this thread.

Adbot
ADBOT LOVES YOU

Zombywuf
Mar 29, 2008

Jabor posted:

In InnoDB, the primary key is also used as a clustering key.

Someone familiar with MySQL might realize that this makes using strings as primary keys a bad idea :ssh:

SQL server does that too. The problem appears to be that it flushes the transaction log far to aggressively (which can apparently be tuned somewhere).

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