Note that there are some explanatory texts on larger screens.

plurals
  1. POProgramming Classes: Theory of Making Good Classes
    text
    copied!<p>As a scientist not a software engineer I find that my code is generally okay as a one off but then when I need to change something it takes longer to rewrite than the original.</p> <p>I am trying to figure out how to break down my code into classes to make them reusable and allow the code to be read and understood more easily.</p> <p>I've read all of the stuff that says that Classes should be a real object with parameters that simulate this e.g. Car (doors, wheels, accelerator etc). But I don't really find this useful when it comes to actually programming as I am generally dealing with tables and forms.</p> <p>The example I will give is for C# but my problem is more generic than that.</p> <p>I have a Windows Form that has a whole bunch of Combo Boxes populated from tables. Some of these populate based on the values of other Combo Boxes. The wiring is somewhat complex as some fields are required some not and some fields depend others. So there are methods for ensuring that boxes aren't empty, populating them, emptying them making sure they are exist etc. There are also some Tab Pages for navigation plus a bunch of buttons that both navigate and writing to files.</p> <p>It seems that all of this just gets dumped under the Partial Class of my new form that inherits from Form. While I have tried to move stuff out from here I find that so many things need to reference data within the form that it just becomes more trouble than it is worth to pass or reference this information to classes. If I do pass it out then I find half of my time is spent looping through Controls to find the right ones to check, populate or receive information.</p> <p>I won't post an example because it would probably cause physical and emotional trauma to members. I'm just hoping someone could point me in the right direction of some good Class theory. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload