I've used the following approach without issue to force parameters into a more useful sequence than the default alpha sort:
private int pSmaPeriod = 10; // 01 private int pVolPeriod = 21; // 02 private double pAtrMult = 1.5; // 03 . . . private string pAtmTemplate = "myATM"; // 18 . . . [Description("SmaPeriod")] [Category("Parameters")] public int p01_SmaPeriod { get { return pSmaPeriod; } set { pSmaPeriod = Math.Max(0, value); } } [Description("VolPeriod")] [Category("Parameters")] public int p02_VolPeriod { get { return pVolPeriod; } set { pVolPeriod = Math.Max(0, value); } } [Description("AtrMult")] [Category("Parameters")] public double p03_AtrMult { get { return pAtrMult; } set { pAtrMult = Math.Max(0, value); } } . . . [Description("AtmTemplate")] [Category("Parameters")] public string p18_AtmTemplate { get { return pAtmTemplate; } set { pAtmTemplate = value; } }
- I control the sequencing of parameters,
- parameters can be identified using meaningful names vs awkward variations to control sorting.
- I know immediately that a class variable prefaced with a "p" is of local scope and the same variable name prefaced with "pNN_" to be of public scope,
- Adding new variables is a simple cut and paste operation and avoids managing the upper/lower case versions of the public/private scope variables,
- Referring to a parameter item by number can have its advantages when working with a long list of parameters,
- Of course, inserting a new variable can be a real hassle since the sequence number is hardcoded in the public variable name but it's a necessary evil if parameter sequencing is desired.
Ideally, it would be nice to control the sequencing through other means. Comments and alternative ideas welcome.
Regards,
Whitmark
Comment