简体   繁体   中英

LiveBindings or OOP?

I have a question regarding OOP. I'm not new to Delphi, but I learned it by myself, mostly from the internet and didn't learned it the "correct" way. I just started to take a look at OOP some weeks ago. So this is my problem: I have an own Class called "Session". This class is connected with Edits through Visual LiveBindings. I want to fill my class with data from a TClientDataset (there is a reason why I don't bind the dataset with the edits directly). Now I have 2 ideas: 1. I build another class which implements the Dataset and handles the opening of files and Navigation. 2. I Drag and drop the ClientDataset one my Form and connect it to my class with Livebindings, like this: DataSet <---> Class <---> Edit

I hope you understand my description. So: Which idea is better? I have the feeling that LiveBindings "destroy" the Concept of OOP. On the other hand I don't need to write Code and typecast, because the live bindings do that for me. So which way would you choose and why? Or has somebody another idea?

I hope you understand what I mean and can help me :)

With LiveBindings it is perfectly possible to bind to objects instead of datasets. See: http://www.malcolmgroves.com/blog/?p=1084

In summary: take look at TAdapterBindSource component. It is designed for creating LiveBindings between existing controls and custom objects. In it's onCreateAdapter event you can return a TObjectBindSourceAdapter as aBindSourceAdapter in case you want to bind one specific object, or return a TListBindSourceAdapter for binding list of objects.

LiveBindings and OOP does not bite each other!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM