Friday, November 14, 2008

New Set of Rules I am gonna follow!

SOURCE

How to Write Unmaintainable Code

In the interests of creating employment opportunities in the programming field, I am passing on these tips from the masters on how to write code that is so difficult to maintain that the people who come after you will take years to make even the simplest changes. Further, if you follow all these rules religiously, you will guarantee yourself a lifetime of employment, since no one but you can hope to maintain the code.
  1. Lie in the comments. You don't have to actively lie, just fail to keep comments up to date with the code.
  2. Pepper the code with comments like /* add 1 to i */; however, never document woolly stuff like the overall purpose of the package or method.
  3. Make sure that every method does a little bit more (or less) than its name suggests. As a simple example, a method named isValid(x) should, as a side effect, convert x to binary and store the result in a database.
  4. Use acronyms to keep the code terse. Real men never define acronyms; they understand them genetically.
  5. In the interests of efficiency, avoid encapsulation. Callers of a method need all of the external clues they can get to remind them of how the method works inside.
  6. If, for example, you were writing an airline reservation system, make sure that there are at least 25 places in the code that need to be modified if you add another airline. Never document where they are. People who come after you have no business modifying your code without thoroughly understanding every line of it.
  7. In the name of efficiency, use cut/paste/clone. This works much faster than using many small reusable modules.
  8. Never, never put a comment on a variable. Facts about how the variable is used, its bounds, its legal values, its implied/displayed number of decimal points, its units of measure, its display format, its data entry rules (e.g., total fill, must enter), when its value can be trusted etc. should be gleaned from the code. If your boss forces you to write comments, lard method bodies with them, but never comment a variable, not even a temporary!
  9. Try to pack as much as possible into a single line. This saves the overhead of temporary variables and makes source files shorter by eliminating new line characters and white space. Tip: Remove all white space around operators. Good programmers can often hit the 255-character line length limit imposed by some editors. The bonus of long lines is that programmers who cannot read 6 point type must scroll to view them.
  10. Cd wrttn wtht vwls s mch trsr. When using abbreviations inside variable or method names, break the boredom with several variants for the same word and even spell it out longhand once in a while. This helps defeat those lazy bums who use text search to understand only some aspect of your program. Consider variant spellings as a variant on the ploy; e.g., mixing international colour, with American color and dude-speak kulerz.
  11. Never use an automated source code tidier to keep your code aligned. Lobby to have them banned from your company on the grounds that they create false deltas in PVCS (version control tracking). You are now free to accidentally misalign the code to give the optical illusion bodies of loops and ifs are longer or shorter than they really are.
  12. Rigidly follow the guidelines about no goto, no early returns and no labeled breaks especially when you can increase the if/else nesting depth by at least five levels.
  13. Use very long variable names that differ from each other by only one character, or only in upper/lower case. Wherever scope rules permit, reuse existing unrelated variable names. An ideal variable name pair is swimmer and swimner. Exploit the failure of most fonts to clearly discriminate between ilI1| or oO08 with identifier pairs like parselnt and parseInt or D0Calc and DOCalc.
  14. Never use i for the innermost loop variable. Use anything but. Use i liberally for any other purpose, especially for non-int variables.
  15. Never use local variables. Whenever you feel the temptation to use one, make it into an instance or static variable instead to unselfishly share it with all the other methods of the class. This will save you work later when other methods need similar declarations. C++ programmers can go a step further by making all variables global.
  16. Never document gotchas in the code. If you suspect there may be a bug in a class, keep it to yourself. If you have ideas about how the code should be reorganized or rewritten, for heaven's sake, do not write them down. Remember the words of Thumper: "If you can't say anything nice, don't say anything at all." What if the programmer who wrote that code saw your comments? What if the owner of the company saw them? What if a customer did? You could get yourself fired.
  17. To break the boredom, use a thesaurus to look up as much alternate vocabulary as possible to refer to the same action; e.g. display, show, present. Vaguely hint that there is some subtle difference where none exists. However, if there are two similar functions that have a crucial difference, always use the same word in describing both functions (e.g. print to mean write to a file, and to print on a laser and to display on the screen). Under no circumstances should you succumb to demands to write a glossary with the special purpose project vocabulary unambiguously defined. Doing so would be an unprofessional breach of the structured design principle of information hiding.
  18. In naming functions, make heavy use of abstract words like it, everything, data, handle, stuff, do, routine, perform and the digits; e.g., routineX48, PerformDataFunction, DoIt, HandleStuff and do_args_method.
  19. Never document the units of measure of any variable, input, output or parameter; e.g., feet, meters, cartons. This is not so important in bean counting, but it is very important in engineering work. As a corollary, never document the units of measure of any conversion constants or how the values were derived. It is mild cheating, but very effective, to salt the code with some incorrect units of measure in the comments.
  20. In engineering work there are two ways to code. One is to convert all inputs to S.I. (metric) units of measure, then do your calculations and then convert back to various civil units of measure for output. The other is to maintain the various mixed measure systems throughout. Always choose the second. It's the American way!
  21. I am going to let you in on a little-known coding secret. Exceptions are a pain. Properly-written code never fails, so exceptions are actually unnecessary. Don't waste time on them. Subclassing exceptions is for incompetents who know their code will fail. You can greatly simplify your program by having only a single try/catch in the e n t i re application (in main) that calls System.exit(). Just stick a perfectly standard set of throws on every method header whether they could throw any exceptions or not.
  22. C compilers transform myArray[i] into *(myArray+i), which is equivalent to *(i+myArray), which is equivalent to i[myArray}. Experts know how to put this to good use. Unfortunately, this technique can only be used in native classes.
  23. If you have an array with 100 elements in it, hard code the literal 100 in as many places in the program as possible. Never use a static final named constant for the 100 or refer to it as myArray.length. To make changing this constant even more difficult, use the literal 50 instead of 100/2. These time-honored techniques are especially effective in a program with two unrelated arrays that accidentally happen to both have 100 elements.
  24. Eschew any form of table-driven logic. It starts out innocently enough, but soon leads to end users proof reading and then, shudder, even modifying the tables for themselves.
  25. Join a computer book of the month club. Select authors who appear to be too busy writing books to have had any time to actually write any code themselves. Browse the local bookstore for titles with lots of cloud diagrams in them and no coding examples. Skim these books to learn obscure pedantic words you can use to intimidate the whippersnappers that come after you. Your code should impress. If people can't understand your vocabulary, they must assume that you are very intelligent and that your algorithms are very deep. Avoid any sort of homely analogies in your algorithm explanations.
  26. I have saved the best for last. From a psychological warfare point of view, this is the most effective weapon for rattling maintenance programmers. On a method called makeSnafucated, insert only the comment /* make snafucated */. Never define what snafucated means anywhere. Only a fool does not already know, with complete certainty, what snafucated means.

Thursday, November 13, 2008

More Quotes

All thanks to a good friend of mine :)

  • I would rather have a mind opened by wonder than one closed by belief-Gerry Spence
  • I would never die for my beliefs because I might be wrong- Bertrand Russel
  • Success is the result of good judgement, good judgement is a result of experience, experience is often the result of bad judgement- Tony Robbins
  • If the only tool you have is hammer, you approach every problem as if it were a nail- Bobby Knight
  • Half of our mistakes in life arise from thinking when we ought to feel and feeling when we ought to think-Robert Frost
  • Most of us can read the writing on the wall; we just assume it's addressed to someone else- Ivern Ball
  • You were born an original.Don't die a copy-John Mason
  • It's not that I'm so smart, it's just that I stay with problems longer-Albert Einstein
  • Great spirits have always found violent opposition from mediocre minds-Albert Einstein
  • It is hard to believe that a man is telling the truth when you know that you would lie if you were in his place-HL Mencken
  • Don't expect a great day, make one- On a billboard in Manhattan
  • Never let your sense of morals prevent you from doing what's right- Isaac Asimov
  • I couldn't wait for success, so I went ahead without it- Jonathon Winters
  • Even if you are on the right track you'll get run over if you just sit there- Anonymous
  • Nobody says "it's just a game" when their team is winning- Anonymous
  • The price good men pay for indifference to public affairs is to be ruled by evil men- Plato
  • I'm looking for a lot of men who have an infinite capacity to not know what can't be done- Henry Ford
  • Most of what matters in your life takes place in your absence- S
  • Life is a tragedy for those who feel, and a comedy for those who think- La Bruyere
  • The hardest job kids face today is learning good manners without seeing any- Fred Astaine
  • The problem with the world is that fools and fanatics are always so certain of themselves, but wiser people so full of doubts - Bertrand Russell
  • By working faithfully eight hours a day, you may eventually get to be boss and work 12 hours a day - Robert Frost

Wednesday, November 12, 2008

Cleansing of the Parliament

Currently the situation of Indian Parliament is such that every one in four MP has a criminal background or a criminal case registered against him. Well as is expected in any other other 'free' country, India too has in laws that all men are to be considered as not guilty unless convicted. But the problem is that the judiciary here is too overloaded and too slow for any conviction to happen. Partly because of three courts of appeal and partly cause of police inefficiency (includes corruption etc). Whatever be the cause the truth is that hardly ever any sitting MP has been convicted for any crime. But here are some steps that may help in criminals reconsidering their entry in politics atleast directly:

  • First whenever any person is elected as MP, MLA or any other Elected Representative all cases pending against him are transferred to a special fast-track court with a special CBI type authority investigating them.
  • Make appointment for CBI Chief, Chief Election Officer and Chief Justice as election of President is held. There is still scope for favoritism but its better that government directly appointing them.
I think the above steps can really help in preventing criminals from getting elected.
Few more thing that can be done to really improve the situation are:
  • Option of 'None of the Above' in voting list (has also been suggested by EC). It was also suggested that if the above option wins the majority then the candidates cannot appear in re-poll.
  • Next, American style we can have properly organised debates between party leaders which are telecasted by all the channels. What we have right now is that top leaders of parties come in different channels and its more a show of who has a louder voice than of issues. The debates should be conducted by any known neutral authority and direct questions must be asked pertaining to present issues. With a growing of young and educated class of voters it will help them more in deciding whom to vote for.

Sunday, November 2, 2008

!(Jai Marathi); Let Humanity Survive

Am sure all of us (even those who live in dream world or whatever) must have heard of Raj Thackeray these days. Well it seems that hes just keeping up with the traditions of his family. But the sorry fact is that instead of opposing him politicians from ALL parties are siding up with him.

Here is the most recent endorsement:
http://timesofindia.indiatimes.com/NCP_backs_Raj_campaign_against_migrants/articleshow/3665048.cms
and thats from the opposition party and from a cabinet minister!

what he is opposing against is influx of north indian (up and bihar) migrants in mumbai. atleast thats the issue he wants to bring out. Okay its true to some extent that in comparison labuor is cheaper from north india. Also about the RRB exam. It may be somewhat wrong to allow candidates from same state to participate in different exams held by different divisions. but is violence the solution?
and where will the division stop?
what is the solution?
seal borders of all states?
allow only those who will benefit the state to enter it?
and will the leaders be satisfied in state division?

what if the now asking to seal bombay so that nagpur people dont come in. surely labour would be cheaper out of mumbai that in mumbai. why cant people see that as raj thackeray is interested in winning polls from only maharashtra that why he's just a maharashtrian. when a new person comes whos satisfied with being just mumbaikar then he'll ask for a seperate mumbai. when will people stop falling for division on lines of states, religion, language or anything new these corrupt politicians come up with. why dont they protest against many foreigners based in the city who have raised the cost of living of mumbai. surely thats affecting the common man.

Also about Marathi signboards. Why does people force common sense out of their mind? In a metropolitian city like Mumbai how can a shop choose a marathi signboard over an english one. If they can put two then its alright but choosing marathi one over english is as good as cosing down the shop.

Its similar to the kind of argument i heard few years back for making Hindi as the national language and to make it compulsary for learning. Now using raj thackerays sense of marathi only we can assume that everyone will learn the language of the state. thats valid for all of south states. Now no one challenge English as the worldwide language. So anyone who studies gotta learn english too. Now how in sane mind can you expect a normal person to learn 3 languages in his childhood? Why can people see that for any reason English is much more suitable for being a unifying language of india instead of Hindi. Am not saying that let any culture die. For that even Sanskrit is important. But make it optional. Culture does not survive by force but survives only when people are really interested. Even I was forced to learn (excluding any understanding) Sanskrit but that forceful act did not result in me preserving the language. I threw it out of my mind as quickly as i gave my exam.

And lastly when will people realise that violence for any reason is not justified!!. Am not a preacher of Gandhi but I bealive unless someone physically hurts you violence should be avoided.

Why do people need some label to bind them! Is not human heart and mind strong enough for that? I just hope that someday people rise above divisions and think with an individual mind!

Any Indian still left out there??? or better anyone whos satisfied just being a HUMAN?????????

Recent Comments


Stats