10 ms·
Fizz Buzz: Enterprise Edition
- jxf 14y agoFunny, but a little too obvious. What if you did a Poe's Law version of this? That is, try to create the most contrived parody of a solution to FizzBuzz possible, but one which still fools at least 50% of interviewers into thinking it's a legitimate response.
- minimaxir 14y agoThat would just be a script to Google for the FizzBuzz solution.
- mimiflynn 14y agoThe obviousness is probably to avoid flames. I'd love to see a branch of this with your suggestion, though... and maybe a script that would automatically generate a file structure that reflect the namespace of serious business with which one is interviewing. You know, for fun ;)
- canadev 14y agoI got about 4 levels deep in the folder hierarchy before I got disgusted and had to close the tab.
- Aco- 14y agorefactored: class F{public static void main(String[]a){for(int i=0;i++<100;)System.out.println((i%3>0?"":"Fizz")+(i%5>0?i%3>0?""+i:"":"Buzz"));}}
- deleted 14y ago[deleted]
- WayneDB 14y agoThat's great, but we're here to make fun of "Enterprise" programming and anything associated with it. Now you come along and give us this simple example that works. I bet it would still be better in Javascript or Ruby because those are the only two languages that I know and everything is better as a web app anyway.
- georgemcbay 14y agoThis would be hilarious if it weren't so painfully accurate for some code bases I've had the misfortune of working with.
- fournm 14y agoThis is my day job in a nutshell. Somewhere around the 5th folder click I couldn't decide if I wanted to laugh or cry.
- joshrotenberg 14y agoCry. You wanted to cry.
- skore 14y agoI did cry a little. Hit too close to what is sometimes home[0]. [0] https://plus.google.com/u/0/111011776153281260419/posts/GWdkoC4f1Gb https://plus.google.com/u/0/111011776153281260419/posts/GWdk...
- selter01 14y agohow?!?
- bediger4000 14y agoIt's not so accurate with codebases I've worked on in that the indenting is far too regular. Naming convention seems consistent throughout, as well.
- rjzzleep 14y agolol, cracked me up. I met some c# guy who did the whole enterprise thing in his version, but it wasn't tongue in cheek at all. in my head I went, this is why the whole ms enterprise stack sucks balls. the sad part is that they actually think it's good to abstract away something really simple. EDIT: removed the link, sorry for offending you dude
- WayneDB 14y ago"in my head I went, this is why the whole ms enterprise stack sucks balls." Brilliant. So, if some random programmer built some way-over-complicated Javascript solution, would you think that the entire web platform "sucks balls"? "the sad part is that they actually think it's good to abstract away something really simple." Who is they? Microsoft, this random c# guy or all c# programmers? If you answer anything but "random c# guy", I'd like your evidence please. Also, let's see some of your code please. Not fizzbuzz. I wanna see some of your real life code.
- pekk 14y agoThe problem isn't random programmers, it is a culture and tool ecosystem which says that this is the right way to do things. If it were just one random programmer, there would be nothing to complain about. If some guy decides to write his website in his own dialect of Visual Basic, that isn't really being inflicted on anyone but his employees. The deeply-nested StrategyFactory stuff is an infection which worst affects languages like Java and C# (recruiters call it "OOP") because those communities do not strongly reject it.
- fmstephe 14y agoI love this. I just wish it was a joke. This is a daily reality for so many of us.
- niggler 14y agodo you put .java. in your package names? That one stood out as really strange (others were par for the course)
- ajanuary 14y agoWhat if you have projects in other jvm languages?
- georgemcbay 14y agoI haven't actually seen java in package names, but I can easily imagine the conversation where some over-planning architecture astronaut decides that the project may need code in another language in the future (without bothering to worry about if that language even uses Java style packages) and so they better make a directory that is specific for the Java code so they can keep the other code separate, if they need to add more languages in the future.
- fournm 14y agoI've not seen it directly in the package names, but I've definitely seen project hierarchies with source/java even though no other languages were used (or going to be used, for that matter).
- niggler 14y agoWhere's the build script?
- joeblau 14y agoGradle build script of course!
- mosburger 14y agoThis is obviously bogus. Where are the XML configuration files?
- Terretta 14y agoThis needs at least 70 maven dependencies.
- jlgreco 14y agoIt's just not enterprise if it's not relying on an internally modified version of maven that drops compatibility with the outside world.
- rapind 14y agoDon't you know that auto-wiring dependencies changed everything? Look at how much more concise this is now without all that XML...
- ambiate 14y agoThis is how I learned Java in software engineering. Simplistic if/else logic transitioned to enterprise madness. It left a bad taste for most of us in the program. If you are a teacher in this position, provide fleshed out source/examples of enterprise software/requirements and have the students extend the functionality. Using minimized examples to prove the concept leads to rebellion/disgust.
- paf31 14y agoI can't tell if some of the obviously missing patterns are accidental or just representative of that usual type of code with all of the wrong patterns and none of the right ones.
- edw519 14y agoPlease note that GitHub no longer supports Internet Explorer versions 7 or 8. How ironic. This covers so many enterprise programmers with locked down Windows PCs.
- bicknergseng 14y agoTwitter stopped supporting both a while ago as well.
- arkitaip 14y agoGithub's analytics probably says something else.
- idunno246 14y agoWhat are the chances that a company that locks down on IE will let them use github
- mikegirouard 14y agoIn my case, it lasted for about 4 months.
- portlander12345 14y agoOf course, a really industrial-strength FizzBuzz would be in an SVN repo.
- packetslave 14y agoHa! You think any enterprise IT shop is going to trust an open-source product like Subversion with their mission-critical source code? It would be in Perforce or MS Team Foundation Server.
- at-fates-hands 14y agoSometimes they don't have a say. I've worked with several large fortune 500 companies who use SVN, regardless of how much the IT Department objected to it.
- grannyg00se 14y agoThis is terrifying. It's like a docu-horror flick for programmers. I actually felt depressed, anxious, frightened, and dispaired going through that code.
- gingerlime 14y agomy colleagues had to come round to my desk to see what it was I was laughing about. Don't remember the last time looking at code made me laugh.
- jonahss 14y agoIt's rather cumbersome that you have to initialize all those factories in FizzBuzz.java. You should probably be using an Inversion of Control system.
- modarts 14y agoBut what if you wanted to swap out your IOC container? I think you'd have to inject your container using an InversionOfControlFactory pattern
- Mahn 14y agoNeeds more Internal Frames.
- Silhouette 14y agoIt's all fine, you just need a better IDE. :-)
- deleted 14y ago[deleted]
- stugrey 14y agoSo, so good. I hope it includes at least one undocumented legacy code nightmare for true authenticity.
- leothekim 14y agoWow. There were pull requests that were accepted to this project: https://github.com/Mikkeren/FizzBuzzEnterpriseEdition/pulls?direction=desc&page=1&sort=created&state=closed https://github.com/Mikkeren/FizzBuzzEnterpriseEdition/pulls?... The potential for more funny is great here.
- SatvikBeri 14y agoMy favorite: Change <= to < and == "One-liners lead to unclear code that has too much responsibility crammed into too little space. It's better to do less per line and keep the code readable. This changes the very complex and ambiguous operation <= into two separate, easily understood operations < and ==."
- kibwen 14y agoLast week my colleagues and I realized that the official, Zend-provided, XML-based communication system that allows our PHP middle-end to talk to our RPG-based backend doesn't allow you to return any character string that includes a less-than symbol. One of our routines returns a SQL string. Sometimes SQL strings contain less-than symbols. After much handwringing and an official bugfix that fixed nothing whatsoever, we decided on the next-best solution: all instances of `where foo < bar` must be generated as `where foo != bar and foo !> bar`. I shit you not, that is a not-greater-than operator. http://pic.dhe.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.qmf.doc.ref%2Fdsqi2mst263.htm http://pic.dhe.ibm.com/infocenter/dzichelp/v2r2/index.jsp?to... I may sound frustrated, but I'm not. We all had a good laugh at the workaround and got back to work. This sort of thing is sometimes known as "job security".
- sbmassey 14y agoWhere is the Spring dependency injection stuff? You can't just hard code all your Factories in FizzBuzz.java, you need to specify everything using XML so you can switch Factories without going through a recompilation.
- cgh 14y agoExactly. No Spring, no Maven...I mean, come on. Plus, I'd like to see some Camel routing defined for sending my crucial FizzBuzz results to various endpoints. Oh yeah, and what about when I want to run scheduled FizzBuzz? Obviously I need Quartz, which requires...more XML! Let's not get into the necessity of making a FizzBuzz OSGi bundle - we'll tackle that in the next iteration.
- portlander12345 14y agoSounds like a typical Gemfile.
- MattRogish 14y agoI've often wondered - is it the language that spawns this or the mindset of the developer (or both?) I see this primarily in Java or .NET shops - massive layer upon layer, code generation, factories, classes, etc. - when a simple architecture would be best. Why do we get these insane things to begin with? What's going on? It feels sort of like premature scaling (what if we have millions of programmers - we need more abstractions!) combined with misuse/misapplication of design patterns. You'll never* see stuff like this in Ruby on Rails, JavaScript, Python projects, etc. I'm curious how one goes from a simple, elegant program to over-engineered monstrosities. * Hardly ever. I haven't in > 7 years.
- DannyBee 14y agoPart of it is "customers want it", part of it is because people are taught "abstraction is good", rather than "abstraction can be useful". So folks abstract everything, because they don't stop to think about whether it makes sense. You know, just in case the day comes when they need to send requests using carrier pigeons instead of TCP. They never stop to think whether "in a world where we need carrier pigeons, would this app be useful anyway?"
- bitwize 14y agoPart of it is "customers want it", part of it is because people are taught "abstraction is good", rather than "abstraction can be useful". "Object-oriented abstraction is going to change everything." "Yeah, abstraction is good."
- tracker1 14y agoHave to agree there... but without having to support/supplant multiple systems simultaneously, or in support of rigid testing, it doesn't make much sense. In the former case, it's usually easier to rewrite than write a new, compatible abstraction... in the latter, with simpler more custom interfaces, testing can be smoother than a lot of frameworks for these things.
- deleted 14y ago[deleted]
- ffn 14y agoGod... this is particularly painful because I remember first seeing this in a thread on boards.4chan.org/g/... and now, several months later, here it is on hacker news.
- trotsky 14y agoStartup edition: * provision one ec2 instance per number to check * assign numeric order based on uptime in msec using zookeeper * serve result via json * render it on the client.
- emiljbs 14y agoDon't forget about the RESTful interface to the application.
- rjzzleep 14y agofirst of all restful and json are not really welcome. do your JAX-WS first and then we can talk about these new silly things.
- brightsize 14y agoGood point. Those fizzy SOAP requests need to be signed too. Enterprise Security and all.
- d4nt 14y agoNo, step #1 is to put up a launchrock page promising FizzBuzz'd numbers and seeing how many signups you can get.
- raverbashing 14y agoMaybe they will use Heroku instead of EC2 It is done in node.js with the latest something.js fad that provides event-driven async MVC interfaces in Coffee script or something like that Also, they will have 100% code coverage (thanks Uncle Bob) but will fail at launch since nobody bothered to test it for more than one user.
- eurodance 14y ago* import multiple javascript libraries titled as their filename.
- kemiller 14y agoI'm disappointed. They could have removed the if/else blocks by dynamically selecting the strategy and abstracted the loop. B- ;) Tempted to send this to my Java colleagues.
- daeken 14y agoI had a bunch of fun coming up with terrible ways to write FizzBuzz a little while back. My favorites, in Python https://gist.github.com/daeken/1e3c680c20da98c680c4 https://gist.github.com/daeken/1e3c680c20da98c680c4 and C https://gist.github.com/daeken/15769d83b66974335f78 https://gist.github.com/daeken/15769d83b66974335f78
- pcote 14y ago# That inspired me to have a bit of my own fun. Here's my awful Python take on it. [(n, (lambda x: ("fizz" if x % 3 == 0 else "") + ("buzz" if x % 5 == 0 else ""))(n)) for n in range(1,51)]
- Goopplesoft 14y agoThat python code made me cringe. decorators, parsing, compiling and evals? You win.
- reinhardt 14y agoNo metaclasses or descriptors though, still needs some work.
- pcote 14y agoOh, you want metaclasses? How about this? print(type("",(),{"__call__": lambda self, start, end: [(n, (lambda x: ("fizz" if x % 3 == 0 else "") + ("buzz" if x % 5 == 0 else ""))(n)) for n in range(start,end+1)] })()(1,50))
- shuzchen 14y agoHere's my python version that uses the y-combinator: https://gist.github.com/sirpengi/3443999 https://gist.github.com/sirpengi/3443999
- jconley 14y agoAmateur hour. Serious Business this is not. Where are the tests? The Inversion of Control? The logging? The analytics system? Documentation? Architecture diagrams? Someone should either fire or promote this engineer immediately.
- camus 14y agoAnd he should have used a CHAIN OF RESPONSABILITY pattern instead of the IF/ELSE to handle each case , and the FOR loop should have been handled by a STATE PATTERN , finally the system.prints require a full BUILDER to decouple datas from rendering triggered by COMMANDS , that work is indeed "amateurish" , especially without a SERVICE LOCATOR.
- whichdan 14y agoIf you want to turn this into a SaaS solution, I would be happy to donate the domain FizzBuzzAPI.com to your cause. I think the community would really benefit from being able to offload the overhead of solving FizzBuzz problems to an external service.
- jrabone 14y agoNothing new here... https://groups.google.com/forum/?fromgroups=#!msg/alt.humor.best-of-usenet/DRfqzWlNUbQ/iPlJIjfaiN8J https://groups.google.com/forum/?fromgroups=#!msg/alt.humor.... [1997]
- orangethirty 14y ago*Ticket 23145gwy54fvdr* Variable names do not follow standard. Revise and submit to Q&A.
- kayoone 14y agoHaha, i remember this new java guy at my (games)company that implemented his version of a skill/weapon system and in the end had like 20 Different Classes/Interfaces/Abstract Classes/Factories. It worked, but was horribly over engineered and much harder to understand than a much simpler version we made out of it. Abstraction makes code harder to read, so use it wisely!
- brightsize 14y agoThis may be Enterprise Quality but without UML diagrams our Architects are not going to be able to understand or use the code. Are you offering support contracts? MegaCorp Management requires that we have paid support, the more expensive the better.
- habosa 14y agoCan you get this into a Maven repo? I'd like to include it via my pom.xml, I have some numbers that need FizzBuzzing and they always say great developers never repeat the work of others.
- 31reasons 14y agoI think a lot of programmers in the enterprise world are consultants and paid by the hour or day. That means longer it takes to solve a problem and then later support it the better. You are paid more for working on the project longer. That naturally drives people to create elaborate schemes for simple problems and make more money. I give another example where goals and rewards are misplaced. India has a serious Cow problem. Every city in india has thousands of cows roaming freely on the streets. New Delhi, india's capital decided to solve this problem by hiring workers who would take this cows from the streets , put them in trucks and move out of the city. They get paid for the number of cows they collect every day. Guess what happens ? They release the cows next day into the city so that they can collect again and make money. Anywhere there are goals and rewards misplaced, inefficiencies will creep up.
- agibsonccc 14y agoWhere's the xml configuration and dependency injection? (I'm a java programmer primarily myself and thought this was hilarious)
- edmond_dantes 14y agoTo truly be enterprise it needs a Maven build and JavaDocs.
- rachelbythebay 14y agoWant to see this kind of stuff done entirely seriously? Search for solutions to the "Thoughtworks rover" problem. When you see a class for each direction you might be heading, you know you're on the right track.
- raganwald 14y agoThis seems to be implemented in a single programming language without any dependencies on legacy systems. A truly enterprise-grade system talks to PL/SQL stored procedures. Or it would, if the DBAs had written the stored procedures. But they haven't responded to your ticket request yet. And when they do, it will be with a mostly irrelevant question delaying actual work for another week. by which time their manager will be offsite at OracleWorld and won't be able to approve the changes.
- Shorel 14y agoAt the very least we can have a FizzBuzz table with a FizzBuzz field and the following records: 3 5
- serverascode 14y agoAwesome! :)
- dansari 14y agoAnd access it using Hibernate.
- xntrk 14y agoThere should also be other applications that do almost exactly the same thing but display the information in a slightly way but use a completly different code bases.
- logn 14y agoInteresting. I see a need for an adapter library and maybe some runtime configuration settings to choose your preferred, underlying fizz-buzz library.
- logn 14y agoAlso it would be nice to configure the strategies with XML. Plus it would be super helpful to have jar plugins for new strategies. And seriously, there's no SOAP interface? This is hardly usable then. Also how the heck am I supposed to build this without Ant and batch and shell scripts to call Ant? Plus once you get ant files you can integrate it with Hudson. And package this as an EAR and add some user authentication too, probably single sign on. Also needs some log4j. And there are probably all sorts of unforeseen bugs and style issues, so it needs Findbugs and Checkstyle integrated.
- samspot 14y agoIMO this doesn't make the cut because they didn't externalize the Strings "Fizz" and "Buzz".
- Aloisius 14y agoCan someone tell me why Java seems so to have developed into this kind of chaos? It isn't just enterprise java, has anyone looked at the Apache java projects lately? Tens of thousands of lines of dependency xml (that often doesn't even work because of incompatible common dependencies), three different built systems (ivy, ant and maven), abstraction for classes that have just a single concrete version, dependencies that are old and no longer supported (I'm looking at you Apache Gora). Hell, find the download link on most Apache java project sites. Now find the one for the source repository. What madness has infected Java developers? (Sadly, I've recently had to start doing a bunch of big data work with hadoop, possibly the most fractured and poorly documented open source project ever created)
- ekimekim 14y agoYour fallacy here is that: Enterprise programmer -> Java Developer Java Developer -/-> Enterprise programmer The correct question is: What madness has infected Enterprise developers (and why do they all use Java)?
- jlgreco 14y agoIt is not as common these days, but the "enterprise bug" pops up with C++ sometimes as well. "Enterprise C++" doesn't look quite the same as "Enterprise Java" (generally the build tools/system/etc are not particularly enterprisified), but when you see it you'll recognize it as the product of a similar mind by it's distinct smell.
- tomjakubowski 14y agoJust so I never have to answer it again for an interview, I wrote a specification and implementation for FBaaS (FizzBuzz as a Service): http://github.com/tomjakubowski/fbaas http://github.com/tomjakubowski/fbaas https://github.com/tomjakubowski/fbaas/tree/sinatra https://github.com/tomjakubowski/fbaas/tree/sinatra Accepting pull requests! I've had a couple mind-blowing contributions in obscure languages, my favorite being a provably correct Fizzbuzz service written in Coq: https://github.com/tomjakubowski/fbaas/tree/coq+hs+wai https://github.com/tomjakubowski/fbaas/tree/coq+hs+wai
- capkutay 14y agoHe forgot to mavenize the project...
- jodrellblank 14y agoHow is anyone supposed to tell this is a spoof when things like this ' sum = sum + i Array.SetValue( Text.Append( "GetSum", GetSum_Locals), "sum", Array.GetValue( Text.Append( "GetSum", GetSum_Locals), "sum" ) + Array.GetValue( Text.Append( "GetSum", GetSum_Locals), "i" ) ) - http://wiki.smallbasic.com/Simulating%20Local%20Variables.ashx http://wiki.smallbasic.com/Simulating%20Local%20Variables.as... unironically exist in a language "aimed at bringing "fun" back to programming. By providing a small and easy to learn programming language in a friendly and inviting development environment, Small Basic makes programming a breeze" ?
- Tichy 14y agoSo can this automatically be distributed to multiple servers? Impressive.
- ttrreeww 14y agoPlease open your issues at https://github.com/Mikkeren/FizzBuzzEnterpriseEdition/issues?state=open https://github.com/Mikkeren/FizzBuzzEnterpriseEdition/issues... And contribute your fix.
- rcoh 14y agoThis is missing Spring config! How could is possibly be considered a real enterprise app without at least half of its logic encoded in XML!