February 28, 2013

Application design ideas


Today I was reading a few blogs and questions on various forums. This made me thinking about writing some parial answers to this question: How to write a good application using Delphi?
  • Separate as much as possible the user interface from the processing
  • Encapsulate every processing in a class (or component)
  • Use events to free your classes from things that can change
One big mistake the newbie is doing when he starts programing with Delphi is to create a form with his user interface and put all processing in the form’s events handler. This results in huge forms where reusability and testability are very poor.
 
Instead, create a classes or components to encapsulate the items your program is managing and create methods to handle processing.
 
Of course, when you design classes or components, there are things that should not be done within the class, for example getting some runtime value, storing results, displaying warnings, and more. All those tasks can be done in line by triggering an event.

Follow me on Twitter
Follow me on LinkedIn
Follow me on Google+
Visit my website: http://www.overbyte.be

2 comments:

Unknown said...

François,
You are right, but your principles are not specific to Delphi. My main question, today, about a new dev with Delphi is more 'what user interface library ?' : VCL, VCL + Themes, FM, Metropolis UI, another one ?

Juan C.Cilleruelo said...

If you put to work the suggested idea of separate the User Interface, of the process classes, this is not an important thing to take in account.

My last application has about 90 forms. Migrate it from VCL to FireMonkey 2 has been the minor of my problems.

I use a Model-View-Controller pattern based architecture, adapted to Delphi Language.

Of course I know what is the user interface that don't need to be taked in account: Metropolis.