Clean Code - naming related classes

Viewed 105

I've read Clean Code by R.C. Martin and I'm trying to adopt his suggestions about clean code as broadly as possible.

But I'm not sure how to name related classes.

Let's say I have a class named TreeDirectoryList.

I want to cut implementation of this class into many smaller classes. Let's say I'll create a class named ParentIndexStack.

ParentIndexStack will implement functionality very dependent on TreeDirectoryList, so it's very not probable that this implementation of ParentIndexStack will be useful with any other class in the future.

But the name of ParentIndexStack is very generic, it's possible, that I'll need another class with the same name, within the same project.

So I thought I'll name ParentIndexStack more precise, like TDLParentIndexStack (prefix TDL is from TreeDirectoryList).

Would it be correct ?

I'll end with many classes starting with TDLxxxxx.

1 Answers

One option is to put that set of classes in their own namespace. Then you can have simple, concise names that still communicate the full meaning of the class through the namespace context.

Related