Semantic Versioning Patch versions: fix defects. Minor versions: add features; never change existing (correct) behavior. Major version: break backwards compatibility Make the tiddly-waka (~>) count for something!
No classes named “Base” Don’t make grepping any harder than it needs to be. Identify the concept, and name it. (ActiveRecord::Record, anyone?) Exceptions: Libraries involving baseball Libraries about base jumping Libraries concerned with Swedish 90s pop group Ace of Base
Block-style configuration Code-as-config for ultimate flexibility Discoverable: default values can be queried. A convenient point to add validations Can be called more than once
Top-level Facade Top-level API acts as a reference Doesn’t tie client code to the structure of your library Gives you more leeway to move things around internally Or proliferate classes
Exception Classes Logic Error: Library has a defect. Client Error: Client mis-used the library. Transient Failure: Some external dependency isn’t working right now.
No-raise API request.on_complete do |response| if response.success? # hell yeah elsif response.timed_out? # aw hell no log( "got a time out" ) elsif response.code == 0 # Could not get an http response log(response.curl_error_message) else # Received a non-successful http response. log( "request failed: " + response.code.to_s) end end