3 ms·
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
by hackernoon 8y ago
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 {
// ...
}
- SamuelAdams 8y agoWouldn'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 8y agoThis only works in languages that support optional variables or overloading.
- relyio 8y agoIt doesn't result in a cleaner interface, which is what matters the most (arguably).
- lmm 8y agoIt would; unfortunately Java doesn't support that.