Refactoring-the same way to operate on different objects

description

  • trouble boss to point out how to reconstruct the operations of different objects with the same method?
  • At the bottom of
  • is the code. The save methods here are all the same operation. The object is used as a reference here. I just want to ask if this can be refactored?
  • if it were me. I guess I will take the value myself, pass the input value, and then return a path and operate it alone, but I think I can use the object directly here, but I haven"t found any relevant information. Can you give me some advice?
public class ObjectA {
    public save (AA aa) {
        //  aa get , , ,  set  aa
    }
    public static class AA {
        private String img;
        // ... 
        // ... set get 
    }
}
public class ObjectB {
    public save (BB bb) {
        //  bb get , , ,  set  bb
    }
    public static class BB {
        private String img;
        // ... 
        // ... set get 
    }
}

clipboard.png

judge by instanceof. And then take out the data. Then execute the public method
directly generic and you are done

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35cef-2b80d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35cef-2b80d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?