Live data from Hacker News

Be Nice and Write Stable Code

technosophos.com

21–30 of 159 posts

Re: Be Nice and Write Stable Code

#21
A lot of people are commenting that SemVer doesn't work, because it's still at the mercy of humans choosing good version numbers.

Elm's package manager, elm-package, actually tries to remove humans from the equation, by automatically choosing the next version number, based on a diff of the API and the exported types of a package: https://github.com/elm-lang/elm-package#publishing-updates

It's not perfect, but it's better than anything else I've seen.

Re: Be Nice and Write Stable Code

#22
post #14
post #9

Earlier quoted context omitted.

While it's easy to say, how far do you go? Do you test every bit of every upstream library you use? The ideal is probably yes, but the reality is this rarely happens. Even with a test, you may not find this. In the IOException example, the author calls out why: > When we upgraded, all our tests passed (because our test fixtures emulated the old behavior and our network was not unstable enough to trigger bad condition…

> While it's easy to say, how far do you go? Do you test every bit of every upstream library you use? The ideal is probably yes, but the reality is this rarely happens. It depends. I have a friend who used to work on banking systems. They had full test coverage of every dependency. Even standard lib functions and language features. One time they found a bug in the md5 implementation in a minor version of a popular da…

Tests Georg is an outlier, and should not have been counted.

Re: Be Nice and Write Stable Code

#23
This is a great piece. I think my only addition to it is to point out two small insights.

1. SemVer works great in some communities (Ruby) and shit in others (Python). Generally the more computer sciency the community the better I find the SemVer'ing. Python has a bunch of scientists using it, so it's less reliable, even if many of the core libraries follow it pretty well.

2. Apps, plugins, frameworks, and libraries are different things with different SemVer strategies. With a paid app versioning is often a marketing decision. Framework plugins versioning is often a "match the framework to reduce mental burden" decision. Whereas frameworks and libraries I find a much higher adherence to what SemVer strives to do.

Re: Be Nice and Write Stable Code

#24
This is something that can I cannot stress the importance of, yet rarely ever receives the recognition that it should. Being able to delicately and compassionstely work on old code, while still bringing valuable updates is hard.

It’s even harder to make your changes look easy and obvious in hindsight.

This is something that most engineering organizations are not equipped to recognize and promote as a virtue - it’s sort of hard to explain as it is. If anything, this patience can be considered an enemy to progress.

When you see people who do this well, take note.

Re: Be Nice and Write Stable Code

#25
I try to encourage everyone to define a contract, code to that contract, and update the contract when it is no longer accurate. The exact nature of the contract is contextual, sometimes a schema, sometimes a well documented comment header or perhaps a project README.

Re: Be Nice and Write Stable Code

#26
post #12

It would be helpful to mention that these guidelines -- and semver generally -- don't really apply to applications from what I've read. Versioning applications still feels like a gut feeling.

I'd assume marketing considerations dominate the version number discussion for (consumer) applications--whether you want the release to be seen as the good old whatever you know and trust or as new and improved.

Re: Be Nice and Write Stable Code

#27

SemVer is a social construct, not a contract. It's nice when it applies, but you cannot rely on other developers to adhere to it. One man's bugfix is another man's breaking change. If product A implements a workaround for a bug in product B, but the bug gets fixed in a patch version, it could break product A's code, so it becomes a breaking change. The only way to anticipate these changes is reading the change logs/r…

> SemVer is a social construct, not a contract. It's nice when it applies, but you cannot rely on other developers to adhere to it. Whats the solution here? Fuck standards? Imagine if we had that same attitude with regards to HTTP.

A good idea ia to treat every change as a major change.

Or use ComVer

https://github.com/staltz/comver/blob/master/README.md

Re: Be Nice and Write Stable Code

#28

A lot of people are commenting that SemVer doesn't work, because it's still at the mercy of humans choosing good version numbers. Elm's package manager, elm-package, actually tries to remove humans from the equation, by automatically choosing the next version number, based on a diff of the API and the exported types of a package: https://github.com/elm-lang/elm-package#publishing-updates It's not perfect, but it's be…

That’s a pretty neat strategy. Elm really brings a lot of cool (and fun) sugar to dev flows. I’ve been looking for a reason (project) to use it in so I can transition from an enamored fan-person to a true evangelist :)

Re: Be Nice and Write Stable Code

#29

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 {
  // ....
  }

Re: Be Nice and Write Stable Code

#30

A lot of people are commenting that SemVer doesn't work, because it's still at the mercy of humans choosing good version numbers. Elm's package manager, elm-package, actually tries to remove humans from the equation, by automatically choosing the next version number, based on a diff of the API and the exported types of a package: https://github.com/elm-lang/elm-package#publishing-updates It's not perfect, but it's be…

Is API compatibility computable in general? My instinct is that it is, but I’ve never seen a theorem.
Post reply on HN