Specifically I broke down the command stuff and implemented descendants of TCommand that know what to do to the model - i.e. the model doesn't do anything other than respond to the data changes (or not as is the current state).
This means I have ended up with code like this ..
TCalculateCommand = class (TCommand)
procedure Run (model : tObject); override;
end;
..
{ TCalculateCommand }
procedure TCalculateCommand.Run (model : tObject);
begin
(model as TDomainModel).Data.Price := self.Params[0].Value;
(model as TDomainModel).Data.Consideration := ((model as TDomainModel).Data.Size *
(model as TDomainModel).Data.Price) + (model as TDomainModel).Data.Charges;
end;
This is a lot simpler in my view.
However it doesn't solve the problem with how to indicate that a field is invalid?
I might have to register each control with the model, so it knows which fields map to each control. That sounds like a lot to faff, but I don't know how else to do it.
2 comments:
Hi, i found this tutorial of the Delphi implemention of MVC pattern design very useful. Can you tell me, where can i download the source code of the example described in the the tutorial?
Hi,
I was just using this as a memort aide. I can't really post my code on online, as (a) it isn't finished, and (b) you will need an iSeries to make it work!
So, I would point you at the Joanne Carter pages that I largely cribbed / copied / changed.
Hope this helps
Post a Comment