Best Practices
From 4DWiki
Despite 4D's long presence in the database world, not many formal studies have been conducted to establish "best practice" when using 4D to create programs. 4D is a fairly specialised programming environment, with some interesting idiosynchrasies not found elsewhere in the programming world. But in the main, "best practices" that apply to a procedural language like C or Pascal also apply to the language of 4D, which is based on Pascal.
Languages like C++ and its derivatives make error handling a matter of choice between returning error codes and throwing exceptions. While there is some debate about how and when to use exceptions in those languages, they offer a useful programming paradigm that can be adapted to the world of 4D. Recall that in languages that have exceptions, there is usually only one exception active per execution thread, and that although an exception itself is an object, it often contains a string that describes the error that occurred. Having an object is useful, but the functionality of the error message in the object can be modelled in 4D using a process variable and a series of wrapper methods that manage the process variable and affect the program's flow of control.

