There is a post going round on facebook of a mug with some code on it. There's even a reddit post on it. The mug looks quite nice but sadly the code on it is crap.
- The code is not placed in a separate namespace
- A
var
keyword is not used when assigning theCoffee
object - The object oriented style abstraction is broken
- There is no container for the coffee
- There is no dispenser for the coffee
- There is no person to drink the coffee
- There is no SoftwareDeveloper object
- There are flaws in the logic
- When the
coffee
is refilled it is not drunk - The logic is only run once
- When the
- The comment is totally useless
- The code style does not adhere to the C# coding standards for .NET
- Rule 2.3. Do not create declarations of the same type (namespace, class, method, property, field, or parameter) and access modifier (protected, public, private, internal) that vary only by capitalization.
- Rule 2.18. Try to prefix Boolean variables and properties with “Can”, “Is” or “Has”.
- Rule 4.3.33. Avoid invoking methods within a conditional expression.
- There is no logging, error handling or messaging
Honestly, if I came across such code in a peer review it would not pass.
Beside these issues, the code is written in C# (created by Microsoft) and not in the more suitable CoffeeScript
At a certain point I might feel like writing a better version.
Right now, my coffee mug is empty, so I'm going to get a refill first ;-)