A friend got me a stack overflow mug and its amazing - but one thing has always troubled me.

Is the code written in a real world language? The code seems like it could be improved slightly.

if (owner.isCoding() && mug.isEmpty()){

enter image description here

It appears to me that isCoding and isEmpty are methods but could possibly be properties on an object to save checking the conditions each time.

Also wouldn't it be safer for the fill method on mug to expect a parameter with a type other than string.

closed as not constructive by AakashM, kiamlaluno, BinaryMisfit, Josh Darnell, Manishearth Jul 5 '12 at 17:10

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    where can i get that mug? – mithunsatheesh Jul 5 '12 at 12:49
  • 1
    I was going to link to the shop shop.stackexchange.com/password but it seems it been closed? – benni_mac_b Jul 5 '12 at 12:52
  • 7
    Meh. Looks like Java. – slugster Jul 5 '12 at 12:52
  • 1
    @benni_mac_b What happened to the Stack Exchange store? – AakashM Jul 5 '12 at 12:55
  • 4
    I think you drank one too many cups... ;) – Lix Jul 5 '12 at 12:55
  • 7
    The single quotes around 'coffee' wouldn't compile in Java. – Bill the Lizard Jul 5 '12 at 13:10
  • I first thought too that it looks like Java. Well, it is not C#...could be JavaScript. On the other hand, wouldn't it be better if 'coffee' would be extracted into an Enum (if the language supports it)? I always at those "magical strings", as they are the same for me as "magical numbers"... – Time Traveling Bobby Jul 5 '12 at 13:14
  • What, you don't like my coding style? My suggestion was the basis for what's on the mug, with some editing by others if I recall, but I can't find the post where I suggested it. I think it's now been deleted. At least they sent me a free mug for using my idea. It's currently full of pistachio shells. ;) – gnostradamus Jul 5 '12 at 16:50
  • 1
    Have at the source meta.stackexchange.com/questions/14253/… @gno – random Jul 5 '12 at 16:59
  • @random that's a 404 for me. Deleted page? – Servy Jul 5 '12 at 17:00
  • @gnostradamus amazing, I was hoping the author would appear. Would love to see the other suggestions – benni_mac_b Jul 5 '12 at 17:03
  • 1
    Here's a screenshot of the original suggestion, with its comments... probably not as exciting as you're expecting it to be. It was an answer to "What types of Stack Overflow schwag would you like to see?" – Pops Jul 5 '12 at 19:03
  • The string coffee should be enclosed in double quotes instead of single quotes, thereby adding at least C and C++ to the list of languages in which the code is legal. – Alnitak Jan 21 '15 at 15:43
  • looks like javascript 8) – Dan Pantry Jan 7 '16 at 20:26

As the owner of such a mug, I can assure you that the code definitely works; when I'm coding and drinking from that mug, the ingredients are always coffee (at least in the duck-typing sense: it looks like coffee, smells like coffee, and tastes like coffee).

So any objection would purely be regarding the code style, but as they say: If it ain't broke, don't fix it :)

  • 24
    Mine is filled with water right now. What compiler are you using? – Bill the Lizard Jul 5 '12 at 13:13
  • 38
    @BilltheLizard The answer "CoffeeScript" would be too obvious, wouldn't it? – balpha Jul 5 '12 at 13:14
  • 11
    Ever got a bug in your coffee? Now that's nasty. – Shadow The Princess Wizard Nov 21 '13 at 20:42

I'm sorry, this just won't work for me. There should be a while loop and an instruction to suspend the current thread until the mug becomes empty again, at which point the producer is woken up by the consumer to put more coffee in the buffer (mug).

  • 9
    Just hope it's not a ring buffer, that'll make a mess on your desk. – balpha Jul 5 '12 at 17:38

Its not effing C#, which offends me.

Not the answer you're looking for? Browse other questions tagged .