Hacker News new | ask | show | jobs
by testing12341234 4948 days ago
Boss: I need you to write me a program to print the numbers from 1 to 100

Me: Really? Is that really a business requirement? Any other requirements you need done?

Boss: Yes, it's your number 1 priority. No, just 1 to 100

Me: <a few minutes later> Done. Give it a review and I'll push it live.

Boss: <a few minutes later> No! I said 1 to 100 and everything divisible by 3 should be replaced by "FIZZ". Why didn't you do that?

Me: I'm pretty sure you didn't ask for that, but I'll do it right now. Any other requirements than FIZZ?

Boss: Thanks for taking care of this. There aren't any other requirements.

Me: <a few minutes later> Done. Give it a review and I'll push it live.

Boss: <a few minutes later> Seriously! Why didn't you put the BUZZ in there?

Me: What BUZZ are you talking about? You only asked for FIZZ.

Me: Wait a second, are you having me program FIZZBUZZ for you? What the heck!

Boss: Yes! Somebody on the internet asked how a non-programmer like myself would solve FIZZBUZZ!

Me: Sigh...

4 comments

    Me: Really? Is that really a business requirement? Any other requirements you need done?
I landed a graduate assistantship in 1992 as "the computer guy's assistant" at my school's physical plant. My first assignment was to generate a fixed format file with one phone number per line. The file was to range from 1-900-0000 to 1-900-999-9999 and was needed by the campus telephone system to block all premium rate calls. They asked me to do it because they got back a 30 day completion estimate from the central IT department after filling out an internal RFP form.

I'm sure somewhere, someone has been paid to write a program that prints 1 to 100.

I know people who spent at least 40 hours/month just updating dates in monthly/weekly excel reports.

Edit: and had 6 figure salaries.

This should be the definition of a modern society.
Yes, but if you fuck it up heads are gonna roll.
I ended up doing the equivalent so many times I wrote a sequence command that had masks and could increment (count) through arbitrary series of characters (AVF => A, V, F, AA, AV, etc). Good for dataset fills.
Marketing: That's great, but can we change it so that it says now with 25% more buzz? And also get anyone who reads FIZZBUZZ to sign up for our newsletter?
Marketing: And can you add some social media buttons? That will help it go viral.
Sales: Yeah, our nerds just completed this new platform called FIZZBUZZ we want you to buy. What's that? Of course it's a fully-featured CMS/CRM/DataWarehouse/SocialMediaAggregator, the developers just have to make a few tweaks...they should be finished in a day or two at most.
Support: Your salesperson told you WHAT?! FIZZBUZZ isn't really capable of that, I'm sorry. No. No. I'm sorry, no. No, again, I apologize, I can't change that for you right now. If you'd like, I can put in a feature request for you. No, I can't give you an ETA...
Technical Cofounder: Can we release it as a simple REST API that lets you calculate fizz buzz in the cloud?
Researcher: What is the meaning of FIZZ and BUZZ? What's the definition of the operation by which FIZZ and BUZZ combine into FIZZBUZZ?
To be fair when doing front end work you sometimes need to make pretty patterns that do something like "print this table but apply this css class to every other row and one of these other classes to this row if a certain flag is set depending on what the previous class was".
And this is the problem I have with CSS selectors. What you just described is ridiculously fragile and will send shudders down the spine of any developer experienced with wrangling projects that have tangles of inappropriate coupling, but in many cases, there simply isn't a more elegant solution. Your options are:

1. Implement a sane (albeit less powerful) view hierarchy system, foregoing basically all of the CSS selector stuff, and applying styles individually. The framework will be big and unwieldy, and you'll take a performance hit, but you'll be able to maintain the client code.

2. Bite the bullet and implement it the ad hoc way, comment the crap out of it, and hope that whoever comes and changes something later will remember to read those comments.

This stuff is getting solved, for the particular example you can use n-th child in modern browsers[0].

[0]http://www.quirksmode.org/css/nthchild.html

Well, that sort of solves some of the problem, but in other ways it makes it worse. The fundamental problem is that mentally applying CSS rules is difficult, particularly when the DOM structure being styled is complex and is determined by an imperative program.

Imperatively generating and dealing with a DOM structure using simple selector queries is relatively easy to do, as is modeling what is happening in your head. Dealing with more complex CSS rules as they apply to a static (or dynamic but very simple) DOM structure is a little trickier, but not completely unwieldy. When you run into problems is when you try to do both simultaneously. Suddenly you have to not only mentally model a mutable DOM structure, but you have to model how those CSS rules will be applied in a generalized and abstract form. It's not hard to paint yourself into a corner where you'd actually start having to prove theorems about your code in order to be reasonably assured that the CSS will apply correctly.

Of course, hardly anybody actually lets it get that far. Instead, they start applying styles imperatively using JavaScript. And that sucks.

I don't know what the solution to this is, or if there even can be one that is a progression from where we currently are. But I don't think fancier CSS selectors are the answer.

the problem here is that CSS is _not_ a good abstraction for laying out application. Its good for styling (and i would argue, styling static content too). But css isn't very modular, and has very very high coupling with the structure of the DOM - something that isn't easily discernable at the time of modifying the css.

Like you, i can't think of a good solution - a lot of UI frameworks either just has really heavy restrictions, or it doesn't actually provide enough abstraction to actually help with the problem. Sigh...

3. Write your site in the form of a program that generates the site itself (or include javascript that generates the relevent pieces.)
That's the same as 1.
Or add classes during output generation.
Well yes, but I would consider that only a variation of option 1.
This sounds like a daily interaction with my current employer.

Sigh.