My answer for – What is wrong with this code #02

A lot of things can be found in the snippet at “What is wrong with this code #02″. Here it is again: [sourcecode language=”java”] public MyObject { private String myField; … (imagine multiple fields) … public GenericObject toGenericObject() { GenericObjectFactory genericObjectFactory = GenericObjectFactory.getInstance(); GenericObject genericObject = genericObjectFactory.create("myObject"); genericObject.setField("myField", myField); // imagine multiple lines using genericObject.setField("field", […]

What is wrong with this code #02

Given that the functionality of the method toGenericObject must be preserved; there is something obviously wrong in this code, can you find it? If so, can you think of an easy solution? [sourcecode language=”java”] public MyObject { private String myField; … (imagine multiple fields) … public GenericObject toGenericObject() { GenericObjectFactory genericObjectFactory = GenericObjectFactory.getInstance(); GenericObject genericObject […]