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

Simple, Complicated, Complex, and Chaotic Systems: The Cynefin Framework

Perhaps you’ve previously encountered concepts such as complex systems, complicated systems, or complex adaptive systems, for instance when reading Jurgen Appelo’s Management 3.0, or when considering Ken Schwaber’s thoughts on the applicability of Scrum. This might sound intriguing, but it can be difficult to find logical sense in it if one lacks a certain theoretical foundation. This is where it’s worthwhile to examine Dave Snowden’s concept called Cynefin, which is based on complex systems theory, anthropology, evolutionary psychology, and cognitive psychology.

Read More

Simple, Complicated, Complex and Chaotic Systems, in Other Words Cynefin. And How Does It Relate to Software Development?

Intro

You might have already come across terms such as complex systems, complicated systems, or complex adaptive systems; especially, if you have read Management 3.0 by Jurgen Appelo or heard about Ken Schwaber’s ideas about the applicability of Scrum. It might sound intriguing, but finding logic in it is difficult without some background theory. This is the point at which Dave Snowden’s Cynefin concept comes in handy. This concept is based on complex systems theory, anthropology, evolutionary psychology, and, last but not least, cognitive psychology.

Read More

The Natural Order of Refactoring Examined Part 4: Refactoring to Patterns

The Natural Order of Refactoring Examined Part 4: Refactoring to Patterns

By following the steps outlined previously, we begin to see a more structured solution, predominantly consisting of methods grouped into classes. It’s now time to apply object-oriented principles, such as those encapsulated by the SOLID principles. We analyze the code for patterns of repetition, the need for flexibility, and code smells, and introduce design patterns where appropriate.

Read More