I just re-watched an excellent video by David Schwartz on form/code separation. Schwartz gave this presentation during a 2014 Code Rage 9 session.
Schwartz says the majority of Delphi Form-to-Form code he has seen uses what he calls "Back-Door" injection. Where all the data movement to and from controls is handled at the form level. This is in contrast with the “normal” use of properties to enforce encapsulation in the movement of data into and out of objects. He discusses "Constructor" injection and "Property" injection pointing out the pros and cons of both.
I'm one of these "back-door" injection coders. I've never used properties. I'm learning how to use them. Here are my main reasons for not using them in the past:
- Short how-two Delphi videos... "You can do all of this with no code".
- They seem overly complicated to type.
- Ignorance on the benefits provided.
I found this very interesting.
CodeRage9
Have You Embraced Your Inner Software Plumber Yet?
David Schwartz
Here are time jumps to specific sections:
Schwartz has some interesting ideas. I haven't seen anything from him for some time. I wonder what he's up to now. I'm a big fan of "callbacks" or anonymous methods as a means of decoupling modules. One of the areas he deliberately didn't talk about involves data aware controls. It would be interesting to see how he integrates applications with data aware controls along with some of his other methods of data transfer. Specifically, I'm wondering about taking a query from a TDataSet and converting it to JSON to pass it to a selection form rather than just letting the selection form access the data directly.
ReplyDeleteWe'll probably be discussing pros and cons of all kinds of approaches long after I retire to my vegetable garden!
Thanks for this.
Milan, I'd like to see how Schwartz uses data-aware controls as well. Perhaps he'll drop in and make a comment or two.
DeleteThanks for re-posting this thought-provoking CodeRage session. I've just started rebuilding an app from the ground up and trying to decouple things better this time around - so your timing is perfect!
ReplyDeleteYou are welcome. I am also porting over an old app. Mine was last coded using Delphi 5.
DeleteThanks for bringing this back to life, Mike. Just an note tho: I believe there are NO dependencies on Raize Components. I think I simply forgot to remove something from the Uses clause.
ReplyDeleteI'm reviewing the video and it needs to be about twice as long with a few more explanations. I'm not sure how anybody got anything from it. :/
If there's much interest, I could go through it at a more leisurely pace on a Zoom session and see how that goes.
Also, I set up a redirect to the goo.gl link displayed at the end of the video should send you to a Dropbox folder with both the video and the Demo files. The link is: http://goo.gl/8GRLDk
Thanks David and Michael. Some of this went over my head, but I got the gist of it and found it very interesting.
ReplyDelete