Add new tag Agil Buzz Google Wave databas DDD design design presentation design principle dto ejb3 extjs frameworks google google-collections hibernate Java javascript JSR 305 links Mind ORM pattern process scrum selenium Tdd team test transform web application
WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.
“Tell dont ask -, Procedural code gets information then makes decisions. Object-oriented code tells objects to do things.” — Alec Sharp
“Tell dont ask -, Procedural code gets information then makes decisions. Object-oriented code tells objects to do things.”
Username:
Password:
Remember me
Vad tycker du om Buzz?
View Results
primitive obsession
public class PersonTest {
final static String firstName = "Firstname";
final static String lastName = "Lastname";
@Test
public void shouldCreatePersonWithFirstNameAndLastName() {
Person person = new Person(firstName, lastName);
assertThatNameIsSetOnPerson(person, firstName, lastName);
}
public void shouldCreatePersonWithParameterName(){
Person person = new Person(firstName(firstName).lastName(lastName));
public void shouldCreatePersonWithDiffrentFirstName(){
String karin = "Karin";
Person person = new Person(firstName(karin).lastName(lastName));
assertThatNameIsSetOnPerson(person,karin, lastName);
private void assertThatNameIsSetOnPerson(Person person, String firstName, String lastName) {
assertThat(person, notNullValue());
assertThat(person.getFirstName(), is(firstName));
assertThat(person.getLastName(), is(lastName));
package domain;
public class Person {
private String firstName;
private String lastName;
public Person(final String firstName, final String lastName) {
this.firstName = firstName;
this.lastName = lastName;
public Person(Name name) {
this.firstName = name.firstName;
this.lastName = name.lastName;
public String getFirstName() {
return this.firstName;
public String getLastName() {
return this.lastName;
public class Name {
public final String firstName;
public final String lastName;
private Name(String firstName, String lastName) {
public static NameBuilder firstName(String firstName) {
return new NameBuilder(firstName);
public static class NameBuilder{
private NameBuilder(String firstName){
public Name lastName(String lastName){
return new Name(firstName,lastName);
Name (required)
Mail (will not be published) (required)
Website