Full readme:
Title:
---
The Beast 101
About:
---
(C) Copyright 2007 Michael Meeuwisse
Entry for the OMGWTF competition
Compile instructions:
---
I'm completely unfamiliar with VC++. Most files (except the really big ones)
which it generated are still included, try opening the vcproj in calculator?
It's a plain win32 console app (no clr / .net / whatever) and uses the same
initialisation stuff as the original framework. I had to turn off unicode
in the settings, you probably have to do that as well if you make a new
project file.
Description:
---
Finally getting a serious project, the junior programmer remembers
all those introduction classes into enterprise-level subjects like Model View
Controller, Backus-Naur form, how efficient it is to calculate with a stack, the
wonders of Reverse Polish Notation and how to automatically generate that from
mere infix input.
The results were... interesting. Maybe it was his misunderstanding of most
subjects, maybe it was the C++ tactics applied in plain C. Either way, the
project worked and a shining example of his enthousiasm.
He was fired the next day.
Attached is his calculator, which by now has been nicknamed The Beast. Not for
the faint of heart, since it all looks perfectly fine at a first glance. But
then, the horrors will quickly take your breath wishing you had never heard of
the language once called C.
This entry was unfortunately disqualified for unknown reasons, probably because it wouldn't compile (which I still find odd, it still works without a problem here... but see the readme) however I still think I had a few nice points in there worth your attention, so I asked Alex to put it online.
A few WTF dots explained;
- Has a terrible BNF implementation which /isn't/ used to calculate the final result (when you're learning BNF, the first thing you get to know is how to build a 'calculator' with it) and ends up being an overengineered divide-by-zero checker
- Converts from infix to postfix by use of a binary tree, which (again) /isn't/ used to calculate the final result (again, when learning about binary trees, one of the first thins you get to know is.. you get the idea here). Oh, and it does this badly, don't do complex negative math like 8-4*5.
- Uses a 'stack' implementation for speed, but has some terrible hacks around it (particulary in the BNF checker) and does the actual calculations there.
- Goes completely object orientated with button 'objects' and other kinds of 'objects' by a reimplementation of something that looks like the 'new' keyword, things like 'this' are all over the place, and functions are 'connected' to an 'object' by use of functionpointers in structs. The whole OO-in-plain-C is just asking for trouble. Also, hardcoded polymorphism by use of a switch in the constructor of the buttons.
- Does a few other things like applying MVC, but doesn't actually has a model so simply uses this 'object' as a place to store a bunch of globals.