Changes

Jump to: navigation, search

JSON RPC Adapter Project

567 bytes added, 18:36, 26 November 2010
Phase 8: Apply Changes per Code Review 3 (Done)
===Phase 8: Apply Changes per Code Review 3 (Done)===
*JSONWriter.java:
**Can a <code>StringBuilder </code> be used instead of a <code>StringBuffer</code>? Maybe the same change can be done in <code>TextMarshaller </code> as well? The member field can still be called <code>m_buffer</code>. Using <code>StringBuilder </code> instead of <code>StringBuffer </code> avoids the synchronization overhead.**writeString: remove the unnecessary conversion to a character array; the length can be accessed via <code>String.length()</code>.
*JSONMarshaller.java
**Can you fill in the comment for parameter “writer” <code>"writer"</code> on method “marshal” <code>"marshal"</code> of interface <code>Marshaller</code>? It is currently marked with <code>TODO</code>.**You can use the string id <code>err.rpc.mshType </code> instead of <code>err.rpc.json.mshType</code>**Can you define the <code>Timestamp </code> marshaller first, then the <code>java.util.Date </code> marshaller? Vassiliy wanted the default framework type’s marshaller first, followed by its synonyms.
*JSONParser.java
**Putting parts of the error message in the error arguments Object array that is passed to <code>fail() </code> isn’t localizable. The error message should be part of the value of the string id. String ids are stored in the <code>*.strings files</code>. For string ids used by Java code, the .strings files are in <code>core/src/nexj/core/meta/sys</code>. You need to ensure that there is an entry in this file for each id that you use. These are then translated into French (and possibly other languages) by people who specialize in translating software interfaces. The only things passed in the error arguments Object array should be data.**There should be a blank line before “break” <code>break</code> and “return” <code>return</code> statements.
*JSONUnmarshaller.java
**For the <code>castTo* </code> methods, can you rename them to <code>get* </code> and have them take a <code>String sKey </code> argument, which is the key to lookup in <code>m_valueMap</code>? This will more closely follow what Vassiliy intended when he said “Rather than directly type casting values retrieved from json map, you can have unmsh accessor methods for the common types, which can also do error checking, so that one does not get a generic type cast error and wonder what went wrong and where.”**<code>parseObject()</code>: I don’t think you need separate branches of code for handling the first key in the iterator and subsequent keys. Also, for iteration, prefer <code>for() </code> to <code>while()</code>.
*JSONUnmarshallerException.java
**The overload with <code>(String sExpected, Class actual) </code> isn’t localizable. Remove this overload and use the <code>(String sErrCode, Object[] argArray) </code> constructor. In <code>JSONUnmarshaller get* </code> methods, pass an <code>Object[] </code> of length two for the <code>argArray</code>. Ensure that both are strings.
**Please add a string for err.rpc.json.unmsh.CastException to en.strings in core/src/nexj/core/meta/sys. The various parts of the string id should all start with lowercase letters, e.g. CastException à castException. Use a meaningful name instead of “CastException”—CastException is what it is, not what the error is.
*JSONTests.java
**<code>testSerializeException </code> doesn’t need to initialize the <code>marshaller </code> and <code>unmarshaller</code>: they are initialized already by <code>setUp()</code>, which is run before each <code>test*() </code> method.**please remove the parts of tests that are duplicated. For example, in <code>testServerObjects() </code> you test the serialization of a Symbol called “sym”<code>sym</code>, a <code>PrivilegeSet </code> of “480000”, and a <code>PCodeFunction </code> with <code >code</code> 0, 1, 2. But these have already been tested by the “testSerializeRequestCheckJSON” <code>testSerializeRequestCheckJSON</code> which uses the m_request object initialized by the superclass.**Use <code>Primitive.createInteger</code>, <code>Primitive.createLong</code>, etc. instead of <code>new Integer(…), new Long(…)</code>, etc. where possible. 
===Phase 9: Code Review 4 (Done) ===
* Send patch to NexJ for review
1
edit

Navigation menu