Objects are all about the interfaces. Coming up with the interfaces that are easy
to understand and use is a key in developing good object-oriented software.
Often the simplest and most important thing you can do is to change the name of
a method, naming is a key tool in communication.
If you understand what a programm is doing you should not be afraid to use
Rename method to pass on that knowledge. You can also rename variables and
Small methods to factor complex processes are very importat, done badly can lead
you on a merry dance to find out what all the Little methods do.
The key to avoid this merry dance is naming the methods.
The methods must be named in a way that communicates their intention.
Normally used when you need more information in a method and this information
was not sent yet.
Normally used when a method is no longer using the information sent by the
You can easily add or remove parameter but you have to be careful because it can
lead you on troubles,
If you have more than two parameters, you must be careful because you
parameter list is getting bigger and it can be forgot.
“When you have a function that gives you a value and has no observable side
effects, you have a very valuable thing. You can call this function as often as you
like. You can move the call to other places in the method. In short, you have a lot
less to worry about. ”
“It is a good idea to clearly signal the difference between methods with side
effects and those without. A good rule to follow is to say that any method that
returns a value should not have observable side effects. Some programmers treat
this as an absolute rule [Meyer]. I'm not 100 percent pure on this (as on anything),
but I try to follow it most of the time, and it has served me well. ”
Create a parameter for methods that do similar things and replace them with a
new method with that parameter.
When you are using methods that do something in base a parameter. You should
create other methods that do what you want, just to avoid the conditional.
You can send an object as a parameter when you need different information from
the same object.
Remove all methods that only affect one field and that do this just one time.