When you’re a software developer…

You’ve got to work in teams, or at least you’ve got to work with the idea that someone OTHER THAN YOURSELF is going to be working with your code at some point. I’m sure there are some people out there developing some crazy proprietary stuff that will never release their code to anyone but the client.

I haven’t blogged in a bit, but today’s boiled my blood enough that I kind of had to.

If you don’t code, just wait for my next post.

And without further ado: Danny Iachini, since you’re the only one in the intersection of “reads my blog” and “codes a lot” (at least that’s apparent to me)

So I’m doing this project that was made awhile ago by some guy I’ve never met (thank goodness) and I’ve been plenty mouthy about my issues with this project. It’s a management system for a global company to keep track of their products and statuses and servicing and stuff like that. It also includes an RMA system. I inherited most of the code, which is script-based, and went to work patching things up and adding a few little functions here and there.

Sadly, no two coders are alike, but I think that most coders have common ideas about what is efficient, scalable, and elegant. I am working with code that is none of these things.

  1. First off my number one problem with this code, is the goddamn whitespace. For any non-coders reading this, whitespace is sort of like indenting your paragraphs in a word document. it makes it easy to read, easy to see where paragraphs start and end, and you’re quickly able to see the details when browsing quickly. Whitespace is a programmers best friend. This guy doesn’t use it. No tabbing inward, although sometimes random spaces are thrown in to sort of emulate the idea of whitespace without it being consistant at all.
  2. Now, I don’t know if this is a valid complaint, but I’ve always coded php using echos. So, in other words, I echo out what I need in the dynamic parts of the page, interrupting strings to concatenate variables into it where they’re needed. This means that I’ve got solid blocks of PHP embedded in whatever other code I’m working with. This guy does the opposite. He interrupts a huge big list of html (that all gets processed by the server) with multiple sets of php-openers and closers for things like end-brackets and if-statements. ugh. Not only does this make it ugly, segmented, and longer/more taxing than necessary, but coupled with the lack of whitespace, i have NO clue where one function will end and another begins. It’s horrid.
  3. This guy’s variable names are full of capital letters, underscores, and all sorts of other fun crap that I have to hit the shift-key for. Thanks for taking up my time because you want to be extra accurate in naming this column Product_Name instead of simply productname.
  4. The database. Ugh, I don’t even want to get into it. There’s more redundancy per table than I’ve seen anywhere lately. A good example is in the RMA system. There are flags for steps of the RMA (it being received, investigated, and returned), as well as dates for when these processes were completed. What I don’t get is why the flags need to be there. It’s an extra set of columns in the table used for determining if something had been done yet. YET you could just as easily have a script investigate that for you just by testing to see if the cell is empty or not. That’s just one example. There’s tons.
  5. Error messages are passed through request variables in the URL. When’s the last time you were ever at http://a-site.com/?I’m sorry you can’t view this page because you’re not logged in. ?? ugh.
  6. I don’t know the previous author’s grudge with more than one file, seeing as every file has about 1000 lines of crap that could easily be split into function-specific files. Instead of edit_products.php, why not just have edit_product1, edit_product 2, and so on…
  7. Well that’s it. I’m done ranting. I feel better now.

    Oh yeah there are california videos and stuff if you can find them ;)


8 Responses to “When you’re a software developer…”

  • Danno Says:

    KNAPPZ! You’re blogging!! WOoooo! I’m going to blog on your blog… so I apologize in advance for the length (that’s what I said!)

    It is so incredibly true that no two programmers are alike and that you must plan accordingly because of that.

    1. Whitespace is an absolute MUST. Anything that is nested should get another tab indentation (at the very minimum, 2-4 spaces) and lately I’ve even been including whitespace inside my lines because it’s even easier for me to read. Ex:

    echo ( function_call ( param1 , param2 ) );

    I don’t know how you feel about that, but it really makes my life easier…

    2. I’m not sure how I feel about that use of echoes. I most certainly separate the majority of my PHP and HTML (putting all the MySQL queries up at the top (or in an external function) and organize everything accordingly), but if I’m looping through a 2-D array (let’s say first name, last name) and printing the stuff out into a table, I end the PHP section after the loop structure, put regular HTML (with echoes) there, and start the PHP back up to end the loop structure. With my “proper” indenting and my typical comment on the end of the php (

  • Danno Says:

    (I either exceeded your comment length or broke it by putting PHP code in there… lemme try again continuing that last one…)

  • Danno Says:

    (broke it again.. one last try without the PHP at all…)

    , I think that my way works out pretty understandably. The main reason I do it this way is because I ADORE syntax highlighting and my echo statements don’t get highlighted as HTML…

    3. Variable names are something that everyone disagrees on. I wouldn’t be able to STAND your code if you don’t distinguish words by either capitalization or underscoring ( prodid doesn’t click as naturally for me as ProdID or prod_id — I even sometimes like Prod_ID.. but I wish I didn’t because that’s a pain in the ass…). I think the important thing is for consistency throughout the program. As long as all variable names are done with the same formatting, it shouldn’t be too terribly difficult to adjust to the style when you change projects…

    4. I haven’t taken a database design course (yet! next spring I finally get to fit it into my schedule, hopefully), so I don’t understand every single in and out.. but with all my THON work, I’ve picked up on a pretty good deal of DB design techniques. Redundancy can be really obnoxious a lot of the time, but it can also be handy in certain situations. In my work project, I had a universal field in every one of the tables so that I could avoid making double the queries…

    5. That is so 1998.

    6. I’m still not entirely sure how I feel about multiple files… If there is a logical way to separate different things, I say go for it absolutely… however, if you’re putting every 20-line function into it’s own file, that can get to be a BUNCH of files you’re looking at. The way that I’ve been doing is having one GlobalFunctions.php which contains functions which are used on several different pages. So each of my pages are much less code because they just call functions in this massive GlobalFunctions file… with good use of whitespace in between functions and similar naming techniques, the GlobalFunctions file becomes a tamable beast.

    ::Whew:: sorry about that… I just thought you brought up some great points which definitely merited discussion.. Keep up the awesome blogging!!!!

    (Video notes:

    When the camera cut to you while driving, I totally thought you were going to pull a Nalts!

    I can’t believe you know the entire “Still Alive” song… that’s hella nerdy. )

  • SourceForge Community Choice Awards « Danny Iachini’s Weblog Says:

    [...] quick side notes:  1) Knappz finally blogged again and it’s an awesome one!!   2) I’m going up to State College this weekend for Arts Fest!  If you’re gonna be [...]

  • Justin Says:

    Hay I read your blog too, Timmy.

    But I guess I’m not really a software developer. :(

    Wah. Wah.

  • Alex Parker Says:

    Your list is spot on (I feel your pain)

  • Maryann Says:

    I’m practically a programmer, I won the University of Pittsburgh’s Computer Science Bowl in high school. Maybe you’ve heard of it.

    Look at this mess I get to redesign:
    http://www.engr.psu.edu/international/

    My favorite part is the hideous flash menu.

    Anyway, I agree with the parts of this post I understand (aka the white space part). My favorite part of the post, though, was Danny’s excessive amount of commenting.

    Also, California was awesome for me, hope you’re loving it too!

  • Tim Says:

    Danno, I totally get ya.

    2. While your both of our ways work fine, this person likes to start a loop, and then in the executable part, END the PHP, type in lines of HTML (including starting/stopping the PHP within those HTML lines to pipe out a variable), and then START the PHP again, putting in the brackets to contain it all. And of course it’s not properly whitespaced at all.

    3. With variable names I tend to do what java programmers do, personally that variable for me would have been called prodID or something akin to it. It’s just that this database he built and all his damn variable names are like that, so I’ll be cruising along and have to hit shift a good 2 times more per variable name, especially with the underscores which I have to actually remove my right hand to hit (maybe I’ll work on that).

    4. There are a million and seven ways to reduce redundancy simply by smart querying, joins, relational tables, etc. In my opinion, at least, scalable projects use very far-reaching queries in very streamlined databases.

    5. I didn’t mean that I wanted multiple files for everything. I always make up function files and connection files and stuff to include here and there, but the project I’m doing now is like taking wordpress’ files for creating a new post, editing old posts, managing oomments on posts, and any other function that could be related to posts — and throwing them all together. If it was coded efficiently, I’d have no problems. But the includes are nonexistent and (again) often a lot of the code is totally redundant across the modes the php can be put into, and really, it’s just a personal preference but I like having short files that I don’t have to hunt through to find errors in other areas of that file’s functionality.

    That’s all =) Thanks for the input Danny I feel cool having 7 comments on a post.