robot clothes About Us Projects News
return to lablog homepage
 
 
 

« Open Studios | Main | The Observer Pattern »

May 09, 2005

Design Patterns

I just read the first chapter of Head First Design Patterns. Since we are writing the program in Java, I might as well learn some Design Patterns to help development. Design Patterns are a set of solutions to problems that developers commonly encounter. They also provide a vocabulary for describing these solutions. The fist chapter explains the strategy pattern.


The Strategy Pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.

For the purpose of our software, I'm not sure if we can use this pattern. A contender for this pattern is motors. Let's suppose that motors have enough in common that they warrant having one motors superclass. We can extend the motor superclass with a servo class and a stepper class. Now if everything about these motors is basically the same except for how they return their position, we could make a Position interface. Then we could make two classes that implement Position with the appropriate behaviors.

I'll have to learn more about the components in the project to make these kinds of decision, but hopefully by describing it here I am absorbing the concept a little bit better.

Posted by michelle at May 9, 2005 01:42 PM

Comments

Post a comment




Remember Me?


 
Creative Commons License
This work is licensed under a Creative Commons License.

Powered by Movable Type