Re: A pattern for curves calculations ?




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

.



Relevant Pages

  • Re: I dont get it: Memento and Undo/Redo
    ... an execute and undo method that is implemented by concrete commands. ... And I have a command stack where I push command objects to it when ... public void Execute() ...
    (comp.object)
  • I dont get it: Memento and Undo/Redo
    ... an execute and undo method that is implemented by concrete commands. ... And I have a command stack where I push command objects to it when ... public void Execute() ...
    (comp.object)
  • Re: The Promise of Forth
    ... After awhile I ... found a chart of the Z80 command set and I wrote a disassembler, ... stack operator. ... Then I got my own PC and I tried out Pygmy Forth. ...
    (comp.lang.forth)
  • Re: Analysing a minidump cause by a release build
    ... Since you got a .dmp file generated from the .dump /ma command, you have a complete picture of the process at the time of the dump creation. ... You indicate that you see only one call stack. ... I can also see that the WER process wrote a minidump to my Local Settings\Temp folder, but access to it is denied. ...
    (microsoft.public.vc.debugger)
  • Re: does vb2005 have builtin UnDo feature for apps? or do I have t
    ... When you say stack - are you refering to the Heap stack? ... My goal is to not re-invent the Undo Wheel if it already exists in VB2005. ... undo routine where I store each action as I described above stuff to their ... If you create a set of Action objects then they should all inherit from a base class that has the methods defined that you will use 'Do' and UnDo'. ...
    (microsoft.public.dotnet.languages.vb)