Creating a record class without using the UML – Even Better Way!

Thanks to Stefano Sarcletti over on our Facebook Group, we now have an even better way to do this! This is version to of this article with the new and improved method.

If you use our File Manager classes then you know we use the UML model to generate our record classes from the Analysis. This works great when you already have an analysis and you are starting fresh with record classes, but starts showing a few chinks in the armor when you need to add a new table later, or modify a table. It becomes very hard keeping the UML in sync.

After I posted the original version of this article, Stefano Sarcletti on our Facebook Group, suggested a slightly different way that cuts off a few steps. Unfortunately it still doesn’t use any of the setting from the programming charters and generates everything with prefixes. But we avoid a few steps with this method regardless.

In this example we have a table in the Analysis called Scenario we need to create a record class for.

  1. In the project explorer in the Class section right click, and select New -> New server Class. Note I have a custom folder called FileManager, where I store all of out File Manager classes to get them organized, by right clicking on the folder, the class gets created in that folder.
  1. Name it the same as in the Analysis
  1. That creates an empty class like this
  1. Now on the Analysis plane, select all the fields of the table
  1. And drag and drop then onto the declaration section of the class we created, now your class looks like this
  1. Click you mouse in front of the first <MAPPING … behind the variables
  2. Hold down the alt key while holding the left mouse button (you are now in column select mode) and select all the <MAPPING … stuff
  1. Press Delete
  2. Now use the same technique to remove all of the m_ from the front of the variables
  3. What you should have left looks like this
  1. Click the save button and You Now have record class!!!

If you are generating a bunch of record classes the UML is definitely quicker, especially if you are using the wxPerts charter. But for a quick single record class this sure beats creating by hand, or dealing with other issues related to the UML. We have asked PCSOFT to please add logic so that this method follows the Charter rules, hopefully we can get that in a future release.

Thanks again to Stefano Sarcletti for his contribution to this new method! And if you are not part of our Facebook group, this is exactly the type of collaboration that your are missing out on!

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s