I have created the attached demo project as an example of some principles that I am trying to learn and incorporate into my code. I have attached this code example.
I have a class called Person and in this class I have a method called SetSkinColor. SetSkinColor opens up a form, the user enter some values, when they leave a text box the values are processed by another method in my Person class called AddSkinColors. AddSkinColors takes the colors adds them together, saves the result to a member variable and returns the result to the calling class.
*** I hope I explain this right ***
I was having a tough time trying to figure out a way to call a method from the same class that called the form class. The only way I was able to figure this out was to create a public object on the form of type Person and then the SetSkinColor method would be able to add a reference of its class to the form.
In light of the note: “Avoid using many member variables. Declare local variables and pass it to methods instead of sharing a member variable between methods. If you share a member variable between methods, it will be difficult to track which method changed the value and when.” at this web site http://www.dotnetspider.com/Technolo...Practices.aspx
I am wondering if I really should be coding this way.
Is this OK or should I be looking to do this another way?
I would think that your Person class should have a property named SkinColour. I don't think your Person class should know anything about any Form objects. You could have a Person object as a member of a form that takes user input and then sets the SkinColour property of that object.