Alysson

10%
Flag icon
Let’s say we have many classes where add will create a new value by adding or concatenating two existing values. Now let’s say we are writing a new class that has a method that puts its single parameter into a collection. Should we call this method add? It might seem consistent because we have so many other add methods, but in this case, the semantics are different, so we should use a name like insert or append instead.
Clean Code: A Handbook of Agile Software Craftsmanship (Robert C. Martin Series)
Rate this book
Clear rating
Open Preview