Hi Malte,

Frank Schönheit - Sun Microsystems Germany wrote, On 10/23/06 13:50:
Hi Malte,

...

I for sure don't want to see some "virtual bool IsUnlimitedTextLen()
const;".
Why? That's a much cleaner solution than imposing a magic^W special
semantics on a special value - no matter if "0" or "EDIT_NOLIMIT".

1) There is IMHO a lot of API doing something like that with "0".
An Edit with max text len "0" doesn't make much sense, so 0 is fine.

There is also API interpreting 65535 as "no limit", like the Edit is today. There is also API using -1 for "no limit". If things are documented, this is usually no problem, but if it is not it is an absolute mess!

That reminds me of the Rectange, where there was no comment about when a rectangle is meant to be empty. There is a define now in the same file (which helps in the first place, because you have a chance to find it then):

#define RECT_EMPTY      ((short)-32767)

BTW., what the heck (hack) is this? Why is the define a short whereas nBottom and nRight are long?

Looking into the source-code (which is inline probably for documentation reasons) nBottom or nRight can be RECT_EMPTY for the rectangle to be empty. This is an implementation detail, which a user of this API usually shouldn't have to know.

Fortunately, we now have SetEmpty() and IsEmpty() methods (finally!) And this is great! Everything else is not acceptable.

And this is the same here. IsUnlimitedTextLen() makes absolutely sense. Magic in the sources is always a bad thing, IMHO, especially if not well documented.

Why not having:

// set some limited maximum length
SetMaxTextLen( xub_StrLen );
SetUnlimitedMaxTextLen();
bool IsUnlimitedMaxTextLen();

This leaves the implementation the possibility to use a special value for unlimited (because EnableMaxTextLen( false ) would make no sense then). SetMaxTextLen() with the unlimited special value could then throw an exception (for compatibility it maybe shouldn't). Well of course this must be documented and is not the best solution, but pragmatic insofar as the existing code doesn't break.

just my 2cts

-Bjoern

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to