接口||摘要||都? [英] Interface || abstract || both?
问题描述
关于它们的使用已经进行了很多讨论,但我只是想知道普遍接受的做法。
我写了一个字典类,需要命令他们的方法作为字符串和类,然后将字符串映射到类的方法。
我预计在将来,我或他人可能希望使用这样可以创建其他词典。因此我希望尽可能多才多艺。
用法:
我应该使用抽象并为其他人提供一个空白的界面来抽象?
我应该使用类的接口,将抽象留给其他人吗?
命名:
应该我使用抽象或A为接口添加前缀和抽象类?
IDictionary
AbstractCommandDictionary
CommandDictionary
我尝试过:
目前有接口/类设计
请参阅 java interface vs abstract - Google搜索 [ ^ ]。
A lot of discussion has been made over their use but I just want to know the generally accepted practice.
I have written a dictionary class, it takes commands their methods as strings and a class, then maps the strings to the methods of the class.
I anticipate that in the future, either myself or others may wish to use this to create other dictionaries. Therefore I wish to make it as versatile as possible.
Usage:
Should I use abstraction and provide a blank interface for others to abstract?
Should I use an interface with a class, leaving abstraction to others?
Naming:
Should I prefix interfaces with I and abstract classes with Abstract or A?
IDictionary
AbstractCommandDictionary
CommandDictionary
What I have tried:
Currently have the interface/class design
See java interface vs abstract - Google Search[^].
这篇关于接口||摘要||都?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!