I do a lot of data analysis scripting, comparing two objects or strings to determine differences or come up with gaps that need to be filled.
When you're in a loop, comparing object a to object b, do you have a preferred coding standard that makes sense (i.e., it is self-documenting) and can travel nicely to other code? Or are variable names irrelevant in this type of code:
for (String a : TreeMapvar) {
// Read b from data source
if (a.equals(b)) {
// Update a
} else {
TreeMapvar.add(b);
}
A different example:
TreeMap<String, MyObject> TreeMapvar = new TreeMap<String, Object>();
File f = "Somefile";
// Open the file with bufferedReader br
while ((line=br.readLine)!=null)) {
//insert code parse line to get object a
if (TreeMapvar.containsKey(a)) {
if (TreeMapvar.get(a).somefield.equals(a.somefied)) {
//insert code to update a
} else {
//insert code to insert new object
}
}
}