Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Is cleaner always better?

Name: Anonymous 2009-07-22 10:22

Well, I make a student in web development, and my professor insists on using the longer version of things when writing PHP simply because he is used to it. Now, I have kind of gotten used to writing redundant code.

Here's an example of Me vs. My Professor:

Him


   if(!get_magic_quotes_gpc()) {
    $username = addslashes($username);
   }

   $q = "select password from users where username = '$username'";
   $result = mysql_query($q,$conn);
   if(!$result || (mysql_numrows($result) < 1)){
      return 1; //Indicates username failure
   }


Me


    !get_magic_quotes_gpc() ? $username = addslashes($username) : TRUE;

    $query = "SELECT password FROM users WHERE username = '$username'";
    $result = mysql_query($query,$connection);
   
    !$result || (mysql_num_rows($result) < 1) ? '1' : '2';


Which way do you prefer writing it in?

Note

If you see any errors, please feel free to correct them.

Name: Anonymous 2009-07-22 10:27

>>2 here

If you do not want to introduce the chance of false appeal to supposed authority you should ask "Here is code from two people of the same age. Which is better?."

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List