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
Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction
You should suggest more vertical whitespace. An extra line break for every line or it's not readable :colbert:

Adbot
ADBOT LOVES YOU

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

Zakalwe posted:

3000 lines is :psyduck:, but there's nothing wrong with using the occasional goto. "Never ever use goto" is generally promulgated by people who've heard of Dijkstra's article but never read the drat thing.

I'm skeptical that goto has a valid place outside of perhaps some simple scripting. I challenge you to show me a valid example of goto use in modern object oriented code.

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

subreality posted:

The same guy also wrote a login.php that went a little something like this:
php:
<?
  $logged_in = false;

  $users = mysql_query("SELECT * FROM users");

  while ($row = mysql_fetch_assoc($users)) {
    if ($row['username'] == $_POST['username'] && $row['password'] == $_POST['password']) {
      $user_id = $row['id'];
      $logged_in = true;
    }
  }
?>
He probably only read the first page of the PHP/MySQL tutorial...

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction
code:
year = ORIGINYEAR; /* = 1980 */

while (days > 365)
{
    if (IsLeapYear(year))
    {
        if (days > 366)
        {
            days -= 366;
            year += 1;
        }
    }
    else
    {
        days -= 365;
        year += 1;
    }
}
Whoops :ohno:

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

Zakalwe posted:

code:
bool is_odd(const int a)
{
        return( a%2 == 0);
}

Perfect for the thread right here

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

The Evan posted:

"I've set up a massive switch statement that consists of all the prime numbers up to 271"

He hard-coded a LUT for primes. Mother of god. Somewhere in my deep dark past, I recall reading an optimization suggestion that checking prime-ness is so easy computationally that making a table is a complete waste of memory, even ROM.

What made him stop at 271, anyway?

:psyboom:

Whoooosh

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

Lexical Unit posted:

Exhibit 3
code:
int pants_size = 0; // global
int pants_type = 0; // global

void handle_pants_event(int size, int type)
{
	if (pants_size == 0 && pants_type == 0)
	{
		pants_type = type;
		pants_size = size;
	}
	else if (pants_size != size || pants_type != type)
	{
		pants_type = type;
		pants_size = size;
	}
}

I do not understand how even the most novice day 1 programmer could look at this and think it is okay.

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

dancavallaro posted:

The Something Awful Forums > Discussion > Serious Hardware / Software Crap > The Cavern of COBOL > WOW6432 Megathread?

:smug:

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction
It's indicative of 1:1 mental modelling to code, and shows that to him the code only makes sense if it explicit returns "true" somewhere and "false" somewhere else. There's no jump to the higher order of thinking where the return value of the call can be returned, or once you've achieved that, possibly scrapping the helper function altogether because you realize the inner call does everything you need.

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction
I just figured it was the worlds only example of good php code.



:cool:

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

MrMoo posted:

while (0) is used to allow a semicolon after the macro call, it's pretty much the only place it should be used.

Another piece of ammunition for my next anti macro rant.

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

Avenging Dentist posted:

Congrats on being ignorant.

lol defending macros

quote:

Who is this hexadecimal you all keep implying I am, which I am not?
We know you'll get perma'd again if you admit it, so don't feel like you have to individually respond to everyone who outs you.

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction
Why not execute it in a loop as a single dynamic sql statement that uses string concatenation to specify the correct variable



:ughh:
:negative:
:suicide:

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

Argue posted:

Okay, here comes another wonderful piece of architecture from our client, incidentally a very large company that's well-known in my country.

There's an HTTP server running, and it listens for requests such as "reset PIN#". When the server receives such a request, it dumps the connection into a pool, and queues up the request for processing by another thread, the service thread.

Now, the service thread does its processing (which is partly what my previous posts were about), and generates a response. How do you suppose this response gets sent back to the original requester?

That's right! It doesn't! Instead, it just plucks any connection out of the pool, and returns the response there. The results are exactly as you might expect. One guy might receive a "successful" confirmation message when his transaction failed, and vice versa. :toot:

This is wonderful

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

yaoi prophet posted:

If I ever write a language this will be a compile-time error.

I have discovered exactly one useful case for an empty exception handler: on Windows when you attempt to launch a process with elevated privileges (such as, relaunching yourself from standard user -> admin with some state parameters) and the user hits cancel, the C# process class throws an exception. But it's very possible you don't want to do anything if they hit cancel. So just swallow.


~~~TMYK~~~

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

Wheany posted:

code:
//not needed anymore
/*
function someFunction(){

}
function someOtherFunction(){

}
function yetAnotherfunction(){

}
*/

This is just someone who's not used to version control and/or wants the logic of those functions readily available for some reason.

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

NotShadowStar posted:

And that's why you always, always, always use equals equals equals in javascript!

Then you're be writing is_feature_supported[i] === "true" which would be a worse horror. If you're going to play along with that array of features business then just use actual bools.

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction
this whole page is the horror

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction
What? No it doesn't, at least circa 2008. Are you running an addin that's doing it for you like something from RedGate?

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

TRex EaterofCars posted:

Yeah it does. In both 2005 and 2008 R2 at least.

Open SSMS, go find a table, right click on it, Script Table as >, SELECT To >, New Query Editor Window. Commas first.

I stand corrected. It doesn't do that for drop/create script creation though, which is what I checked when I read your post.


Anyway, gross. Add that to the unending list of SSMS failures I intend to solve with my SQL IDE.

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

angrytech posted:

Wait, there's supposed to be a turtle in that gif?

haha

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

w00tz0r posted:

"Forward compatibility is easy, all Microsoft products are completely forward compatible. I can write a program on Windows Vista and have it run on Windows 95. The only thing that broke forwards compatibility is UAC."

:allears:

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

tef posted:

also, 'ruby is written in c so it's fast' :allears:

ruby + mysql via orm, the fastest way to write your web three point blah apps for

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction
I'm guessing you can't update any other records besides your own though, right? They probably didn't have time/care to write a web service interface just to show you high scores in the game.



I hope.

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

Threep posted:



Welp.


You know what, "write a bit of sane database interface code" should replace FizzBuzz as the idiot filter.

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

Dicky B posted:

indie_game_developers.txt posted:

fully block all incoming attacks.

:allears:

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

Zombywuf posted:

Aside from that, what the hell are you doing in that other 95ms? Seriously? Factoring the user's IP address?

The jig is up, Zombywuf, your trolling has now become obvious

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction
From reddit

quote:

Javascript thinks that 64.99 * 100 is 6498.999999... Go ahead, try it any way you like. If someone can explain this, I'll be eternally grateful.
submitted 2 hours ago by collin_ph
Ok, javascript post. More laffeaux javascript nonsense?


Nope, just floating point. And this is pointed out:

quote:

I don't think you understand how floats are stored in memory. Click on any of the links posted and read up on it.

But then,

redditor collin_ph posted:

I'm wondering who's bright idea it was to do this. It's funny after programming for nearly 30 years, I run into this TODAY. Makes me feel kind of dumb-- however, I wonder how people avoid this type of thing with MONEY.

...


I'm an Oracle certified DBA, worked for the government for about 16 years, and most recently as an IS manager.

Uhhh...

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

Golbez posted:

God help you if you order the same amount of something twice in one day.

Well, not to excuse the godawful design, but assuming that DATETIME has a time component as I assume it ought, then you're probably ok.

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction
:stare:

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction
This must be what the nosql revolution looks like

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

plushpuffin posted:

Just got this gem the other day from the senior developer / project lead:


code:
public class MyClass
{
    /// <remarks>
    /// It's okay to make this static because
    /// MyClass is only used as a singleton, but
    /// I wish I didn't have to make it public, too.
    /// </remarks>
    public static HashSet<int> SomeSetModifiedByMultipleThreads;
}

Haha this is so precious, I love it

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction
The next time that "everyone should learn to code" meme sweeps through hacker news, remember how!! exists and shudder.

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

Zhentar posted:

I don't know about faster, but it's definitely easier to use a dummy date and write
SQL code:
WHERE @date BETWEEN table.START_DATE AND table.END_DATE
than it is to write
SQL code:
WHERE @date BETWEEN table.START_DATE AND table.END_DATE
	OR @date >= table.START_DATE ANd table.END_DATE IS NULL

SQL code:
WHERE @date BETWEEN isnull(table.START_DATE, '0001-01-01') AND isnull(table.END_DATE, '9999-12-31')

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

Bunny Cuddlin posted:

I have a Kinect sensor attached to my computer and I wrote an app that sits between my PC and the database server and it only allows me to run destructive commands if I do a little voodoo dance and say a magic word can we get off this please

https://www.youtube.com/watch?v=Mx-Y8KFFHpE

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

Aleksei Vasiliev posted:

I've never seen this in a Java library, but .NET loves it and I loving despise it.

As I'm sure I've posted before in this thread, there's certain cases where "what makes good sense" for the situation and Hungarian notation overlap. Naming Windows Forms buttons "btCancel" isn't a horror, and neither is naming your interfaces I*, especially because it matches the standard .NET naming convention for interfaces:

quote:

*Name interfaces with nouns or noun phrases, or adjectives that describe behavior. For example, the interface name IComponent uses a descriptive noun. The interface name ICustomAttributeProvider uses a noun phrase. The name IPersistable uses an adjective.
*Use Pascal case.
*Use abbreviations sparingly.
*Prefix interface names with the letter I, to indicate that the type is an interface.
*Use similar names when you define a class/interface pair where the class is a standard implementation of the interface. The names should differ only by the letter I prefix on the interface name.
*Do not use the underscore character (_).

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

DAT NIGGA HOW posted:

If this guy is as smart about crypography as he makes himself out to be with his tone in the article, they why is he spending his time writing blog posts? Why should I trust this guy's assessment at all? Maybe if he had an alternative that other experts can either agree is done right, then I'll listen to him. Otherwise its just blogspam.

Crypography is the kind of thing where if you understand the concepts, building a cryptocat site is trivial. If you don't understand the concepts, then cryptography is hard.

Just writing a blogpost saying "the devs of cryptocat are idiots that don't understand anything about crypography dont use it". OK... gee thanks for the tip random internet stranger. It just kinda reeks of monday morning quarterbacking to me...

Welcome back how!!

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

Pilsner posted:

Heh, I thought of that too. Other annoying variations are "exc". Or naming it when it's not even used is bad.

All of my exception variable names are either "e", "ex", or an acronym for the exception like NullReferenceException becomes "nre". How else are you supposed to do it?

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

Shinku ABOOKEN posted:

I am guilty of using PROGRA~1 more than once. Escaping paths is :effort:

E: This was on 32bit and for personal purposes only thankfully.

mklink /d "c:\program files (x86)" c:\bin32
mklink /d "c:\program files" c:\bin

Adbot
ADBOT LOVES YOU

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

Monkeyseesaw posted:

This may be unpopular but I think git is a bit of a coding horror in the fact that it fails to really hide any details of its implementation and makes source control more complicated than it should be. I really didn't grok git until I realized my branches were pointers and my commits were nodes in a graph. I've never had to understand the internals of any source control system like that before.

This is coming from someone who uses git at work and likes git and understands how it's more empowering than, say, SVN but the learning curve on it is much sharper than it could (and should) be.

This is why, I continue to believe there's an opportunity for a killer git UI out there. It doesn't exist yet, but there are several okay ones like Github's clients, and Sourcetree.

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