Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is "prepare bacon" necessarily part of "prepare food" itself, though? Rather than hardcoding preparing bacon as a stage of food prep, it's probably more maintainable to have the kinds of food passed in (as a list, a Menu object, whatever) - what you're cooking strongly influences the entire process.

  washHands()
  for f in val(foods) do
     coroutine.init(f)
     ...
  end
  waitUntilDone()
  if (not aLazyGit) then doDishes() end
Really, cooking usually involves interwoven stages of things like setting water boiling, whisking a roux, kneading dough, chopping peppers, etc. Tacking on "...and make bacon" at the end of all cooking batches doesn't make sense. Instead, break prepareFood() down further into operations such as boilWater(vol), preheatOven(temp), etc.; Those should be reusable, barring unusual circumstances (e.g. boiling water at high altitudes). Without a lot of specialization via arguments, prepareFood() is too coarse an abstraction, about as vague as doTaxes().


Begs the question: How do you know whether an abstraction is too coarse without writing the code?


Maybe you don't. So then you refactor when you find out.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: