[Solved] Java: Merge code [closed]


You write out the commands that perform each operation one at a time, then you put them all within one method.

— update to give fictional example —

public void updateUserAgeByName(String name, int age) {
  User user = fetchUserByName(name);
  user.setAge(age);
  updateUser(user);
}

another example could be

public void updateUserByName(String name, User newValues) {
  User user = fetchUserByName(name);
  user.setAllFrom(newValues);
  updateUser(user);
}      

there are infinite variations, depending on what facilities are available to you, what you intend to accomplish, and how you structure your code. There is no “right” answer, but there are answers that are better than others, depending on the patterns of usage and other requirements that need to be met.

2

solved Java: Merge code [closed]