|
..btt posted:Every time I read that there's a part of me that believes it's not really true, nobody could design a database that isn't null aware and have, of all people, financial institutions adopt it as their standard RDBMS. It's some in-joke among Oracle-types... right guys? We live in a world where MongoDB is seeing widespread market adoption, specifically because it is incapable of enforcing any constraints. I'll accept NULL decaying to empty string as an alternative.
|
# ? Nov 13, 2013 20:09 |
|
|
# ? May 27, 2024 19:28 |
|
Yeah, I don't get that at all. I really like Mongo's API, but I haven't used it for anything I'd want an RDBMS for. Because it isn't an RDBMS.
|
# ? Nov 13, 2013 21:03 |
|
SavageMessiah posted:All this is moot on ~*Oracle*~ because '' IS NULL there... I've actually come to appreciate this about Oracle. 9 out of 10 times the distinction between null and '' is of no interest to my business logic anyway, so I like not having to worry about which one I put in the database. The only thing I hate is when I forget that col = '' doesn't work (you have to do col IS NULL). Even '' = '' returns false.
|
# ? Nov 13, 2013 21:39 |
|
..btt posted:Yeah, I don't get that at all. I really like Mongo's API, but I haven't used it for anything I'd want an RDBMS for. Because it isn't an RDBMS. The aggregation framework is really nice. Being able to project and rebuild documents on the fly is really handy. Then again, it's supposed to be used for document-type records.
|
# ? Nov 13, 2013 22:29 |
|
Houston Rockets posted:
What type is data? Could they have just used for line in data[2:]: ?
|
# ? Nov 13, 2013 23:58 |
|
Bognar posted:
Python code:
|
# ? Nov 14, 2013 01:52 |
|
Just use itertools.islice, that's what it's for!
|
# ? Nov 14, 2013 03:31 |
|
LOOK I AM A TURTLE posted:I've actually come to appreciate this about Oracle. 9 out of 10 times the distinction between null and '' is of no interest to my business logic anyway, so I like not having to worry about which one I put in the database. The only thing I hate is when I forget that col = '' doesn't work (you have to do col IS NULL). Even '' = '' returns false. It's a lot more likely to bite you if you're writing poo poo tons of PL/SQL code.
|
# ? Nov 14, 2013 16:30 |
|
code:
code:
|
# ? Nov 14, 2013 19:29 |
|
I'm no expert on the lambda internals, but doesn't that result in more evaluations of "GetLength" than the original? Might not be a concern in that context, dependant on array size or implementation, of course.
|
# ? Nov 14, 2013 19:36 |
|
Possibly, but I'm 100% certain that performance considerations did not cause the original version.
|
# ? Nov 14, 2013 19:48 |
|
..btt posted:I'm no expert on the lambda internals, but doesn't that result in more evaluations of "GetLength" than the original? Might not be a concern in that context, dependant on array size or implementation, of course. streets = streets.OrderBy(s => s.GetLength()).ToArray(); would get you down to O(N) calls to GetLength() if the sort doesn't specifically need to be in-place. If it does need to be in-place, the number of calls to GetLength did matter, and I'm not just forgetting about an existing in-place version, then I would still want to just write the in-place version.
|
# ? Nov 14, 2013 20:01 |
|
SavageMessiah posted:It's a lot more likely to bite you if you're writing poo poo tons of PL/SQL code. Oracle doesn't even index null fields*, so that's always fun when you have them all over the legacy schema. * without trickery like indexing on (column, someconstant) and even so it works better in 11g+.
|
# ? Nov 14, 2013 22:18 |
|
Plorkyeran posted:streets = streets.OrderBy(s => s.GetLength()).ToArray(); I would prefer that code to the .Sort() implementation even if it was less performant. It just reads a lot better.
|
# ? Nov 15, 2013 00:00 |
|
GrumpyDoctor posted:
Is this a half-baked attempt at snake_case?
|
# ? Nov 17, 2013 05:12 |
|
Woodsy Owl posted:Is this a half-baked attempt at snake_case? It's what you do when your algorithm is implemented as a single 1000-line long function and you want a way to kind of indicate that some variables are more "temporary" than others. I guess. (It's also how you name class data members according to the Google C++ style guide )
|
# ? Nov 17, 2013 05:31 |
|
GrumpyDoctor posted:It's also how you name class data members according to the Google C++ style guide
|
# ? Nov 17, 2013 06:10 |
|
Am I a bad person for using the half-assed p_, m_, _ Hungarian notation
|
# ? Nov 17, 2013 16:15 |
|
Sockser posted:Am I a bad person for using the half-assed p_, m_, _ Hungarian notation Everyone has the right to use whatever notation they want. The case I was talking about just looked strange to me from my notation and readability point of view. Maybe I was too critical, and it isn't really my place to judge others' notation choice unless it's absolutely horrible.
|
# ? Nov 17, 2013 16:23 |
|
Sockser posted:Am I a bad person for using the half-assed p_, m_, _ Hungarian notation Yes. Hungarian notation is a concept whose time has passed.
|
# ? Nov 17, 2013 16:34 |
|
Plorkyeran posted:The Google C++ style guide telling you to do something is a pretty good sign that you shouldn't do it. Which style guidelines would you recommend?
|
# ? Nov 17, 2013 17:35 |
|
I don't think of m_ as being Hungarian notation as such. It's more so you can have public members with the same name (e.g. accessors). I would just use _Name (I do in C#), but in C++ you aren't supposed to start names with underscores, it's reserved for the implementation or something.
|
# ? Nov 17, 2013 17:35 |
|
Using any sort of programmer-enforced convention of prefixes or suffixes in identifier names to convey semantic meaning is a form of hungarian notation. It's not a very good idea.
|
# ? Nov 17, 2013 17:43 |
|
That's why I said it's not for semantic meaning, it's to prevent name collisions - at least for me.
|
# ? Nov 17, 2013 17:48 |
|
I mostly use it just to keep track of variables easier, insofar as "oh poo poo what is foo" is reduced to "oh poo poo what is p_foo oh well it's a parameter so that's something" and now I don't think I can ever stop doing it
|
# ? Nov 17, 2013 17:52 |
|
Sockser posted:I mostly use it just to keep track of variables easier, insofar as "oh poo poo what is foo" is reduced to "oh poo poo what is p_foo oh well it's a parameter so that's something" You aren't using an IDE that can provide that information to you so you don't have to encode it into your variable names by convention?
|
# ? Nov 17, 2013 18:55 |
|
Rottbott posted:I don't think of m_ as being Hungarian notation as such. It's more so you can have public members with the same name (e.g. accessors). I would just use _Name (I do in C#), but in C++ you aren't supposed to start names with underscores, it's reserved for the implementation or something. At global scope this is correct, but otherwise only double underscore in a variable and a prefix of underscore followed by a capital letter are reserved. _member is perfectly okay. EDIT: Of course, then you have POSIX whose rules end up reserving things like "tolerance" and "isomorphism" FamDav fucked around with this message at 19:04 on Nov 17, 2013 |
# ? Nov 17, 2013 19:00 |
|
Modified Hungarian is great for several things. The one that comes up all the time in my work is storing the same data 2 different ways. For example, you ask the user for their date of birth in a text box, so you get it as a string, but you need it as a DateTime. sDateOfBirth and dtDateOfBirth. Also, sometimes an object being a certain class is everything you need to know about that variable. If I'm making an ASP.NET TableHeaderRow, I am almost always going to name it thr. I'm going to name the header cells thcName, thcIdNumber, etc. Then, in the loop that makes the table, I'm going to name the regular cells things like tcName and tcIdNumber. Sometimes, the class names tell you tons about the object's intended uses. Hungarian warts make variable names almost automatic.
|
# ? Nov 17, 2013 19:53 |
|
Happy Big Fun posted:Modified Hungarian is great for several things. The one that comes up all the time in my work is storing the same data 2 different ways. For example, you ask the user for their date of birth in a text box, so you get it as a string, but you need it as a DateTime. sDateOfBirth and dtDateOfBirth. "sDateOfBirth" and "dtDateOfBirth" don't tell me anything about the variables other than what type they are. I have an IDE that can tell me which type they are, so what do I get out of naming them after what type of data they contain? Nothing. This sounds like a job for Actual Descriptive Names! In the example you provided, I have the date the user is providing, and the parsed version of that date. So I'd call them inputDateOfBirth and parsedDateOfBirth. Now I look at those variables and I know which one is from user input and which one is the parsed version. For your table example, you should be naming it after what the table is actually going to contain. "thr" tells me nothing other than the type, which is just not useful for writing readable, maintainable code. It might not matter much in specific cases, but it's easier to just be consistent and always be descriptive.
|
# ? Nov 17, 2013 20:06 |
|
Once we're finished today's bikeshedding session, I think we'll all agree that proper names should be dateOfBirthAsInputByUser and dateOfBirthForOperatingOnByProgram
|
# ? Nov 17, 2013 20:17 |
|
Also it's important to remember that while having good tooling is nice, if you're working with C++, your IDE isn't guaranteed to know what's going on with any particular identifier. And it will take five seconds to admit failure. (And this is not a weird edge case, it happens pretty frequently.)
|
# ? Nov 17, 2013 20:25 |
|
Ithaqua posted:"sDateOfBirth" and "dtDateOfBirth" don't tell me anything about the variables other than what type they are. I have an IDE that can tell me which type they are, so what do I get out of naming them after what type of data they contain? Nothing. This sounds like a job for Actual Descriptive Names! In the example you provided, I have the date the user is providing, and the parsed version of that date. So I'd call them inputDateOfBirth and parsedDateOfBirth. Now I look at those variables and I know which one is from user input and which one is the parsed version. Frankly, inputWhatever and parsedWhatever don't tell you anything about it either, aside from them being different somehow. Both methods are pretty much equivalent. You can look at sDOB and dtDOB once and then it will be more obvious next time you see sWhatever and dtWhatever and maybe even lWhatever (long), etc. You can also look at inputDOB and parsedDOB once and remember whatever pattern they use for inputWhatever and parsedWhatever. They both give you a slightly lower mental hurdle to jump though, theoretically. But both also rely on consistency throughout the codebase. carry on then posted:bikeshedding
|
# ? Nov 17, 2013 20:27 |
|
FamDav posted:EDIT: Of course, then you have POSIX whose rules end up reserving things like "tolerance" and "isomorphism" Don't POSIXshame. isomorphism and tolerance for all
|
# ? Nov 17, 2013 20:53 |
|
Ithaqua posted:You aren't using an IDE that can provide that information to you so you don't have to encode it into your variable names by convention? Honest question, are you always in your IDE? I do a lot of cross mobile app development, one code base for Android and iOS. If I'm looking at code it could be in:
(Maybe the list of tooling is the horror?) So while we don't do any Hungarian here there's sure times I wish we did. I fixed a bug yesterday that probably existed for several years before I started where someone put an NSInvocation into an NSMutableDictionary and tried to remove it by referencing it's (id)Target. IDE didn't help and the app has been leaking memory since before release.
|
# ? Nov 17, 2013 21:38 |
|
Ithaqua posted:You aren't using an IDE that can provide that information to you so you don't have to encode it into your variable names by convention? Not defending hungarian, but I mostly just use vim to develop, and I'm sure I'm not alone in using just a text editor (emacs, sublime text, textmate, etc) to write code. I hate having to start up a heavy program to write code, and knowing vim (or emacs) makes it easier to work on code over ssh or whatever too. That being said, I don't usually mark variables as anything; I tend to prefer using self or this explicitly, and in any case, if you have so many variables in your function that you can't tell which one is local or class or global, you probably have some issues w/r/t your codebase. It shouldn't be that hard to look up in your function to see if something is declared as a local inside the function or in the parameter list, and if you don't see it there, chances are it's either a member variable, class variable or global, or a syntax error*. *dynamic langauges are a little different with this, but a lot of dynamic languages require some form of explicit self for member reference anyway.
|
# ? Nov 17, 2013 21:59 |
|
Hughlander posted:Honest question, are you always in your IDE? When I'm writing code? The vast majority of the time (>99%), the answer is "Yes". I code almost exclusively in a Microsoft bubble, though.
|
# ? Nov 17, 2013 23:39 |
|
GrumpyDoctor posted:Also it's important to remember that while having good tooling is nice, if you're working with C++, your IDE isn't guaranteed to know what's going on with any particular identifier. And it will take five seconds to admit failure. (And this is not a weird edge case, it happens pretty frequently.) This. Plus, having g_ helps a lot, too. (please don't ask )
|
# ? Nov 18, 2013 00:20 |
|
Hughlander posted:Honest question, are you always in your IDE? The only time that I'm not is when I'm using a code review tool like reviewboard or gerrit. Realistically, the only time I'm not using an IDE to do actual development is when I'm editing a config file or something similar.
|
# ? Nov 18, 2013 03:45 |
|
GrumpyDoctor posted:Also it's important to remember that while having good tooling is nice, if you're working with C++, your IDE isn't guaranteed to know what's going on with any particular identifier. And it will take five seconds to admit failure. (And this is not a weird edge case, it happens pretty frequently.)
|
# ? Nov 18, 2013 04:08 |
|
|
# ? May 27, 2024 19:28 |
|
Lol @ u if you're using an IDE, clearly you're a subpar coder and also a nooblet. Seriously, what's wrong with IDEs? They're incredibly helpful and make organizing a project a lot easier.
|
# ? Nov 18, 2013 15:23 |