ENUMS simulations
Charles Yeomans
yeomans at desuetude.com
Fri Jun 18 17:11:07 CDT 2004
On Jun 18, 2004, at 4:50 PM, Ruslan Zasukhin wrote:
>
> Right, I will add fields.
>
> Btw, let's discuss the next idea.
>
> Right now module Valentina have mixture of constants from different
> types
> and enums.
>
> It looks that I can improve this in the next way,
> And get syntax 100% the same as Java have
>
> * I can create in plugin MANY modules with e.g. name
>
> ELockType
>
> And constants
>
> kNoLock, kRadOnly, kReadWrite
>
>
> * then we can write such syntax:
>
> db.SqlSelect(
> query,
> ECursorType.kServerSide
> ELockType.kReadOnly,
> Edirection.ForwardOnly )
>
>
> Compare to current attempt
>
> db.SqlSelect(
> query,
> Valentina.kServerSide
> Valentina.kReadOnly,
> Valentina.ForwardOnly )
>
> It looks to me that the first way is more clean.
> And again, Java work with enums in this way.
>
As I understand it, the advantage of enumerations is that one can
check types at compile time. I don't see that the scheme you propose
offers any advantage over Valentina.kCursorServerSide. An alternative
here would be to define a query class that has properties like
ServerSide as Boolean; indeed, I use such a class myself. But, no
matter how much you twist and turn, there doesn't seem to be a way to
work around the lack of enumerations for properties that aren't Boolean
in a way that provides compile-time checking. Clearly, one can check
assignment at runtime and (as I like to do :) raise an exception for
invalid values.
Charles Yeomans
More information about the Valentina-beta
mailing list