Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
SamuelAdams
on July 24, 2018
|
parent
|
context
|
favorite
| on:
Be Nice and Write Stable Code
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 { // .... }
jniedrauer
on July 24, 2018
|
next
[–]
This only works in languages that support optional variables or overloading.
erwan
on July 24, 2018
|
prev
|
next
[–]
It doesn't result in a cleaner interface, which is what matters the most (arguably).
lmm
on July 24, 2018
|
prev
[–]
It would; unfortunately Java doesn't support that.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
For example: