[Json-rpc-java] coding style

Michael Clark michael at metaparadigm.com
Thu Sep 27 20:57:48 SGT 2007


Hi Folks,

Just wanted to ping the list on coding style.

Since we are in talks with Arthur about a possible merge of the 
JSON-RPC-Java project and JAbsorb I wanted to get some wider feedback on 
coding style (it is a pretty major change and effects patch 
compatibility if you have local changes).

Ping us back that you:

 * prefer 1
 * prefer 2
 * prefer 2 but 1 might be a good idea until after my patch gets merged?

I'll just feedback the results and stay neutral :)

1. This what we have in json-rpc-java svn trunk (which is similar to 
that of apache-ant)

indent=4 braces on same line

    public void registerSerializer(Serializer s) throws Exception {
        Class classes[] = s.getSerializableClasses();
        Serializer exists;
        synchronized (serializerSet) {
            if(serializableMap == null) serializableMap = new HashMap();
            for (int i = 0; i < classes.length; i++) {
                exists = (Serializer) serializableMap.get(classes[i]);
                if (exists != null && exists.getClass() != s.getClass())
                    throw new Exception(
                            "different serializer already registered for "
                                    + classes[i].getName());
            }
            if (!serializerSet.contains(s)) {
                if (isDebug())
                    log.info("registered serializer " + s.getClass().getName());
                s.setOwner(this);
                serializerSet.add(s);
                serializerList.add(0, s);
                for (int j = 0; j < classes.length; j++) {
                    serializableMap.put(classes[j], s);
                }
            }
        }
    }



2. This what we have in jabsorb trunk:

indent=2 braces on their own line

  public void registerSerializer(Serializer s) throws Exception
  {
    Class classes[] = s.getSerializableClasses();
    Serializer exists;
    synchronized (serializerSet)
    {
      if (serializableMap == null)
      {
        serializableMap = new HashMap();
      }
      for (int i = 0; i < classes.length; i++)
      {
        exists = (Serializer) serializableMap.get(classes[i]);
        if (exists != null && exists.getClass() != s.getClass())
        {
          throw new Exception("different serializer already registered for "
              + classes[i].getName());
        }
      }
      if (!serializerSet.contains(s))
      {
        if (log.isDebugEnabled())
        {
          log.debug("registered serializer " + s.getClass().getName());
        }
        s.setOwner(this);
        serializerSet.add(s);
        serializerList.add(0, s);
        for (int j = 0; j < classes.length; j++)
        {
          serializableMap.put(classes[j], s);
        }
      }
    }
  }





More information about the Json-rpc-java mailing list