Skip to content

Stupid People and Input Validation

October 15, 2010

I’ve had it with stupid people. Why? Well, I recently had to write a program for my computer science class. A really long program. Couple hundred lines of code. Yeah, it was fun, but it got to a point where it was annoying because I was just repeating the same lines over and over again. This is known in Computer Science as the dreaded “input validation”. What’s that? Well, that’s when the computer program notices that you’re an idiot because you put the wrong combination of words or letters or numbers into the program, therefore not following the explicit instructions OBVIOUSLY stated in the user input prompt, and tells you that you’re wrong in a generally (unless I’m in a bad programming mood) nice way. Say you have to input the month. You want to write “January”. Instead, you write “FHUOIEWHORIareawwa” because you’re an idiot. How many lines of code is that? Well, switch statements can’t handle strings in C++ for some reason, so that’s a shitload of if statements. A shitload. That’s how much. It scrolls through the program, seeing if by “FHUOIEWHORIareawwa” you meant “january”. Nope. “February”. Nope. “february”. No, yet again. And it goes on. And on. And I have to write every single one of those goddamn lines of code, preventing you from being an idiot and wasting my time coding repetitive avoidable shit.

 

You can tell, I’m angry. But I have a solution. Just import this function and call it before the user input in your program begins and it’ll all be fine. Write your 60 line program in peace, fuck the 220 lines of input validation. Sorry for the indentation, WordPress is a bitch.

 

void StupidityTest(){

int a;

int b;

int c;

cout<<“Welcome to the input validation validation test.”<<endl;

cout<<“Did you vote liberal in the most recent election? Press 1 for yes, 0 for no.”<<endl;

cin>>a;

if (a==1)

exit();

cout<<“Do you see Glenn Beck as the Lord Baby Jesus back from God to save us all? 1 for yes, 0 for no.”<<endl;

cin>>b;

if(b==1)

exit();

cout<<“Can you FOLLOW THE GODDAMN INSTRUCTIONS SO I DON’T HAVE TO WRITE BULLSHIT INPUT VALIDATION CODE? 0 FOR NO, 1 FOR YES.”<<endl;

cin>>c;

if(c==0){

cout<<“Smartass. I’m ending this program. Then I’m ending you.”<<endl;

exit();

}

}

Advertisements
2 Comments leave one →
  1. Aptronym permalink
    November 3, 2010 1:23 pm

    What string comparison methods are available in C++? In Java, something like

    str.toLowerCase().equals(“january”)

    might shave a couple of lines of code off. Or maybe a for loop checking the following with an array of months and spitting out an appropriate integer saying which one it equals.

  2. November 3, 2010 4:28 pm

    Our teacher taught us toUpper() the week after the project was due. I felt like an idiot. I figured it out though, it wasn’t bad mentally, just a lot of copy pasting.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: