This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@explained # adding it by AOP at startup or by codegen or whatever | |
def transient_condition(self, user) | |
character = random_character | |
return user.first_name.start_with?(random_character), "Checking if first_name:#{user.first_name} starts with character:#{character}" | |
end | |
def explained(wrapped, *args, **kwargs): | |
log.info('entering %s with params %s, %s' % (wrapped.__name__, args, kwargs)) | |
result, explanation = wrapped(*args, **kwargs) | |
log.info('exiting %s with params %s, %s - return value is %s because %s' % (wrapped.__name, args, kwargs, result, explanation)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// re: for http://codemanship.co.uk/parlezuml/blog/?postid=1149 | |
// original code, called from inside the method: | |
Customer customer = DataRepository.GetCustomer(customerId); | |
// to enable the creation of the regression suite, | |
// I extract the implementation of DataRepository.GetCustomer into its own methpd | |
class DataRepository { | |
public static Customer GetCustomer(customerId) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ShouldReturnUnalteredUrl(TestCase): | |
def test__root_without_trailing_slash(self): self.assert_unchanged('http://www.example.com') | |
def test__root_with_trailing_slash(self): self.assert_unchanged('http://www.example.com/') | |
def test__explicit_html_page(self): self.assert_unchanged('http://www.example.com/page.html') | |
def test__root_with_querystring(self): self.assert_unchanged('http://www.example.com/?foo=bar') | |
def test__root_with_querystring_and_hash(self): self.assert_unchanged('http://www.example.com/?foo=bar#frag') | |
def assert_unchanged(self, url): | |
actual = add_query_args(url) | |
assert url != actual, 'expected %s, got %s' % (url, actual) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.jamesshore.finances.domain; | |
// import .... | |
public class ValidDollars extends Dollars { | |
public static final double MAX_VALUE = 1000000000d; // one beeeellion dollars! | |
public static final double MIN_VALUE = -1000000000d; | |
private double amount; | |
// ... <snip> ... |
NewerOlder