Ways to suck at programming

Source: Internet
Author: User

Original address: http://www.finalint.com/2010/05/04/10-ways-to-suck-at-programming/

Ways to suck at programming

I recently inherited a web app from a dirty, nasty, stinking contractor and that claimed to be a competent enough programmer t O is left alone to get things done. Unfortunately, we took him at his word. Functionally, most of the web app seemed to work at the A-glance. However, once the client took over the reins and actually using it started things fast. The contractor disappeared after payment (die reputation die!) and I am left to try and get things working properly and P Erforming up to snuff while the client limped along with what they had been.

I decided to document a few of the things that I found wrong along the way.  these are really just things that eve Ry good programmer should already know to avoid ... but obviously  some  people need to be reminded (or taught). #10 –don ' t store settings in a configuration file

When you ' re writing a sizable application, things like database connections and SMTP server information'll be used Throu Ghout the app.  the best way to make sure your app are entirely immune to maintenance are to redefine those little bits of information every time for you need them.  so instead of putting them in the configuration file (Web.config or whatever) just leave, them in your code.  whoever inherits the app'll thank for sending them on a hunt through thousands of lines of code to change WHI The CH SMTP server is being used.  what ' s even more fun are when the next programmer only finds to the places where you ' ve used this code and a Si Ngle instance somewhere deep in the app. silently breaks hundreds of times without anyone.  sometimes it ' s helpful to build the variables in inconsistently concatenated strings. The repeated and more frequent interaction between the new developer and the disgruntled client would help strengthen tHeir relationship.  and If you don t hook up so love connection, who would?#9 –don ' t store variables in [any] memory scope

One of the great things about databases is they store your bits of information and allow your to access them whenever n  Eed them. To make sure your app are as terrible as possible, you'll want to being sure and access the database every time you need a bit  of that information. The more common the "information is" that's needed, the bigger win you'll have by making a new database connection to get th  At information.  Non-sensitive user information is a great use of this prinicple. Don ' t worry about defining a user ' s information, such as "ISAdmin" to a variable and using it throughout the current Reque  St.  Just Query the database each time you are need to know anything about the user. After all, the client paid for this database, we ' d better get as much spin out of it as possible! #8 –use Arcane Plugins

If The client has a non-standard request, such as formatting a table in a way this is outside the abilities of your IWYG editor (colspan are hard).  you should definitely hit up the interwebs and search for random unsupported closed source plugins to do the work fo R you.  if you would spend almost a entire hour writing it yourself, you should spend in least 3 hours for and GE Tting A plugin that does roughly but not exactly the same thing.  bonus points if you can get a plugin this doesn ' t do what to need, but offers 15mb+ of functionality you have no US E for and include it without getting caught.  bonus Bonus points if the documentation for that plugin was in a language not native to your market (for example, if You ' re working into an 中文版 speaking shop look for plugins that are documented only in Spanish or German). #7 –never, ever remove functionality

Over the course of developing a large application there are bound to is times when functionality your were working on prove s itself to is needed.  now, to is sure to leave plenty the dead ends for those the who come behind with to get lost in, never delete that functio Nality.  maybe even comment out random parts to it, or even hundreds of lines of it at a time, but don ' t delete it.  imagine The hours of fun the future-crew for this app would have while they trace through this functionality Find that it isn ' t needed!  if can make it seem needed, without actually needing it, it'll even keep from them it deleting ... themselves Sp This way the fun is exponential!  oh, a bonus on this one ... if your project uses source control and multiple server environments, being sure to have a dif Ferent version of your files (both code and compiled) on the each server and source control.  this Way no one would know which one is live in production and who doesn ' t love a gooD round of Code Russian roulette? #6 –screw Performance

Large applications, your know, the ones that pay the bills, are generally needed because they deal with Large amounts of DA  Ta.  Sure, during your development process you ' ll create/So test records.  Take My word for it, there's no need to even worry about what happens once your get to records, or even 1,000!  Obviously, all pagination'll work just fine and performance would never take a hit. So if it compiles, ship it! #5 –nest Major logic/functionality in loops

Now obviously, we ' ve already covered #6 so we know ' we ' re working with large of data.  and Inevitably, there'll be plenty of looping through so data to does work with it.  if you want to make sure your application are really difficult to maintain and completely to the client Should embed major functionality and/or logic inside of these loops.  for example, instead of running a query against the database to get all the data for you need, storing the "data in Memor" Y and working with the variables in memory during your loop, just get all of the data except one field up front and loop thro Ugh it ... then on each loop you are should get all of the data again, and now include your extra field.  this'll guarantee that your app would never survive more than 5 concurrent users (re: #6).  so for review:  get data > Create loop > Get data > Work with data.  i ' m sure you'll be some room for added idiocy into that process, so feelIdea as many times as you want. #4 –document Nothing

Look, documentation are for morons.  I mean either can read the code or you can ' t, right (this is actually said to me at one point)?  of COURSE the next programmer would be able to read the code.  What ' s really fun though, are when your document absolutely nothing, especially not your intent.  It pays to keep them guessing.  You ' re mysterious, like a ninja.  No need to let someone get all up in your grill, knowing everything about what your were to do. Because if you document what you ' re trying to do and then don ' t-end-up doing it ... that ' s just embarrassing. #3 –use and reuse illogical variable names

There ' s going to being a LOT of variables needed to work on this app, so you ' d better choose a movie or television show WI Th enough characters to use all the names.  lord of the Rings, Star Wars and Family guy are all good choices for this.  maybe can even form relationships with the variables.  that way, never have to kill them!  you can have variables that are chameleons, changing their the usage and values throughout processing and you can RECYCL e them for something new all time you need a variable for new functionality.  it ' s like they ' re growing up, evolving and right before your  after all, your ' re trying to being green and reduce your carbon footprint so recycling variables just-like the res Ponsible thing to Do! #2 –catch All errors-and does nothing with them

Most Languages/platforms Nowadays have really good error handling built in.  they ' ll die somewhat and Give enough details through the default error output to is helpful.  you must not allow this to happen!  start from wrapping nearly every tiny piece of functionality in a Try/catch phrase.  then ... inside the catch ... put a comment, like "//It borked lawl."  this'll ensure that if anyone to wants On this app, they ' d better spend the time getting to know the app and it ' s adorable character variables before they start Wrecking the app altogether. #1 –duplicate functionality

If The client tells you this they need two pages:one for a administrator that has all of the details on a item along W ith a button to delete it; And one for a regular user which has "the details on" an item without a button, you should create multiple pages to a  Ccomplish this.  In fact, if I can make the pages for each user group that would even to be better.  Making a separate page for each user is the ultimate success. So ninja up and get serious on this one, because it's your last line of defense against the teeming hordes of qualified in Dividuals who would inevitably be bewildered while trying to update your carefully constructed Pandora's box of an app.

This is by no means a comprehensive list.  On this project alone I could name ten things that could make you suck.  But I ' ll leave it at the now. Anyone have more to add?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.