Heavily influenced by (stealing large chunks of code from,) a colleague. I have decided to try my hand at implementing an MVC in lotus notes.
I've already had some success to. As you may imagine there a several issues around this, notes does not like to be used in clever ways and complains a lot.
My current design is based around a colleagues implementation of separation of code. In which he creates a class that is than bound to a form. This class allows you to separate all the many disparate bits of code from the form and create a single store of all that code. As you can imagine this makes finding/editing/fixing the code much easier, especially when combined with a rather nifty event/error logging code that i intend to "borrow". From this point on i will refer to this as the UI class.
So i took this model and defined the form as the View.
The UI class above is the controller.
The model is a new class i have added that performs the business logic and updates the "database"(document). It essential wraps the document for each form, and defines procedures around data retrieval/data setting/triggers etc. These functions are than used by the UI class. In this way i have decoupled the business logic from any UI specific commands.
By separating the Business logic into a separate class the document now follows the same processes when being created/deleted independent of weather it is done using the UI or through a background agent. Preventing the common problem of having to replicate code from the form (UI code) into agents when updating documents.
I'll give more specific examples in future posts, until then below is a very simple example. I'm doing this from memory so please forgive any mistakes.
public Class myFormUI
Private myForm as myForm
Private ws as NotesUiWorkspace
public sub new()
set myForm = new MyForm()
private Function bindEvents()
'use QuerySave to do preSave processing
private Function querySave()
private Function onChangeOfName()
messageBox("You changed the name field" & chr(10) & "Well done!")
public Class myForm
public sub new
public function preSaveProcessing()
public function setName(value as string)
public function onChangeOfName()