Skip to content

Instantly share code, notes, and snippets.

// The first thing I did was generalize the "orders have free shipping to Australia" concept
// to "orders adjust their shipping charges in some way".
// I wouldn't want Order to get cluttered with lots of shipping rules.
// Instead of doing this in constructor, it could instead have a method like
// order.adjustShipping(shippingAdjustments).
@Test
public void whenCreatingAnOrder_AdjustsShippingCharges() {
ShippingAdjustments mockedShippingAdjustments = mock(ShippingAdjustments.class);
Country mockedCountry = mock(Country.class);
Order order = new Order(mockedCountry, mockedShippingAdjustments, other, parameters);
// Inefficient, but interesting "string to title case" implementation using Linq.
"some text"
.Split(' ')
.Select(word => char.ToUpper(word[0]) + word.Remove(0, 1).ToLower())
.Aggregate((result, nextValue) => result + ' ' + nextValue);
'a' asJQuery each: [ :index :value |
value asJQuery on: 'click' do: [ :event |
event preventDefault.
window alert: 'I am link #' , index
]
]
// Game
public class Game {
private final Grid grid;
private final PlacementError placementError;
private Mark playingMark;
public Game(PlacementError placementError) {
grid = new Grid();
playingMark = Mark.x();