Domino 6.5 EOL

Search

Languages

Other languages on request.

About Me

I am the "Lotus Technology & Productivity Advisor" for IBM Asia Pacific. I'm based in Singapore.
Reach out to me via:
Follow notessensei on Twitter
Yahoo IM
Skype
Sametime
IBM

Twitter

Ads by Google

Visitors

« XPages and Validation | Main| LSX Toolkit finally gets updated »

Building extensible applications

QuickImage One challenge that all Notes developers, including the IBM template team, face is the customer's need or desire to customize given applications. Warren started to ask if that is a good thing. With a little planning you can design your applications so they can be easily customized without creating an upgrade nightmare (it still might be a bad dream). A very interesting example for such a "upgrade-save" extension is actually the Domino Directory (a.k.a the Name and Address book). It contains for people, groups etc. subforms that are empty. IBM will *never* touch these subforms. They are designed for schema extensions. So when you change these forms to contain additional fields, code or actions a system upgrade never will overwrite them (you need to follow some instructions to be save). In your own applications you would have these additional subforms so your customers can add functionality as needed (OK it doesn't help when you want to change the main forms).
When you want to make your behavior extensible you need to take a few extra steps:
  • Move your event code from the forms and the views into a custom class.
  • Ideally that custom class would inherit from a base class, that determines general behavior (e.g. validation based on a system configuration)
  • Buttons, Links or Field Events can call methods of the class
  • You might have the class, which obviously needs front-end methods (otherwise the On Event doesn't work) contain a class that does back-end only, so you can have the same function in your web application too.
  • Now create a second/third class that inherits from the class that does all the work but leave it empty. Never touch that one, it is for your customers. That class would live in its own script library and can be overwritten by customizers without impacting your general design. Remember Interfaces live forever
  • Link that class using "On event" to the form or view so the form/view events are handed down the class hierarchy until executed, see the diagram below. And no: it is not time expensive.
ExtensibleClassArchitecture.png

Comments

Gravatar Image1 - Stephan,

Great post. I get the high level concepts, but it'll take me a little bit to digest the meat of it I think. I love Custom Classes, but haven't done a lot with sub-classing yet.

The really interesting thing that you touch on, which I'd love to get more details/examples on (hint hint) is putting the form/view event code inside custom classes. I've seen that discussed before in the "YellowVerse" but I don't remember seeing best practices on how to do just that. How do you link these events to the class methods? There's more to it then just calling a method from inside an event isn't there?

Seperating the Backend from Front end is also a neat idea. Anything to make code more re-usable is a good thing!

Thanks again for the post. I'll be pondering this one for a while.

Gravatar Image2 - @David:
It is the "On Event" statement. In your form you would have code in Globals:
Dim formlogic as formSampleAimp

In your Query or PostOpen:
Set formlogic = new formSampleAimp(source)

and in the class

Public Class formSampleAimp as formSampleAction
Private uiDoc as NotesUIDocument

Sub new(uDoc as NotesUIDocument)
Set Me.uiDoc = uDoc
On Event QuerySave From uiDoc Call Me.QuerySave
End sub

Sub QuerySave(Source as NotesUIDocument, Continue as Variant)
Msgbox("Attached event fires")
End Sub
...

End Class

So you need a little code in your form, but only in one event.

Gravatar Image3 - Well that filled in some missing pieces. Can't wait to play with this! Thanks a lot!


Post A Comment

Please note: Comments without a valid and working eMail address will be removed. This is my site, so I decide what stays here and what goes.

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::rolleyes:;-)

Disclaimer

This site is in no way affiliated, endorsed, sanctioned, supported, nor enlightened by Lotus Software nor IBM Corporation. I may be an employee, but the opinions, theories, facts, etc. presented here are my own and are in now way given in any official capacity. In short, these are my words and this is my site, not IBM's - and don't even begin to think otherwise. (Disclaimer shamelessly plugged from Rocky Oliver)

© 2003 - 2010 Stephan H. Wissel - all rights reserved as listed here: Creative Commons License
Unless otherwise labeled by its originating author, the content found on this site is made available under the terms of an Attribution/NonCommercial/ShareAlike Creative Commons License, with the exception that no rights are granted -- since they are not mine to grant -- in any logo, graphic design, trademarks or trade names of any type.

Get Firefox Use OpenDNS