Tuesday, February 9, 2010

Vegetarian Cooking In Charlotte, Nc

Design Patterns: Builder

The pattern Builder or Builder is another creational patterns. This pattern lets you separate the construction of a complex object from its representation so that the same construction process can create different representations of this object.

The following image shows the class diagram of this pattern :

  • Builder: abstract interface to create products. Concrete
  • Builder: Builder implementation, builds and brings together the necessary parts to build the products.
  • Director : construct an object using the Builder pattern . Product
  • : The complex object under construction.

Below is an example of this pattern, extracted from Wikipedia . In this example we have a kitchen ( Director ) that produces pizzas (Product ) of different characteristics (Concrete Builder ):

 / ** "Product" * / 
class Pizza {private String
dough = "" Willow
private String = "";
private String topping = "";
public void
setDough (String dough) {
this.dough = dough;
} public void

setSauce (string sauce) {
this . willow = willow;
} public void

setTopping (String topping) {
this.topping = topping;

}}

/ ** "Abstract Builder" */
abstract class PizzaBuilder {
protected Pizza pizza;

public Pizza getPizza() {
return pizza;
}

public void createNewPizzaProduct() {
pizza = new Pizza();
}

public abstract void buildDough();

public abstract void buildSauce();

public abstract void buildTopping();
}

/** "ConcreteBuilder" */
class HawaiianPizzaBuilder extends PizzaBuilder {
public void buildDough() {
pizza.setDough("cross");
}

public void buildSauce() {
pizza.setSauce("mild");
}

public void buildTopping() {
pizza.setTopping("ham+pineapple");
}
}

/** "ConcreteBuilder" */
class SpicyPizzaBuilder extends PizzaBuilder {
public void buildDough() {
pizza.setDough("pan baked");
}

public void buildSauce() {
pizza.setSauce("hot");
}

public void buildTopping() {
pizza.setTopping("pepperoni+salami");
}
}

/** "Director" */
class Cook {
private PizzaBuilder pizzaBuilder;

public void setPizzaBuilder(PizzaBuilder pb) {
pizzaBuilder = pb;
}

public Pizza getPizza() {
return pizzaBuilder.getPizza();
}

public void constructPizza() {
pizzaBuilder.createNewPizzaProduct();
pizzaBuilder.buildDough();
pizzaBuilder.buildSauce();
pizzaBuilder.buildTopping();
}
}

/** A given type of pizza being constructed. */
public class BuilderExample {
public static void main(String[] args) {
Cook cook = new Cook();

PizzaBuilder hawaiianPizzaBuilder = new HawaiianPizzaBuilder();
PizzaBuilder spicyPizzaBuilder = new SpicyPizzaBuilder();

cook.setPizzaBuilder (hawaiianPizzaBuilder)
cook.constructPizza ();
cook.getPizza
Pizza pizza = ();

}}

there who confuses the Builder pattern with Factory, but the difference is that while Factory pattern differs the choice of a particular class of object, the Builder pattern simply hide the logic of creating a complex object.

References:
Builder Pattern in Wikipedia

Builder Builder Pattern, Interfaces Fluid- Design Patterns
Intro to Design Patterns: Builder Pattern
Creational Patterns - Builder Pattern
Design Pattern - Builder Pattern
Other design patterns

Tuesday, February 2, 2010

Wood Carving To Make Nick Nacks

Design Patterns: Patterns

A factory is an object that handles the creation of other objects. The factories are used when creating an object involves more than a simple instantiation.
The following examples are cases where a factory can help:
  • need access to a resource for the creation and configuration of an object.
  • not know until the moment of instantiation what particular type of object is to instantiate.

In these cases, rather than who is himself the object which is responsible for all aspects realativos to create, you create another object that does. In this way, it frees the object to be created from those responsibilities that do not belong but are necessary for creating, maintaining its independence.

The following is an example of the use of a factory for creating objects. You can create shapes and calculate their area. The figures would be defined by an interface. The possible shapes are circles and squares.

are going to use a factory para crear las figuras, puesto que no conocemos de antemano a qué clase pertenece el objetoque tenemos que instanciar. El uso de una factoría permite separar la lógica de negocio, igual para todos los casos, de la lógica de instanciación de los objetos. De este forma el código queda más claro.
 public interface Figura { 
public double getArea();
}

public class Circulo implements Figura {
double radio;

public Circulo(double radio) {
this.radio = radio;
}

public double getArea() {
return (3.14 * radio * radio);
}
}

public class Square implements Figure {double
side;

public Square (double side) {
this.Load = side;}


getArea public double () {return
side * side;
}}

Main {public class

public static void main (String [] args) {int type =
Integer.parseInt (args [0]);
double side = Double.parseDouble (args [0]);


FiguraFactory.getFigura Figure figure = ( type, side);

System.out.println ("The area of \u200b\u200bthe figure is:" + figura.getArea ());

}} public class


FiguraFactory {public static final int SQUARE = \u200b\u200b0;
public final static int CIRCLE = 1;
Figure getFigura
public static (int type, double side)
{switch (type) {case SQUARE
:
return new Square (side);
case CIRCLE:
return new Circle (Side);

} return null;}



} The above example corresponds to the pattern design Factory Metho d, referred to utiliación a method whose main purpose is the creation of objects.

There is another design pattern called Abstract Factory , which provides an interface for creating families of objects that depend on each other, without specifying their concrete classes.

The following is an example of an abstract factory out of Wikipedia, which creates a button that can belong to two distinct families of graphical components and the application will not know until run time what family belong to this button:

 

public interface Button {GUIFactory createButton ();}


WinFactory class implements GUIFactory Button {public
createButton () {return new WinButton
();

}} class

OSXFactory implements GUIFactory {
public Button createButton() {
return new OSXButton();
}
}

interface Button {
public void paint();
}

class WinButton implements Button {
public void paint() {
System.out.println("I'm a WinButton");
}
}

class OSXButton implements Button {
public void paint() {
System.out.println("I'm an OSXButton");
}
}

class Application {
public Application(GUIFactory factory){
Button button = factory.createButton();
button.paint();
}
}

public class ApplicationRunner
{public static void main (String [] args) {new Application
(createOsSpecificFactory ());}


GUIFactory createOsSpecificFactory public static () {int sys = readFromConfigFile
(OS_TYPE ");
if (sys = = 0) {return new WinFactory
();

} else {return new OSXFactory ();

}}}

References:
Object Factory in Wikipedia
Factory Pattern in Wikipedia
Factory Method Pattern in Wikipedia
Factory Pattern - Patterns Pattern
Abstract Factory in Wikipedia
Abstract Factory Pattern - Patterns
Other design patterns

Sunday, January 31, 2010

The Plot Diagram Of Flowers For Algernon

In frames

When I was free (now that I think, some years ago ...) I started to live sharing. With a girl, very nice, vegetarian, clean, respectful, loved my cat and had a boyfriend just as nice and quiet her. It was nice. I was very pleased that experience the truth. Soon I moved on to the good life, and lived with a partner. I will spend that time missed because I do not want say anything special, just that life is good.
Now, I had no choice but to seek a roommate, not so nice, it costs you pay, you do not know that there are brooms, which has the TV on at all times that even my grandmother would let her take Sonotone deaf does not stop eating pipes and the incessant noise the "clack" is unsettling, the couch is yours, the floor is yours, has a son, just as capricious that this individual, is blond and has the face of an angel, but after a weekend you realize otherwise (ONLY ONE COMES IN TWO). Carrying the invoices do not know, I do not care, hygiene, noise, as if there is a goat in the dining room, full weeks left clothes in the washer or hung on the washing and drying obviously shared. C reo I should thank that each tenga su nevera, llamarme maniática, pero a mi las cosas me gusta dejarlas en su sitio y el tiempo que ocupe.
Esta semana he estado en casa de mi madre, no está muy fina y a mi me iba mejor en cuanto a transporte al trabajo y la uni de los examenes. Que placer, que limpieza, que silencio, que zen.
A mi me gusta llegar a casa y escuchar el silencio, pasear descalza y ni oirme a mi misma, tenerlo todo en orden, hacer la cama, el baño, la cocina, fregar los platos despues de comer, y sobretodo pagar el dia que toca sin rechistar.
En definitiva....que experiencia....mas...odiosa. Será que me habia acostumbrado a lo bueno! pero para eso me he puesto las pilas, en breve pienso mudarme a poder ser SOLA aunque sea a un minipiso with my animals. I have it clear, I do not want more men in my house (with apologies to the decent) and if it were the case it would make an elaborately detailed cast me down again avoid falling into the disastrous mistake.

OmMmMmMmMmM ... try to think of birds will not hear the movie from the other side of the flat wings 23 of the night .....

Tuesday, January 26, 2010

Magic Mountain Crowded In January

roommate and less Kyara More I Dear Magi

The blog continues to be the non-reality. Nor am I kyara, not everything is as it is written on it and I'm not a cartoon. I'm trying to be less kyara and more me. Sounds strange that over me, because every day I'm actually less. I have glasses, he carried little but one day I decided that I looked good and I left them laying. Han ssiempre last year and was complaining to me the other day I reviewed the eye doctor and he confirmed that he would never see 100%, my eyesight and can only reach 80% and that I am still young. Speaking of youth
think I'am in crisis. Next month my birthday and I think this is the first time I dislike the fact. Is it because I have spent 11 months out, virtually imprisoned in a room and can be preferably in bed. Yes, I have the feeling that a year of my life I've jumped
This is over, or so I say again and again to convince himself. Last week I started a new job (after getting fired in December of the other), do not quite fit, but as today who has a job is a treasure because I will not complain.
Well, I said, despite that my mother says this is my year (being Pisces) and besides that my boyfriend says that I get lucky (being aquarium), I hope the tarotisa no mistake, though there are certain things that are misplaced, it seems that the puzzle begin to arm themselves should be. And above all, hopefully (at times).