Created
May 12, 2011 03:48
-
-
Save nettofarah/967894 to your computer and use it in GitHub Desktop.
Service Obsession
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
public class Product { | |
private String name; | |
private float price; | |
public Product(String name, float price){ | |
this.name = name; | |
this.price = price; | |
} | |
// ... getters and setters | |
} | |
public class ProductService{ | |
public void updatePriceWithDiscount(Product product, float rate){ | |
float newPrice = product.getPrice() - product.getPrice() / rate; | |
product.setPrice(newPrice); | |
} | |
//... other USELESS methods | |
} | |
public class ProductController{ | |
//... | |
//Maps some url or stuff like that | |
public void updatePriceWithDiscount(Product product, float rate){ | |
productService.updatePriceWithDiscount(product, rate); | |
//do some other thing with the response.. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment