Question: naming of control classes

This forum is meant for questions and discussions about the XSharp Tools libraries, which contain code written by XSharp users that they want to share with others,
The development team is not responsible for this code

Moderator: wriedmann

User avatar
wriedmann
Posts: 3754
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Question: naming of control classes

Post by wriedmann »

Hello All,

when naming subclasses of controls and windows, I would like to use the standard control class name and a prefix or suffix.

Example: the tools version of the TextBox class could be named TextBoxXST, or XstTextBox.

What do you would prefer: prefix or suffix? My personal preference is to use a prefix.
And what should the prefix/postfix be? Here my personal preference would be Xst for XSharp Tools.

Thank you very much for suggestions/wishes!

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
FFF
Posts: 1580
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Question: naming of control classes

Post by FFF »

I think, i prever prefix, as this sorts naturally. And "X" would imho suffice ;)
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
wriedmann
Posts: 3754
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Question: naming of control classes

Post by wriedmann »

Hi Karl,

thanks! You are right, an 'x' alone should be enough.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
TerryB1
Posts: 306
Joined: Wed Jan 03, 2018 11:58 am

Question: naming of control classes

Post by TerryB1 »

Hi All

I suggest a prefix - x alone is too limiting - Xst would give more scope for searches later.

Reason: You may want to find all Xst Controls whatever they may be: Just search for Xst.
OK so you could do that with x alone.

But suppose you want to group something else in your searches - x has gone as an option.

Xst or Xctl is easier to read and interpret.

Just a thought

Terry
FFF
Posts: 1580
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Question: naming of control classes

Post by FFF »

I don't see, where x vs xst changes anything in search /sort, a prefix is a prefix..;)
Karl
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
robert
Posts: 4518
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Question: naming of control classes

Post by robert »

Wolfgang,
I would not choose a prefix. That makes things indeed more difficult to find in alphabetical completion lists etc.
I think the most important thing is to put the classes it in the right namespace. The class name itself should be meaningful. That's all I think. If you really want to add something to make the name unique, I would go for a suffix.
So you would have something like XSharp.Tools.Windows.Forms.TextBox, or XSharp.Tools.Windows.Forms.TextBoxEx or
XSharp.Tools.Windows.Forms.TextBoxXT

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
wriedmann
Posts: 3754
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Question: naming of control classes

Post by wriedmann »

Hi Robert,

the correct namespace is IMHO obvious, and a meaningful name is very important too - self documenting code is a must.
But since there will be using statements for both namespaces (for example System.Windows.Forms and XSharp.Tools.Windows.Forms) it is important to keep different names - to make it easier for the programmer to understand which controls are effectively used.
Your arguments for a suffix instead of a prefix are very valid! Until now, I have always used prefixes in both VO and X#, but I have to admit that I'm typing the names most of the time, and there a prefix comes handy, at least when it is short.

Thank you very much!

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
TerryB1
Posts: 306
Joined: Wed Jan 03, 2018 11:58 am

Question: naming of control classes

Post by TerryB1 »

Hi Karl

A prefix is a prefix - Yes.

It can also help to identify groupings:

Suppose you want to all controls on a global basis. You could search on basis of " Xst" or " x" I agree.
But what if your app had numerous Xml classes etc?

I have also read Roberts reply.

The question seems to be "Do you want to add something to make the name unique"?

Terry
User avatar
wriedmann
Posts: 3754
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Question: naming of control classes

Post by wriedmann »

Hi Terry,
The question seems to be "Do you want to add something to make the name unique"?
IMHO this is absolutely necessary. In the other case there would be the need to fully qualify every type, both on declaration and initialization because in most cases both namespaces would be included in the source file.

And unique names make the code also a lot easier to read (and this is one of the things I like very much in xBase languages: that they are easy to read even after years).

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
TerryB1
Posts: 306
Joined: Wed Jan 03, 2018 11:58 am

Question: naming of control classes

Post by TerryB1 »

Just wondering: are you considering this for Windows Forms alone, or will it be extended to cover WPF controls.

Terry
Post Reply