Pure code - naming related classes

I read RC Martin's Clean Code, and I try to make the most of his clean code suggestions.

But I'm not sure what to call related classes.

Let's say I have a class called TreeDirectoryList.

I want to reduce the implementation of this class in many smaller classes. Let's say I create a class called ParentIndexStack.

ParentIndexStack will implement functionality highly dependent on TreeDirectoryList, so it is very unlikely that this ParentIndexStack implementation will be useful with any other class in the future.

But the name ParentIndexStack is very common, it is possible that I will need another class with the same name within the same project.

So, I thought that I would call ParentIndexStack more accurate, for example TDLParentIndexStack (TDL prefix from TreeDirectoryList ).

Will it be right?

I will finish many classes starting with TDLxxxxx.

+4
source share
1 answer

One option is to put this set of classes in your own namespace. You can then have simple and concise names that still convey the full meaning of the class through the namespace context.

+5
source

Source: https://habr.com/ru/post/1686815/


All Articles