Programming rant

by 31 replies
37
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 #programming #rant
  • 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
  • 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.
  • I LOL'd






    (does this make the message upto 10 chracters?)
  • 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.
  • 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.
  • 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::
    • [ 3 ] Thanks
    • [1] reply
    • Couldn't agree more! If you're going to use PHP, at *very least* use a damn framework like CodeIgniter or Symfony2.
  • Banned
    [DELETED]
  • Banned
    [DELETED]
    • [ 1 ] Thanks
  • 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!?"
    • [1] reply
    • 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.
      • [1] reply
  • 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
    • [1] reply
    • Banned
      [DELETED]
    • 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.
    • [DELETED]
  • 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
  • The OP never said anything about HTML and CSS being a programming language anyway, no idea where that came from. Back on topic
  • [DELETED]
  • [DELETED]
  • What's wrong with using php? Php is used all over the world. Even Facebook uses php.
  • Banned
    [DELETED]
  • PHP is most definitely a programming language. A horrible one, but nevertheless a programming language.
  • [DELETED]
    • [ 1 ] Thanks
  • I think we lost some posts, lol. It looks like you're talking to yourself. Har har har, oh well, I missed it.
  • 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.
  • Haha, yeah, the whole thing was a complete aside.
  • 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
  • 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.
    • [2] replies
    • Yeah, well there's also some people newly banned as of late. Which is also understandable for a few reasons... live and learn
    • 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!
  • 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.
    • [1] reply
    • 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.

      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.

      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!
      • [1] reply
  • 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

Next Topics on Trending Feed

  • 37

    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.