Re: A pattern for curves calculations ?
- From: "wysza" <awysza@xxxxxxxxx>
- Date: 8 Aug 2006 09:12:29 -0700
theName wrote:
--
Hello everybody,
I am using/writing/maintening a software which make some curves
calculations : for example, I start with an array of points X and Y
(theCurve) and I can make some different smoothing, applying some
baseline, making some fitting, ... so I looking for a design pattern
(if exist) to get some good ideas to make the best program that can
manipulate easely the curves with functions like undo, redo,...
I hope some software like peakfit, mathlabs,... have used this type of
patterns and they can be found somewhere... ;-)
sorry for my poor english...
best regards
Sébastien
Command pattern for your operations is definately helpfull when
talking about implementing undo, redo operations.
http://www.dofactory.com/Patterns/PatternCommand.aspx
In a nutshell: you define operations according to command pattern. For
example all of your command objects have Execute method that takes
param object (each command may take different type of parameter class
but all params have to inherit from one base class).
You have to 2 stacks: undo and redo. When user (or a code) performs
operation, you put that on the stack - for example you put the
operation class type and parameter object (the actual values) on undo
stack. Then when undo is required, you have UndoManager that takes one
item from the stack (FIFO order) and calls command object (class name
was saved) - commandobject.undo. This undomanager puts that command
information on redo stack. RedoManager will call Execute on this
object.
As far as actual code for undo operation - there is no magic - it all
depends on the algorythm and the process that you are doing: sometimes
it is enough to perform the same steps as for execute but with negative
values (passed in parameter object) and sometimes it is not enough. In
cases when it is not enough, you may end up with another class type
that will know how to handle reverse operation given values that the
commandobject received to perform Execute.
I hope it's enough to paint the picture and start detailed discussion.
hth
.
- References:
- A pattern for curves calculations ?
- From: theName
- A pattern for curves calculations ?
- Prev by Date: Re: need help in finding a pattern for my requirement
- Next by Date: uml case tool with gof support
- Previous by thread: A pattern for curves calculations ?
- Next by thread: need help in finding a pattern for my requirement
- Index(es):
Relevant Pages
|