The "..." part you redacted out explicitly said "it is many different sections of code". It was (quite obviously) not one or two 5-line blocks of code, let alone "simple" ones like FizzBuzz.
A friend asked me to do some web scraping for her. Since I didn’t have much time, I figured out the difficult part — some home grown encryption/obfuscation scheme used by the website in question, and handed ~30 lines of Python to another programmer friend of hers, a Fortune 500 Java programmer, to finish the remaining boring work.
A day later the Java guy got back to me with a full blown Java project three levels deep which was just a translation of my ~30 lines of Python, and it “didn’t work”. I had to read what was now hundreds of lines of Java to find 3(!) bugs in it.
That day I realized FizzBuzzEnterpriseEdtion is much closer to reality than I thought.
I've seen examples of FizzBuzz Enterprise in practice, eg a small algorithmic challenge that reads in some data and finds a value was split into several files, one class to read the data, one class to run the algorithm, one file to print out the results, etc etc. What was supposed to be one function with less than 50 lines turned into a multi-class multi-file monstrosity. The Java coder doing it couldn't imagine doing it any other way.
I really struggle with the concept that some programmers cannot write FizzBuzz. I'd expect it from someone who has finished their first programming unit.
The below github account is making fun of the concept 'Enterprise code' and contains an Enterprise-level FizzBuzz solution. I have never seen that much code do so little.
FizzBuzz typically gets raised eyebrows from folks who never had to do it because they assume there's a trick somewhere. It can't just be a one-liner they assume.
> It was designed as "This is one of the simplest possible programs one can write.
Weeellll, I mean it doesn't totally succeed in meeting that design criteria. Fizzbuzz weeds out three kinds of candidates:
- candidates who are (currently) unfit for any programming job
- candidates who freeze up during the interview
- candidates who have never used the mod operator
I fault fizzbuzz a bit, because there are candidates in that last category who have several years of experience successfully duct-taping together libraries to meet product requirements, yet panic because they've never had to find the remainder of division in their language of choice. They might be fine for the rec you have open.
A fizzbuzz with fewer false-positive rejections might be something like "implement multiplication without using the multiplication operator".
edit: Oooh! "How many ways can you implement multiplication" would be a much more interesting warm-up/weed-out question! Allows the quality candidates lots of room to shine.
Ha! Thanks for sharing “enterprise FizzBuzz”; I’d not seen that before. I was digging through the code before I had a PTSD-related flashback from debugging some OO at my last company…
My friend and I were working together, when one of our seniors came over and asked us for help figuring out how to modify an algorithm that someone new on the project had rewritten. The algorithm was 20-30 well-commented lines of code, until the rewriter decided that it lacked flexibility. It had been rewritten to use a Singleton Factory to instantiate an implementation of an interface that itself delegated every snippet that could possibly be conceived of as a function to one of several different classes (Policy, Actor, Dispatcher, etc.). Every function was three lines or less, and all were entirely illegible taken in part or in whole.
I’m glad that team member got to show us how many times he read about design patterns and how much he knew about OOP, but it took four engineers (we later roped in another) to venture 15 layers down the call stack of virtual functions to figure out where a simple constant came from. Quality code indeed.
It is really fascinating, but I disagree a bit with your pick :)
To me, the most fascinating part is using a bytecode interpreter. It makes perfect sense, it's basically optimizing the code size to fits in the cache. It's also a bit like defining a whole new instruction set dedicated and optimized for Fizzbuzz!
Most of the state of the Fizzbuzz program is encoded in this bytecode.
> "Slower L3 memory operations", I've not read that sentence before
You hear it all the time when trying to optimize for speed in a hot loop. Keep your data structures in a way that fits in the cache. Align your data with cache boundaries. Code needs to be small too, hence the bytecode approach. This is also the reason why you can't unroll loops too much.
If your implementation does not need to fetch (or write) data from(/to) higher levels of the memory hierarchy, you'll see tremendous gains. There's even this bit in the original source: "while waiting for writes to go through to the L2 cache" :)
There are a few more very interesting hacks, such as the "high-decimal" format that skips the "need to do binary/decimal conversions."
>Pretty much everyone I asked to do Fizzbuzz failed
…I can't help but wonder what that really means? They gave up without producing any work? The program didn’t compile because they were typing random characters into the IDE? They were unfamiliar with the IDE, and couldn’t find the "compile" button? They couldn’t get the program to compile because of missing semicolons? The program didn’t write anything out to the terminal? The program never printed out "Fizz"? They printed out "FizzBuzz" on every line? The program never printed out numbers? The program printed out commas instead of newlines after every number? They went from 1 to 101 instead of 1 to 100?
Sorry to tell you, no they can't. There's a thousand business dudes with ideas that need implementing for every one that can code. And there's a shit ton of people who claim to be able to code but couldn't solve FizzBuzz.
The problem with sample code is that I have no idea if you actually wrote it. Maybe you copied it from Google, maybe your friend "helped" you. I have no idea. When I'm first interviewing you, I have no idea how honest you are. The only way I know for sure that you wrote the code is if I watch you write it in front of me.
I really like Fizzbuzz because for someone who is a good programmer, whether they've ever seen it or not, they can do it in about two minutes, and then at least I can believe that their code sample is theirs.
This was literally part of my first programming assignment in college. Can people really not do this? Isn't fizzbuzz considered too obvious these days? I feel like I must be misunderstanding...
reply