Page 1 of 3
Question: naming of control classes
Posted: Mon Aug 06, 2018 8:06 am
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
Question: naming of control classes
Posted: Mon Aug 06, 2018 8:16 am
by FFF
I think, i prever prefix, as this sorts naturally. And "X" would imho suffice
Question: naming of control classes
Posted: Mon Aug 06, 2018 8:21 am
by wriedmann
Hi Karl,
thanks! You are right, an 'x' alone should be enough.
Wolfgang
Question: naming of control classes
Posted: Mon Aug 06, 2018 9:55 am
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
Question: naming of control classes
Posted: Mon Aug 06, 2018 12:08 pm
by FFF
I don't see, where x vs xst changes anything in search /sort, a prefix is a prefix..
Karl
Question: naming of control classes
Posted: Mon Aug 06, 2018 1:05 pm
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
Question: naming of control classes
Posted: Mon Aug 06, 2018 1:14 pm
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
Question: naming of control classes
Posted: Mon Aug 06, 2018 1:30 pm
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
Question: naming of control classes
Posted: Mon Aug 06, 2018 1:37 pm
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
Question: naming of control classes
Posted: Mon Aug 06, 2018 2:40 pm
by TerryB1
Just wondering: are you considering this for Windows Forms alone, or will it be extended to cover WPF controls.
Terry