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

So How’s It with Architecture - Up-Front Design or Evolutionary Architecture?

So How’s It with Architecture - Up-Front Design or Evolutionary Architecture?

Where does architecture currently stand? We can say that there are two classic approaches:

Read More

A Manifesto Against Developers

A Manifesto Against Developers

I hate you because:

  • You focus on the features of your IDE instead of the features your client/user needs.
  • You consider typing at the keyboard as thinking.
  • You waste countless hours manually testing your code.
  • You spend more time struggling with frameworks than delivering value to end users.
  • You code for hours without asking yourself, “What am I really doing?”
  • You naively believe that technologies and tools will solve your problems.
  • You naively believe that a good algorithm is more important than a good understanding of requirements.
  • You naively believe that your intuition is enough for writing good code.
  • You naively believe that you can manage the complexity of the system piece you’re working on.
  • You agree to unrealistic deadlines.
  • You write poor code and rationalize it with various excuses (because there is no time).
  • In your head, you create code snippets without really knowing what needs to be done.
  • You guess what needs to be done rather than clarifying.
  • You mindlessly follow the technology you use.
  • You don’t understand the tools and technologies you use.
  • You isolate yourself in your piece of code, breaking contact with the world.
  • You think it’s all the fault of managers or clients and believe you can’t do anything about it.

… even though I love you because I am a programmer myself.

Read More

Have You Ever Thought About a Career as a Trainer/Consultant?

As our activities at BNS IT (bnsit.pl) continue to expand, we have openings for individuals eager to work with others to share knowledge and experience. We aim to support teams in increasing their work efficiency.

Read More