Wednesday, February 10, 2010

Code Stutter

In all my experience as programmer (~9 years) I have contemplated, seen and created a few coding and naming conventions. But there was one kind of convention that always struck me as odd and lately as extremely annoying.

Here's a contrived example:

class MySQL {
  function sql_connect() {
    //...
  }
  function sql_query() {
    //...
  }
  function sql_error() {
    //...
  }
}

And another:

class FTP {
  function ftp_connect() {
    //...
  }
  function ftp_put() {
    //...
  }
  function ftp_get() {
    //...
  }
  function ftp_chdir() {
    //...
  }
  function ftp_pwd() {
    //...
  }
}

And one more:

class PDF {
  function pdf_begin_document() {
    //...
  }
  function pdf_end_document() {
    //...
  }
  function pdf_begin_page() {
    //...
  }
  function pdf_end_page() {
    //...
  }
  function pdf_save() {
    //...
  }
}

Notice something? Is it just me or are the programmers who write this stuff mentally stuttering?

Is there some other query language besides SQL that MySQL accepts?

What else is that FTP class supposed to be doing, aside from issuing FTP commands - SQL statements, maybe?

Do these people enjoy typing "PDF" so much, it has to be repeated over and over again, or are they afraid they might forget what that class/function does again?

Are they afraid, the object created by $pdf = new PDF(); might suddenly become something else - an FTP object, maybe?

Or is it, they are just lazy, and copy-pasted the names from the procedural functions?

Whatever the reason, please stop it! I consider this to be mental and physical abuse and am offended by it. Typing is already a chore and anything that saves me some is welcome.

No comments:

Post a Comment