object_oriented_design_proj

object_oriented_design_proj - George Francis Object...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
George Francis Object Oriented Design Final Project Creational Patterns The creational pattern that I chose was the Abstract Factory pattern. According to the textbook, the abstract factory pattern solves the problem of creating families of related classes that implement a common interface. Below is an example of a generic design class that incorporates the abstract factory pattern.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Lets use an example from the DoFactory.com website. Suppose we wanted to develop code to create different animals worlds for a computer game, similar to the game Animal Crossing. We want to be able to provide an interface to create different types of animals from classes like herbivore and carnivore, without specify which concrete class we want. The abstract factory will return an instance of a specific ConcreteFactory such as the AfricaFactory or AmericaFactory based on a system property that is read in at run time. Well the abstract factory pattern lets us do just that. According to the website, the animals created by the Continent factories are different but the interactions among the various types of animals remain the same. We can use the generic design class diagram above to further illustrate the concept. Below are the conversion references: The classes and/or objects participating in this pattern are: * AbstractFactory (ContinentFactory) - declares an interface for operations that create abstract products * ConcreteFactory (AfricaFactory, AmericaFactory) - implements the operations to create concrete product objects * AbstractProduct (Herbivore, Carnivore) - declares an interface for a type of product object * Product (Wildebeest, Lion, Bison, Wolf) - defines a product object to be created by the corresponding concrete factory - implements the AbstractProduct interface * Client (AnimalWorld) - uses interfaces declared by AbstractFactory and AbstractProduct classes
Background image of page 2
Below is the code segments taken from DoFactory.com that shows the behavior of key methods. / "AbstractFactory"
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/03/2008 for the course CSE 1002 taught by Professor Marico during the Spring '08 term at FIT.

Page1 / 11

object_oriented_design_proj - George Francis Object...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online