[OFBiz] Dev - why set operation for minilang?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[OFBiz] Dev - why set operation for minilang?

Si Chen-2
David,

I saw your solution of creating a "set" operation for typecasting in
minilang.  So does "set" cause the old "field-to-field" to be
deprecated?  When should one use "set" versus "field-to-field"?  Is it
bad to put the typecasting code into "field-to-field," as our patch
suggested?

Thanks,

Si
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - why set operation for minilang?

David E. Jones

Si,

The idea of putting the set operation into the simple-method has been  
on the table for a while, part of a general effort to make tools more  
consistent and such.

The related operations in the simple-method are a mess right now and  
I don't like them a whole lot (and a lot of people have been quite  
open about sharing similar sentiments...). The field-to-field, env-to-
field and field-to-env operations are all there for legacy reasons.  
In fact the whole field-name/map-name pairs that exist all over the  
place only exist because originally we didn't have the dot and string  
expansion syntax stuff in place so it was the only way to get at a  
Map entry.

After the map accessor and string expander were introduced the  
preferred operation to use was the env-to-env operation, but the set  
operation and the way it works is much more flexible and can take the  
place of all of those, plus the string-to-field operation, plus it  
does type conversions and supports a default-value and such.

Sooner or later I'd like to get rid of all field-to-field, field-to-
env, env-to-field, env-to-env, and even string-to-field operations  
and replace them all with usage of set, and then just get rid of  
those as they are confusing (as demonstrated by this question...).

-David


On Sep 26, 2005, at 10:00 AM, Si Chen wrote:

> David,
>
> I saw your solution of creating a "set" operation for typecasting  
> in minilang.  So does "set" cause the old "field-to-field" to be  
> deprecated?  When should one use "set" versus "field-to-field"?  Is  
> it bad to put the typecasting code into "field-to-field," as our  
> patch suggested?
>
> Thanks,
>
> Si
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/dev
>

 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev

smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - why set operation for minilang?

Si Chen-2
In reply to this post by Si Chen-2
Ok.  So now I see that field-to-field is deprecated.  I also did a

sichen@linux:~/eclipse/workspace/ofbiz/applications> grep -r
field-to-field * | wc -l
2164

There are still a lot of field-to-field operations out there.  Would it
be bad thing, for now, to use our type conversion code in FieldToField.java?

Si

Si Chen wrote:

> David,
>
> I saw your solution of creating a "set" operation for typecasting in
> minilang.  So does "set" cause the old "field-to-field" to be
> deprecated?  When should one use "set" versus "field-to-field"?  Is it
> bad to put the typecasting code into "field-to-field," as our patch
> suggested?
>
> Thanks,
>
> Si
>
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/dev
>
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - why set operation for minilang?

David E. Jones

I'm not sure about this.... If we were to do something like this we  
might as well do it in the Entity Engine itself, but I'm not sure if  
I like that idea. In other words, we could always try to convert the  
data to the right type in the field.set/put operation, and then if it  
failed throw an exception rather than throwing an exception when it  
is the wrong type.

Would this be a good thing or perhaps cause more problems than it  
solves?

-David


On Sep 26, 2005, at 12:53 PM, Si Chen wrote:

> Ok.  So now I see that field-to-field is deprecated.  I also did a
>
> sichen@linux:~/eclipse/workspace/ofbiz/applications> grep -r field-
> to-field * | wc -l
> 2164
>
> There are still a lot of field-to-field operations out there.  
> Would it be bad thing, for now, to use our type conversion code in  
> FieldToField.java?
>
> Si
>
> Si Chen wrote:
>
>
>> David,
>>
>> I saw your solution of creating a "set" operation for typecasting  
>> in minilang.  So does "set" cause the old "field-to-field" to be  
>> deprecated?  When should one use "set" versus "field-to-field"?  
>> Is it bad to put the typecasting code into "field-to-field," as  
>> our patch suggested?
>>
>> Thanks,
>>
>> Si
>>
>> _______________________________________________
>> Dev mailing list
>> [hidden email]
>> http://lists.ofbiz.org/mailman/listinfo/dev
>>
>>
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/dev
>

 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev

smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [OFBiz] Dev - why set operation for minilang?

Si Chen-2
David,

I don't think that we should be modifying the entity engine to convert
types automatically.  Since types need to be specified explicitly in
Java, whoever writes the code should be using the right types.

In minilang, there is no explicit typing or type-conversion code, so I
think we should do some kind of type conversion in minilang when setting
values.  If you've done it with the set operation but not with
field-to-field, then all the code related to field-to-field may be
creating the wrong values and thus be a source of potential bugs.  The
choices would be to change all 2000+ instances of field-to-field to set
or to support type conversion in field-to-field.  The second option is
what our patch to OFBIZ-500 did.

By the way, I tried the latest version, and it did not work for me, so I
will re-open OFBIZ-500 with some new error logs.

Si

David E. Jones wrote:

>
> I'm not sure about this.... If we were to do something like this we  
> might as well do it in the Entity Engine itself, but I'm not sure if  
> I like that idea. In other words, we could always try to convert the  
> data to the right type in the field.set/put operation, and then if it  
> failed throw an exception rather than throwing an exception when it  
> is the wrong type.
>
> Would this be a good thing or perhaps cause more problems than it  
> solves?
>
> -David
>
>
> On Sep 26, 2005, at 12:53 PM, Si Chen wrote:
>
>> Ok.  So now I see that field-to-field is deprecated.  I also did a
>>
>> sichen@linux:~/eclipse/workspace/ofbiz/applications> grep -r field-
>> to-field * | wc -l
>> 2164
>>
>> There are still a lot of field-to-field operations out there.   Would
>> it be bad thing, for now, to use our type conversion code in  
>> FieldToField.java?
>>
>> Si
>>
>> Si Chen wrote:
>>
>>
>>> David,
>>>
>>> I saw your solution of creating a "set" operation for typecasting  
>>> in minilang.  So does "set" cause the old "field-to-field" to be  
>>> deprecated?  When should one use "set" versus "field-to-field"?   Is
>>> it bad to put the typecasting code into "field-to-field," as  our
>>> patch suggested?
>>>
>>> Thanks,
>>>
>>> Si
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [hidden email]
>>> http://lists.ofbiz.org/mailman/listinfo/dev
>>>
>>>
>> _______________________________________________
>> Dev mailing list
>> [hidden email]
>> http://lists.ofbiz.org/mailman/listinfo/dev
>>
>
>------------------------------------------------------------------------
>
>
>_______________________________________________
>Dev mailing list
>[hidden email]
>http://lists.ofbiz.org/mailman/listinfo/dev
>
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev