Sunday, November 15, 2009

The Criminal Coder

Mr. Reader, in case you have read my previous posts (in case, is the key phrase here), you might be by now thinking me to have lost my psyche. How can I, the ubiquitous attorney of coders on this planet (and Mars) call them evil? Well, to clear out doubts, they are criminals when compared to their superiors (read developers).

How can anyone deglamorise the developer by comparing him with a coder? To me coders are beginners, not absolute beginners, but people who know stuffs, but simply skip to do them, the way it is meant to be done, for laziness or for reasons I fail to understand. It’s not the lack of intellectual capacity that causes them to commit mistakes (read crime), its rather their sluggishness, that makes them do what they want to do, even if that brings about compromise in terms of the code they inject to dilute (read pollute) the system.

The following are some snippets from production code(basic changes made to trim the demo) that I have encountered, in this short span of life (read professional life), and when debugging performance problems in applications, stumbled upon them, and literally felt like giving digital life imprisonment to those who had the audacity to commit these bits!

  • Object declarations inside loops: For simple objects I sometimes feel it’s unavoidable to declare objects of types inside a loop, but for complex types, it’s simply a crime. The following code was intended to improve the performance of the application by spawning new threads. Don’t find the need to say more, the code is self explanatory (and yes, gives a boost to performance):

    public  void UploadXML()
    DataTable dt = GetDataTableFromXML();
    for(int i=0; i<dt.Rows.Count; i++)
    Thread th = new Thread(…);
    Guess what will be the first problem that your app may run into? An OutOfMemoryException.

  • Unacceptable usage of If construct: The code is overly expressive of my intent.

    for(int i=0; i<1000; i++)
    //Do something here

  • Overly expressive logic: I didn’t have the courage to congratulate this guy and kept shut even after seeing this. There were 10 checkboxes in the page and all of them had this. All of them!

    //As if Checked return a float
    bool b = (checkBox.Checked==true? true: false);
    And I have seen even experienced guys do a

    on a string. What more do you expect from visual studio? Auto-detect these overly expressive conversions? Surely, it would do so, may be in VS 2014!

  • Global declarations in methods: Why not lazy declare and initialize at the point of usage? We are not in the C age any more (or are we?).

    public void Foo()
    int a, b, c, d;
    //50 LOC before using c and d

  • Avoiding short circuits: Short circuits were provided in the language for some reasons, why not use them to decrease the number of characters typed and let the compiler expand them?

    bool a = false;
    bool b = true;

    //do something with b here
    if(a ==false)
    //this is left blank (and yes, intentionally)
    if(b == true)
    //Some code to execute
    //Again left blank (intentionally ofcourse)
    Why is the following so uncommon to write amongst few geniuses (strict pun intended)?

    if(a == true && b==true)
    //Some code to execute

    I know you might be thinking who on earth will follow the above pattern and dilute the code, but I have seen it far too many places to avoid mentioning it. Fact is, some coders simply forget the fact that an if can stay without an else. There are innumerable examples and I will certainly update this post to show some really valid places for short circuits, which were completely skipped (and did i mention, knowingly?).

The above list can’t ever be exhaustive, since each coder has his own pattern of seeing the code. At times I tend to give them (the coders) some leniency by considering their experience with a particular language, but most times, it’s just unacceptable and unforgiveable.

The following is a beautiful extract about the types of competence (or incompetence) that we encounter:
  • Unconscious incompetence: You don’t know what you don’t know.
  • Conscious incompetence: You know what you don’t know.
  • Conscious competence: You know how to do it, but you have to think your way through it.
  • Unconscious competence: You can do it without thinking. You just know what to do.

By the way, the reason I termed the above as crime, was because all those coders had live code at their disposal while adding these bits. They simply ignored the style of existing code used in the application and were arrogant enough to not tilt from their style of coding.

To me, that is simply unacceptable and unforgivable crime!

Hail Visual Studio! Save us from the criminal coders!

Sunday, November 8, 2009

The agonizing SME developer

Before you begin to think too much into SME, let me sync you up by expanding it for you to the Small & Medium Enterprise (SME). To me these enterprises are a source of raw mystery. When hiring or making decisions up front they are humble to use the latter portion of the acronym (considering themselves no less to Google or MS), and while sharing rewards and parting with their stuffs, the former part is acknowledged (the financial stability is, as they say, on the rocks, literally and did I mention, always).

An interesting find about the word "agony" is that it not only covers intense physical pain but also the "mental anguish" associated with or without it. Through recursion, I soon found out that anguish leads to extreme anxiety or emotional torment. Emotions, almost always, shell themselves into passions, which by the way, is the root cause of misery of all software developers on planet Earth and Mars (they, the guys at NASA, have been shouting all along that life exists at Mars and if life exists, you bet, software developers exist too). So what has a naïve SME developer got to do with agony? Well, at the lowest permissible degree, they were married, in time and space, forever and ever and ever (infinite loop begins, statement truncated).

The lifecycle of an agonized SME developer is what follows…

the morning
A beautiful day begins with a beautiful morning, and this, surprisingly doesn’t hold good any more for the SME dev. Unlike any other professional, the first thought that crosses his (not intending to be gender biased, it’s just natural, you see, it could have been her as well, instead of his) mind is: what can go wrong today, it’s such a beautiful day? Little does he know, that for no fault of his (yes, almost always, there is no fault of his directly, and I am being subjective here) the day will turn out to be, to say the least, bewildering!

the journey to the castle
Notwithstanding the delight of travelling via public transport (describing it as pathetic would be an understatement, hence skipped), he transcends to the castle a.k.a. office in other professions. The unquestionable devotion (no pun intended) towards his work is physically visible as he takes long strides and enters the castle. Life, society, culture, esteem, pride and many other eligible candidates of personal character stay out as he walks in to the castle.

the starters
The most crucial activity of the day begins, checking personal email account. And to just give an example of the overflowing talent in him, even the strictest of firewalls and blockages are incapable of preventing him from accessing his aspirations. His concealed talent, resembling his meager pay slip, can by no measures be hidden, no matter how much he endeavors.

the dream
Unlike other professionals of his age (and beyond), he doesn’t intend to spend (again, skipping waste to avert understatement) his time, forwarding mails to his friends (remember, the social thing in him just stayed out as he entered the castle?). Rather with translucent aspirations, all he searches for (with a far optimized index then what Google can ever manage) is a call from anyone (being complacent) from his list of dream companies. Aghast!  Unlike Google, which returns a million results for even the most horrendous search terms, he witnesses a no results found (that’s why Google roars about its better, less optimized index).

the call
And before he could balance himself, here comes the call, from no one else, but his PM or TL or MD or CEO (remember its SME, so even CEOs have enough time to get on with individuals) or anyone at a relatively higher position then him. Yes, this is it! Life, if ever existed, will cease to exist. Problems, in case they don’t exist, will be created and accredited to him.

the aftermath
The repercussions of the call, a tiny list of tasks, generally, varied in nature and ranging from simple to super complex tasks, to be, in all magnitudes of time, be completed by the currently running day. And did I mention it’s already lunch time!

the optimizations
Being super talented has its own advantages; it allows you to optimize time, beyond the ordinary, spent in professional activities. And the SME dev is no exception, he quickly walks through the tasks list, completing the tasks ranging from simple to considerably complex in irrelevant time spans. The ultimate desire at any point of the day that keeps him inclined - leaving for home (sweet home) at the right time.

the valor
Quickly sensing that the day isn't as good (sarcasm intended) as it was supposed to be, he aims towards his superior with one of the most irrelevant issues of his life, increment (presuming his steady association with the company, which simply refuses to end).

the crime
Approaching for increment in an SME is in itself an offense, unforgiving and regretful. Irrespective of the person being approached, the debate, most of the time leads to a plethora of branching discussions (healthy ones) about - the ubiquitous recession. Even though he wasn't the offender in bringing the slump to the economy in general, still, as a solemn employee of the company, it is his (and solely his duty) to forget increments, incentives, and any other term that relatively maps to the same meaning. He is a developer, passion feeds him, and code recharges him, why on earth has he the need of a better pay scale? Why do we need money? Mostly for our social activities, and if the very social element is missing, why direct the funds in the wrong place?

the return
With an absolute sense of satisfaction, understanding his very own importance in the company and the role (the most important one) that he plays in the general growth of the company (as alluded by his superior), he returns to his desk, unaffected by the discussions, proceeding to what he was supposed to do, code!
The evening is as stale as the dreams he has, and proving his multitasking abilities, he goes ahead in search of his dreams again (accessing his personal email account, remember?) while coding the most complex tasks, wishing them to auto-complete, be auto-verified and surely get auto-published.

the home coming
It would be audacious to imagine that nothing went wrong while the evening squeezed past. Client feedback (mostly neutral, the positive, if any, never make up to him, an auto-transfer mechanism transfers his credits to his superior's account), bug lists, pending tasks (even after a full dedicated day of work) and an extinguished desire to return home is what awaits.
 The journey to home is as exciting (remember the public transport factor?) as it can be and seldom enough does he get time to re-structure his goals (which by now have been declared static).

The day ends, as any other; battles won (and battles lost), nevertheless the passion, the dream, the very sense of being a developer, remains!

Be an SME developer, its an experience life apart!

Saturday, October 24, 2009

IMiserable <T>

Before you think otherwise let me clarify that IMiserable <T> is not a new generic interface introduced in .NET 4.0. As I climb up the stairs as a developer, every passing day, there are certain things that simply make my life miserable day-in  and day-out.

I hereby attempt to list down the top 3 things that I believe are a mess for developers at large. It’s amazing how most of us (if not all) find ourselves hooked up eradicating these miseries per project, per day basis.

  • #3: My Code, my browser: I have been developing web applications for around 3years now and I simply couldn’t understand why I am supposed to make my pages compatible on all major browsers. For people who might say “why not”, here is my defense: Web is everywhere and the way to access it, the ubiquitous browser. Give me 1 reason as to why as a browser vendor, you need to make your own rendering decisions? Why can’t differences be only in terms of the underlying performance engine and client script execution engine? Why do u need to render tags differently, be it alignment for certain tags or other rendering decisions or awfully at times, some completely new names for similar elements across the DOM (supported across the browser with different names for same elements)? And to add insult to injury, you guys can’t even maintain compatibility between your own versions (and someone asked cross browser compatibility).

    Just because I don’t have a browser of my own (Vaibhav Explorer or VaiFox or Vaifari), am I supposed to tolerate this misery?

  • #2: this.Validate(): Did it ever cross your mind that if you were not supposed to write validation code (for all possible combinations of mess that the user can create) how much time, LOC, and execution optimization you might have gained? Just recently I was coding a Registration page with something around 30 fields with good numbers of Checkboxes, RadioButtons (in various groups) and plenty of DropDownLists and TextBoxes. And guess what, each dropdown was supposed to have a “Select” item at the top of the list and awfully enough, all fields (except checkboxes) were required. So selecting “Select” in a DropDownList wasn’t allowed and I was supposed to validate and prevent the user from submitting “invalid” input. This is the too common misery for all of us developers out there. And yes, did I mention that I was asked not to use the ASP .NET Validator controls (for some cynical reasons which only my PM can answer). And needless to say, every failed validation would prompt an alert box (in client script) with a custom prompt message. Trust me, and you would agree, roughly 60% of LOC of that page was validation script code. And yes, the ultimate saver of any developer Mr. Copy & Paste couldn’t help me beat the frustration out!

    Why can’t the world (denoting my dear clients and their honest and well-intentioned users) just provide valid input in the first place! I know it’s impossible but just imagine a world with no validation where every byte of input comes from a trusted source, is perfectly what I need and needless to say, side-effect free!

  • #1: Works on my Machine: This is undoubtedly the numero uno of our miseries! How many times have you found something perfectly executing on your local workstation and simply freaked up on the live server. And the first reply that comes (by default) when the PM enquires for the crash is: “It works on my Machine”! As if you didn’t knew that the client didn’t pay to browse “localhost”. It’s humorous how even seasoned developers cite this reason. And I have self witnessed this so many times that while my fellow dev was freaking out I was almost insane with an internal laughter (an external display of laughter will only dispose me and make me garbage collected by my company).

    And you would agree, the maximum time this misery appears is when it’s time for you to buzz off and the PM being a very respectable, honorable and understanding person, makes it clear that you aren’t leaving before everything is fixed showing absolutely no interest nor intent of lending even half the hand to help you out.

Share your miseries that you feel are worthy of being added to this list!

Debugging miseries is all we do day-in and day-out. Let’s just continue with it (as if there were other options available)!

Happy Coding!

Saturday, May 23, 2009

Windows 7 - Dreams come true!

Welcome to Windows 7!

Yes, version 7 of the flagship product from Microsoft, the successor of the not so overwhelmingly popular Windows Vista. Going by the release of this edition of Windows, it won't be unsafe to say, they finally got it right!

Having received thrashing from all corners of the world and from all user bases, including Developers, for the earlier version of Windows, “Windows Vista”, Microsoft was under tremendous pressure to recapture its lost esteem in the ever dominated arena of Operating Systems.
How many of us know the full names of operating systems that don’t start with the word Windows? Apple Mangoes anybody?
Truth be told, no matter how many times we hate that Blue Screen of Death (BSOD) or the sudden domination of the invisible force that hangs our work (and us literally), Windows is “the One” when it comes to the system software that runs atop stupid hardware!

Windows 7 is in the Release Candidate phase, meaning it’s almost complete, and is awaiting final feedback from users worldwide before final release to manufacturing (RTM). You can download it here.

Here’s what you need to have:
    • 1 GHz 32-bit or 64-bit processor or higher
    • 1 GB of system memory or more
    • 16 GB of available disk space
    • Support for DirectX 9 graphics with 128 MB memory (to enable the Aero theme)
    • DVD-R/W Drive

      • Quick preview of the things that caught my eye, instantly:

        • Taskbar -see it to believe it

  • Windows Media Player 12 - simply awesome!

  • Math Input Panel - awestruck!

  • Sticky Notes - why wasn't it included earlier?

  • Calculator - on steroids!

  • Paint & WordPad - kids grow up finally

Folks, I have been using Windows 7 since its RC (its free until March 01, 2010 after which the computer will start shutting down on itself every 2hours to remind me to purchase the final build). Its hard to believe but once you use Windows 7, u will end up saying "Gosh! How did i never feel the necessity of all these supremely essential features ever ?"

Its insane to say this, but this is by far the best Windows ever!
(Sorry XP darling, you have finally come off age)

Tall claims huh! Well, i can support it with some logic
(deriving from my programming background):
  • Built on the failure of Windows Vista, it boasts of all the customer driven improvements that Microsoft received for its previous release of Windows.
  • Compatibility, the core of the problem that plagued Vista, gets accurately and reasonably addressed, thanks to the thousands of devices that Windows 7 supports, simply out-of-the-box.
  • Superior performance, the gains are clearly visible if you have installed Windows Vista and then migrated to Windows 7. Same platform, same configuration, a boost in performance guaranteed, and as Microsoft claims, RC is just a work-in-progress as far as perf is concerned!
  • Customise, customise and customise. The biggest USP of Windows XP, that makes it still the most popular and widely acclaimed version of Windows till date, was customisation. With XP, you controlled your PC, literally. With Vista, they simply messed it up! Accessible options of XP were simply missing or unreachable. With Windows 7, you will experience the ultimate in customisation and usability.
There are simply innumerable features in this gigantic release of Windows 7, an entire bible might even fall short of explaining and exploring them. If you have reasonable hardware and a descent intent to enterprise, go ahead and install Windows 7.

You won't regret it!

Happy Windows 7 exploration!

Sunday, February 8, 2009

Why Software Development ?

I have been thinking off late as to why I chose to be a Software Developer ?

Here is what some of us may be driven by:
  1. humble pay slips,
  2. hi-tech (cool) workspaces, or
  3. sheer joy of being under stress?
The fact is, we don't do it for money, and neither did we choose it for the hi-tech life that comes with it. Also, people seldom like being under stress throughout the day (and more so as the evening approaches and clock strikes 07.00 pm, and you start wondering, why the task list is still incomplete, though you did nothing but the tasks, whole daylong)!

So what is it that drives us (we developers)?

Let’s face it, we are software developers because we were born such ways!
Nothing else fits us; we are good for nothing but code.
Our limited area of knowledge extends mostly to the following list:
  1. bugs (the entire day passes with these ugly things),
  2. stacks (varied nature, call stack, locals stack, global stack),
  3. heaps (ya, even though we didn’t create them in the first place, we simply used it),
  4. errors (design time, run time, unhandled, handled, may be even deliberate ones created by us).
For us the ultimate joy in life is seeing the error list shrinking down and eventually getting empty; the output window emitting “Build successful” and pressing F5 always is a path to glory (untold and unrewarded).

Isn’t it the most fulfilling thing on earth to see people using our applications and fulfilling their dreams and aspirations?

What is more satisfying then to see the minor differences that exist between our pay slip and the re-reimbursement that our company receives from our esteemed clients?

Truth be told, we are proud of ourselves.
So much so that, we don’t care who gains what due to us; rather we care about our IDEs, our editor font, and most importantly our clients’ feedback (they also call it bug list, but I would rather keep it motivating and call it feedback).

Be a developer... there is simply nothing more sufficing, nothing more rocking!

Happy Coding!