What Name for This Method?

Table of Contents

What Name for This Method?

public class OptionsAwareObject {  
    private Options options;  
      
    public void updateOptions(String fontName, int fontSize) {  
       options.setFontName(fontName);  
       options.setFontSize(fontSize);  
    }  
}  
   
class Options {  
    private int foregroundColor;  
    private int backgroundColor;  
    private String fontName;  
    private int fontSize;  
    // ...
}

Is updateOptions a good name for this method? Of course not! updateOptions is a general name that suggests a comprehensive update of options. Meanwhile, we are only updating font-related information. The responsibility of the method is thus the change of font-related options. A better name would be:

public void updateFontOptions(String fontName, int fontSize) {  //...

(Text translated and moved from original old blog automatically by AI. May contain inaccuracies.)

Related Posts

Technical Leader Worries: I Want to Build Trust in My Team but I Don't Want Them to Do What They Want

Understanding Trust in Leadership

Trust is a very big word and very often misused. Many leaders, in an attempt to build trust, feel obliged to allow people to do anything they want. However, they also wish to have some impact on how a task is completed.

Read More

Meeting Deadlines at All Costs is a Mistake!

The Necessity of Deadlines

Deadlines are necessary. Whether you work in Scrum (Agile) or a waterfall-like methodology, one thing is certain: without deadlines, there is no motivation. According to Parkinson’s Law (no relation to the disease), deadlines are essential.

Read More