java - How to prepare Business Objects for possible expansion in web services -


while creating web service decided exchange business object (bo) between client , web service.

if in future request expand model , put new attributes (field) in bo , send client, best approach?

so basically, each bo may have 0..n meta-fields.
each meta-field key,value like, keys can simple data types other bos.

here little java code modelling bos, need confirmation i'm on right track.

class abstractbo{   //optional list of meta fields future extension  list<metafield> metafieldlist;   //setters. getters  }  ----  class metafield {   private object key;  private object value;   // setters // getters  }  ----  class mybo extends abstractbo {  //bo specific fields private string name; ...   }  ---  today  class person extends abstractbo {   private string name;  private int age;   //extend metafieldlist = null;  }   ----  tomorrow  class person extends abstractbo {   private string name;  private int age;   //list new metafield   } 

how model person tomorrow purposes?

if, follow-up comment implies, want send direct object code (presumably implementing serializable) instead of using xml or json (which you'd typically when implementing web service), don't know how you'd able achieve want.

when java tries recreate object deserializing it, have match input data against believes class be. best practice purposes, should implementing serialversionuid , changing each time modify class when add variables, person on other end won't able erroneously reconstruct class send them if have old version of code.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -