« USB annoyances | Main | The application must be too fast »

WWANSBCD

After months of complaining about code written by a bunch of not-so-bright-consultants, I've decided to approach the problem differently. Don't just tear my hair out.. sit down and try to reason the solution the way the people who wrote the code must have been thinking.. Put myself in their shoes, so to speak. Here it is.. WWANSBCD[0]


  • Problem:
    Our system has users, users have roles and every now then we like to look at their roles and see them as more than just a bunch of numbers.
    Solution
    Take the list of role ids associated with each user and add role descriptions to the same object. If it's a string it's a role name, if it's an integer, it's a role id. Easy! Correlation? That wasn't specified in requirements.
  • Problem:
    Some roles can only be assigned if other roles are also assigned, in other words, there is some dependency.
    Solution:
    Create a JavaScript that makes sure checkboxes for roles that are dependent on others always stay checked... keep track of them by index in the list in which they're retrieved[1]
  • Problem:
    System design calls for using of business rule objects to validate information entered by the user.
    Solution:
    Create a IsValidString business rule object which checks for null string therefore satisfying the requirement for using a business rule object.
  • Problem:
    System design calls for using descriptive javadoc comments as documentation.
    Solution:
    Copy-paste the same comment all over the place without changing anything
  • Problem:
    System design call for using constant values for often used values.
    Solution:
    Define a constant value for 0. Name it ZERO. Use it in if statements.
  • Problem:
    Presentation code should not use classes from persistence package without going through EJB layer.
    Solution:
    Copy-Paste the code from persistence package into a common package and use it from there.

There's more.. oh is there ever more.

[0] What Would A Not So Bright Consultant Do, what else?
[1] And by all that is holy, don't change the order-by statements on the SQL that retrieves them from the db!

Comments

Anything shareworthy? thedailywtf.com always takes submissions, I hear.

At least be glad your system is not this system:
http://thedailywtf.com/forums/57637/ShowPost.aspx

Oh dear. I can definitely get a sense of the frustration this might cause, having gone through similar exercises, often with loud exclamations of rage and despair when I've grasped what the NSBC was thinking.

Conversely, when I have for left behind slabs of particularly horrible code (for one reason or another, including sheer laziness and time pressure), or slabs of particularly complicated code, I usually leave a comment saying "Hic est draco" and explaining either

a) it's horribly complicated and *will* break if you try to "fix" it;

or

b) it's horrible, and I wasn't trying to be clever, it's just horrible and deserves to be burnt at the stake.