Falling in lust with Classes

I have used custom Classes within LotusScript some in the past, but am really starting to fall in lust with them as of late.  Last August, I wrote a series of articles on using Lists to write decent reports in Notes.  Well, this past week, I took things a bit further by creating my own classes to replace the Lists I had used before.  Well, that's a bit misleading, because my classes were really objects that contained lists of other classes, that were lists of objects.  Capice?  Of course, I really blame all of this on Jerry and his damn SnTT Tip.

While I don't think that the change to using classes for this agent saved me any coding over my procedural code I had before, it did allow me to control the data integrity better and hopefully improve the performance of the application.  One thing I did notice while developing my classes was that I started to change the way I viewed the data and actions I wanted to perform.  Everything started to look like objects and I started to see the actions I wanted to perform as subs or functions for those objects.  I am not sure if it made my code any clearer, but it certainly made my mind see what I had to do much easier.  It also allowed me to be able to expand this report in the future without having to change any of the underlying data structure of the classes.

The easiest way to think of using classes is to see everything in Notes as a list.  A database is just a list of notes, both data notes and design notes.  A view is just a list of documents.  A document is just a list of fields.  A field is just a list of values.  And so forth.  Since everything is just a list, creating classes that handle those lists should be relatively easy.  Just as a NotesDocumentCollection is a list of NotesDocuments, you could create a class called CatalogItems that could contain a list of attributes for a given item.  Then you could create a class called Catalog that could contain a list of CatalogItems.  Once you start, the variations and options seem almost endless, just like the first time you were introduced to Notes.

The most important new keyword you need to learn when creating custom classes is Me.  Me is used to reference attributes of the class that you are working in using dot annotation.  Just as you would use doc.UniversalID to get the document id for a Notes document, you can use Me.attname to get or set the value of the attname attribute.  If an attribute is Public, it can be read and set directly by other code using dot annotation.  If it's Private, it can only be read or set by functions and subs within this class.  Basically, if you want to be able to control access to the attributes of a class, set them to Private and use Public functions within the class to get or set the variables.  If this seems Greek to you, don't worry, it did to me too.  If you have any questions, feel free to respond here or ask more knowledgeable people like Wild Bill.  H is knowledge of OO programming makes me proud to be a Scot.

So basically I created a class that was my entire results table.  That class had a number of attributes, the most important of which was the one that was a List of rows.  The rows were another class that had contained the values for each column as attributes.  And since the values of the classes are loaded into memory, any manipulation or retrieval of the data is significantly faster.

Later on this week (think Thursday) I will release a class I wrote to calculate elapsed time, both total and business.  A simple example such as that should help if you are still having trouble visualizing what I am talking about.

<< Previous Document / Next Document >>
  • 1) SME - toni
    Created 3/22/2006 3:58:05 PM email | website

    Hi Sean, I am a recruiter who is desperately trying to locate lotus notes developers with a TS/SCI lifestyle poly clearance. My client needs to hire about 5 of them NOW and they seem to be scarce. I am hoping you might know of a good developer you could please refer me to who wants to make lots of money and work in Vienna, VA. thank you so much for your help.

  • 2) More OO Pleasure :) - Kapali
    Created 3/23/2006 9:03:58 AM | website

    You could increase your happiness by indulging in writing a pure Java based application that would use Notes as a datasource. With Java you get more chances to use OO options. With design patterns you could take it to new heights. Just for academic pleasure that is.

  • 3) Re: SME - Sean Burgess
    Created 3/23/2006 10:01:59 PM email | website

    If I knew 5 Notes Developers with TS/SCI clearances, I'd quit my job and create a company to do nothing but hire them out. Good luck on filling your requirements.

    Sean---

  • 4) Lists are Cool - Jerry Carter
    Created 9/21/2006 9:33:10 PM email |

    Hey Sean,

    Ego surfing led me to Technorati which led me here. I had n idea I had caused so much upheaval. But, it sounds great. you are spot on with the realization of everything essentially being a list of objects that contain lists. What would be super handy is if LS supported polymorphism. Then you could do something like set item = new listItem.ClassOf(). Then you wouldn't have to write so much code to have a list handling class that could literally handle any other notes class in a list.


Discussion for this entry is now closed.