Hello Peter,

I do much the same, but with the tiOPF framework I ported from Delphi
to Kylix to Free Pascal. Hopefully this was the last time I need to
port tiOPF. :-)
I tested tiOPF years ago, when I start to mantain DePO code. :-)

For tiOPF I created a set of Mediators/Observers, based on the MGM
design pattern, to allow me to make standard GUI components object
aware.  MGM is very similar to MVC.  I am planing on getting fpGUI
components working with tiOPF as well. tiOPF is the core of my
business projects.  The GUI components of Lazarus already work fine.

I would be very interested in your MVP code based on Objects.  I am a
bit clue less when it comes to Interfaces and most MVP's seem to be
implemented in that.  Is that MVP code available for download from
your site?
I have all code in my machine, and is based on objects (like you) but with DePO and using DevExpress components (for view), but this part is very simple to change, just modify the control class in View, and the trigger event. I started to port all this to interfaces, but if you want I can send all actual code for you.


I have heard, but do not know what ValueType Frameworks (VTF) are.Would you mind explaining a bit?
ValueType, how is called in .NET, is the Types for attributes, so VTF is like a "Attribute Framework", microsoft introduce a name space "ValueType" in .NET framework.

The aim of VTF in Jazz, is be the base for all Business Objects and attibutes, this provides all necessary for integration with others frameworks, like
- VTF dont "have" to know nothing about OPF or MVP
- Implements Subject for integration with others frameworks using Observer Pattern - Provides ObjectState (Modified, Deleting, Deleted, Loaded, Persisted) that is changed by Notification
- Have own TypeInfo register, do not uses RTTI.
- All based on interfaces, so the properties and methods is mostly in protected, but can be overrided to be used with "objects"
- Properties can be simple types (string, integer, currency, etc)
- Fields should be of ValueTypes (IStringType/TStringType, ICurrencyType/TCurrencyType) - so the integration and notification happen without extra code (here is where really VTF is used) - the only information necessary for persistance here is for LazyLoad so the TMemberType have a reference to IDataProvider.
 IDataProvider = interface(IInterface)
   ['{581DEB88-29B5-4546-B992-BE1660841643}']
function Load(const Member: IMemberType; const AutoLoad: boolean = False): boolean;
 end;

with this, when the object is loaded for the first time, the persister notifies the object,
and the sender is the "Data Provider",
LQuery.CurrentLoaded.Notify(Session, ntLoaded);
this is used for transparent lazy load, when the a attribute or related object is accessed for the first time the DataProvider is called to load the related object(s).

A business object in Jazz is something like this:

unit BOPerson;

interface

uses
 (* delphi *)
 Classes,
 (* jazz *)
 JazzValueTypeIntf, JazzValueType, JazzTypeInfo,
 (* application *)
 BOPersonIntf;

type
 TPerson = class(TObjectType, IPerson)
 private
   FID: IStringType;
   FName: IStringType;
   FBirthDate: IDateType;
   FDocument: IStringType;
   FPicture: IBlobType;
 protected
   function GetBirthDate: TDateTime;
   function GetDocument: string;
   function GetID: string;
   function GetName: string;
   function GetPicture: TStream;
   procedure SetBirthDate(const Value: TDateTime);
   procedure SetDocument(const Value: string);
   procedure SetID(const Value: string);
   procedure SetName(const Value: string);
   procedure SetPicture(const Value: TStream);

   property ID: string read GetID write SetID;
   property Name: string read GetName write SetName;
   property BirthDate: TDateTime read GetBirthDate write SetBirthDate;
   property Document: string read GetDocument write SetDocument;
   property Picture: TStream read GetPicture write SetPicture;
 public
   procedure AfterConstruction; override;
 end;

implementation

{ TPerson }

procedure TPerson.AfterConstruction;
begin
 inherited;
 AddMember(FID, 'ID', TStringType);
 AddMember(FName, 'Name', TStringType);
 AddMember(FBirthDate, 'BirthDate', TDateType);
 AddMember(FDocument, 'Document', TStringType);
 AddMember(FPicture, 'Picture', TBlobType);
end;

function TPerson.GetDocument: string;
begin
Result:= FDocument.Value;
end;

function TPerson.GetID: string;
begin
 Result:= FID.Value;
end;

function TPerson.GetName: string;
begin
 Result:= FName.Value;
end;

function TPerson.GetPicture: TStream;
begin
 Result:= FPicture.Value;
end;

procedure TPerson.SetDocument(const Value: string);
begin
 FDocument.Value:= Value;
end;

procedure TPerson.SetID(const Value: string);
begin
 FID.Value:= Value;
end;

procedure TPerson.SetName(const Value: string);
begin
 FName.Value:= Value
end;

procedure TPerson.SetPicture(const Value: TStream);
begin
 FPicture.Value:= Value;
end;

function TPerson.GetBirthDate: TDateTime;
begin
 Result:= FBirthDate.Value;
end;

procedure TPerson.SetBirthDate(const Value: TDateTime);
begin
 FBirthDate.Value:= Value;
end;

end.




_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to