How to name an subclass that add a minor, detailed thing? [closed]

What is the most concise (yet descriptive) way of naming a subclass that only add a specific minor thing to the parent? I encountered this case a lot in WPF, where sometime I have to add a small functionality to an out-of-the-box control for specific cases.

Example: TreeView doesn’t change the SelectedItem on right-click, but I have to make one that does in my application.

Some possible names are

  • TreeViewThatChangesSelectedItemOnRightClick (way too wordy and
    maybe difficult to read because there is so many words concantenated
    together)
  • TreeView_SelectedItemChangesOnRightClick (slightly
    more readable, but still too wordy and the underscore also breaks the normal
    convention for class names)
  • TreeViewThatChangesSIOnRC (non-obvious
    acronym),
  • ExtendedTreeView (more concise, but doesn’t describe what
    it is doing. Besides, I already found a class called this in the
    library, that I don’t want to use/modify in my application).
  • LouisTreeView, MyTreeView, etc. (doesn’t describe what it is doing).

It seems that I can’t find a name which sounds right. What do you do in situation like this?

3

If your application is supposed to use both the original, non-right-sensitive version and your own improved version, then the name absolutely has to express what the derived class does. Otherwise everyone navigating the code base will go nuts understanding what the difference is and where it applies or not. Something like RightSensitiveTreeView is probably your best bet, even though it is already clumsy and will become much more clumsy if you ever need to express more than one extended behaviour.

But if you use the extended version exclusively, there is little harm in using a euphonious, even proud name like LouisTreeView – it will stay accurate even if you add more enhancements later, since those presumably will also be used everywhere. The only thing you should not do is reuse the original name exactly and disambiguate by putting it into a different package path. That is just asking for confusion.

(Disclaimer: proverbially, there are only two really hard things in computer science – cache invalidation and naming things. This is my opinion, but people will probably come forward with very different views.)

3

For a single class like your TreeView subclass that just adds a small amount of functionality, it’s probably not necessary to try too hard to make a good name. Personally I would make do with CustomTreeView or similar. Then the actual “Custom” bit can be described in some docs or comments above the class definition.

However suppose you have several of these classes, each extending TreeView in some small way. Then a generic name like the above wouldn’t cut it. You could attempt to name each customisation descriptively but then you things could go south – “RightSensitiveTreeView” for example is a bit lengthy for a class name.

If you want to add bits of functionality to a class, consider this approach: Create one subclass in your application (or personal/company library) and call it CustomTreeView or whatever. Make it work identically to TreeView by default. Add properties/methods that enable/disable the extended functionality – say, a selectOnRightClick property would do nicely for your extension. Then you can add as many customisations as you like to your one subclass, and all code that uses your subclass automatically has access to those customisations, with minimal change to code.

1

If it’s just generic functionality that will probably be wanted anytime you use such a control, such as changing items on right-click, I usually just add Ex to the end of my class to signify it’s an extended version of the class. For example, TreeViewEx or TabControlEx

The actual word being used doesn’t really matter, but I do try and keep it consistent throughout all my customized classes, and generic so I can add other functionality later if needed without having to rename the class (Ex, Extended, Custom, etc).

Of course, if the control does something specialized that is unlikely to be wanted in other cases when using that control, then I’ll add a more descriptive suffix to the control name instead.

I also add the word at the end of the control name (TreeViewCustom instead of CustomTreeView) so it pops up in auto-complete when you try and use the standard control.

5

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật