One thing we often hear about good practice when coding is to be DRY (Don’t Repeat Yourself). This means we only have the code in one location. If we find an issue or want to improve functionality, we can update it, and everywhere that uses that code will also be improved. Happy Days!
With that in mind when adding a custom dialog form to the Business Display Demo that is always going to be used in the same way (i.e. Created, passed a list of paramaters, gets a result from the user and returns it and free’s the created form) a Class Methods is really helpful way to wrap this functionality up with the class. Class methods exist along with the class declaration; they don’t require an instance of the class to be called (which is really handy as you can then call them all in one line of code).
The golden rule with a class method is that they should take in, create and use everything they need to perform the logic they contain.
Anyway. that should be enough to get you going. Time to watch this short video (under 4 minutes) and see how they are used in the demo.Posted by Stephen Ball on January 18th, 2013 under Business Display Demo, Delphi |