|
jarito posted:IIRC there are some issues in using UUIDs for auto-generating keys in some databases. It's been a while since I looked into it so that might not be an issue anymore. To that I would say don't have the DB autogenerate the ID, have the middleware generate the UUID for you. Plus yes they need a separate column. Being clever and doing wizardry on the PK screams "bad architecture."
|
# ? Jul 12, 2012 01:18 |
|
|
# ? Apr 23, 2024 16:04 |
|
trex eaterofcadrs posted:Am I the only one who thinks things like Order ID's should just be generated with a UUID? It would solve SO many problems. You are apparently not, since we have a non-trivial number of tables with UUID primary keys. jarito posted:Even so, using UUIDs doesn't seem to solve his problem since what they need is a way to differentiate two of the same record types. They are using a 'reserved' part of the PK key space which, with UUIDs, would be about a bajillion times worse. It sounds like they just need a separate field. Reserving part of the UUID key space isn't very hard (prepending the UUID with a particularl constant, for example) BP's stretching a bit with the horror though. It's an overlooked edge case in legacy code, and he's probably the first developer to ever be seriously bitten by the issue. Zhentar fucked around with this message at 01:22 on Jul 12, 2012 |
# ? Jul 12, 2012 01:20 |
|
Zhentar posted:You are apparently not, since we have a non-trivial number of tables with UUID primary keys.
|
# ? Jul 12, 2012 02:27 |
|
Zhentar posted:BP's stretching a bit with the horror though. It's an overlooked edge case in legacy code, and he's probably the first developer to ever be seriously bitten by the issue. Probably the first in a while, yes. But there's standard code to set the next ID to a new value, so I suspect it's been a problem in the past. Also: there are UUID primary key tables??
|
# ? Jul 12, 2012 03:28 |
|
I've done this before for certain cases but we always made the "system" IDs be negative numbers so regular transactions could go on with IDENTITY/auto values and we could do identity inserts for the system records (which are infrequent enough that we can just scan the table for new IDs since it isn't concurrent either). Of course when it is up to me I just add a column to store the record type like a sane person.
|
# ? Jul 12, 2012 03:51 |
|
BP posted:Also: there are UUID primary key tables?? using UUIDs as pkeys is really really awesome
|
# ? Jul 12, 2012 04:05 |
|
Kim Jong III posted:using UUIDs as pkeys is really really awesome Except on InnoDB and other databases that treat the primary key as a clustered index. Those random-rear end IDs are going to get stuck all over the table and waste a lot of I/O time doing so.
|
# ? Jul 12, 2012 07:48 |
|
That is why you use a modified GUID with clustered indexes, so that the GUIDs are sorted by a timestamp that replaces the most significant part of the GUID data. The GUID data space is so large that this does not lead to any significant loss of uniqueness, while also allowing nice performance with clustered indexes. I have successfully used clustered GUID primary keys with SQL Server tables up to 100 GB (+indexes), with no real downsides. I have not seen integer primary keys in years Which part of the GUID should be the timestamp might depend on the database engine. For example, with SQL Server, you need to make it the last bit, like seen here: code:
EssOEss fucked around with this message at 08:51 on Jul 12, 2012 |
# ? Jul 12, 2012 08:48 |
|
What are the reasons for using UUID primary keys except for doesn't require auto-increment/making ids not guessable?
|
# ? Jul 12, 2012 09:12 |
|
KaneTW posted:What are the reasons for using UUID primary keys except for doesn't require auto-increment/making ids not guessable? One example that I've personally dealt with: If you have a geographically diverse application with multiple local databases that eventually need to be centralized for reporting or whatever, the UUID will make the rollup operation so much easier.
|
# ? Jul 12, 2012 13:51 |
|
This is one line of Ruby. I'm not going to use the code tag because it will break tables. = form.select :id, [["-- Choose --", ""]].concat((@current_user ? @current_user.promotion : @promotion).locations.nested(nested_level, (@current_user||@user).locations(nested_level - 1)).collect{|l| [l.name, l.id]}),{:selected => (@current_user||@user).locations(nested_level).nil? ? nil : (@current_user||@user).locations(nested_level).id}, :name => 'locations[][id]', :class => "required" 390 loving characters
|
# ? Jul 12, 2012 14:32 |
|
trex eaterofcadrs posted:One example that I've personally dealt with: Riak, which is distributed/locally replicated (and supports replication over high-latency links in the expensive version) uses random strings as default keys for the same reason.
|
# ? Jul 12, 2012 14:54 |
|
Bob Morales posted:This is one line of Ruby. I'm not going to use the code tag because it will break tables. Looks like one giant long ternary statement. Not the fault of Ruby as I could do the same in Java.
|
# ? Jul 12, 2012 14:59 |
|
Vintersorg posted:Looks like one giant long ternary statement. Not the fault of Ruby as I could do the same in Java. I'm just saying that it could be written differently and be a hundred times more readable
|
# ? Jul 12, 2012 15:24 |
|
Bob Morales posted:I'm just saying that it could be written differently and be a hundred times more readable Anyone who does something like that in any language should have the living poo poo beaten out of them. I like this example of ternary horror, personally: http://stackoverflow.com/q/9101719/781754
|
# ? Jul 12, 2012 15:43 |
|
Bob Morales posted:This is one line of Ruby. I'm not going to use the code tag because it will break tables. Oh god and it's done in a template too? It belongs in Ruby code:
|
# ? Jul 12, 2012 15:56 |
|
It's in a partial. It doesn't even work and this site has been live for a year Is it wrong that I still cringe when I see HAML?
|
# ? Jul 12, 2012 16:24 |
|
Ithaqua posted:Anyone who does something like that in any language should have the living poo poo beaten out of them.
|
# ? Jul 12, 2012 22:18 |
|
I managed a process that ran from a .bat file nightly and would shuffle some files around, print, and archive them. It's not complex at all. I was able to transfer managing it to someone else, which also involved having them install all the necessary software on one of their machines. After a couple days being told multiple times "it doesn't work" and finding out multiple times that the error is "x is not recognized as an internal or external command, operable program or batch file", followed by telling him to google the error, we finally got to the point where all required software was installed and added to the path. In addition, I had to teach him that instead of running the bat file each time, to just run one line at a time to troubleshoot any particular errors, plus to not run things that depend on previous commands to have been completed. This also included training on how to change directories from the command line, among other things. The bat file also had comments as to what each line did. There was no mystery yet I'd be at his desk helping him, he'd pick a line and ask what it does, or say "this must do X". I'd ask him what the comment said it does. This is a guy that was hired that had worked in a computer lab for a few years, had a associates in CS with an emphasis in programming, and also claimed to have no problem reading other people's code and taking it over when necessary. I was questioning the lack of experience compared with what was told in the interview and I get back quote:Remember, my experience is writing the scripts and running them as a whole. I have never broken one down to run seperate parts of it. I've also heard things about how unlike other people, he doesn't need to plan out anything when he programs or builds a database. He just needs to be told what the problem is and he'll build the solution. Recently, he was having trouble with a query not working right. It was just so bad that I don't even want to imagine what sort of things he's been writing since he started. It's the fact that he's not asking questions and just assuming he knows how all the tables work that drives me crazy when I think about it. It's the small things like this that just keep building up and stressing me out. chemosh6969 fucked around with this message at 23:26 on Jul 12, 2012 |
# ? Jul 12, 2012 22:59 |
|
Bob Morales posted:Is it wrong that I still cringe when I see HAML? HAML is a solution to a problem that never existed. The hipster vibe given off on their website about how "poetic" it is is horrible, too. HTML with embedded templates is far more legible to me than any HAML I've seen. I'm not big on Coffeescript for the same reason, despite the positive things I've heard about it. I don't find Javascript that difficult to express myself in. I haven't dived too far into the latest version of Rails yet but when I created a placeholder project and noticed that it had Coffeescript assets by default, it made me a little sad. At least SASS adds some meaningful features like mixins, variables, and inheritance, so I don't mind that so much -- especially since I can compile the stylesheets to pure CSS before deploying.
|
# ? Jul 12, 2012 23:18 |
|
Flobbster posted:HAML is a solution to a problem that never existed. The hipster vibe given off on their website about how "poetic" it is is horrible, too. HTML with embedded templates is far more legible to me than any HAML I've seen. I use hamlpy for my Django templates, it basically compiles haml syntax to a django template. As long as you break up the templates into reasonable chunks with includes and extends I find it much easier to read what's going on, especially with if else statements and the like. YMMV of course but I do like how I can reorganise html by just shifting the indentation. It can still accept if else statements in the class and ID attributes as well, if you use the attribute syntax rather than the shorthand. edit: I do find them waxing lyrical on their front page a little groan worthy though. Actually turned me off bothering with it for a while. Maluco Marinero fucked around with this message at 23:52 on Jul 12, 2012 |
# ? Jul 12, 2012 23:42 |
|
Flobbster posted:HAML is a solution to a problem that never existed. The hipster vibe given off on their website about how "poetic" it is is horrible, too. HTML with embedded templates is far more legible to me than any HAML I've seen. I don't really care about the bracelessness of Coffeescript or whatever but the list comprehensions and proper support for iterating over the keys of an Object that aren't the built-in properties are really useful.
|
# ? Jul 13, 2012 00:49 |
|
I thought a lot of the point of HAML was mostly about making really drastic structural changes to HTML (re-indenting and pivoting about tables, for example) easier than with most templating languages. I could imagine using it for writing out some HTML shorthand for a quick layout in the early stages and then when I'm done iterating through different designs I'll use an actual templating language like I dunno JSTL or Jinja or whatever.Flobbster posted:I'm not big on Coffeescript for the same reason, despite the positive things I've heard about it. I don't find Javascript that difficult to express myself in. I haven't dived too far into the latest version of Rails yet but when I created a placeholder project and noticed that it had Coffeescript assets by default, it made me a little sad.
|
# ? Jul 13, 2012 15:28 |
|
Same bitcoin site hacked againa, Bitcoinica apparently didn't want to change its passwords after being compromised top to bottom. Oh, and they apparently store their own use passwords/API keys for other sites hardcoded inside the code
|
# ? Jul 13, 2012 17:29 |
|
HAML is just less typing than HTML for equivalent and well-formed results:code:
code:
CoffeeScript is the same thing: "->" is more succinct than "function", indents are more succinct than counting "}"s, and if your poo poo is so complicated you find yourself having trouble relating the compiled output to the CoffeeScript input, you should learn to program simpler stuff.
|
# ? Jul 13, 2012 17:30 |
|
BonzoESC posted:HAML is just less typing than HTML for equivalent and well-formed results: Is there a good way to write recursive functions in coffeescript? There's no named functions in it so I guess you can use arguments.callee, or obviously a Y combinator would work, but those seem a little ugly-ish for common use.
|
# ? Jul 13, 2012 18:00 |
|
Just name it?code:
|
# ? Jul 13, 2012 18:04 |
|
necrobobsledder posted:From what I've seen of Coffeescript, its primary use case is in helping write more OOP-like code using Javascript without getting lost in closure after closure. . I would argue that this is not necessarily a feature... At least not for someone who isn't a JavaScript expert. Forcing your brain to unlearn existing OO class-based systems then to really live and breathe prototypes+closures expands your understanding in the same way learning multiple spoken languages as a child does. Then you can circle back around and learn to hate JavaScript all over again, like a parent who bent over backwards to give you everything in life, but was also horribly abusive. You love them but you also wish they would hurry up and die.
|
# ? Jul 13, 2012 18:18 |
|
pokeyman posted:Just name it? Oh, I was under the assumption that they were totally anonymous and that it wouldn't bind before that (similar to be behavior of let in scheme).
|
# ? Jul 13, 2012 20:21 |
|
Look Around You posted:Oh, I was under the assumption that they were totally anonymous and that it wouldn't bind before that (similar to be behavior of let in scheme). Nah, it's just JavaScript. Works identically. JavaScript code:
|
# ? Jul 13, 2012 21:07 |
|
Look Around You posted:Oh, I was under the assumption that they were totally anonymous and that it wouldn't bind before that (similar to be behavior of let in scheme). JavaScript code:
|
# ? Jul 13, 2012 22:46 |
|
so if you're ever writing PHP and using in_array or array_search with an associative array that could possibly have a value of 0, don't let yourself think you're going crazy when you run into this wonderful horror:php:<? $wtf = array("whatthechrist" => 0); var_export($wtf); echo "\n------\n"; var_export(in_array("baaalllllllssssssssssssssss", $wtf)); // prints TRUE the real answer, as always is, PHP's lovely equality operator ("arbitrary string" == 0 )! You can get around it by passing TRUE as a third parameter to either of those functions, which forces a strict comparison, but this is a fine example of why you should always use strict comparisons in PHP. what a poo poo language!!
|
# ? Jul 14, 2012 10:13 |
|
Well if you're going to be mixing data types together in PHP you should pretty much be using the identity operator. I mean in general you should be using it anyways.
|
# ? Jul 14, 2012 17:06 |
|
quote:bool in_array ( mixed $needle , array $haystack [, bool $strict = FALSE ] ) I guess my point is, maybe $strict should default to TRUE, not FALSE. Or maybe there should be a PHP setting where everything is treated as strict. PHP.
|
# ? Jul 14, 2012 19:10 |
|
Golbez posted:But... in the situation shown above, we would have no reason to assume we need to set strict. I've never used strict with in_array(), yet I know that scenario could potentially appear in my code. I'm guessing its due to having to maintain backwards compatibility for older PHP scripts.
|
# ? Jul 14, 2012 19:25 |
|
Strong Sauce posted:I'm guessing its due to having to maintain backwards compatibility for older PHP scripts. That's a reason they can't change it now, not why it never worked properly in the first place. And, as shown earlier with that horrific number_format() bug, they obviously don't care about maintaining backwards compatibility if it means cleaning up something in their codebase.
|
# ? Jul 14, 2012 20:40 |
|
putting a setting in php.ini to force in_array and array_search etc. to use strict comparisons wouldn't break existing code, because you could just leave it off for legacy code.
|
# ? Jul 14, 2012 22:11 |
|
Golbez posted:That's a reason they can't change it now, not why it never worked properly in the first place. And, as shown earlier with that horrific number_format() bug, they obviously don't care about maintaining backwards compatibility if it means cleaning up something in their codebase. I think they do care about backwards-compatibility as a general rule. The number_format() thing was just down to it being a poorly-managed project I think.
|
# ? Jul 14, 2012 22:14 |
|
Hammerite posted:I think they do care about backwards-compatibility as a general rule. The number_format() thing was just down to it being a poorly-managed project I think. No, it was down to a change made to the parser that actually changed the return value of a function. Which is pretty absurd.
|
# ? Jul 14, 2012 22:29 |
|
|
# ? Apr 23, 2024 16:04 |
|
Accidental backwards compatibility changes from code cleanups are okay, but intentional ones to make the stdlib less awful aren't.
|
# ? Jul 15, 2012 00:10 |