|
Golbez posted:for ($NumberOfIterations = 0; $NumberOfIterations <= 100; $NumberOfIterations++) { Surely you mean for ($CurrentPositionInIteration = 0; $CurrentPositionInIteration <= 100; $CurrentPositionInIteration++) {
|
# ? Dec 5, 2012 23:57 |
|
|
# ? May 23, 2024 07:55 |
|
In a modern IDE even if the method is some huge mess, syntax highlighting will tell you the scope so there's no need for any of that pFoo mBar fBuzz crap some ancient contractor left in the code that I'm trying to maintain right now. Getting the original declaration and associated comments are just a keystroke away and in a language with annotations it should display them as well. Annotations like @NotNull are far superior to some sort of naming convention that people may or may not follow.
|
# ? Dec 6, 2012 00:56 |
|
Volte posted:Unless you're in some kind of untyped wasteland, that sort of naming convention is completely useless. That's not even Hungarian notation. Hungarian notation affixes some kind of meaningful descriptor to the variable (like cnt for counter, fh for file handle, etc), not the type. There's "apps hungarian" (which is what you describe) and "systems hungarian". The former did in fact originate in an "untyped wasteland" but got carried over into the MS Applications team (hence the name). The popular one, however - and the one most people mean when they say "hungarian notation" - is systems hungarian, which just prefixes each variable name with the language type of the variable. And yes, it is completely useless. That's why everyone hates it.
|
# ? Dec 6, 2012 01:50 |
|
Optimus Prime Ribs posted:Surely you mean for ($CurrentPositionInIteration = 0; $CurrentPositionInIteration <= 100; $CurrentPositionInIteration++) { a lot of for loops in the codebase where I work have (int ii = 0; ii < whatever; ii++) and I just realized why this is.
|
# ? Dec 6, 2012 02:24 |
|
1337JiveTurkey posted:In a modern IDE even if the method is some huge mess, syntax highlighting will tell you the scope so there's no need for any of that pFoo mBar fBuzz crap some ancient contractor left in the code that I'm trying to maintain right now. Getting the original declaration and associated comments are just a keystroke away and in a language with annotations it should display them as well. Annotations like @NotNull are far superior to some sort of naming convention that people may or may not follow. How much do you want to bet that Perl scope is undecidable?
|
# ? Dec 6, 2012 02:36 |
|
yaoi prophet posted:How much do you want to bet that Perl scope is undecidable? It's perfectly decidable outside of contrived examples where a BEGIN block may or may not alter how something parses.
|
# ? Dec 6, 2012 02:52 |
|
Jabor posted:It's perfectly decidable outside of contrived examples where a BEGIN block may or may not alter how something parses. I mean, given that parsing it in general is undecidable I figured it wouldn't be that much of a stretch.
|
# ? Dec 6, 2012 02:55 |
|
yaoi prophet posted:I mean, given that parsing it in general is undecidable I figured it wouldn't be that much of a stretch. perl parses Perl just fine - I think I already mentioned that the only undecidable cases are contrived examples where executing a BEGIN block can change how it parses. Pretty much the same thing as how executing preprocessor statements can change how a piece of C parses, really.
|
# ? Dec 6, 2012 03:04 |
|
Bunny Cuddlin posted:a lot of for loops in the codebase where I work have (int ii = 0; ii < whatever; ii++) and I just realized why this is. If you haven't done that yourself, you haven't written enough scientific code.
|
# ? Dec 6, 2012 05:39 |
|
fritz posted:If you haven't done that yourself, you haven't written enough scientific code. I'm not sure what you mean, but what I mean is they're using Hungarian notation on the temporary integer i by prefixing it with i, thus making.. ii. They use Systems Hungarian everywhere else so I'm fairly sure this is what's going on.
|
# ? Dec 6, 2012 05:44 |
|
Bunny Cuddlin posted:I'm not sure what you mean, but what I mean is they're using Hungarian notation on the temporary integer i by prefixing it with i, thus making.. ii. Scientific research code is notoriously horrible in quality. A great deal of it is still written in forth, and is written by researchers, not developers.
|
# ? Dec 6, 2012 05:48 |
|
Zombywuf posted:The default encoding of ISO-8859-1 was set back in the dawn of time before the UTF encodings were hewn from the very rock of the IETF standards mines. And by this you mean "the default encoding of ISO-8859-1 except when we decide to send windows-1252 without telling anyone because we thought it was the same thing".
|
# ? Dec 6, 2012 06:08 |
|
Jabor posted:perl parses Perl just fine - I think I already mentioned that the only undecidable cases are contrived examples where executing a BEGIN block can change how it parses. This is the coding horror thread, what makes you think I care about the contrivedness of any examples?
|
# ? Dec 6, 2012 06:19 |
|
Bunny Cuddlin posted:I'm not sure what you mean, but what I mean is they're using Hungarian notation on the temporary integer i by prefixing it with i, thus making.. ii. What I mean is your indexing variables go i, j, k, then ii, jj, kk, and then maybe iii, etc.
|
# ? Dec 6, 2012 07:06 |
|
fritz posted:What I mean is your indexing variables go i, j, k, then ii, jj, kk, and then maybe iii, etc. Does scientific code not have functions or something? Just kidding, why would it?
|
# ? Dec 6, 2012 08:05 |
|
Goat Bastard posted:Does scientific code not have functions or something? Functions would just slow things down!
|
# ? Dec 6, 2012 09:00 |
|
Bunny Cuddlin posted:a lot of for loops in the codebase where I work have (int ii = 0; ii < whatever; ii++) and I just realized why this is. I'd have thought it was so someone could search for 'ii' and find the loop variable, rather than trying to search for 'i' and finding every drat thing.
|
# ? Dec 6, 2012 09:11 |
|
So search for \bi\b instead unless you're using a text editor so lovely that it doesn't support regex search. In which case, get a better editor, and then search for \bi\b.
|
# ? Dec 6, 2012 09:18 |
|
fritz posted:If you haven't done that yourself, you haven't written enough scientific code. Maybe if that language doesn't support high-order functions.
|
# ? Dec 6, 2012 10:19 |
|
If you're using functions you haven't written enough scientific code
|
# ? Dec 6, 2012 10:33 |
|
yaoi prophet posted:How much do you want to bet that Perl scope is undecidable? I don't have much experience with perl in particular, but given that members of objects in other dynamic languages can be path dependent, my gut feeling goes towards undecidable.
|
# ? Dec 6, 2012 10:35 |
|
pokeyman posted:And by this you mean "the default encoding of ISO-8859-1 except when we decide to send windows-1252 without telling anyone because we thought it was the same thing". That's only Microsoft. Given that Microsoft's contributions to HTTP 2 have involved a submission describing upgrading a HTTP 1.1 connection to SPDY using both an UPGRADE response and websockets (only needing two additional headers) I think we can ignore their technical contributions here.
|
# ? Dec 6, 2012 12:37 |
|
Otto Skorzeny posted:Asked the apps engineer at $chip_vendor that is writing their optimization guide if he had a recommendation for a profiler. It's the vendor in your title isn't it?
|
# ? Dec 6, 2012 16:42 |
|
movax posted:It's the vendor in your title isn't it? Yes someone bought me a title
|
# ? Dec 6, 2012 16:59 |
Ugh, I need to vent about this thing I'm working on atm. It's not really an unusual WTF, it's just that I haven't worked on many old projects yet. Zend Framework. Well it's PHP, the documentation for it is terrible, but it kinda works. However the things built onto it in this application makes me want to scream. Inverted responsibilities all over the places. Superclasses that are certainly "super", they contain half the functionality of all the classes derived from them. There is a single class derived from Zend_Db_Table which all of our custom database table classes then derive from in turn, and that intermediate class has all kinds of checks for "what actual class was this method called on", doing various kinds of magic depending on that. I also just found a magic method pushed away in a corner that contains what seems to be a re-duplication of most of the collecting data for the frontend, except it's in another intermediate class, does everything slightly differently, and uses this pattern: PHP code:
|
|
# ? Dec 6, 2012 17:42 |
|
Well it's that or Symfony. Both have 2.0 versions now, though. I assume you're on 1.x?
|
# ? Dec 6, 2012 19:43 |
|
BiohazrD posted:
I nearly was responsible for a horror like this . Had a program I was writing that needed to save/load the current value of about 20 different types of control. code:
I thought "I could probably simplify this by using macros. Wait, I'm using C++, lets use an inline template function!" So I wrote something like this: (Recreated from memory, I actually had it to a compilable state with proper types specified) code:
code:
About that time I realised what I was doing and nuked the loving thing.
|
# ? Dec 7, 2012 13:24 |
|
Star War Sex Parrot posted:Of course you do. I actually really enjoy the atmosphere and posts of yospos (especially that thread, holy poo poo is it great) but I'm afraid I'd be chewed up or something so I never post. Maybe one day
|
# ? Dec 7, 2012 13:48 |
|
Ephphatha posted:I nearly was responsible for a horror like this . So what's the "right" way to do this?
|
# ? Dec 7, 2012 16:32 |
|
movax posted:So what's the "right" way to do this? Well if you have a bunch of different controls you have no option other than to hit each one to save them. If you are doing the same operation on a type of control then you can split that out into a function. Some frameworks automate this type of stuff for you.
|
# ? Dec 7, 2012 17:48 |
|
As my office switches to .NET, eventually we are going to have a talk about new naming conventions. Our current variable naming convention is <scope><datatype>_variablename like string ls_user_name or long ll select_count or boolean ib_read_only. What is the argument against having scope and datatype in your variable names? If I have a variable in a method, how can I tell if it belongs to the method or the class if it is not prefixed with a 'l' for local or an 'i' for instance? (Apparently right-click, go to definition isn't the answer.) Is using the m_ prefix for your fields the answer? It makes sense although all the books I see have private camelCase fields and public PascalCase properties instead. As the most junior programmer here I have a feeling any argument I give will not be enough to sway opinion, but since most of you seem opposed to it, I would at least like to know why.
|
# ? Dec 7, 2012 19:05 |
|
movax posted:So what's the "right" way to do this? Probably writing a new class to manage it, so even if the code is awful, it's awful in one place and everywhere else can interact with a nice API. Jewel posted:I actually really enjoy the atmosphere and posts of yospos (especially that thread, holy poo poo is it great) but I'm afraid I'd be chewed up or something so I never post. Maybe one day Nobody's criticism actually matters in yospos, if you get chewed out ignore it and post post post.
|
# ? Dec 7, 2012 19:07 |
|
Crazy Mike posted:What is the argument against having scope and datatype in your variable names? You're using an IDE that tells you all of that information instantly. Putting it in the variable name is at best redundant and at worst incorrect, when you realize that dbl_Foo is actually float_Foo. If you're moving to .NET, just follow Microsoft's Naming Conventions and Guidelines for Names. Install ReSharper and/or StyleCop on everyone's dev environments to help enforce it. Problem solved. [edit] Visual Studio will show you the scope and type of a variable if you hover the mouse over it. New Yorp New Yorp fucked around with this message at 19:16 on Dec 7, 2012 |
# ? Dec 7, 2012 19:13 |
Crazy Mike posted:What is the argument against having scope and datatype in your variable names? Plorkyeran posted:In general I am of the opinion that if marking the scope of variables in their names is ever useful then you have far too many things in scope. And if it would be a major pain to scroll to find where a variable is declared, then your function/class is likely getting too long.
|
|
# ? Dec 7, 2012 19:24 |
|
I like marking globals by prepending them with g_ to make them feel dirty (as they should)
|
# ? Dec 7, 2012 19:33 |
|
I like marking globals by prepending them with //
|
# ? Dec 7, 2012 19:37 |
|
Just use Java so globals are impossible to define
|
# ? Dec 7, 2012 19:39 |
|
Amarkov posted:Just use Java so globals are impossible to define Java code:
|
# ? Dec 7, 2012 19:43 |
|
Nope, not in the global namespace so it doesn't count. (Don't you dare import *)
|
# ? Dec 7, 2012 19:46 |
|
|
# ? May 23, 2024 07:55 |
Amarkov posted:Just use Java so globals are impossible to define Just use BASIC so you don't have to worry about which scope to place your variables in. (Also gets your type markers on variable names for free!)
|
|
# ? Dec 7, 2012 19:46 |