Frameworks and encapsulation

An intriguing area for me. Being a programmer from a fundamentally "procedural" background, OOP isn't exactly second nature. That said, I find myself becoming increasingly drawn to it, as I read more, look at more code, and so forth. I'm starting to "get it" I think! When developing or retro-fitting Notes applications, I'm at the stage where the same old things go in, at least to start. Some kind of "All documents" view. A system for configuring the database(s) and looking-up parameter values. Basic workflow engines. All the same stuff, with just a few tweaks here and there. Where is this leading? Well, I'm getting to the stage where I have enough of an idea of what it is I'm trying to achieve that a "framework" makes sense. By this, I mean a transferrable system that can work for me again and again. Instead of just doing File / Database / New and relying on muscle memory to get the work done thus:

	Set db = session.CurrentDatabase
	Set dc = dc.UnprocessedDocuments
	Set doc = dc.GetFirstDocument

	While Not(doc Is Nothing)

.. or hammering away at form design, outlines, and so on, I usually find myself breaking out the pencil and paper, and this has been the case for several months now. It usually comes down to designing an application — or process — -specific model that extends an established framework of classes and functions allowing the kinds of processes alluded to above.

In designing the new model, we need to decide what objects we need: what do they need to know? What do they need to know about each other? It's important to state that all of these objects are business objects. They have nothing to do with the Domino object model as such. Instead of focussing on implementation right from the off, we look at the business problem and how to solve it: encapsulation is super!

I'd say that articles like Business domain-driven Java class hierarchies for Domino over at the Lotus Developer Domain (or developerWorks: Lotus, or whatever it's called now) are extremely timely, and I urge any Domino developers out there who haven't looked at this stuff to get in there. It's fun, and sets you up well for any move you may have to make, be it to Java or something else.

So, here endeth the lesson ;-). Are you making this kind of transition? How are you finding it?


  1. I made the transition to OOP a few years ago when I did an open university course on Java. They recommended a particularly good, approachable book called "Object Orientated Programming in Java v2".
    We now use the OO techniques in our iDM product. Which is great -three guys, 30,000 lines of script, over 100+ libraries now. Its the only way that you can cope with that level of compexity.
    So - classes. Containing lists of classes. repeat. Enjoy!
    (Oh - and the next stage is dynamically loading lotusscript classes - instead of hardcoding them in with "use"..)
    ---* BillWild Bill#
  2. Rolling your own ClassLoader must be real fun though Bill! ;-)

    The biggest issue I have with doing lots of development like this in Notes is the IDE: we really need a class browser!!Ben Poole#
  3. Great post! I theoretically learned OOP in college, and thought I got it then, but it wasn't until after a few years of working with Java that I really began to "grok" it. I think the thing that really did it for me was paying attention to the design of the Java libraries and imitating them. Later on, I would say that the design of the Cocoa frameworks took me to an even more advanced level. It's funny--if you look at some of my later Java code for my former employer, it starts to look a lot more like Objective-C code (in the naming conventions used, the preference for factory methods over constructors, etc.).Buzz Andersen#
  4. great post ben!

    i like the point about business objects, that is so right on. i definitely didn't get the OOP thing until i started doing a lot of studying and coding in java. i thought i had the basic idea, but there was quite a lot i was missing. really, the lightbulb just went on for me very recently about encapsulation. all my java code was very procedural until about a month ago. i know i still have a lot to learn too.

    i have written some classes in lotusscript, but like you say the ide just isn't built for it. this is where i think for a lot of people its finally going to become clear, unless they revamp designer to handle lotusscript OO better, lotusscript is on the way out. how could it not be? i'm not sure i see the point of continuing to develop applications for the notes client. at least for the stuff i'm doing… i'm sure not everyone would agree. i just want to move on.

    also i'm understanding better why people say that to get certain concepts in programming you really have to learn the languages that truly support those concepts. if i'm still doing this a few years from now (and it looks pretty likely i will be) at some point i'm going to tackle lisp.

    thanks for the link to that article…

    *consuming* :-)jonvon#
  5. In what context do you build these business objects, Ben - agents, UI or scheduled, web or client, or all of 'em?

    I've tried to implement pure business objects in various places, totally abstracted from the underlying data structures - but I've found the results to be a little mixed - often it's great, but sometimes it feels like it's overkill for any specific instantiation (ie. too generalised, catering to all but properly serving none), other times it's frustrating because LS doesn't make it as easy as (say) a Java-based 3-tier system, where you're *really* abstracting your data reading/writing. Usually a servlet-based or old-fashioned GUI app has a lot of classes in memory over extended periods of time… in Notes it's more run-this-run-that-edit-edit-run type work, which is a different kettle of fish. Even scheduled agents, where there's a lot more scope for OO work if you're doing a lot of churning, tends to be create-destroy-create-destroy type work, where objects tend to be focused on doing 1 or 2 things, ie. only using certain limited *aspects* of a class.

    With Notes I think we're sometimes a little too close to the data, but are our applications and designs of necessity closely tied to the Domino object structure? If so, whether that's a good thing or not is debatable I suppose, but I think that part of the RADity of Notes is exactly this 'closeness' to the data. Bit of a catch-22…

    But mixing OO with LS is something I'm a big fan of, regardless. Not having a class browser is a pain, but being a cheapskate who won't fork out for expensive dev tools, I do my C++ (and occasional Java) work in good ole TextPad and Kate, so I don't mind too much :-)

    Thanks for the link - like jon, I'm off to read…Colin Pretorius#
  6. Good question(s) Colin! Our Notes work tends very much toward the Notes client end of the spectrum. We do Domino work of course, but that's usually very much of the "presenting data" variety, with little in the way of complex interaction and workflow.

    To date, where I've used OO in Lotusscript is primarily within myriad script library routines: how these get called, or implemented, comes second, for good or bad!

    I'm not hugely into coding scheduled agents, partly because I did a lot of my early Notes dev. in an extremely limited environment so far as scheduled agents go…

    With regards classes in LS, I find that I work up a fair ole' selection of classes pretty quickly, hence the need for a browser. My Java stuff sees very much in the realm of TextPad — I tend to stick to a small number of classes at the moment, so the lack of class browser doesn't bother me too much, weird as that sounds. Anyway, when I do need to do fiddly stuff, I tend to crank up ProjectBuilder or Eclipse.

    Sooooo, aye, OO in Notes is a challenge, I agree, but a fun one!Ben Poole#
  7. The good news is that serious bits of code - such as script or agent - are now accessible via XML and preserve 100% fidelity.
    So finally we can wrapper notes in some code, and use a "serious" text editor. If only someone would.. :-) I guess this is the "eclipse" method they used in WebsFear for the Domino Designer plug ins (which I've not played with yet. "Bad Dobbie!"). Or use code revision software with the XML dumps for all design elements. ("CVS for Notes" anyone?)
    Yup. The LS class browser seriously sucks.
    And if you use close binding with large LS class structures, your end-user experience in terms of loading time sucks as well. So we went with "loose binding" (where classes were used within variants). Okay - the "roll your own classloader" works, and it does give a huge amount of independence - no longer do you have to do global compiles every time your class library signature changes.. But god, do I miss compile-time typechecking.
    So - I've been asking for a ' use "*classlib" for a while - the "*" means 'only load it of you need it'. (LSX's support this). Which would give us best of both worlds - tight binding and speed. Not holding my breath though.. Not enough people shouting for it.. Shame..
    One project I did over the summer was to analyse code weaknesses in 500,000 "code sequences" of lotusscript and formula language on a 1.5tb notes environment. Had to build my own lotusscript parser - in lotusscript. (Hence me being quiet[ier] for the last six months!) So - once you have lotusscript parsed - what do you do next ? Well, convert it to Java, of course..!

    Anyone interested in an automatic lotusscript->Java conversion tool for scripts and agents ? If there is - then there'll be a product..

    ---* BillWild Bill#
  8. Great thread Ben - most interesting Notes blog post I've read for a while - I've attempted pure class stuff with LotusScript many times - about to do another project the same way - in the past though - always found it overkill - maybe the applications were not 'deep' enough to warrant the approach.

    Bill - Your scaring me - you seem to know far toooo much - looks like i better get my books out to keep up with some of you guys!Steve Castledine#
  9. jesus yikes, no kidding. wild bill is always scary like that. i have no idea what the hell he's talking about half the time, but wish he'd speak at lotusphere or something so maybe i could find out. his blog brings me to tears on a regular basis for all kinds of reasons…

    fave lines:

    "i like the run-this-run-that-edit-edit-run type work, which is a different kettle of fish." (i think i feel a jig coming on)

    "if you're doing a lot of churning, tends to be create-destroy-create-destroy type work" (uh oh, feet tapping)

    damn good work colin…

    "Bad Dobbie!" (particularly funny to me due to living with a small child who requires dad to rewind multiple times to the part of that harry potter movie with "the puppet", i don't know how many times i've watched that CG bang its head into a lamp, or go on about ironing its own hands…)

    lol, as usual. ben (and gang) just brings it right out somehow… a bunch of mad geniuses says me!jonvon#
  10. Bill, from what I've read the dynamic loading is only really a benefit if you're conditionally loading classes? I imagine the 'graceful' loading of libraries as classes are instantiated might give the user the impression that it's running faster though… (similar concept how WinXP 'boots so fast' iirc) -- my question basically being is dynamic loading that much better, and in what cases isn't there much difference at all? (paraphrased - when is it worth the schlep?)

    That's the biggest pain with LS and script libraries - good sense encourages keeping things in separate libraries to keep things clean and reusable, but the load times encourages keeping classes and routines all heaped together in a few libraries. Ergh!

    I didn't understand what 'trade-off' meant until I started Notes development ;-)Colin Pretorius#
  11. I'm looking for a lotuscript parser
    do you know where I can find one ?Fenriss#
  12. Erm, what do you mean exactly? A syntax file for an IDE? A compiler? What? If the latter, the only parser you will find is that which is in Domino Designer, although LS is broadly compatible with Visual Basic of course, so you might have some joy going down that route.Ben Poole#

Comments on this post are now closed.


I’m a software architect / developer / general IT wrangler specialising in web, mobile web and middleware using things like node.js, Java, C#, PHP, HTML5 and more.

Best described as a simpleton, but kindly. You can read more here.