DBObservers for FileMaker Developers Interested in Xojo
Feb 16, 2015 04:17 PM
Always Learning
We've been using Xojo since 1998 and are still learning about it all the time such as the Observer Pattern. Last year, Paul Lefebvre posted about the Observer Pattern.
Paul stated:
You use the observer pattern when you have an object that needs to notify one or more other objects of specific changes. This is the definition from wikipedia: "The observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods."
FileMaker DB Integration
One of the best things about FileMaker is how it automatically communicates with with the database. We don't need to worry about any of that in FileMaker, but with Xojo, we have a lower level of control and must handle forms ourselves.
Normally, I would create my form and have a method set the form and another method save the form. Anytime I add another field to the form, I'd have to update the set / save methods. That becomes a pain point very quickly.
Implementing with Xojo
DBObservers makes things MUCH easier. Once the DBObservers is set up, all we need is a sqlite table of data like our Contacts table fields and a Window / View with the fields that we need set to their database column names.
The flow is really simple as well, which I love.
Video and Example
Check out the video below and download the example file. Be sure to check out Paul's example file too.
Using techniques like this help to make software for our clients much faster!
You use the observer pattern when you have an object that needs to notify one or more other objects of specific changes. This is the definition from wikipedia: "The observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods."
FileMaker DB Integration
One of the best things about FileMaker is how it automatically communicates with with the database. We don't need to worry about any of that in FileMaker, but with Xojo, we have a lower level of control and must handle forms ourselves.
Normally, I would create my form and have a method set the form and another method save the form. Anytime I add another field to the form, I'd have to update the set / save methods. That becomes a pain point very quickly.
Implementing with Xojo
DBObservers makes things MUCH easier. Once the DBObservers is set up, all we need is a sqlite table of data like our Contacts table fields and a Window / View with the fields that we need set to their database column names.
The flow is really simple as well, which I love.
- You subclass the fields / interface elements that you want to use.
- You add the fields to the form and set the table name.
- You create an array of the fields to be observed.
- You send messages like "Set" or "Save" to the observers.
Video and Example
Check out the video below and download the example file. Be sure to check out Paul's example file too.
Using techniques like this help to make software for our clients much faster!