Skip to content

Instantly share code, notes, and snippets.

9: Designing Cost-Effective Tests

3 Skills Needed to Write Changeable Code

  • Understand OO design
  • Skilled at refactoring code
  • Ability to write high-value tests

Changeability is the only design metric that matters; code that's easy to change is well-designed.

>Good design preserves maximum flexibility at minimum by putting off decisions at every opportunity, deferring commitments until more specific requirements arrive. When that day comes, refactoring is how you morph the current code structure into the one what will accommodate the new requirements.

2: Performing Work

Sending a strong message

The foundation of an object oriented system is the message.

Strong and confident messages requires three elements:

  1. We must identify the messages we want to send in order to accomplish the task at hand.
  2. We must identify the roles which correspond to those messages.
  3. We must ensure the method's logic receives objects which can play those
@jayzz55
jayzz55 / gist:ba60150a0722fe9d257c3c5c581cb775
Last active December 19, 2018 22:04
scala contramap example
F[A] Ordering[Int]
B => A listing => listing.id
F[B] Ordering[Listing]
val intOrderer: Ordering[Int]
val listingOrderer: Ordering[Listing] = intOrderer.contraMap(listing => listing.id)
See: http://igstan.ro/posts/2013-10-31-contravariant-functors-an-intuition.html
@jayzz55
jayzz55 / signal_catching.rb
Created September 10, 2020 14:51 — forked from sauloperez/signal_catching.rb
How to catch SIGINT and SIGTERM signals in Ruby
# Signal catching
def shut_down
puts "\nShutting down gracefully..."
sleep 1
end
puts "I have PID #{Process.pid}"
# Trap ^C
Signal.trap("INT") {
@jayzz55
jayzz55 / deploy_script.sh
Created February 13, 2022 13:49 — forked from julianrubisch/deploy_script.sh
Hatchbox phoenix configuration
# Phoenix
if grep -q '^ "phoenix"' mix.lock; then
source $HOME/.asdf/asdf.sh
source $HOME/.asdf/completions/asdf.bash
export $(cat $RELEASE_DIR/../../.rbenv-vars | xargs)
echo '
-----> Detected Phoenix app.'
mix local.rebar --force
mix local.hex --force