Boost logo

Boost :

From: John Torjo (john.lists_at_[hidden])
Date: 2004-11-19 14:53:02


>>And as a side-note, combo-boxes can be "drop-down" as well. In which
>
>
> What other combo-box is there which doesn't drop down?

"drop-list" for instance, is what I think you assume for "drop-down"
(that is, you can only select from a list).

"drop-down" - you can select an item from a list, but also write it
yourself.

>
>
>>And as for validation, take an employee's data:
>>
>>
>>struct employee {
>> std::string first_name;
>> std::string last_name;
>> int id;
>> unsigned long salary;
>>
>> time_t birth_date;
>>
>> std::string country;
>> std::string address;
>> std::string email;
>>
>> bool has_homepage;
>> std::string homepage;
>>};
>>
>>Here are possible validations:
>>- First and last names should not be less than 4 chars
>
>
> This is a feature of the editline -> no validation is necessary
>
>
>>- ID should be within 10000 and 20000 range
>
>
> A slider with the lower value set to 10000 and the upper value to 20000
>

kidding, right? Would you have a user select an Employee ID with a slider?
  What if, for instance, valid IDs are from 5000 -10000, and 15000-20000?

I'm all for XXXYYY-Widgets, where possible.

However, saying that you should always use widgets for validation, is
about the equivalent of saying that all a class needs are some member
variables, and no validation whatsoever, since the members will take
care of that.

>
> Define 'valid' for an email address.
> Should it contain an @ symbol? If so, then use an Email-Editline widget, dont use a generic text editline widget.

Again, I'm all for this, but you should impose your application logic on
the controls, and not the other way around. I'm sure you'll find cases
whre you need specific logic for, lets say, an edit control, and no
widgets provide it out of the box.

>
>>How do you handle those (and lets not remember user-friendlyness)?
>
>
> I think you ment to say "lets not forget user-friendlyness"...

Yes :)

> In each case I have provided a reasonable example where no validation
was necessary by the application programmer.
All of which provide a reasonable good HCI, far better than simple
editlines.

Because what I've shown was too simple - my mistake here. There are more
complex scenarios where some invariants need to be kept, just like
invariants that appear in a class.

You can even think about it like this: if you have a class that needs to
be editable (in a dialog), if that class has an invariant, so will the
dialog need to have some validation associated with it.

Best,
John

-- 
John Torjo,    Contributing editor, C/C++ Users Journal
-- "Win32 GUI Generics" -- generics & GUI do mix, after all
-- http://www.torjo.com/win32gui/
-- v1.5 - tooltips at your fingertips (work for menus too!)
    + bitmap buttons (work for MessageBox too!)
    + tab dialogs, hyper links, lite html

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk