31 replies
So even though I dont freelance anymore I took a guy from an old client doing some updates to his script. Once apon the time this guy threw a lot of work my way back when I really needed so I figured its time for me to return the good karma and help him out.

So anyway I took this job for this dude, a few changes to a job board script no big deal, figured Id spend the evening on it.

So I get into the code and its a frigging nightmare!

Everything is mixed together CSS / HTML / Logic code / Display code.

There is included CSS, inline CSS, Javascript randomly thrown all around.

There is NO common files, not even a common header or footer. There is no include files, it doesnt even have a common connection function for the database. Its bad enough hes using mysql_connect(), but there is actually one in every file that needs the database.

Who ever wrote this has never heard of DRY / DIE , the same SH*T is all over the place.

And to top it off there is not a single comment. I really mean this to not 1 comment anywhere.

Arrrrrrgggg .. This is driving me nuts. I sooo dont want to do this anymore, but I gave my word. Frigging people who work like who ever this guy is should just seek life else where because they have no business writing anything beyond hello world.

Ok thats my rant, I feel a little better.
#programming #rant
  • Profile picture of the author gabibeowulf
    Rejoice .. it could've been worst.

    In the past I had to change a code that was made by copy paste. The variables had names like ieubasfdb and the likes.

    What was even worst, the guy didn't even know how to interrogate the database. He used "select * from.." only to count all elements in the database. He's done it three times in the same page. The database had 100k records. A fine example of negligence while coding .. if you can call that coding..

    - Gabriel
    {{ DiscussionBoard.errors[7373545].message }}
  • Profile picture of the author davetrebas
    Did this client write the script? If not, why not just level with him and explain that it is way beyond the scope of what you anticipated.

    Any sort of contract, verbal or otherwise?

    Of course, you could come back and say now that I have review your script and requirements here is my bid to fix and/or rewrite it.

    Or, simply, be humble, say I just can't fix it. It's beyond my level of expertise since I can't determine the design objectives or logic just from the code. I give up. That's what I would do. I have nothing to prove and am unwilling to waste my time sorta attitude.

    One problem that I have had is that I deliver a nice clean system with source code.

    Their programmer "fixes" it and breaks it. They come back to me and say - you have a bug in your program and it no longer works. Since I always have a full copy of what I delivered, they, at some point have to admit that they made just a few little changes. Then we negotiate. I always have it in my contract that if they make any changes to my code, no matter how small - they "own" it and will not maintain it.

    Example: wrote a large C program to support a COBOL conversion back in the 80's. It was designed to be compiled and ran on a certain computer system. Several years later, they tried to compile and run it on a PC. It compiled but did not run. Big endian, little endian problem. One computer used the bytes in a word left to right, the other computer used them right to left. They gave me a nice contract to fix it even though it was a minor fix once I found the bug.
    {{ DiscussionBoard.errors[7425299].message }}
  • Profile picture of the author Valdor Kiebach
    Originally Posted by FirstSocialApps View Post

    ... they have no business writing anything beyond hello world.
    I LOL'd






    (does this make the message upto 10 chracters?)
    {{ DiscussionBoard.errors[7427237].message }}
  • Profile picture of the author CreateSoft
    Ugh. Reminds me of a start up I worked at a few years ago where the founder wrote the initial ASP pages. Was he a programmer? Nope. Was he a web developer? Nope.

    All variables were two letters and had no meaning: aa, bb, gg, etc.

    I ended up just removing everything he did and writing it the way it should have been written.

    I didn't stay their long. That first assignment should have been a major warning.
    {{ DiscussionBoard.errors[7430589].message }}
  • Profile picture of the author wayfarer
    Let's face it, most people who write some code are not, will not, or at least SHOULD not ever be professional programmers. There just happens to be a huge amount of information available for free, which allows pretty much anyone to get started. This "copy and paste" mentality is encouraged by this.

    Most of us wrote pretty bad code when we first started out. Probably we would all be pretty disgusted looking back, at how bad it was. Unless you learned in college, it's only through experience, and working on others' code, that we learn real principals which allow future maintenance. Separating parts of your codebase into logical workers has been around for a very long time.

    Last year, when I was still freelancing, I took on an assignment to do maintenance on a very large project that been around for over 10 years. As the manager put it, "before MVC". I had to laugh, because it was hardly the truth. Although MVC as it pertains to web-development has only a recent history, it is based on a principal that is over 30 years old! Basic organization is nothing new, but it does take substantial experience to get it right.
    Signature
    I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
    {{ DiscussionBoard.errors[7432097].message }}
  • Profile picture of the author freehugs
    This is why I advocate anything but PHP for beginners to learn programming. Many languages provide just enough rope to hang yourself with.... PHP ties the rope in a noose, hangs it from the rafters, places a stool under the noose, and paints a sign that says "Insert head here and jump off stool".

    You can't fix stupid, but you can minimize its damage.

    ::sigh::
    {{ DiscussionBoard.errors[7439204].message }}
    • Profile picture of the author Damien Roche
      Originally Posted by freehugs View Post

      This is why I advocate anything but PHP for beginners to learn programming. Many languages provide just enough rope to hang yourself with.... PHP ties the rope in a noose, hangs it from the rafters, places a stool under the noose, and paints a sign that says "Insert head here and jump off stool".

      You can't fix stupid, but you can minimize its damage.

      ::sigh::
      Couldn't agree more! If you're going to use PHP, at *very least* use a damn framework like CodeIgniter or Symfony2.
      Signature
      >> Seasoned Web Developer (CSS, JavaScript, PHP, Ruby) <<
      Available for Fixed Fee Projects and Hourly ($40/hr)
      {{ DiscussionBoard.errors[7439226].message }}
  • Profile picture of the author Bo Mill
    Just like when I'm reading any of my code that I wrote 2+ years ago. I'm always like "WTF is going on here!?"
    {{ DiscussionBoard.errors[7441316].message }}
    • Profile picture of the author Valdor Kiebach
      Originally Posted by Bo Mill View Post

      Just like when I'm reading any of my code that I wrote 2+ years ago. I'm always like "WTF is going on here!?"
      Same here, now I end up writing more comments than code. I think the biggest problem is people NOT commenting their code.

      Even the crapest code can be salvaged if it has good comments.
      {{ DiscussionBoard.errors[7460321].message }}
      • Profile picture of the author FirstSocialApps
        Originally Posted by Valdor Kiebach View Post

        Same here, now I end up writing more comments than code. I think the biggest problem is people NOT commenting their code.

        Even the crapest code can be salvaged if it has good comments.
        I agree, that was the biggest complaint I had, the original programmer wrote NO comments. I personally hate that. There is absolutely no reason not to comment your code. If you dont your just being lazy.

        In the end I ended up telling the customer I couldnt work on that code, so I gave him a price for a complete rewrite and just did that
        {{ DiscussionBoard.errors[7460716].message }}
        • Profile picture of the author ALicenseToCode
          Originally Posted by FirstSocialApps View Post

          I agree, that was the biggest complaint I had, the original programmer wrote NO comments. I personally hate that. There is absolutely no reason not to comment your code. If you dont your just being lazy.

          In the end I ended up telling the customer I couldnt work on that code, so I gave him a price for a complete rewrite and just did that

          Just thought I'd chime in here and congratulate you for getting one of the best possible results you could have from your situation!

          I've definitely been in a similar position at least 3 times in my life. However I just can't bring myself to hate PHP, because it lets you get out there and do business on the web without a college level coding education. If you do well you can always pay someone who knows what they're doing to help you out later. It's kind of like the official coding language of the American Dream lol.

          Doesn't mean I don't groan anytime I see some really bad uncommented code (osCommerce was one of the worst things I ever worked on)
          {{ DiscussionBoard.errors[7463667].message }}
          • Profile picture of the author wayfarer
            Originally Posted by ALicenseToCode View Post

            However I just can't bring myself to hate PHP, because it lets you get out there and do business on the web without a college level coding education.
            Agreed, there's no reason for religious hatred against PHP. It's a great language for many reasons, not so great a language for other reasons. Plus, it's a great "gateway language" into other languages. Sure, it provides just enough rope to hang yourself with, but if you hang yourself, you're in the wrong business anyway. Just my perspective...
            Signature
            I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
            {{ DiscussionBoard.errors[7465263].message }}
  • Profile picture of the author scottlpool2003
    Programming rant fail...

    So I get into the code and its a frigging nightmare!

    Everything is mixed together CSS / HTML / Logic code / Display code.

    CSS = not a programming language
    HTML = not a programming language

    Hell, even PHP isn't a programming language.

    "PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML."
    http://php.net/manual/en/intro-whatis.php
    {{ DiscussionBoard.errors[7442748].message }}
    • Profile picture of the author wayfarer
      Originally Posted by scottlpool2003 View Post

      Hell, even PHP isn't a programming language.
      Nonsense. All scripting languages are programming languages. But not all programming languages are scripting languages. When Steve Wosniak was asked recently what programming languages he still used, he replied, "Mostly I used scripting languages, otherwise, just straight C."

      People have been repeating the "scripting languages are not programming languages" myth for years. Any coding language that is Turing Complete is by definition a programming language.

      According to the Tiobe Index, even Transact SQL is a programming language, because of its Turing completeness.
      Signature
      I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
      {{ DiscussionBoard.errors[7443993].message }}
    • Profile picture of the author FirstSocialApps
      [DELETED]
      {{ DiscussionBoard.errors[7452085].message }}
  • Profile picture of the author Rideem3
    PHP actually is a programming language. Check this stackoverflow question out:
    php - What is a "real" programming language? - Stack Overflow

    They answer it very concisely.

    Anyway, CSS and HTML aren't programming languages, at least in my book. HTML is what it stands for: markup language.

    But to agree with your rant, disorganized codes are a real pain
    {{ DiscussionBoard.errors[7449566].message }}
  • Profile picture of the author wayfarer
    The OP never said anything about HTML and CSS being a programming language anyway, no idea where that came from. Back on topic
    Signature
    I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
    {{ DiscussionBoard.errors[7451113].message }}
  • Profile picture of the author FirstSocialApps
    [DELETED]
    {{ DiscussionBoard.errors[7452442].message }}
    • Profile picture of the author DEaFeYe
      Banned
      [DELETED]
      {{ DiscussionBoard.errors[7452451].message }}
  • Profile picture of the author Rideem3
    What's wrong with using php? Php is used all over the world. Even Facebook uses php.
    {{ DiscussionBoard.errors[7452813].message }}
    • Profile picture of the author DEaFeYe
      Banned
      [DELETED]
      {{ DiscussionBoard.errors[7453637].message }}
      • Profile picture of the author FirstSocialApps
        [DELETED]
        {{ DiscussionBoard.errors[7453881].message }}
  • Profile picture of the author Bo Mill
    PHP is most definitely a programming language. A horrible one, but nevertheless a programming language.
    {{ DiscussionBoard.errors[7453736].message }}
  • Profile picture of the author FirstSocialApps
    [DELETED]
    {{ DiscussionBoard.errors[7454112].message }}
  • Profile picture of the author wayfarer
    I think we lost some posts, lol. It looks like you're talking to yourself. Har har har, oh well, I missed it.
    Signature
    I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
    {{ DiscussionBoard.errors[7455203].message }}
  • Profile picture of the author FirstSocialApps
    LOL .. yea. Dont worry you didnt miss anything. I let a troll jack my thread and then get under my skin Really just turned into a wasted thread, Id delete the whole thing if I could.
    {{ DiscussionBoard.errors[7455427].message }}
  • Profile picture of the author wayfarer
    Haha, yeah, the whole thing was a complete aside.
    Signature
    I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
    {{ DiscussionBoard.errors[7455643].message }}
  • Profile picture of the author umrbd
    You need a good editor, I guess something like netbeans which can help you to find and replace the code all over the project at once. Just get rid of extra code put it in common file and things will start getting some shape. You are may be thinking to just patch up the stuff and get rid of it but I think it will took more time, if you can just clean the code somehow you will have better chances to complete the task early
    {{ DiscussionBoard.errors[7459597].message }}
  • Profile picture of the author FirstSocialApps
    Yea there is a lot of PHP hate of late. And it is understandable for many reasons because PHP is easy enough that a novice can become a self proclaimed 'expert' quickly and produce bad code. But I really dont think thats the languages fault. Thats the programmers fault. Hating the language because its to easy to make bad code with it is like hating your oven because its to easy to cook bad food with it.
    {{ DiscussionBoard.errors[7466501].message }}
    • Profile picture of the author wayfarer
      Originally Posted by FirstSocialApps View Post

      Yea there is a lot of PHP hate of late. And it is understandable for many reasons...
      Yeah, well there's also some people newly banned as of late. Which is also understandable for a few reasons... live and learn
      Signature
      I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
      {{ DiscussionBoard.errors[7466666].message }}
    • Profile picture of the author Brandon Tanner
      This thread has given me a good idea. I don't know if anything like this already exists or not, but if someone wrote a script or desktop program that could automatically clean up & optimize bad code, it would be really useful. Something that would...

      * Delete all internal/inline CSS, Javascript, and PHP, and put all that code in external files instead.

      * Automatically detect when the same exact code is used on multiple different pages (ie headers, menu bars, footers), then move that code to a single header file, a single menu bar file, a single footer file, etc, where it can be called from each webpage via PHP includes.

      * Delete all tables (tables used for layout, at least), then figure out the correct HTML and CSS code to put in it's place.

      * Replace all old, obsolete tags and elements with modern, standards-compliant code.

      * Automatically add comments where each div begins AND ends.

      * Properly indent all div's, and add whitespace where necessary to improve readability. And when it comes time to deploy the code, have the option to minify the code to increase page load speed.

      I know there are a few programs out there that can do 1 or 2 of the above tasks (ie HTML Tidy), but I can't think of anything that can do all of the above. Something like that would be soooooo kickass! You could call it something like "HTML4 Bit**slap".

      My project plate is pretty full at the moment, but if something like this hasn't been developed within the next handful of months, I may be tempted...

      Bet something like that would sell like crazy to web dev's!
      Signature

      {{ DiscussionBoard.errors[7466947].message }}
  • Profile picture of the author wayfarer
    You're basically talking about developing a lint tool. I don't think you'll be able to automatically solve the tables to standard layouts transition though. That's just too complicated. Even just removing inline styles is complicated, since you need to make the precedence work the same way, and inline styles take ultimate precedence.

    So you'd need to have automatically generated ID attributes, which could conflict with current IDs, so then what do you do? Plus, having automatically generated IDs is just bad practice, just look at Dreamweaver garbage code.

    It would be nice to have a simple lint program that would at least identify and point out bad parts of your code however.
    Signature
    I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
    {{ DiscussionBoard.errors[7467111].message }}
    • Profile picture of the author Brandon Tanner
      Originally Posted by wayfarer View Post

      I don't think you'll be able to automatically solve the tables to standard layouts transition though. That's just too complicated.
      Why not? It just boils down to number crunching. You figure the pixel-specific layout of each table and each element in the table (rows, cells), then translate that into the equivalent margin and padding settings for the new DIV's.

      Originally Posted by wayfarer View Post

      Even just removing inline styles is complicated, since you need to make the precedence work the same way, and inline styles take ultimate precedence.
      One way around that would be to add "!important" to all of the inline styles that are moved to external files. Also, there are other ways to manipulate style precedence.

      Originally Posted by wayfarer View Post

      So you'd need to have automatically generated ID attributes, which could conflict with current IDs, so then what do you do?
      Before generating a new ID name, you would check to make sure that no existing ID's are overwritten.

      Anyways... I never said this would be an easy program to develop... as I'm sure it would take a lot of testing and tweaking to get right. But it certainly would be cool!
      Signature

      {{ DiscussionBoard.errors[7467586].message }}
      • Profile picture of the author wayfarer
        Originally Posted by Brandon Tanner View Post

        Why not? It just boils down to number crunching. You figure the pixel-specific layout of each table and each element in the table (rows, cells), then translate that into the equivalent margin and padding settings for the new DIV's.
        Ok, so how do you determine when a table is being used for layout, and when it is being used for data, as it should?

        Even if it is possible to accurately determine which tables are used for layout and which aren't, being pixel specific doesn't seem to me to help much, unless you plan on positioning everything absolutely, which is terrible practice. I guess it could be solved with enough time, but I doubt it's practical to work on a solution. It would be fun to see what you could come up with though. Very difficult problem.
        Signature
        I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
        {{ DiscussionBoard.errors[7468674].message }}
        • Profile picture of the author sjeichman
          On the topic of your original rant, I feel your pain!

          One of the guys that use to program for our organization was big on copy/paste. One of the web pages I had to recode was about 3000 lines of code, all copy/paste from a block of about 30 original lines. Each new code block had a change in 1 line to make the code client0specific. To top it off, when the guy would put documentation in the code, he never used the "Enter' key to make things more readable. So, some lines of code were like 900 characters long!

          As I said, he doesn't program for us anymore!
          Scott
          Signature
          {{ DiscussionBoard.errors[7573018].message }}
  • Profile picture of the author Terry Crim
    one of the older Dreamweaver versions had a plugin someone wrote that tried to do this. It worked sort of. For the life of me I can't remember which tool I was using, phpStorm from Jetbrains? maybe, that has a feature that will take inline and put it into external files, worked for CSS and I want to say also JS. Could of been Dreamweaver CS6..

    There are plugins for Dreamweaver I have seen that say they will convert html tables into DIV and CSS based but I have never tried them. I don't really use dreamweaver even though I have it with Adobe's Creative Cloud subscription. I must say though that the new Dreamweaver does write much better code than the old versions did but I still can do a better job myself.

    From my experience working with IDE's that try to do this they seem to me to be try to be all for everybody and end up being total crap for anyone that seriously designs or programs. I know you are not talking about designing an IDE, maybe something that plugs in to IDE's and notepad++ ?

    Html-kit maybe is the tool I was thinking about that converted tables to divs and divs to tables but there are or were plugins for dreamweaver that would do this as well.. sort of.

    - T
    {{ DiscussionBoard.errors[7468440].message }}

Trending Topics