I think TimeDuration is a useful base type. It is something that exists in .NET 
system package (TimeSpan class) but has not been given as much importance in 
java land. I personally prefer name TimeSpan over TimeDuration.
I think very nice to replace if-then-else with OO equivalents. Ofbiz has too 
much if then else.. Makes things harder to extend.


On a note of caution. Currently system has very few fundamental types and 
everything has to be built from those few blocks. It keeps the foundation very 
simple.
Custom data types can be powerful but it could be bad if different apps start 
adding their own types and building on that. Maybe this is something that 
should be reasonably easy to add at system level but users should not be 
encouraged to add types.

Harmeet

----- Original Message -----
From: "Adrian Crum" <[email protected]>
To: [email protected]
Sent: Tuesday, November 10, 2009 10:40:54 PM GMT -05:00 US/Canada Eastern
Subject: Discussion: User-Defined Java Data Types In The Framework

I first started thinking of this idea in a Jira issue:

https://issues.apache.org/jira/browse/OFBIZ-3125

I thought it would be easy to extend the framework to support a new Java object 
type (or class). I wanted to be able to pass around a TimeDuration instance in 
services, mini-lang, screen widgets, etc. I thought it would be easy. It wasn't.

Those framework artifacts convert Java objects from one type to another using 
the ObjectType class. I had to make changes to a huge monolithic if-else-if 
block in that class. Then I had to modify some code in the Entity Engine. I 
couldn't get the Entity Engine to support the TimeDuration class because of two 
monolithic switch statements where Java data types are mapped to integers, but 
not in a centralized way.

I stopped trying to wedge the TimeDuration class into inflexible code, and 
instead started working on making the code more flexible.

I replaced the monolithic if-else-if block in ObjectType with polymorphism. Now 
components can extend the framework with their own Java object type conversions.

I still need to work on the Entity Engine. I would like to replace its 
monolithic conditionals with the new conversion code. Before I get started, I 
wanted to present the idea to the community to see if there were any objections.

The goal is to make it easier for developers to add new Java data types to the 
framework. I see this as a big benefit to writing OFBiz add-ons or 
customizations.

What do you think?

-Adrian



      

Reply via email to