Re: OOP style




"swansnow" <schultz@xxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1125005329.141501.276110@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

> A form which is basically a settings screen. When it's time to save,
> several things have to happen:
> validate the fields (make sure required fields aren't empty, make sure
> the database server is alive at the drive letter the user indicated),
> if this is a new user create the database record, create their working
> databse tables, copy some files, write to an ini file. If this is
> modifying an existing user, post the data, and see if they have the
> current version of the database tables; set some global variables.
> Handle errors, make sure the state of things is always valid.

I personally prefer to do validation and the like during data entry. In fact
my approach is to generally not enable saving when there is invalid data
entered. It may mean more runtime expense, but since its during an i/o bound
sequence, its not noticeable.

> Then the Save button handler is simply method calls, such as:
>
> if not RequiredFieldsValid then exit;
> if newUser then
> if not createNewUser then exit;

Its a matter of personal preference, but I don't particularly like using
Exit. I would have written the above as

if RequiredFieldsValid
then begin
if newUser . . .

or, if the logic permits

if RequireFieldsValid and
newUser and
createNewUser . . .

> Programming seems similar to writing an essay -- get it all out, and
> then revise and streamline it.

As any experienced author will tell you, it helps to have a solid outline
before getting started.


.


Quantcast