3 ms·
The trouble with solution 1, removing a boolean method parameter and instead creating two methods like: public class FileUtils { public static void
by adrianmsmith 8y ago
The trouble with solution 1, removing a boolean method parameter and instead creating two methods like:
public class FileUtils {
public static void createFile(...) { .. }
public static void createTemporaryFile(...) { .. }
}
is that there is now no way to create a single wrapper function.
Let's say you want to create a function "createFileAndLog" which takes the boolean parameter and passes it to the underlying "createFile" function, now you have to create two "createFileAndLog" functions rather than just one, even though you didn't have the if statement in your code.
I haven't provided a great example, I know, but I've definitely split up such methods myself, felt good about it for increasing readability, then come to regret it later.
- QasimK 8y agoPass the "create file" function itself as a parameter to the "create file and log" function?