DEV Community

Discussion on: Code Smell 134 - Specialized Business Collections

 
mcsee profile image
Maxi Contieri

Extension should be made when protocol is different.

Dictionary and MyNames might be primitive obsession code smell. But this is the case when we need specialized behaviour. The quest is to find this behavior

Thread Thread
 
gorynych profile image
Stepan Mozyra

Pardon, don't get it. What protocol do you mean?

Thread Thread
 
mcsee profile image
Maxi Contieri

Protocol is the set of functions an object understands, AKA behavior

Is the only important thing we need to know in order to program

Thread Thread
 
gorynych profile image
Stepan Mozyra

Aha, thanks.

I tend to generalize it a bit - the only important thing is the Domain. So, if we have somewhere in our domain "MyNames" thing - we should reflect it in our code. Even if it will be just one line, like

public interface MyNames extends List {}

(of course, it's better to have

public interface MyNames extends List {} )

Protocol extension could come after that, but not have to. The better code should looks like domain expert speech, and there's no lists of strings ;).