r/badcode • • Mar 22 '21

[deleted by user]

[removed]

257 Upvotes

86 comments sorted by

View all comments

Show parent comment

16

u/Mabi19_ Mar 22 '21 edited Mar 22 '21

Here are the features, in case you can't read the pure embodiment of evil above. (Okay, maybe I'm exaggerating a little.)

  • No-one remembers that * makes a pointer, so I use Ptr<type> everywhere
  • I just used a #define for the PtrCast because I felt like it (definitely not because I forgot how to make it using template metaprogramming)
  • The using namespace std; is only for 1 function call
  • References don't exist
  • I don't know what the new operator actually does
  • Mixed old style and new style of I/O
  • The braces are just everywhere
  • Brackets too, though not as much
  • One overly descriptive function name
  • The pointer compare is made into less-than-or-equal instead of just less-than when an extra null pointer argument is passed in
  • Pointer arithmetic everywhere, except when I learned that you can just use array indexing but I didn't want to change all of the existing code
  • A possum (readPossum: corrected case readPosSum) counts the characters read
  • It leaks all of the world's memory
  • I always choose the function that is the worst possible choice for the task.