Maximiliano Contieri
1 min readAug 25, 2020

--

syntactically they are the same

But naming is important:

1) setColor gives the idea of the object being undefined ot *not set* at some point in time

2 setColor can be identified as a setter so the reader might think you are assigning the color to the argument you are sending. this violating information hiding.

changeColor: on the other hand is implementation agnostic, so you can store your color in a completely different format (for example hexadecimal) by translating your argument

Name is much less coupled

--

--

Maximiliano Contieri
Maximiliano Contieri

Written by Maximiliano Contieri

I’m a senior software engineer specialized in declarative designs. S.O.L.I.D. and agile methodologies fan. Maximilianocontieri.com

Responses (1)