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

IMlemon posted:

Boolean flags are set or unset in a longass method and are impossible to keep track off. That closeSession method?

code:
protected void closeSession(Session s) {
		if (SomeHelper.isWebThread()){
			//do nothing
		} else {
			/*if (s != null) {
				s.logout();
			}*/
		}
	}

Did you truncate this or does it really do nothing, thanks to the comments?

Adbot
ADBOT LOVES YOU

IMlemon
Dec 29, 2008

Golbez posted:

Did you truncate this or does it really do nothing, thanks to the comments?

This is all original code, except I removed the beginning of the first code snippet and changed exception names.

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.
Nothin' better than commented-out code. Especially when they use stream comments, so grep gives misleading results!

Munkeymon
Aug 14, 2003

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



Hammerite posted:

When you talk to the database server you are using a particular character set to do so. For example, you might be using UTF-8, which can express a superset of the characters that can be expressed in iso-8859-1 or in iso-8859-15. If I send an INSERT or UPDATE statement that stores a particular string value in a column whose character set is iso-8859-1 (say), the string value needs to contain only valid iso-8859-1 characters. If it contains other characters, it is not a valid string value for that column. That is a "specific requirement of the data", in your words. This is what I mean when I say that the character set of a column is a constraint on that column. It also implies an interpretation of the data stored in the column, as you say.

If you try to insert, say, UTF-8 3-byte code points into into an ISO-8859-1(5) column in MySQL, does it error or warn you?

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Mustach posted:

Nothin' better than commented-out code. Especially when they use stream comments, so grep gives misleading results!

In my world, having commented out code outside of a dev branch is an automatic code review failure.

Munkeymon
Aug 14, 2003

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



Ithaqua posted:

In my world, having commented out code outside of a dev branch is an automatic code review failure.

Something tells me the world that code came from doesn't include code reviews.

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

Ithaqua posted:

In my world, having commented out code outside of a dev branch is an automatic code review failure.

Out of curiosity, when you say 'code review', is this a human process or something you put through a program or both? I'm the primary of only two devs here so my code review process is rather sparse for his code (making sure nothing kills the site or has SQL injections) and non-existent for mine.

shrughes
Oct 11, 2008

(call/cc call/cc)

Golbez posted:

Out of curiosity, when you say 'code review', is this a human process or something you put through a program or both? I'm the primary of only two devs here so my code review process is rather sparse for his code (making sure nothing kills the site or has SQL injections) and non-existent for mine.

He meant human. That's generally what the term implies. A program can't discern between instances where it's okay to commment out code (examples of using an API given in comments) and you'd have to make a machine learning algo to discern between code and text anyway... *effort*. It's definitely not a computer.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Golbez posted:

Out of curiosity, when you say 'code review', is this a human process or something you put through a program or both? I'm the primary of only two devs here so my code review process is rather sparse for his code (making sure nothing kills the site or has SQL injections) and non-existent for mine.

It's a human intervention thing. When I worked on a larger team, every 2-week iteration, there would be a person assigned to be the code reviewer. This was to prevent groups of "code review buddies" from forming who would let each others' poo poo slide. Immediately before merging code from their dev branch to the integration branch, they'd schedule a code review session, and the two people would sit down together and go over the code.

The goals were:
- Ensure that the code meets standards (naming conventions, etc)
- Ensure that the code is well-designed
- Ensure that the code has appropriate unit test coverage and that all tests pass
- Ensure that the code meets all of the acceptance criteria

Of course, some people were far stricter than others.

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
Sounds fun. Sounds like something for a larger place than us... I guess I could get him to review my code.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Golbez posted:

Sounds fun. Sounds like something for a larger place than us... I guess I could get him to review my code.

Code reviews are also a great way to pass your wisdom and experience to newer people on the team.

epswing
Nov 4, 2003

Soiled Meat

Golbez posted:

Sounds fun. Sounds like something for a larger place than us... I guess I could get him to review my code.

Assuming you are the senior guy, it would absolutely make sense for your co-worker to review your code, if nothing else to read better code than his own.

^ :argh:

epswing fucked around with this message at 18:36 on Jun 13, 2012

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Golbez posted:

Sounds fun. Sounds like something for a larger place than us... I guess I could get him to review my code.

I think code reviews should be done on any team with more than one developer, personally.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Ithaqua posted:

I think code reviews should be done on any team with more than one developer, personally.

A thread for single developers to review each others code. Good idea or bad?

Since I'm entirely self taught and haven't worked with any other developers before (besides minor-ish contributions to open source projects where I didn't really work with anyone else, I just fixed stuff and submitted it), I think I'd benefit a lot from code reviews.

Hammerite
Mar 9, 2007

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

tef posted:

Frankly, beyond percussive maintenance, I am unsure how to transmit this information to you.

I suggest a convincing argument.

Here is the starting point: a primary key is, by definition, a column or sequence of columns that can be used to uniquely identify rows in the table. I observe that a string can be used to uniquely identify rows in the table. Thus, a string can be used as a primary key.

It seems to me that it is at that point up to you to say, "Well yes, but..." and give a reason why strings should not be used in that way even though they can be. It is not up to me to prove that no such reason exists (how would I even go about doing that?). It is up to you to provide one.

Munkeymon posted:

If you try to insert, say, UTF-8 3-byte code points into into an ISO-8859-1(5) column in MySQL, does it error or warn you?

It is surprisingly difficult to find out this information from the MySQL manual, and I gave up trying to find out what the exact behaviour is from the command line because it was too much of a pain in the rear end to work out what was MySQL's behaviour and what was a limitation of the Windows command-line client. I may try to find out later using better tools.

The behaviour that I would expect is for it to depend on the sql mode. I would expect it to refuse to perform the insert in strict mode and otherwise to do something like truncate the data or replace the offending character with a '?'.

No Safe Word
Feb 26, 2005

Thermopyle posted:

A thread for single developers to review each others code. Good idea or bad?

Bad. The spirit would be good, but it's just way too subjective to have it all out in the open like that. A coordinated thread for one-to-one or one-to-many code reviews outside of the forums might not be a bad idea if there was a way to coordinate those reviews.

Doctor w-rw-rw-
Jun 24, 2008

Thermopyle posted:

A thread for single developers to review each others code. Good idea or bad?

Since I'm entirely self taught and haven't worked with any other developers before (besides minor-ish contributions to open source projects where I didn't really work with anyone else, I just fixed stuff and submitted it), I think I'd benefit a lot from code reviews.

I'd be happy to code-review others' Java code, especially Android, but I'm afraid I can't share most of my own code, seeing as how it's written for my job and thus not shareable.

And while I'd want some code review for some Scala stuff I'm doing on my own time, I'm a little hesitant to create a throwaway GitHub account. My main one can connect me to my place of employment, which for now I prefer to keep private.

No Safe Word posted:

Bad. The spirit would be good, but it's just way too subjective to have it all out in the open like that. A coordinated thread for one-to-one or one-to-many code reviews outside of the forums might not be a bad idea if there was a way to coordinate those reviews.
Issuing pull requests and posting them in the thread to solicit comments on said pull requests (assuming GitHub)? I wonder if you can issue your own project a pull request, to give people the opportunity to comment on it. It'd also mean that there would be a definitive resolution to each code review because it'd have to be merged or closed.

Doctor w-rw-rw- fucked around with this message at 19:02 on Jun 13, 2012

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Thermopyle posted:

A thread for single developers to review each others code. Good idea or bad?

Since I'm entirely self taught and haven't worked with any other developers before (besides minor-ish contributions to open source projects where I didn't really work with anyone else, I just fixed stuff and submitted it), I think I'd benefit a lot from code reviews.

I like the idea, although the thread would probably be so fast-moving that it would be difficult to have reasonable discussion. I like No Safe Word's idea -- we could start a code review buddy thread and pair people up.

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.

No Safe Word posted:

Bad. The spirit would be good, but it's just way too subjective to have it all out in the open like that. A coordinated thread for one-to-one or one-to-many code reviews outside of the forums might not be a bad idea if there was a way to coordinate those reviews.

I don't see why subjective=bad idea in this case. If two reviewers have differing opinions on something they can discuss it and maybe one of them ends up learning more about how to do reviews.

Breaking things down into individual private pairs means that only one person gets to benefit from the review, while keeping the discussions in-thread would let other people learn what is considered good/bad practice from their example. If some exchange really gets down to a level where it couldn't be considered general interest enough for the thread the people involved could move to PM/emails on their own.

Doctor w-rw-rw-
Jun 24, 2008

PDP-1 posted:

I don't see why subjective=bad idea in this case. If two reviewers have differing opinions on something they can discuss it and maybe one of them ends up learning more about how to do reviews.

Breaking things down into individual private pairs means that only one person gets to benefit from the review, while keeping the discussions in-thread would let other people learn what is considered good/bad practice from their example. If some exchange really gets down to a level where it couldn't be considered general interest enough for the thread the people involved could move to PM/emails on their own.

Disagreements about code can be a good way to learn more, since supporting claims must be made to back them up. I agree - the process should be open and discussion would help. If it becomes popular, I can see one thread being too fast-moving to keep up with, but that problem can be dealt with then.

No Safe Word
Feb 26, 2005

PDP-1 posted:

I don't see why subjective=bad idea in this case. If two reviewers have differing opinions on something they can discuss it and maybe one of them ends up learning more about how to do reviews.

Breaking things down into individual private pairs means that only one person gets to benefit from the review, while keeping the discussions in-thread would let other people learn what is considered good/bad practice from their example. If some exchange really gets down to a level where it couldn't be considered general interest enough for the thread the people involved could move to PM/emails on their own.

It's not so much the subjectivity that makes it bad it's just that you'd get lots of strong differing opinions and if the goal was for folks to learn, it could be difficult for them to choose and could end up being more destructive than constructive when reviewers start sniping at one another.

But, if people disagreeing was that big of a problem these forums wouldn't exist so I guess me just stating that it'd be outright "bad" without qualifying it a bit was overstatement.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Mustach posted:

Nothin' better than commented-out code. Especially when they use stream comments, so grep gives misleading results!

I like deleting commented out code in files that I edit. Usually because whole rows are commented out, my edits don't show up in blame either :devil:

McGlockenshire
Dec 16, 2005

GOLLOCKS!

Munkeymon posted:

If you try to insert, say, UTF-8 3-byte code points into into an ISO-8859-1(5) column in MySQL, does it error or warn you?

Not to continue the horrible MySQL ranting much longer, but...

ISO-8859-$FOO code points are single 8-bit bytes. All 256 combinations of bits are valid characters.

UTF-8 is the encoding of a Unicode characters into 8-bit bytes. It happens that any legal UTF-8 encoding is also legal ISO-8859-$FOO. This is why things like Unicode em dashes end up looking like – when displayed in ISO-8859-$FOO. Each of those characters is a legal ISO-8859-$FOO character, even though the sequence of bytes means something different in UTF-8.

Given that it would look legal, nothing at all should ever get in the way of you treating a UTF-8 encoded string as if it was ISO-8859-$FOO. This is why it's so important to get it right the first time.

npe
Oct 15, 2004
It's also why no normal human being would ever call the character set on a column a "constraint". A constraint in database terms implies a requirement that is actually enforced. If you take a stream of multibyte utf8 data and jam it into an ISO-8859-1 column, you end up with one of two things: if the client tried to convert from utf8 to the target character set, you will get dropped characters (the infamous "question marks in my data"). If the client jams the bytes in there as if they were the target encoding, then you get actual garbage from misrepresented bytes (as McGlockenshire describes).

It's really hard to imagine a scenario where you'd want anything other than UTF8. You get 8 bits per character for the ASCII range (code points < 128) and proper support for everything else. There is literally no argument for using 7 bit ASCII, and only really bad arguments for using any legacy 8 bit encoding (involving handwaving about 3rd party applications that can't be changed).

I can't fathom how you'd construe any of this as being a "constraint" by any sensible definition of that word.

Hammerite
Mar 9, 2007

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

npe posted:

It's also why no normal human being would ever call the character set on a column a "constraint". A constraint in database terms implies a requirement that is actually enforced. If you take a stream of multibyte utf8 data and jam it into an ISO-8859-1 column, you end up with one of two things: if the client tried to convert from utf8 to the target character set, you will get dropped characters (the infamous "question marks in my data"). If the client jams the bytes in there as if they were the target encoding, then you get actual garbage from misrepresented bytes (as McGlockenshire describes).

There is a third possibility that you are not considering: the server tries to convert to the target character set and notices that some of the characters can't be expressed in the target character set, and therefore refuses to do it and returns an error. That's a "requirement that is actually enforced", i.e. a constraint. This is what should happen!

Hammerite
Mar 9, 2007

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

Hammerite posted:

It is surprisingly difficult to find out this information from the MySQL manual, and I gave up trying to find out what the exact behaviour is from the command line because it was too much of a pain in the rear end to work out what was MySQL's behaviour and what was a limitation of the Windows command-line client. I may try to find out later using better tools.

The behaviour that I would expect is for it to depend on the sql mode. I would expect it to refuse to perform the insert in strict mode and otherwise to do something like truncate the data or replace the offending character with a '?'.

OK, I just tried this out on my web host's PHPMyAdmin. I created this table:

SQL code:
create table x (s char(5)) character set latin1
I ran these two pieces of SQL (nb. PHPMyAdmin defaults to non-strict mode):

SQL code:
insert into x (s) values ('see below');
SQL code:
set @@sql_mode = 'TRADITIONAL';
insert into x (s) values ('see below');
With the first one, '?' is inserted. With the second one, nothing is inserted and you get this error message:

code:
#1366 - Incorrect string value: '\xC7\xA0' for column 's' at row 1 
This is the behaviour I was expecting. The observed behaviour in strict mode is what I consider to be correct behaviour.

EDIT: The forum doesn't let me put the character I actually used in the "code" environment. I used the string 'Ǡ' (LATIN CAPITAL LETTER A WITH DOT ABOVE AND MACRON), not the string 'see below'.

Hammerite fucked around with this message at 22:03 on Jun 13, 2012

Doctor w-rw-rw-
Jun 24, 2008

Hammerite posted:

OK, I just tried this out on my web host's PHPMyAdmin. I created this table:
(etc)
Dunno about you, but having both localized apps and dealt with encoding issues, I'd much rather have localization and encoding problems in program code than in database queries, which are often dynamically generated to some degree. Also, altering a table can be much more difficult than pushing new code.

If errors happen on a database level, I want them to be severe and I want to be notified NOW so I can fix them, and I want to handle errors in my code in the most transparent way possible, i.e. "Did my database gently caress up? Better check my queries." rather than "Did my database gently caress up? Better check my data". It's also easier to debug the program code because the fuckups have a line number, because code is generated so much more rarely than database queries.

If I were interviewing a candidate and s/he argued that it's generally not a bad idea to handle encoding conversions at the database level, I would fail said candidate. The worst error you should have with character sets and encoding is a client showing a couple of hosed up characters.

Hammerite
Mar 9, 2007

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

Doctor w-rw-rw- posted:

Dunno about you, but having both localized apps and dealt with encoding issues, I'd much rather have localization and encoding problems in program code than in database queries, which are often dynamically generated to some degree. Also, altering a table can be much more difficult than pushing new code.

If errors happen on a database level, I want them to be severe and I want to be notified NOW so I can fix them, and I want to handle errors in my code in the most transparent way possible, i.e. "Did my database gently caress up? Better check my queries." rather than "Did my database gently caress up? Better check my data". It's also easier to debug the program code because the fuckups have a line number, because code is generated so much more rarely than database queries.

If I were interviewing a candidate and s/he argued that it's generally not a bad idea to handle encoding conversions at the database level, I would fail said candidate. The worst error you should have with character sets and encoding is a client showing a couple of hosed up characters.

I think this is consistent with what I am saying. :confused:

Of course you should check at the application level that data to be inserted is correct and satisfies constraints. But if the application fails in that regard then what should the database do? It should return an error for the application to deal with, of course.

Toady
Jan 12, 2009

"how to use pointers in Objective c"

Objective-C code:
- (void)setupWebView:(UIWebView**)aWebView {

    UIWebView *webview = [[UIWebView alloc] init];

    // ...

    if (*aWebView) {
        [*aWebView release];
    }

    *aWebView = webview;
}

Toady fucked around with this message at 22:47 on Jun 13, 2012

Doctor w-rw-rw-
Jun 24, 2008

Hammerite posted:

I think this is consistent with what I am saying. :confused:

Of course you should check at the application level that data to be inserted is correct and satisfies constraints. But if the application fails in that regard then what should the database do? It should return an error for the application to deal with, of course.

What I mean is, I have trouble seeing why your database would be anything other than UTF8. In virtually all cases, everything you write should speak UTF8, and keep encoding issues as far from the internals of the code as they can reasonably get. Database access counts as one of those internal things. Ideally, exceptions relating to encoding errors between the database and its clients would simply not exist, because they'd both be UTF8.

I can't imagine a common case where character sets are a reasonable thing to constrain on the database level.

Doctor w-rw-rw-
Jun 24, 2008

Toady posted:

"how to use pointers in Objective c"

Objective-C code:
- (void)setupWebView:(UIWebView**)aWebView {

    UIWebView *webview = [[UIWebView alloc] init];

    // ...

    if (*aWebView) {
        [*aWebView release];
    }

    *aWebView = webview;
}

Without context, that looks like a standard Objective-C variable swap plus a handle, so it can swap something externally. Unconventional, but not *necessarily* horrific. It doesn't look like it should be an instance method, though.

EDIT: Nope. I'm wrong. Also post was edited to add context. Been a while since I did any Obj-C. I suppose the variable swap itself does warrant some additional sanity checks, and the ivar vs. property thing is a good point. Still, even stuff like swizzling Apple's own Cocoa classes is done in some iOS apps I've heard of, at least as of two years ago. If you know what you're doing...

Doctor w-rw-rw- fucked around with this message at 22:54 on Jun 13, 2012

Look Around You
Jan 19, 2009

Hammerite posted:

But as I said, I don't see the discussion of the merits, or otherwise, of MySQL as being the real focus of discussion here. (Actually of the things being discussed, I find the thing about whether a column character set is a constraint the most interesting, but perhaps I am weird.) I was moved to defend (my perception of) MySQL's acceptable (although it has one or two warts) Unicode support by Zombywuf's barb that UTF-8 "actually works in Postgres".

You literally asked for a comparison between Postgres and MySQL and then jumped on everything people said when they compared the two.


quote:

Well I do think that's the issue you and Zombywuf have with what I'm saying, isn't it?

What requirements are there of a primary key? By definition, it is meant to uniquely identify rows in the table. To that, you and Zombywuf would both add (unless I misunderstand you) that the primary key should be meaningless. (And I would agree that in the great majority of cases it should be meaningless, I just don't join you is saying that it must 100% of the time be meaningless.)

Yes, the only requirement for a primary key is that it is unique for each entry. However, using business data for primary keys is a horrible idea because then you're hardcoded into that particular setup.

quote:

It is possible to have an integer that is meaningful, and it is possible to have a string that is meaningless. So I think when I said "you don't think PKs should have business meaning", I was not handwaving but getting to the heart of the matter.

Yes both of those are possible, however you still haven't provided a good use-case for a meaningful PK, which is apparently the heart of the matter. *See below*

quote:

The use-case I was referring to is the following (bold not in original):

Hammerite posted:

Handy if you want to use UTF-8 to support internationalisation, but also want to use ASCII text for some key columns used internally. For example, if you have a table of user privileges you might use (say) a CHAR(20) CHARACTER SET ascii COLLATE ascii_bin NOT NULL as the primary key so that you can identify privileges by descriptive names. You don't want the indexed column to be 80 bytes when it should be 20 bytes.

:what:

How about this?
code:
privilege_id : int (unique, not-null) - PRIMARY KEY
privilege_description : string (unique, not-null)
So no, that's not really a good reason to use a string as a primary key.

quote:

I guess I was incorrect when I said that you would have to be able to trace it back to another table's primary key. I still don't think your suggestion of a composite key containing a string is a sensible exception to the rule "no meaningful primary keys", if we accept that rule. Essentially because a primary key that consists of a single string column is surely just a special case of "composite primary key that includes a string". You note that the example (last name, first name, dob) is a bad one (on this we both agree), but I am not convinced that there is a class of examples where a reasonable argument could be made for a composite primary key containing a string but the argument would collapse if the scenario were changed to make the string the sole component of the primary key.

It's still a horrible idea and not a very valid exception at all (nor was I actually suggesting it as one), I was just trying to see what your reasoning for including a string PK would be.

Also:

quote:

It seems to me that it is at that point up to you to say, "Well yes, but..." and give a reason why strings should not be used in that way even though they can be. It is not up to me to prove that no such reason exists (how would I even go about doing that?). It is up to you to provide one.

It actually is up to you to provide a reason for using a string as a primary key that is actually a better alternative to factoring out the business information into a separate column and using a "meaningless" integer PK, since it's honestly against best practice at least 99% of the time.

Hammerite
Mar 9, 2007

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

Look Around You posted:

You literally asked for a comparison between Postgres and MySQL and then jumped on everything people said when they compared the two.

I asked for a comparison that was (among other things) unbiased. I didn't ask for a scattering of snide comments about how this or that totally sucks in MySQL, hurr hurr. Notice how McGlockenshire was critical of MySQL but I didn't jump on anything he said.

But in the end you're right, I shouldn't have bothered responding to the barbs since it wasn't really relevant to the topic I was trying to discuss.

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.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

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.

Okay I guess, but why does that mean you have to store them in the table in that fashion? Isn't that just bloating your indexes for no reason?

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:

Okay I guess, but why does that mean you have to store them in the table in that fashion? Isn't that just bloating your indexes for no reason?

Don't forget making it impossible to auto-incrementing the key. Sure do love writing the code to do that manually if I want to maintain a synthetic key.

Suspicious Dish
Sep 24, 2011

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

Hammerite posted:

I asked for a comparison that was (among other things) unbiased.

"unbiased" just means "has the same bias as mine".

tef
May 30, 2004

-> some l-system crap ->

Hammerite posted:

I asked for a comparison that was (among other things) unbiased. I didn't ask for a scattering of snide comments about how this or that totally sucks in MySQL, hurr hurr. Notice how McGlockenshire was critical of MySQL but I didn't jump on anything he said.

But in the end you're right, I shouldn't have bothered responding to the barbs since it wasn't really relevant to the topic I was trying to discuss.

if you want to have sql explained to you, you could perhaps start somewhere other than the coding horrors thread.

Zombywuf
Mar 29, 2008

Hammerite posted:

I asked for a comparison that was (among other things) unbiased.
I'm biased against MySQL because it's terrible.

quote:

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.
Look Around You showed you the correct way to do this.

Zombywuf fucked around with this message at 14:28 on Jun 14, 2012

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

hieronymus posted:

Don't forget making it impossible to auto-incrementing the key. Sure do love writing the code to do that manually if I want to maintain a synthetic key.

Huh. You just made me realize I never have to generate my own PKs; I use autoincrements or compound keys exclusively.

Adbot
ADBOT LOVES YOU

Johnny Cache Hit
Oct 17, 2011

Golbez posted:

Huh. You just made me realize I never have to generate my own PKs; I use autoincrements or compound keys exclusively.

:respek: you aren't a horror.

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

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++;
    }
?>
Naturally I ripped it apart and everyone was pleased. Then the train really went off the tracks - I jokingly said "wow, it must've taken you a while to come up with such a great example of horrible code." No one chuckled. Instead, everyone glanced back and forth at each other, and the senior developer finally said "well... that's actually in production right now."

Apparently they'd fired their last "senior developer" a few months before I interviewed, but not before he wrote two functioning products just like that. They didn't even change the variable names - they literally copy & pasted the code straight from their production machine.

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:

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