To anyone and everyone on the forum...
I'm wondering what coding strategies people use with regards to maintaing the String references to field names that are specified in DataSources and are used throughout the databinding process. For example, if there's a field called "customerName" in the DataSource, chances are excellent that the String "customerName" is going to be used in both client-side and server-side code. At the minimim, that String is going to be typed in the .ds.xml file, and some client-side code.
I have a number of goals in mind:
1. Minimizing opportunity for runtime and/or development bugs stemming from typos with field name strings. Even case-sensitivity can burn you here: "customername" vs. "customerName" and so on.
2. Maximizing the ability of an IDE (Eclipse, IDEA, etc.) to "find the usages" of a given field name and associated code. For example, I may want to easily determine where this "customerName" piece of data is being used in the app.
3. Being able to share this information across projects/applications
4. Being able to easily specify via an API what field names are going to be required by some server-side call, and being able to know what I'm getting back from such a call.
That last one is the killer, I think. When some DMI method, for example, is going to look into a very generic map of "parameters" and attempt to pull values out of it via string keys, I need to know as easily as possible what those keys are (and what data types the method is expecting, ideally). Likewise, if it's going to return a collection of Records, I want to know what's in those Records (if they're not specified directly by the .ds.xml file itself). Otherwise, one must rely on having access to the source code (including .ds.xml files) and/or maintaining a potentially large, parallel code base in the form of human-readable (as opposed to IDE-readable) English documentation. Someone changes the Java without changing the English, and bam... potential runtime error or very confused/delayed programmer.
One nice thing about GWT-RPC is that a given server method-call publishes a specific API that is compile-time checkable, telling you exactly what the method requires as input, and exactly what, if anything, you're going to get back as output. For all of the well-publicized denigrations of GWT-RPC, the loss of that communication to the developer, and its enforcement via the compiler, has non-trivial productivity implications. I'm trying to determine the "best practices" with SmartGWT to recover some of that lost communication and safety.
It seems like some kind of namespace class has to be created somewhere that contains a bunch of constants, like this:
The question then becomes, where does such a class live? A separate project or module external to a particular app where it's being used, to allow for reuse?
How have other people wrestled with this issue? I've been trying a variety of things like the namespace class above, and don't love any of them... hence this post.
Thanks.
I'm wondering what coding strategies people use with regards to maintaing the String references to field names that are specified in DataSources and are used throughout the databinding process. For example, if there's a field called "customerName" in the DataSource, chances are excellent that the String "customerName" is going to be used in both client-side and server-side code. At the minimim, that String is going to be typed in the .ds.xml file, and some client-side code.
I have a number of goals in mind:
1. Minimizing opportunity for runtime and/or development bugs stemming from typos with field name strings. Even case-sensitivity can burn you here: "customername" vs. "customerName" and so on.
2. Maximizing the ability of an IDE (Eclipse, IDEA, etc.) to "find the usages" of a given field name and associated code. For example, I may want to easily determine where this "customerName" piece of data is being used in the app.
3. Being able to share this information across projects/applications
4. Being able to easily specify via an API what field names are going to be required by some server-side call, and being able to know what I'm getting back from such a call.
That last one is the killer, I think. When some DMI method, for example, is going to look into a very generic map of "parameters" and attempt to pull values out of it via string keys, I need to know as easily as possible what those keys are (and what data types the method is expecting, ideally). Likewise, if it's going to return a collection of Records, I want to know what's in those Records (if they're not specified directly by the .ds.xml file itself). Otherwise, one must rely on having access to the source code (including .ds.xml files) and/or maintaining a potentially large, parallel code base in the form of human-readable (as opposed to IDE-readable) English documentation. Someone changes the Java without changing the English, and bam... potential runtime error or very confused/delayed programmer.
One nice thing about GWT-RPC is that a given server method-call publishes a specific API that is compile-time checkable, telling you exactly what the method requires as input, and exactly what, if anything, you're going to get back as output. For all of the well-publicized denigrations of GWT-RPC, the loss of that communication to the developer, and its enforcement via the compiler, has non-trivial productivity implications. I'm trying to determine the "best practices" with SmartGWT to recover some of that lost communication and safety.
It seems like some kind of namespace class has to be created somewhere that contains a bunch of constants, like this:
Code:
public class CustomerFields { public static final String FIELD_CUSTOMER_NAME = "customerName"; public static final String FIELD_CUSTOMER_ID = "customerID"; // etc... } // Usage example in DMI call... Map args = dsRequest.getClientSuppliedValues(); String customerID = (String)args.get(CustomerFields.FIELD_CUSTOMER_ID);
How have other people wrestled with this issue? I've been trying a variety of things like the namespace class above, and don't love any of them... hence this post.
Thanks.
Comment