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
Beef
Jul 26, 2004

Goat Bastard posted:

Maybe I am the horror for expecting two references to the same thing to behave in the same way.

You should read up on Java's and C++'s object model if you find that confusing.

static vs dynamic dispatch

Then read the following spoiler.

In C++ everything is static dispatch unless you use the keyword 'virtual' in front of the method declaration. In Java all methods are automatically virtual, but data members aren't methods...

Beef fucked around with this message at 15:53 on Mar 12, 2012

Adbot
ADBOT LOVES YOU

hobbesmaster
Jan 28, 2008

I'm not sure whether this makes me laugh or cry...

Lets see here:

quote:

When the GA creates the transfer certificate, it gives it a one year validity range. It uses midnight UST of the current day as the valid-from date and one year from that date as the valid-to date. The leap day bug is that the GA calculated the valid-to date by simply taking the current date and adding one to its year. That meant that any GA that tried to create a transfer certificate on leap day set a valid-to date of February 29, 2013, an invalid date that caused the certificate creation to fail.

I'm assuming they're not eating their own dogfood here?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
I'm becoming convinced that Microsoft, almost as a rule, never eats its own dogfood.

It explains garbage like Sharepoint so tidily.

pseudorandom name
May 6, 2007

Alternate theory, it's written in C++, uses GetSystemTime(), and they didn't read the warning hidden away in the SYSTEMTIME page about modifying the struct to get relative times.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

pokeyman posted:

I'm becoming convinced that Microsoft, almost as a rule, never eats its own dogfood.

It explains garbage like Sharepoint so tidily.

Which is rather ironic considering that the term came from Microsoft.

hobbesmaster
Jan 28, 2008

pokeyman posted:

I'm becoming convinced that Microsoft, almost as a rule, never eats its own dogfood.

It explains garbage like Sharepoint so tidily.

They do use sharepoint. They also host all their email on exchange and 99% of their infrastructure is windows server.

Contra Duck
Nov 4, 2004

#1 DAD

hobbesmaster posted:

I'm not sure whether this makes me laugh or cry...

Lets see here:


I'm assuming they're not eating their own dogfood here?

You'd think they would learn after the Zune leap year bug in 2008.

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.

pokeyman posted:

I'm becoming convinced that Microsoft, almost as a rule, never eats its own dogfood.

It explains garbage like Sharepoint so tidily.

A recruiter was talking about flying me out to redmond to interview with the "MS Office Team" for a SDET position. I was tempted but then I figured out the job was really about sharepoint and that tempered my interest level rather significantly.

Captain Capacitor
Jan 21, 2008

The code you say?

hieronymus posted:

A recruiter was talking about flying me out to redmond to interview with the "MS Office Team" for a SDET position. I was tempted but then I figured out the job was really about sharepoint and that tempered my interest level rather significantly.

I just did that in January (different team, though). You should go just for the sweet-rear end hotel they let you stay in.

Chuu
Sep 11, 2004

Grimey Drawer

shrughes posted:

You're saying that as if silently falling through would be a good thing. Which it is not. Crashing the program there is basically the only thing to do. In our C++ code every switch statement has a default case that calls a function unreachable() which prints a backtrace and crashes.

I am blatantly stealing this for use in my own code.

shrughes
Oct 11, 2008

(call/cc call/cc)

Chuu posted:

I am blatantly stealing this for use in my own code.

It might be useful to have __attribute__((noreturn)) (a GCC attribute) on that function.

Our unreachable() is actually defined as a macro unreachable(msg, ...) (producing an expression which gets the noreturn property by calling abort()) for some reason.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
If that's because it gets compiled out in release builds, you might consider having it compile to __builtin_unreachable() in GCC and Clang.

shrughes
Oct 11, 2008

(call/cc call/cc)

rjmccall posted:

If that's because it gets compiled out in release builds, you might consider having it compile to __builtin_unreachable() in GCC and Clang.

It's not. The breakpoint/stacktrace is compiled out, but that's no reason it couldn't have been a pair of functions. There's basically no reason why it's a macro, come to think of it.

Frozen Peach
Aug 25, 2004

garbage man from a garbage can
I just found this code in production.

Let's play the "how many errors can you spot" game.

php:
<?
if (isset($_POST['emailMessage'])) {
    if ($_POST['contact'] == 'librarian') {
        $strSQL = 'SELECT EMAIL from registration where id = \'' . $id. '\'';
        $result = $db->query($strSQL);
        $To = 'olddeveloper@company.com';
        if ($db->num_rows($result) != 0) {
            $Registration = $db->fetch_assoc($result);
            $To = $Registration['EMAIL'];
        }
    } else {
        $To = $Email;
    }

    $message .= 'Name: ' . $_POST['name'] . "\r\n\r\n";
    $message .= 'Email Address: ' . $_POST['email'] . "\r\n\r\n";
    $message .= 'Subject: ' . $_POST['subject'] . "\r\n\r\n";
    $message .= 'Message: ' . $_POST['message'] . "\r\n\r\n";

    $mail = new Zend_Mail();
    $mail->setBodyText($message);
    $mail->setFrom($_POST['email'], $_POST['name']);
    $mail->addTo('olddeveloper@company.com', 'Old Developer');
    $mail->setSubject('Message from Company contact form');
    //$mail->send();

    $status = 'Message Sent!';
}
?>
I'll give you the first error for free. This post uses <input type="image" name="emailMessage"> instead of a submit button. Which means you need to check emailMessage_x or emailMessage_y rather than emailMessage. The code was never even entering the if statement to begin with.

Impotence
Nov 8, 2010
Lipstick Apathy
Zend_Mail does sanitisation in any way right..?

Frozen Peach
Aug 25, 2004

garbage man from a garbage can

Biowarfare posted:

Zend_Mail does sanitisation in any way right..?

quote:

For security reasons, Zend_Mail filters all header fields to prevent header injection with newline (\n) characters. Double quotation is changed to single quotation and angle brackets to square brackets in the name of sender and recipients. If the marks are in email address, the marks will be removed.

Fortunately, yes. That is not one of the horrors. (Unless the Zend_Mail docs are wrong, which could also be a horror :ohdear:)

The Gripper
Sep 14, 2004
i am winner
Haha how did that even come about, guy must have had some severe ADHD; checks if you're contacting the librarian, executes some SQL that doesn't actually take any parameters from $_POST anyway, if it's not going to the librarian it uses some magic $Email variable, ignores the result either way, then concludes by not sending an email and notifying the user that the email was sent.

I bet he wrote it that way as a kind of "why isn't this working? i'll gradually hardcode things until it works..." fix for not using the right $_POST['x'] variable for an image, but couldn't figure out why the email never got sent anyway and just gave up.

Frozen Peach
Aug 25, 2004

garbage man from a garbage can

The Gripper posted:

Haha how did that even come about

For some background, the contact form is for a webapp that creates a custom donation site for libraries. A librarian can sign up for our service, then give the information to a volunteer to be the "program operator." The contact form is so that a donor can come to the site, and either ask the librarian or the person actually running the program questions.

The $id that it uses to pull back the librarian's registration information is set by our header files. The $Email that's used if it's not contacting the librarian is also set by our header files. Those two are legit, and also properly secured and validated.

As for the rest, I have no idea. He had to have tried to fix it, couldn't figure out why it wasn't working, thought he'd go back to it... and then it went into production untested.

The Glumslinger
Sep 24, 2008

Coach Nagy, you want me to throw to WHAT side of the field?


Hair Elf

pokeyman posted:

I'm becoming convinced that Microsoft, almost as a rule, never eats its own dogfood.

It explains garbage like Sharepoint so tidily.

Everyone there uses Firefox, Google, and has iPhones

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
I can't tell if you're being serious.

PalmTreeFun
Apr 25, 2010

*toot*

pokeyman posted:

I can't tell if you're being serious.

I can't say I'd blame them.

Suspicious Dish
Sep 24, 2011

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

pokeyman posted:

I can't tell if you're being serious.

While I heavily believe in dogfooding, I really don't understand the problem with using Firefox and Google and such. Probability says that there's probably someone there who uses Bing because he likes it better or because he believes in the company, but if your day job is hacking on PowerPoint or Kinect or something, why does it matter if you use Google?

There's no sense in an "all employees must use Bing" policy. I bet that the same is true for most other places as well - there's probably a guy at Google who prefers GitHub instead of Google Code Hosting, and a guy at Apple who works exclusively on Windows or Linux.


That said, the one thing that I'm disappointed in is that from my understanding, Microsoft has no commercial desktop products written in the .NET framework. A colleague who works at Xamarin says that SQL Server Management Server 2010 may have a small part of it that's written in WPF. In my opinion, you can't build a platform and make decisions for a platform if the first customer for your platform isn't yourself. If you're not in the trenches using the platform on a day to day basis, your only feedback about the quality of it is customer feedback, which isn't really that useful.

In fact, I find myself disgusted at some of the new features in C# 4.0 which are plastered with the "Do Not Use" disclaimer - default function arguments, as an example.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Visual Studio 2010 uses WPF, and SSMS uses a lot of stuff from VS, so I'd expect it to be more than a small part.

I've been told by a friend who works on Office that antitrust concerns stopped them from using .NET, as it could be viewed as them using a near-monopoly to give their platform an unfair advantage. The settlement finally expired last May, but WinRT suggests that they're still not planning to use .NET for their desktop apps.

Suspicious Dish
Sep 24, 2011

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

Plorkyeran posted:

I've been told by a friend who works on Office that antitrust concerns stopped them from using .NET, as it could be viewed as them using a near-monopoly to give their platform an unfair advantage. The settlement finally expired last May, but WinRT suggests that they're still not planning to use .NET for their desktop apps.

OK, yeah, that's a fair answer. If it's a considerable risk for the company to build products on its own platform (ugh law) then it makes sense not to do it.

A A 2 3 5 8 K
Nov 24, 2003
Illiteracy... what does that word even mean?
Here's how dogfooding worked at eBay. Skype is such a lovely instant messenger that of course employees (outside of the Skype unit) didn't want to use it. Management didn't want to admit or was embarrassed to admit that the only way to get people to use Skype instead of AIM was by forcing them.

So the "IT department" disallowed AIM usage due to a mysterious, unnamed, made-up "security flaw" in the client. Oddly that "security flaw" never got fixed even after years of updates to the official client.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Suspicious Dish posted:

While I heavily believe in dogfooding, I really don't understand the problem with using Firefox and Google and such.

I don't have a problem with it either. I literally wasn't sure if crazylakerfan was being serious.

quote:

In fact, I find myself disgusted at some of the new features in C# 4.0 which are plastered with the "Do Not Use" disclaimer - default function arguments, as an example.

You're not supposed to use default function arguments in C# 4.0?

The Gripper
Sep 14, 2004
i am winner

pokeyman posted:

You're not supposed to use default function arguments in C# 4.0?
I was thinking the same thing. Off the top of my head I can't think of a single available feature that has that disclaimer, even in previews.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

pokeyman posted:

You're not supposed to use default function arguments in C# 4.0?

There are a few little wriggles with default function arguments. They're not specific to the C# implementation - in fact most optional-parameter implementations have a huge morass of odd behaviour under some conditions.

As a quick example, this:

code:
void Butts() {
  Butts(42);
}

void Butts(int i) {
//etc.
does not behave the same as:

code:
void Butts(int i = 42) {
//etc.
If you use the default value, then that value gets baked in to the call site. So if you ship a new version:

code:
void Butts(int i = 16) {
//etc.
Then any existing code that just calls Butts() will still use the old default value - until they get recompiled. This is a pretty nasty trap if you're doing something where stuff might not get recompiled just because a library it uses is updated.

The Gripper
Sep 14, 2004
i am winner

Jabor posted:

Then any existing code that just calls Butts() will still use the old default value - until they get recompiled. This is a pretty nasty trap if you're doing something where stuff might not get recompiled just because a library it uses is updated.
That's a good point, though I can't imagine it's good practice to change default values without being explicit in recompiling any code using it.

You can get around it somewhat by using nullable defaults:
code:
void Butts(int? i = null) {
    if (i.Equals(null)) i = 42
    Console.WriteLine(i);
}
This way the default is baked in as null, and the library is free to test for that and provide it's own default without a recompile.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
http://www.jstree.com/documentation/dnd

This is kind of subtle, I think. I mean, on the surface the page has a clean layout, it looks like it's very well documented and has nice examples with syntaxt highlighting and all.

But look at the "Reorder only demo"

Specifically the check_move function:
First: Who the gently caress makes code examples with 1-character variable names?

code:
var p = this._get_parent(m.o);
Cool "p", and the underscore implies that the function is meant for internal use only. Maybe there is something wrong with your interface if you need to use intenal functions in example code?

And what in the gently caress is m.o?

And a couple of lines later
code:
if(p[0] && m.np[0] && p[0] === m.np[0])
np? How about fu! (np means the new parent, from http://www.jstree.com/documentation/core.html )

The only one-character member names you are allowed to use in public interfaces are "x, y, z", "r, g, b" and "i, j, k", and those are all some kind of vectors.
:rant:

Vanadium
Jan 8, 2005

Wheany posted:

The only one-character member names you are allowed to use in public interfaces are "x, y, z", "r, g, b" and "i, j, k", and those are all some kind of vectors.
:rant:

What about $ then? :colbert:

The Gripper
Sep 14, 2004
i am winner

Wheany posted:

:rant:
The worst is with concurrency frameworks and the like, where the most promising looking example is almost always some complex mathematical computation which probably looks clean and makes a lot of sense to someone that knows that particular math, but to anyone else it's difficult to separate "here's the code I need to use to implement this for my own use" from the "holy god m=p*x ^ 7; _,x=sub1(-y^(x)^add1(m));" part.

I know it's good to have examples that actually do something real and the developers probably have a strong math background, but giving me something like that when I don't even know which parts are the framework and which parts are the payload isn't all that productive.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Vanadium posted:

What about $ then? :colbert:

Which $ do you mean? jQuery or Mootools? :smug:

Zhentar
Sep 28, 2003

Brilliant Master Genius

Suspicious Dish posted:

In fact, I find myself disgusted at some of the new features in C# 4.0 which are plastered with the "Do Not Use" disclaimer - default function arguments, as an example.

pokeyman posted:

You're not supposed to use default function arguments in C# 4.0?

Optional Parameters were added primarily to make COM interop less painful. They have some caveats otherwise (especially if you mix overloads and optional parameters with the same function).

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Zhentar posted:

Optional Parameters were added primarily to make COM interop less painful. They have some caveats otherwise (especially if you mix overloads and optional parameters with the same function).

Well optional parameters aren't the same as parameter defaults, though in C# I understand you can't do one without doing the other.

That said, what are the caveats when using optional parameters in C#?

Scaevolus
Apr 16, 2007

The Gripper posted:

code:
void Butts(int? i = null) {
    if (i.Equals(null)) i = 42
    Console.WriteLine(i);
}
Good luck calling a method on a null object.

code:
void Butts(int? i = null) {
    i = i ?? 42;
    Console.WriteLine(i);
}

The Gripper
Sep 14, 2004
i am winner

Scaevolus posted:

Good luck calling a method on a null object.

code:
void Butts(int? i = null) {
    i = i ?? 42;
    Console.WriteLine(i);
}
It actually works fine, as nullable types are System.Nullable<T>, exposing a bunch of methods for this kind of task. I probably should have used i.HasValue instead of i.Equals(null) though (even though the latter works).

http://msdn.microsoft.com/en-us/library/b3h38hb0.aspx

Zhentar
Sep 28, 2003

Brilliant Master Genius

pokeyman posted:

That said, what are the caveats when using optional parameters in C#?

There are two main ones that I'm aware of. First, the default values are just syntactical sugar for the caller - that is, missing values are not filled in at runtime, but are added to the call site at compile time. This means if you want to change the default value of a parameter, you need to recompile any callers as well.

Second, it adds a complication to overload resolution, and won't always behave how many people expect it to. If you make optional parameters using both overloads and default values, it gets hard to understand what your code will actually call.

Also, default values and interfaces are... weird, at best.

ToxicFrog
Apr 26, 2008


The Gripper posted:

The worst is with concurrency frameworks and the like, where the most promising looking example is almost always some complex mathematical computation which probably looks clean and makes a lot of sense to someone that knows that particular math, but to anyone else it's difficult to separate "here's the code I need to use to implement this for my own use" from the "holy god m=p*x ^ 7; _,x=sub1(-y^(x)^add1(m));" part.

I know it's good to have examples that actually do something real and the developers probably have a strong math background, but giving me something like that when I don't even know which parts are the framework and which parts are the payload isn't all that productive.

I can't help but feel that a lot of code like this would be more readable if the mathparts could be written in - and rendered properly by the editor as - LaTeX.

Adbot
ADBOT LOVES YOU

The Gripper
Sep 14, 2004
i am winner

Zhentar posted:

Second, it adds a complication to overload resolution, and won't always behave how many people expect it to. If you make optional parameters using both overloads and default values, it gets hard to understand what your code will actually call.
The ambiguity rules are n't helpful for it too, using signatures like this isn't a compile-time error if you call Butts(1,2) despite matching both:
code:
public static void Butts(int x, int y) { Console.WriteLine("Butts(int,int)"); }
public static void Butts(int x, int y, string z="1") { Console.WriteLine("Butts(int,int,string)"); }
but signatures like this are if you call Butts(1):
code:
public static void Butts(int x, int y=1) { Console.WriteLine("Butts(int,int)"); }
public static void Butts(int x, string y="") { Console.WriteLine("Butts(int,string)"); }
The call is ambiguous in the first case, but for whatever reason it isn't picked up.

I've had to fix up code once or twice at work where someone has accidentally hidden one method with another this way.

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