- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
Ratty posted:
At my old job some one once wrote:
code: for(int i = 1;i < 3; i++){
if(i == 1){
//the code did something here
}
if(i == 2){
//the code did something here
}
}
The guy that wrote it had a good sense of humour so we printed it out and started a wall of shame.
-- Ratty
He was SO close to independently developing the FOR-CASE paradigm
-- Ratty
|
#
¿
Mar 24, 2008 01:06
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
Apr 29, 2024 19:59
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
pokeyman posted:
Found this in the PHP manual. It's like the guy knew he wanted some kind of conditional execution, but forgot about the "if" keyword.
code:switch (TRUE)
{
case ($phlen < 7):
$ext = $ph;
break;
case ($phlen == 7):
sscanf($ph, "%3s%4s", $pfx, $exc);
break;
case ($phlen > 7 AND $phlen < 10):
sscanf($ph, "%3s%4s%s", $pfx, $exc, $ext);
break;
case ($phlen == 10):
sscanf($ph, "%3s%3s%4s", $area, $pfx, $exc);
break;
case ($phlen == 11):
sscanf($ph, "%1s%3s%3s%4s", $cty, $area, $pfx, $exc);
break;
case ($phlen > 11):
sscanf($ph, "%1s%3s%3s%4s%s", $cty, $area, $pfx, $exc, $ext);
break;
}
Sometimes if{} else if {} just isn't elegant enough.
|
#
¿
Mar 29, 2008 03:01
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
standard posted:
I found this in one of our apps this week.
code:
for (int i = 0; i < collection.getDetails().size(); i++) {
SomeObject object = (SomeObject)collection.getDetails().elementAt(i);
count++;
}
if (count < 1 || count> 10) {
isValid = false;
}
what the hell
Maybe they don't trust the collection.getDetails().size() method?
|
#
¿
Apr 19, 2008 19:05
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
chocojosh posted:
Stack: I tend to code regularly like this:
code:if(!isset($bravo))
$blah = here($something)
elseif(isset($charlie))
$blah = here($charlie)
else
$blah = nothere();
My logic is I hate wasting an entire line just to show a brace.
Unless you're using an 80 line monitor for some terminal from the '80s, there is no such thing as "wasting a line."
That being said, not putting in braces for single line conditionals is probably OK, though I almost always put in braces so that I'm never caught doing something likecode:if(!isset($bravo))
$blah = here($something)
elseif(isset($charlie))
$blah = here($charlie)
else
$blah = nothere();
somethingelse();
when I change my mind later.
|
#
¿
May 7, 2008 21:10
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
Randomosity posted:
I want to kill the people whose code I now maintain. And wtf is an 'appaplexy'
I would assume it's a misspelled apoplexy.
|
#
¿
Jun 17, 2008 21:46
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
ashgromnies posted:
Just ran across this while adding on some functionality to a project...
code:my $id = $req->param($unique_id);
That $id is an identifier given to us by one of our third-party integration partners. We also have different identifiers for users on our side and we map the two to eachother.
So that line grabs the user's third-party ID from the CGI request. Nothing weird, but then 20 lines below that in the same method...
It reassigns $id to $user->get_user_id() which is OUR identifier for users - and it called it on an instance of $user which it reassigns in the next line with the $id it just retrieved - what the gently caress I'm going to cry.
I don't know much Perl, but doesn't the my in front of $id and $user hide those variables within the scope of the if statement? So if you were commenting this, it might go something like:
code:if ($id) { #If the 3rd party id is set
my $id = $user->get_user_id(); #get our id for the current user, and then hide the 3rd party id so we don't have to worry about it
my $user = $self->get_user( $id, 1 );#get a copy of the current user
Still disgusting, but perhaps "sensical?"
|
#
¿
Sep 8, 2008 20:03
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
Munkeymon posted:
Just kill the guy who turned that poo poo in and maybe his job could be filled by someone who doesn't leave the # out of C#.
I think he's programing C♭ instead.
|
#
¿
Nov 21, 2008 23:51
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
Lone_Strider posted:
Holy poo poo, this is like a tell-tale mark for crappy devs. I bet when he was called on it he said "well I'm just making sure"
I'd say it's something more like "well that's how they did it in the on-line tutorial I more-or-less copied that code snippet from wholesale."
|
#
¿
Dec 8, 2008 21:58
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
The only one I see that's worth crying about is the willy-nilly truncation of the XML. I'd say that's a great way to magically create malformed XML. Maybe the fact that he's storing XML in a text field of some sort instead of an XML field, but I guess this is the "coding horrors" thread, not the "critique my dba by looking at 10 lines of application code" thread.
|
#
¿
Aug 17, 2009 16:36
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
Zombywuf posted:
On an SQL flavoured note, something I saw recently. With a table with an id and sub id, where the pair id, sub_id is unique, and sub_id is guaranteed to be 1, 2, etc... for each id.
code:WITH cte AS (
SELECT
...
row_number() OVER(
PARTITION BY id
ORDER BY sub_id
) AS rownum
FROM
...
) SELECT
*
FROM
cte
WHERE
rownum = 1
What's the horror here? I suppose if you can 100% guarantee that records with sub_id = 1 will never, ever, ever "go missing" then it's a bit redundant.
Or is the horror that he named that column "rownum" since that could possibly be a little bit misleading?
|
#
¿
Aug 26, 2009 17:53
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
chocojosh posted:wrok posted:
code: foreach (string item in _ptAttributeDic.Keys)
{
string val = _ptAttributeDic[item];
switch (item.ToLower())
{
case "mail":
if (string.IsNullOrEmpty(base._email))
base._email = val;
break;
case "facsimiletelephonenumber":
base._faxNum = val;
break;
case "telephonenumber":
base._phoneNumber = val;
break;
}
}
So this is such a bad varation of the for-switch that once it matches either "mail", "facsimiletelephonenumber", or "telephonenumber" it's going to exit the loop.
Unless the author meant to only initialize one of them, but then it would just be much easier to use
if(_ptAttributeDic.Contains("X"))
base._X = _ptAttributeDic["X"];
...
The break; in this example only exits the switch statement; it doesn't exit the loop. The one "benefit" to this particular foreach-case is that it replaces checking for the existence of each key, but then of course it does so at the cost of looping through each key of the dictionary. I suppose if the dictionary in question was only going to contain at most the three keys used here it might even count as a clever trick, but other than that it's a pretty standard example of the for-case paradigm.
|
#
¿
Oct 6, 2009 16:28
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
rt4 posted:
Professors: fine for theory, always wrong on code.
Well, in this case I find it far more likely that the dude misunderstood what the professor said, or the professor misunderstood what was being asked.
But I guess that's less funny, so forget I said anything. CS Professors = poo poo.
|
#
¿
Mar 19, 2010 17:11
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
Broken Knees Club posted:
So why is this Epic thing treated like the bubonic plague?
http://thedailywtf.com/Articles/A_Case_of_the_MUMPS.aspx
|
#
¿
Apr 22, 2010 21:28
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
clockwork automaton posted:
An entire class where the only comment is
Thanks guys. That comment is TOTALLY useful.
Sometimes comments are useful for what they tell you about the commenter.
|
#
¿
May 13, 2010 17:54
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
ColdPie posted:
So you'd argue that the library is small enough to just be memorized? I guess I don't disagree. It just seems harsh to me to call it a horror when someone isn't familiar with non-obvious functions like atan2 and fmod.
No, he'd argue that the library is small enough that one could search through the documentation. Hence his use of the term "use documentation" not "memorize documentation".
|
#
¿
May 14, 2010 20:31
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
quote:C89
[snip]
This version of the language is often referred to as "ANSI C", or sometimes "C89" (to distinguish it from C99).
[snip]
C99
In March 2000, ANSI adopted the ISO/IEC 9899:1999 standard. This standard is commonly referred to as C99
So C99 has been adopted by ANSI as the current standard for the C Programming language, but it is not "ANSI C".
|
#
¿
Jan 24, 2011 22:27
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
Flobbster posted:
I mean that's cool and all, but I chuckled at which of the words they deemed important enough to have special cases, like "buffalo" and "tomato", but "potato" gets left out.
Dan Quayle account found.
|
#
¿
Apr 12, 2011 18:46
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
shrughes posted:
Inheritance
"To an external observer, inheritance of T from U is indistinguishable from the presence of a conversion function from T to U."
- Confucious
I was simply saying that from an external observer inheritance of T from U is indistinguishable from the presence of a conversion function from T to U.
This is only true of inheritance without polymorphism.
|
#
¿
Aug 12, 2011 19:36
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
baquerd posted:
The problem was that you kept using the word variable wrong.
code:int i = 0;
Object foo = new Object();
Object bar;
i, foo, and bar are variables. Variables are not objects. Variables have values. The value of i is 1. The value of foo is a reference to an object with type Object. foo is not the object that we created, it is a variable whose value is a reference to that object. bar has no value, since it is uninitialized, but it can hold a value which is a reference to an object of type Object. It is not an uninitialized object, since it is not an object. If the next line of code was this bar = foo;, then both foo and bar would be variables that contain references to the same (unnamed) object created above.
Jethro fucked around with this message at 21:13 on Sep 26, 2011
|
#
¿
Sep 26, 2011 21:09
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
Except, unless I'm misunderstanding what he meant by "the version of binary search that I wrote for the JDK," the binary search in the Java standard library contained this bug. Furthermore, unless Joshua Bloch is uncommonly stupid for a developer of standard libraries, it is likely that other standard libraries with a binary search had this bug.
|
#
¿
Nov 17, 2011 20:03
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
Speaking of poorly named variables...
code:SELECT ...
FROM (SELECT ...
FROM ...
WHERE ...
GROUP BY ...
UNION ALL
SELECT ...
FROM ...
WHERE ...
GROUP BY ...) AS tblFoo
GROUP BY tblFoo.hour;
It's not a table, the naming convention in the database is to POST-fix 'Tbl' (I have no loving idea why), and 'Foo' describes precisely nothing about the purpose or nature of the data.
Fuckers.
I'm not seeing too much that's objectionable here. When you're joining a bunch of tables together it's nice to have reasonable aliases so you don't have to keep asking yourself "which table is A? Which table is AA?", but if tblFoo isn't being joined to anything, it's not like you have to go hunting for the definition. Heck, probably the only reason it even has a name at all is because T-SQL requires them for derived tables.
As for putting Tbl at the end of table names, sometimes it's nice to know when you're working directly with a table or with a view. It's not like you're going to run into the problem of Hungarian notation where the name is out of sync with the type.
|
#
¿
Nov 27, 2012 21:51
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
Okay, so you're using Lua. These problems are somewhat understandable on a cross-platform language.
But loving Windows Poweshell. How in the gently caress can executing programs from under Program Files be so loving difficult in a shell designed for Windows.
I was tearing my hair out with the equivalent of "c:\Program Files\ImageMagick-6.8.2-Q16\convert.exe" "C:\Users\My Username\Pictures\some file with spaces 1.png" -resize 50% "some file with spaces 1.gif"
Where the number in the file name came from a loop index variable.
I've been using Powershell pretty heavily for about a year now. I have no idea how to call an executable that isn't in the current path, so when I have to do so, I just give up and Set-Alias.
|
#
¿
Jan 30, 2013 22:31
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
The same way as you would normally? Or have you found some problematic scenario I have not discovered yet in my mere three months?
code:PS C:\Users\essoess> c:\tee\tf.cmd help
Team Explorer Everywhere Command Line Client (version 11.0.0.201207250346)
Available commands and their options:
Well, the problem scenario occurrs when running an executable with a space in the path. I have just now done some research and discovered that the call operator "&" isn't just for running scripts.
code:PS C:\Users\Jethro> C:\Program Files\Something\program.exe
The term 'C:\Program' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:11
+ C:\Program <<<< Files\Something\program.exe
+ CategoryInfo : ObjectNotFound: (C:\Program:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\Jethro> "C:\Program Files\Something\program.exe"
C:\Program Files\Something\program.exe
PS C:\Users\Jethro> &"C:\Program Files\Something\program.exe"
I am a program that does a thing
So I feel a bit silly. The point still stands that Powershell can be a bit obtuse, even if the design reasons behind that obtuseness often make sense. But I guess this thread is for alternating between feeling silly and feeling smugly superior.
|
#
¿
Jan 31, 2013 19:17
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
Anyway, after a quick look at the git website, it seems like it's a standalone version control program. Is this true? Is it any good?
All your questions can be answered here. Here's a summary: "git is awesome, git is good, please use git like all coders should. mercurial is cool too."
|
#
¿
Apr 17, 2013 17:37
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
Which would be awfully nice for the compiler to know, but it doesn't.
Whether or a pointer points to an element of an array is something determined at runtime based on what the pointer actually points to. The fact that the compiler doesn't (and can't) know whether the pointer points to an element of an array is why section 6.5.6 is written how it is, and it's also why the behavior in question is undefined, as opposed to an error.
|
#
¿
Feb 6, 2014 02:03
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
I'm just gonna leave this here and let you pick your own horrors
Making fun of student projects just isn't fair.
And this is my first real dev job.
Oh... I'm so sorry.
|
#
¿
May 9, 2014 16:54
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
Many are afraid of doing something damaging by accident.
This is, from my limited experience on the helpdesk back in the day, one of the biggest things that prevented people from ever getting better at using their computers.
|
#
¿
Jun 12, 2014 17:12
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
radium was a great source for TFC maps back in the day.
|
#
¿
Aug 14, 2014 16:17
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
If no one will ever see what I'm prototyping, I usually go with butts, lol, and what.
|
#
¿
Nov 7, 2014 15:51
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
I always thought the reason for mocks was you want to test A, which uses C, but C hasn't been implemented yet.
Or C is your 500 GB database. Or you want to see that A responds properly when C fails in certain ways, so you write a mock C that just behaves like a broken C. Or...
|
#
¿
Aug 4, 2015 18:25
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
No need to be a dick about it. I'm well aware of the Parse overloads, but I still don't understand why Parse(string) defaults to converting to local time instead of just setting Kind to Utc.
If you aren't being careful about timezones and whatnot, then you probably don't care about them, so you might as well just leave everything in local time.
|
#
¿
Sep 18, 2015 19:05
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
What I've done is copied the entire column to notepad and back in - since copy to clipboard copies the displayed value, and not the "actual" value, thus dropping the formatting and preserving what I want, but still - how is that sane?
The vast majority of the time users will enter data into a spreadsheet as a string representation, but then they want it to be treated as data, not a string. So it makes perfect sense to take strings that look like numbers, dates, or times and automatically convert them to numbers, dates, or times respectively. If you want something that looks like a number, date, or time to stay a string, put a ' in front of it.
Maybe it might make sense to have the CONCATENATE function automatically use the formatting of the source column when it outputs the string, but if you're already doing string manipulation with functions, just use more functions to make sure the output is exactly what you want.
|
#
¿
Mar 29, 2017 17:05
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
Still, as an inexperienced user with Excel this behaviour strikes me as absurd - if I saw "0.416667" in the top bar, but "10:00:00" in the cell, I'd know the matter is with formatting of a specific value. If I see 10:00:00 in both I'm thinking - this is definitely a string. And I know for sure the person that created the sheet didn't apply time formatting to this column, so why should the app in this case try to fix the data for the user?
If the word "string" means anything to you other than twisted plant or synthetic fibers you are probably more advanced than most Excel users. There are definitely some times when Excel's magic data type conversion causes problems (see the examples above). I see it all the time at my company (lots of items with identifiers like 111E-00 that Excel changes to 1.11E+02). But ultimately spreadsheets are about manipulating data, so Excel has to take what users type and automatically turn it into data without much effort on the part of non-technical users to be of any value. If a user couldn't type 1,000 in one cell and 1500 in another and then add them together without having to do anything else, or have 10:00 and 9:00 sort properly, Excel wouldn't be used everywhere. So maybe it is a bad thing quote:
edit: to clarify - if I open a blank spreadsheet, put in first cell: "10:00:00", second cell "=CONCATENATE("Time is ";A1)" I don't expect it to output: "Time is 0.416667" and I consider it weird that that's the standard behavior.
The magic has to stop somewhere, and a function that depends on you knowing what string means is as good a place as any and probably better than most.
|
#
¿
Mar 29, 2017 19:34
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
That are great points you're making - especially about sorting "9:00" and "10:00"; still, I'd say I prefer Google's approach - it is, what it is, until user makes a conscious decision about changing it
Where does google do that?
Only registered members can see post attachments!
|
#
¿
Mar 29, 2017 20:48
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
e. no wait, I misread you, you're more or less saying what I said.
|
#
¿
Jul 26, 2017 15:38
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
I assume they meant the smallest undefined program that always finishes normally.
Maybe shortest "non-trivial" program.
|
#
¿
Sep 6, 2017 17:57
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
Apr 29, 2024 19:59
|
|
- Jethro
- Jun 1, 2000
-
I was raised on the dairy, Bitch!
|
If you try to represent the number 1.0000000001 as a float32, it will be truncated to 1.0. If you then use that 1.0 to do perform operations with a float64, you will get a different answer than you would had you put 1.0000000001 in a float64 to begin with. If the result is a float64, you may think you've got the precision of a float64 when your precision is really only that of the float32 you started with, and any digits outside of that are spurious.
That said, the solution to a programmer making such a mistake is still probably not to silently downcast to float32. Silently limiting the range of possible results and throwing away digits is not a good way to handle the fact that some of those digits might not be correct in some rare circumstances. And it's definitely always wrong when we're talking about integer types.
|
#
¿
Sep 29, 2017 15:09
|
|