Author Topic: Is this standard coding?  (Read 3584 times)

Offline X-Codes

  • DnD Handbook Writer
  • ****
  • Posts: 2001
  • White, Fuzzy, Sniper Rifle.
    • View Profile
Is this standard coding?
« on: March 10, 2012, 06:06:45 PM »
I actually make money coding PHP now.  Anyway, I'm working on an open source project to customize it to the needs of my employer, and I'm noticing a lot of weird stuff in the code.  It looks like the code implements some amount of the PEAR library, but it only seems to be specifically using *maybe* a half-dozen methods (EDIT: Excuse me, FUNCTIONS.  I speak Java as my native tongue.) specifically from the DB stuff, and only stuff specifically for MySQL databases.  The really weird thing is that it seems that it's been a core feature of PHP to be able to talk directly with MySQL databases for a while now.  At least since they released PHP 4, from the looks of things, and this stuff is in no way more than a decade old.

So yeah... I don't get it.  Are some coders just that lazy?

Offline Jackinthegreen

  • DnD Handbook Writer
  • ****
  • Posts: 6176
  • I like green.
    • View Profile
Re: Is this standard coding?
« Reply #1 on: March 10, 2012, 06:16:27 PM »
"Are some coders just that lazy?"

Is that a rhetorical question?

Offline JohnnyMayHymn

  • Hero Member
  • ***
  • Posts: 762
  • Former Lord of the Kitchen Sink
    • View Profile
Re: Is this standard coding?
« Reply #2 on: March 10, 2012, 07:05:18 PM »
Some coders.  I would say so.  Slow to adapt new methods in some cases perhaps.
The Emperor
Can you find the Wumpus?

Offline veekie

  • Spinner of Fortunes
  • Epic Member
  • ****
  • Posts: 5423
  • Chaos Dice
    • View Profile
Re: Is this standard coding?
« Reply #3 on: March 10, 2012, 11:47:26 PM »
Depends, when coding for simple needs, there is a tendency to be conservative and stick with what you already know will work. Especially for enterprise scale stuff, you need to be aware of how all this stuff works at high stress, and when unusual coding practices(like what everyone else with access to the code would be doing) affect it. At least they know how to debug then.
Everything is edible. Just that there are things only edible once per lifetime.
It's a god-eat-god world.

Procrastination is the thief of time; Year after year it steals, till all are fled,
And to the mercies of a moment leaves; The vast concerns of an eternal scene.

Offline kurashu

  • Sr. Member
  • ***
  • Posts: 294
  • Tinker Mechanic Programmer Player
    • View Profile
Re: Is this standard coding?
« Reply #4 on: March 11, 2012, 01:34:12 AM »
It is odd since PEAR::DB is usually touted for not being tied to a specific database; but I once wrote a class to handle PostGres connections and queries. But that was also to get used to Object Oriented Programming.

I'd say it's just lazy programming. But you should ask to see if there's any reason for it.

Offline ariasderros

  • Epic Member
  • ****
  • Posts: 2507
  • PM me what you're giving Kudos for please.
    • View Profile
Re: Is this standard coding?
« Reply #5 on: March 11, 2012, 03:07:15 AM »
It could be laziness, or it could be a lack of scruples. Some coders will deliberately mess something up so that they must be called in to fix it, at cost.
My new Sig
Hi, Welcome

Offline X-Codes

  • DnD Handbook Writer
  • ****
  • Posts: 2001
  • White, Fuzzy, Sniper Rifle.
    • View Profile
Re: Is this standard coding?
« Reply #6 on: March 11, 2012, 02:16:41 PM »
It is odd since PEAR::DB is usually touted for not being tied to a specific database; but I once wrote a class to handle PostGres connections and queries. But that was also to get used to Object Oriented Programming.

I'd say it's just lazy programming. But you should ask to see if there's any reason for it.
I haven't dug too much into PEAR::DB, but does it have the capability to take a SQL query and translate it into some other database query?  It might be, in that case, that it was used to allow people to use this program with whatever database structure they already had...

Also, yeah.  I was thinking already that I should ask... not my supervisor, but the guy that knows this kinda stuff...

It could be laziness, or it could be a lack of scruples. Some coders will deliberately mess something up so that they must be called in to fix it, at cost.
Well, it's an open source thing, so I don't think it's done to mess up the final product.  That said, it might be done to obfuscate the way the program works so that the guy can take credit for the work for longer.

Offline SorO_Lost

  • Epic Member
  • ****
  • Posts: 7197
  • Banned
    • View Profile
Re: Is this standard coding?
« Reply #7 on: March 11, 2012, 06:14:44 PM »
I'm going to just go with didn't know. Moving from one language to the next or even one project to another you bring X skills. It's what you know and can do, somethings things call for Y.

I can understand some, like someone working on some project in VB needed help and I still don't even know what "byval" means but they stuck to using if/else and += for to build a string that contained some user data where as the code I offered back uses switch and String.Replace. I didn't match their coding style and didn't care to, unless they rewrote it there is a section of code in there that looks way different than the rest.

So the guy either knows PEAR::DB and was moving to PHP, or needed help and was told then answer in PEAR::DB for the same reason but different guy. I'd go with the latter since yeah, PHP has worked with MySQL ever since I can remember it.

Offline veekie

  • Spinner of Fortunes
  • Epic Member
  • ****
  • Posts: 5423
  • Chaos Dice
    • View Profile
Re: Is this standard coding?
« Reply #8 on: March 11, 2012, 11:11:02 PM »
Heck, SQL is practically required for you to do anything significant with PHP to begin with. Odds are if you don't need to hook it up to a database you could just use a straight HTML webpage and nobody would notice.
Everything is edible. Just that there are things only edible once per lifetime.
It's a god-eat-god world.

Procrastination is the thief of time; Year after year it steals, till all are fled,
And to the mercies of a moment leaves; The vast concerns of an eternal scene.

Offline kurashu

  • Sr. Member
  • ***
  • Posts: 294
  • Tinker Mechanic Programmer Player
    • View Profile
Re: Is this standard coding?
« Reply #9 on: March 16, 2012, 01:50:34 PM »
It is odd since PEAR::DB is usually touted for not being tied to a specific database; but I once wrote a class to handle PostGres connections and queries. But that was also to get used to Object Oriented Programming.

I'd say it's just lazy programming. But you should ask to see if there's any reason for it.
I haven't dug too much into PEAR::DB, but does it have the capability to take a SQL query and translate it into some other database query?  It might be, in that case, that it was used to allow people to use this program with whatever database structure they already had...

Also, yeah.  I was thinking already that I should ask... not my supervisor, but the guy that knows this kinda stuff...

Year, the PEAR::DB package is an abstraction layer. It's suppose to let you write generic SQL code and then you have a separate setting that says what database you're using: MySQL or PostGres or Oracle or whatever, and the abstraction layer goes "No problem, let me just do some magic...and there." and the same code will run with MySQL or PostGres or Oracle. It's why an application like phpBB can support one download instead of specific downloads for different databases (and have some not supported at all).

@SorO_Lost PEAR::DB is a package for PHP, not a separate langauge. PEAR stands for something like PHP Extension Application Resource. It lets you either download some files and use them like a web application or install them directly to PHP. And there's PECL which only installs mods to PHP. Just FYI