开发者

Logical way to sort your interfaces

I currently put them in an interface folder but this wont help readability for people who do not know the code开发者_如何学Go base no more than lumping all of your implementation classes in a folder called implementation.

How do you guys logically sort your project interfaces.


I assume you're talking about the kind of interfaces that classes implement in OO languages.

I'd say it's better to name the folder by function, if you really want to separate the interface from implementing classes - call the folder 'listeners' or whatever these interfaces represent. The fact they're interfaces (or abstract classes) should be obvious from the way they're named and used.

Then again, if it's not some form of a framework other people will use, but end up with an interface and a two or three implementing classes you write and leave them be, you might as well stick them all together in the same package. I don't think that making a package for a single class/interface does much for clarity.

Not part of the question but I'll write it anyway - I'm also not a fan of the "I" prefix for interfaces. If it's not obvious without it, then it could probably use a different name/structure.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜