Article 53WJK CodeSOD: Classic WTF: A Char'd Enum

CodeSOD: Classic WTF: A Char'd Enum

by
Alex Papadimoulis
from The Daily WTF on (#53WJK)
It's a holiday in the US today, so we're reaching back into the archives while doing some quarantine grilling. This classic has a... special approach to handling enums. Original. --Remy

Ah yes, the enum. It's a convenient way to give an integer a discrete domain of values, without having to worry about constants. But you see, therein lies the problem. What happens if you don't want to use an integer? Perhaps you'd like to use a string? Or a datetime? Or a char?

If that were the case, some might say just make a class that acts similarly, or then you clearly don't want an enum. But others, such as Dan Holmes' colleague, go a different route. They make sure they can fit chars into enums.

'******* Asc Constants ********Private Const a = 65Private Const b = 66Private Const c = 67Private Const d = 68Private Const e = 69Private Const f = 70Private Const H = 72Private Const i = 73Private Const l = 76Private Const m = 77Private Const n = 78Private Const O = 79Private Const p = 80Private Const r = 82Private Const s = 83Private Const t = 84Private Const u = 85Private Const x = 88 ... snip ...'******* Status Enums *********Public Enum MessageStatus MsgError = e MsgInformation = i ProdMsg = p UpLoad = u Removed = xEnd EnumPublic Enum PalletTable Shipped = s 'Pallet status code Available = aEnd Enum
proget-icon.png [Advertisement] Ensure your software is built only once and then deployed consistently across environments, by packaging your applications and components. Learn how today! TheDailyWtf?d=yIl2AUoC8zAsa728FN7RFc
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments