Mudanças entre as edições de "Interfaces and Implementations"
De Basef
(Criou página com 'These are sometimes a special case for encodings. For example, say you are building an ABSTRACT FACTORY for the creation of shapes. This factory will be an interface and will...') |
|||
Linha 1: | Linha 1: | ||
These are sometimes a special case for encodings. For example, say you are building an | These are sometimes a special case for encodings. For example, say you are building an | ||
ABSTRACT FACTORY for the creation of shapes. This factory will be an interface and will | ABSTRACT FACTORY for the creation of shapes. This factory will be an interface and will | ||
− | be implemented by a concrete class. What should you name them? IShapeFactory and | + | be implemented by a concrete class. What should you name them? '''IShapeFactory''' and |
− | ShapeFactory? I prefer to leave interfaces unadorned. The preceding I, so common in | + | '''ShapeFactory'''? I prefer to leave interfaces unadorned. The preceding I, so common in |
today’s legacy wads, is a distraction at best and too much information at worst. I don’t | today’s legacy wads, is a distraction at best and too much information at worst. I don’t | ||
want my users knowing that I’m handing them an interface. I just want them to know that | want my users knowing that I’m handing them an interface. I just want them to know that | ||
− | it’s a ShapeFactory. So if I must encode either the interface or the implementation, I choose | + | it’s a '''ShapeFactory'''. So if I must encode either the interface or the implementation, I choose |
− | the implementation. Calling it ShapeFactoryImp, or even the hideous CShapeFactory, is preferable to encoding the interface. | + | the implementation. Calling it '''ShapeFactoryImp''', or even the hideous '''CShapeFactory''', is preferable to encoding the interface. |
[[Category:Clean Code]] | [[Category:Clean Code]] |
Edição atual tal como às 12h19min de 27 de janeiro de 2020
These are sometimes a special case for encodings. For example, say you are building an ABSTRACT FACTORY for the creation of shapes. This factory will be an interface and will be implemented by a concrete class. What should you name them? IShapeFactory and ShapeFactory? I prefer to leave interfaces unadorned. The preceding I, so common in today’s legacy wads, is a distraction at best and too much information at worst. I don’t want my users knowing that I’m handing them an interface. I just want them to know that it’s a ShapeFactory. So if I must encode either the interface or the implementation, I choose the implementation. Calling it ShapeFactoryImp, or even the hideous CShapeFactory, is preferable to encoding the interface.