Hacker Newsnew | past | comments | ask | show | jobs | submit | hackernoon's commentslogin

Argh! I love the deprecation example! How elegant! How did I never think of this (or why did I never think to ask)!

edit: pasted here –

  func ListItems(query Query) Items {
    ListItemsWithLimit(query, 0, 0)
  }

  func ListItemsWithLimit(query Query, limit int, offset int) Items {
  // ...
  }


Wouldn't it be easier to write optional variables, allowing you to keep the same method name? This results in cleaner code that doesn't break existing usage.

For example:

  func ListItems(query Query, limit int = 0, offset int = 0) Items {
  // ....
  }


This only works in languages that support optional variables or overloading.


It doesn't result in a cleaner interface, which is what matters the most (arguably).


It would; unfortunately Java doesn't support that.


reminds me of this http://gridlesskits.com – also a DIY storage/solar project that was on HN a few months ago


And just in case, previou HN discussion:

https://news.ycombinator.com/item?id=14821478


This is a repost of the Hackernoon article, no?


Nope, OP of the Hackernoon post here – GK is by us and is the new home of the project. Thanks for policing though :P


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

Search: