best practices in oo lotus script final draft

Upload: srinirao2002

Post on 06-Apr-2018

291 views

Category:

Documents


2 download

TRANSCRIPT

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    1/45

    1

    BP107

    Best Practices for ObjectOrientated Lotusscript

    BP107

    Best Practices for ObjectOrientated Lotusscript

    Bill Buchan

    Director, HADSLPremier Business Partner

    Bill Buchan

    Director, HADSLPremier Business Partner

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    2/45

    2

    AgendaAgenda

    Why use Object Orientated Methodologies?

    OO Basics in Script

    Demo OO application Directory Compare

    Extend or Encapsulate ?

    Large OO projects

    Pitfalls and Tricks

    Summary and questions

    Why use Object Orientated Methodologies?

    OO Basics in Script

    Demo OO application Directory Compare

    Extend or Encapsulate ?

    Large OO projects

    Pitfalls and Tricks

    Summary and questions

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    3/45

    3

    What is OO Programming?What is OO Programming?

    Its a way of writing large, complex systems in amore intuitive manner

    The core assumptions are: Most objects will represent actors or processes in a

    business problem

    You do not need to know how an object is implemented inorder to use it. (Information Hiding)

    Its been in Lotusscript since its inception.

    Its a different way of breaking down problems. Compared to structured programming

    It requires more thought during architecture

    It requires less work during implementation (in a wellarchitected system)

    Its a way of writing large, complex systems in amore intuitive manner

    The core assumptions are: Most objects will represent actors or processes in a

    business problem

    You do not need to know how an object is implemented inorder to use it. (Information Hiding)

    Its been in Lotusscript since its inception.

    Its a different way of breaking down problems. Compared to structured programming

    It requires more thought during architecture

    It requires less work during implementation (in a wellarchitected system)

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    4/45

    4

    Why use OO Methodologies ?Why use OO Methodologies ?

    Maintainability & Robustness

    Small code sequences are easier to maintain

    Code hiding lends to better componentisation anddesign

    Loose Coupling is better than tight coupling.

    Classes can be tested in a stand-alone basis beforeintegration with other components. It can help youtest sooner (and should be considered best practice)

    Promotes Re-use

    The holy grail of software development Standard business components can be re-used.

    Look at the future

    Java anyone ?

    Maintainability & Robustness

    Small code sequences are easier to maintain

    Code hiding lends to better componentisation anddesign

    Loose Coupling is better than tight coupling.

    Classes can be tested in a stand-alone basis beforeintegration with other components. It can help youtest sooner (and should be considered best practice)

    Promotes Re-use

    The holy grail of software development Standard business components can be re-used.

    Look at the future

    Java anyone ?

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    5/45

    5

    How to use OO Methodologies ?How to use OO Methodologies ?

    Define a class Class fredpublic mystring as String

    sub new()

    me.myString = Hello Worldend sub

    end class

    Create one or instances of this class in

    memory Dim myFred as new Fred()print myFred.myString

    Define a class Class fred

    public mystring as String

    sub new()

    me.myString = Hello Worldend subend class

    Create one or instances of this class inmemory Dim myFred as new Fred()print myFred.myString

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    6/45

    6

    Some OO GeneralisationsSome OO Generalisations Its difficult to use - Not at all.

    Its a steep learning curve No

    There is no benefit.

    Untrue. From a medium to large scale project, getting it

    right from the start means more code reuse, more robustapplications, and less effort.

    There is one class for each item in a system

    Probably not.

    Try not to be too prescriptive in any architecture. It takes a couple of projects before you get it.

    This is probably true. The oo moment.

    Its difficult to use - Not at all.

    Its a steep learning curve No

    There is no benefit.

    Untrue. From a medium to large scale project, getting it

    right from the start means more code reuse, more robustapplications, and less effort.

    There is one class for each item in a system

    Probably not.

    Try not to be too prescriptive in any architecture. It takes a couple of projects before you get it.

    This is probably true. The oo moment.

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    7/45

    7

    AgendaAgenda

    Why use Object Orientated Methodologies?

    OO Basics in Script

    Demo OO application Directory Compare

    Extend or Encapsulate ?

    Large OO projects

    Pitfalls and Tricks

    Summary and questions

    Why use Object Orientated Methodologies?

    OO Basics in Script

    Demo OO application Directory Compare

    Extend or Encapsulate ?

    Large OO projects

    Pitfalls and Tricks

    Summary and questions

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    8/45

    8

    How to use OO within Lotusscript ?How to use OO within Lotusscript ?

    Use Classes to define objects.

    Use new and delete to create instances of classes

    Think of notesDatabase

    They bundle together

    members (properties) Functions and Subs (methods)

    Classes can be based on other classes

    In which case they inherit all the properties and

    functions of the parent class More on this later

    Use Classes to define objects.

    Use new and delete to create instances of classes

    Think of notesDatabase

    They bundle together

    members (properties) Functions and Subs (methods)

    Classes can be based on other classes

    In which case they inherit all the properties and

    functions of the parent class More on this later

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    9/45

    9

    OO BasicsOO Basics

    Classes are defined by wrapping them with

    class [as ]

    end class

    The classes are all defined in the declarations section of aLotusscript code sequence.

    Remember. R5 64 limit. R6 bigger. ND7 - Best

    When a class is constructed

    The sub new() function (the constructor) is calledfor this class, and all its parent-classes

    The top-most parent class constructor is called firstWhena class is deleted

    The sub delete() (the destructor) function is called

    You cannot extend subclasses from base notes classes.

    Classes are defined by wrapping them with

    class [as ]

    end class

    The classes are all defined in the declarations section of a

    Lotusscript code sequence.

    Remember. R5 64 limit. R6 bigger. ND7 - Best When a class is constructed

    The sub new() function (the constructor) is calledfor this class, and all its parent-classes

    The top-most parent class constructor is called firstWhena class is deleted

    The sub delete() (the destructor) function is called

    You cannot extend subclasses from base notes classes.

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    10/45

    10

    OO BasicsOO Basics

    You can define items within a class as Public anything else can use this property or method Private only the class itself (or any subclasses) can use

    this property or method)

    You can extend or subclass classes For instance, the class Animal could be extended by

    class dog, which is a more precise version of the class

    Class dog shares and re-uses all properties andmethods from Animal.

    Class dog may OVERRIDE methods within animal Class dog may provide MORE properties and methods

    than class ANIMAL.

    You can define items within a class as Public anything else can use this property or method

    Private only the class itself (or any subclasses) can usethis property or method)

    You can extend or subclass classes For instance, the class Animal could be extended by

    class dog, which is a more precise version of the class

    Class dog shares and re-uses all properties andmethods from Animal.

    Class dog may OVERRIDE methods within animal Class dog may provide MORE properties and methods

    than class ANIMAL.

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    11/45

    11

    Example: Animal and DogExample: Animal and DogClass animal

    Private myName as String

    Sub new()me.myName = Animal

    End sub

    Public function getName() as String

    getName = me.myName

    end function

    Public function getSpecies() as String

    getSpecies = Animal

    End function

    End class

    Class Dog as AnimalPublic masterName as String

    sub new()

    me.myName = Dog

    end sub

    End class

    Class animal

    Private myName as String

    Sub new()me.myName = Animal

    End sub

    Public function getName() as String

    getName = me.myName

    end function

    Public function getSpecies() as String

    getSpecies = Animal

    End function

    End class

    Class Dog as AnimalPublic masterName as String

    sub new()

    me.myName = Dog

    end sub

    End class

    ConstructorConstructor

    Private Member

    Public Member

    Overridden Constructor

    Dog inherits from class

    Animal

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    12/45

    12

    OO Basics some best practicesOO Basics some best practices

    Each class contained in a different script libraryDont expose your internal properties

    Declare them as private!

    Use Me. to resolve ambiguity

    You can use property get & set constructs. Functions that look like class properties

    Advise against it

    Keep the classes small. Large classes mean that you should split them up

    that you probably aren't re-using things as much as youcan

    Always Architect before optimising

    Each class contained in a different script library

    Dont expose your internal properties Declare them as private!

    Use Me. to resolve ambiguity

    You can use property get & set constructs. Functions that look like class properties

    Advise against it

    Keep the classes small. Large classes mean that you should split them up

    that you probably aren't re-using things as much as youcan

    Always Architect before optimising

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    13/45

    13

    AgendaAgenda

    Why use Object Orientated Methodologies?

    OO Basics in Script

    Demo OO application Directory Compare

    Extend or Encapsulate ?

    Large OO projects

    Pitfalls and Tricks

    Summary and questions

    Why use Object Orientated Methodologies?

    OO Basics in Script

    Demo OO application Directory Compare

    Extend or Encapsulate ?

    Large OO projectsPitfalls and Tricks

    Summary and questions

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    14/45

    14

    OO Basics. The Person ClassOO Basics. The Person Class

    Class Person

    Public PersonName as NotesName

    Public DominoDomain as String

    Private UNID as String

    sub new(doc as notesDocument)

    set me.PersonName = new NotesName(doc.FullName(0))

    me.DominoDomain = doc.Domain(0)

    me.UNID = doc.UniversalIDend sub

    End class

    Class Person

    Public PersonName as NotesName

    Public DominoDomain as String

    Private UNID as String

    sub new(doc as notesDocument)

    set me.PersonName = new NotesName(doc.FullName(0))

    me.DominoDomain = doc.Domain(0)

    me.UNID = doc.UniversalIDend sub

    End class

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    15/45

    15

    So how do I use this ?So how do I use this ?

    Use class:personClass

    Dim P as new person(doc)

    Print This persons name is: &

    P.personName.Abbreviated

    Use class:personClass

    Dim P as new person(doc)

    Print This persons name is: &

    P.personName.Abbreviated

    Library names are casesensitive on non-wintel

    platforms!

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    16/45

    16

    AgendaAgenda

    Why use Object Orientated Methodologies?

    OO Basics in Script

    Demo OO application Directory Compare

    Extend or Encapsulate ?

    Large OO projects

    Pitfalls and Tricks

    Summary and questions

    Why use Object Orientated Methodologies?

    OO Basics in Script

    Demo OO application Directory Compare

    Extend or Encapsulate ?

    Large OO projectsPitfalls and Tricks

    Summary and questions

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    17/45

    17

    Extend or Encapsulate ?Extend or Encapsulate ?

    Remember: Extending class takes a class, makes a new class from it, but inherits

    all properties and methods

    You can override original class methods

    You cannot overload methods (as Java can) You can add new methods

    And of course you can extend to any depth

    Encapsulating a class

    makes a new class more useful by using otherclasses within it

    Remember: Extending class

    takes a class, makes a new class from it, but inheritsall properties and methods

    You can override original class methods

    You cannot overload methods (as Java can) You can add new methods

    And of course you can extend to any depth

    Encapsulating a class

    makes a new class more useful by using otherclasses within it

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    18/45

    18

    Make this more useful by EncapsulationMake this more useful by Encapsulation

    Class PersonCollectionprivate people list as Person

    public sub addPerson(P as Person)

    set me.people(P.PersonName.Abbreviated) = P

    end sub

    public function findPerson(userName as String) as Person

    set findPerson = nothing

    if (isElement(me.people(userName))) then

    set findPerson = me.people(userName)end if

    end function

    End class

    Class PersonCollectionprivate people list as Person

    public sub addPerson(P as Person)

    set me.people(P.PersonName.Abbreviated) = P

    end sub

    public function findPerson(userName as String) as Person

    set findPerson = nothing

    if (isElement(me.people(userName))) then

    set findPerson = me.people(userName)end if

    end function

    End class

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    19/45

    19

    So how do I use personCollection?So how do I use personCollection?Dim PC as new PersonCollection

    Dim doc as NotesDocumentSet doc = myView.getFirstDocument

    While Not (doc is nothing)

    dim P1 as new Person(doc)

    call PC.addPerson(P1)

    set doc = myView.getnextDocument(doc)Wend

    Dim P as person

    Set P = PC.findPerson(Joe Bloggs/Acme)If Not (P is nothing) then

    print found person: & P.PersonName.Abbreviated

    End if

    Dim PC as new PersonCollection

    Dim doc as NotesDocumentSet doc = myView.getFirstDocument

    While Not (doc is nothing)

    dim P1 as new Person(doc)

    call PC.addPerson(P1)

    set doc = myView.getnextDocument(doc)Wend

    Dim P as person

    Set P = PC.findPerson(Joe Bloggs/Acme)If Not (P is nothing) then

    print found person: & P.PersonName.Abbreviated

    End if

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    20/45

    20

    Lets improve PersonCollectionLets improve PersonCollectionClass PersonCollection

    public Function loadAllDocsInView(mV as NotesView)

    dim doc as NotesDocument

    set doc = mV.getFirstDocument

    while Not (doc is nothing)

    dim P as new Person(doc)

    call me.addPerson(P)

    set doc = mV.getNextDocument(doc)

    wend

    end function

    end class

    Class PersonCollection

    public Function loadAllDocsInView(mV as NotesView)

    dim doc as NotesDocument

    set doc = mV.getFirstDocument

    while Not (doc is nothing)dim P as new Person(doc)

    call me.addPerson(P)

    set doc = mV.getNextDocument(doc)

    wend

    end function

    end class

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    21/45

    21

    New example code.New example code.

    Dim PC as new PersonCollection

    Call PC.loadAllDocsInView(myView)

    .

    Dim P as person

    Set P = PC.findPerson(Joe Bloggs/Acme)

    If Not (P is nothing) then

    print found person: &P.PersonName.Abbreviated

    End if

    Dim PC as new PersonCollection

    Call PC.loadAllDocsInView(myView)

    .

    Dim P as person

    Set P = PC.findPerson(Joe Bloggs/Acme)

    If Not (P is nothing) then

    print found person: &P.PersonName.Abbreviated

    End if

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    22/45

    22

    Now lets use PersonCollectionNow lets use PersonCollection

    Well use this example class to quickly comparetwo domino directories.

    Open both directories, and views in each database

    Create a new PersonCollection from each view.

    Iterate through the first PersonCollection, and checkto see that this person is in the second view.

    And vice versa.

    Why does this help ?

    We only load the Person Documents once

    We can further improve this by:

    Using NotesViewEntryCollection instead of notesView

    Well use this example class to quickly comparetwo domino directories.

    Open both directories, and views in each database

    Create a new PersonCollection from each view.

    Iterate through the first PersonCollection, and checkto see that this person is in the second view.

    And vice versa.

    Why does this help ?

    We only load the Person Documents once

    We can further improve this by:

    Using NotesViewEntryCollection instead of notesView

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    23/45

    23

    An interesting observationAn interesting observation

    Class PersonCollection

    public Function loadAllDocsInView(mV as Variant)

    dim doc as NotesDocument

    set doc = mV.getFirstDocumentwhile Not (doc is nothing)

    dim P as new Person(doc)

    me.addPerson(P)

    set doc = mV.getNextDocument(doc)

    wend

    end function

    end class

    Class PersonCollection

    public Function loadAllDocsInView(mV as Variant)

    dim doc as NotesDocument

    set doc = mV.getFirstDocumentwhile Not (doc is nothing)

    dim P as new Person(doc)

    me.addPerson(P)

    set doc = mV.getNextDocument(doc)

    wend

    end function

    end class

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    24/45

    24

    Demo Directory Comparison ToolDemo Directory Comparison Tool

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    25/45

    25

    AgendaAgenda

    Why use Object Orientated Methodologies?

    OO Basics in Script

    Demo OO application Directory Compare

    Extend or Encapsulate ?

    Large OO projectsPitfalls and Tricks

    Summary and questions

    Why use Object Orientated Methodologies?

    OO Basics in ScriptDemo OO application Directory Compare

    Extend or Encapsulate ?

    Large OO projectsPitfalls and Tricks

    Summary and questions

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    26/45

    26

    Large OO ProjectsLarge OO Projects

    How to design large OO projects

    Consider various approaches, and iteratetowards a good OO architecture.

    Good design and architecture is better than

    codingUse skeleton classes to mimic behaviour

    Allows early integration

    Allows you to finalise class structure quickly

    Unit test each class.

    And keep unit testing them to prevent regressions

    How to design large OO projects

    Consider various approaches, and iteratetowards a good OO architecture.

    Good design and architecture is better than

    codingUse skeleton classes to mimic behaviour

    Allows early integration

    Allows you to finalise class structure quickly

    Unit test each class.

    And keep unit testing them to prevent regressions

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    27/45

    27

    Large OO Projects Large OO Projects

    Its *never* completely correct Beware tightly bound mutually dependant classes!

    Remember that specifications change over time.

    Architect for clarity and maintenance.

    Performance is an implementation consideration!

    If you have to change class methods frequently You are exposing weaknesses in the design phase

    You are open to regression errors

    Once methods behaviour are finalised, dont changethem! Add more methods, but dont modify.

    You may have to do several OO applicationsbefore you get it.

    Its *never* completely correct Beware tightly bound mutually dependant classes!

    Remember that specifications change over time.

    Architect for clarity and maintenance.

    Performance is an implementation consideration!

    If you have to change class methods frequently You are exposing weaknesses in the design phase

    You are open to regression errors

    Once methods behaviour are finalised, dont changethem! Add more methods, but dont modify.

    You may have to do several OO applicationsbefore you get it.

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    28/45

    28

    AgendaAgenda

    Why use Object Orientated Methodologies?

    OO Basics in Script

    Demo OO application Directory Compare

    Extend or Encapsulate ?

    Large OO projectsPitfalls and Tricks

    Summary and questions

    Why use Object Orientated Methodologies?

    OO Basics in ScriptDemo OO application Directory Compare

    Extend or Encapsulate ?

    Large OO projectsPitfalls and Tricks

    Summary and questions

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    29/45

    29

    Pitfalls Fixup Time on LoadPitfalls Fixup Time on LoadRemember, LotusScript is a p-code compiled,

    interpreted language Similar to Java

    Lotusscript has some loose data constructs:

    This means that Fixup Time is significant.

    What is fixup time ? The time taken to load all modules, and to resolve all variables. In

    traditional compiled programs, this was performed by the linker atexecutable build time.

    How does this affect me ?

    The more complex your applications, the longer it takes almostgeometrically to load. (this applies to ALL code, not just classes)

    Example: 20 classes 4 seconds load time. 120 classes 145seconds load time.

    Remember, LotusScript is a p-code compiled,

    interpreted language Similar to Java

    Lotusscript has some loose data constructs:

    This means that Fixup Time is significant.

    What is fixup time ? The time taken to load all modules, and to resolve all variables. In

    traditional compiled programs, this was performed by the linker atexecutable build time.

    How does this affect me ?

    The more complex your applications, the longer it takes almostgeometrically to load. (this applies to ALL code, not just classes)

    Example: 20 classes 4 seconds load time. 120 classes 145seconds load time.

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    30/45

    30

    Fixup time vs Complexity

    Complexity

    Time(Seconds)

    Fixup time vs Complexity

    Complexity

    Time

    (Seconds)

    Fixup time ?Fixup time ?

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    31/45

    31

    How to code around itHow to code around it

    Fixup time doesnt have significant impactbefore 20+ classes and/or script libraries (in myexperience) My Example: 120+ classes 145 seconds to load.

    Use loose binding instead of tight binding. Use Variants to hold and pass classes

    Use Dynamic Loading to instantiate classes

    After implementation, same 120+ classes 15seconds.

    Downside. No more type checking! Demands programming discipline and rigour!

    Fixup time doesnt have significant impact

    before 20+ classes and/or script libraries (in myexperience) My Example: 120+ classes 145 seconds to load.

    Use loose binding instead of tight binding. Use Variants to hold and pass classes

    Use Dynamic Loading to instantiate classes

    After implementation, same 120+ classes 15seconds.

    Downside. No more type checking! Demands programming discipline and rigour!

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    32/45

    32

    Dynamic Loading referenceDynamic Loading reference

    Dynamic loading is a technique outlined inRedbook

    Performance Considerations for DominoApplications

    SG24-5602

    Buried in Appendix B, Page 243

    Numerous Gary Devendorf Web Servicesexamples

    Dynamic loading is a technique outlined inRedbook

    Performance Considerations for DominoApplications

    SG24-5602

    Buried in Appendix B, Page 243

    Numerous Gary Devendorf Web Servicesexamples

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    33/45

    33

    Dynamic Loading ExampleDynamic Loading ExamplePrivate P as variant This HAS to be global!

    Function createOtherClass_(scriptName as String, className as String) as variant

    Dim exString as String

    exString = | Use | & scriptName & |

    sub initialize

    Set P = new | & className & |Factory &end sub |

    Execute exString Now run the code in exString

    Set createOtherClass = P

    End sub

    Sub DynamicLoadingExample

    dim myClass as variant

    set myClass = createotherClass(class:fred, fred)

    End sub

    Private P as variant This HAS to be global!

    Function createOtherClass_(scriptName as String, className as String) as variant

    Dim exString as String

    exString = | Use | & scriptName & |

    sub initialize

    Set P = new | & className & |Factory &end sub |

    Execute exString Now run the code in exString

    Set createOtherClass = P

    End sub

    Sub DynamicLoadingExample

    dim myClass as variant

    set myClass = createotherClass(class:fred, fred)

    End sub

    This string containsLotusscript code

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    34/45

    34

    Script library class:fred looks like:Script library class:fred looks like:

    Class FredFactory

    Public Function produce As Variant

    Set produce = New Fred

    End Function

    End Class

    Class Fred

    End class

    Class FredFactory

    Public Function produce As Variant

    Set produce = New Fred

    End Function

    End Class

    Class Fred

    End class

    The Factory Version of this class

    exists only to create a newinstance of the main class

    There are no constructor arguments

    being passed to class fred. This willhave to be changed if you choose to add

    constructor arguments.

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    35/45

    35

    Dynamic Loading OO ArchitectureDynamic Loading OO Architecture

    Always have one class that knows how toconstruct the rest WITHOUT using the usedirective.

    A Factory class, for instance.

    You dont have to dynamically load ALL classes. Common classes such as log or config are

    always normally resident

    You can dynamically load different classes.

    Based on Notes/Domino version, Platform, Data

    Using one dynamic load function means you have touse the same signature on the class constructor

    Always have one class that knows how toconstruct the rest WITHOUT using the usedirective.

    A Factory class, for instance.

    You dont have to dynamically load ALL classes. Common classes such as log or config are

    always normally resident

    You can dynamically load different classes.

    Based on Notes/Domino version, Platform, Data

    Using one dynamic load function means you have touse the same signature on the class constructor

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    36/45

    36

    Dynamic Loading OO ExampleDynamic Loading OO Example

    Request

    LogFactory

    Configuration

    User Create v6

    User Create UIUser Create Profile

    User Create v5

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    37/45

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    38/45

    38

    Compilation WoesCompilation Woes Expect Compilation Complexity.

    For instance, consider the fairly simple classstructure

    Expect Compilation Complexity.

    For instance, consider the fairly simple classstructure

    Class Factory

    Agent 1

    Class Factory

    Class PersonCollection

    Agent 4Agent 3Agent 2Agent 1

    Class PersonCollection

    Agent 4Agent 2Agent 1

    Class PersonCollection

    Routines:Examples

    Class Person

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    39/45

    39

    Compilation WoesCompilation Woes Change a subclass deep in the inheritance hierarchy and you

    will probably:

    See Server Console AMGR message or client dialog: 11/23/2004 12:03:03 PM Agent '(Blah)' error:

    Error loading USE or USELSX module: cl_event_v2

    Error %s

    Why ? The signature of the subclass has changed How to resolve ?

    Tools, Compile all Lotusscript.

    Similar to Java. Most java IDEs will rebuild all whensignificant change is spotted.

    Dynamic loading completely sidesteps thisissue

    Change a subclass deep in the inheritance hierarchy and youwill probably:

    See Server Console AMGR message or client dialog: 11/23/2004 12:03:03 PM Agent '(Blah)' error:

    Error loading USE or USELSX module: cl_event_v2

    Error %s

    Why ? The signature of the subclass has changed How to resolve ?

    Tools, Compile all Lotusscript.

    Similar to Java. Most java IDEs will rebuild all whensignificant change is spotted.

    Dynamic loading completely sidesteps thisissue

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    40/45

    40

    Code HidingCode Hiding

    The Hide Design database

    property can sometimes be toorestrictive.

    Should all of your commercial codebe in script libraries, then:

    Find the script librarys design document

    Replace item ScriptLib with some text such as MyName, 2004

    The end-user cannot recompile the library and cannotsee your code.

    Warning. No way back (obviously). So do this on yourBUILD copies of templates, not your developmenttemplates

    The Hide Design database

    property can sometimes be toorestrictive.

    Should all of your commercial codebe in script libraries, then:

    Find the script librarys design document

    Replace item ScriptLib with some text such as MyName, 2004

    The end-user cannot recompile the library and cannotsee your code.

    Warning. No way back (obviously). So do this on yourBUILD copies of templates, not your developmenttemplates

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    41/45

    41

    AgendaAgenda

    Why use Object Orientated Methodologies?

    OO Basics in ScriptDemo OO application Directory Compare

    Extend or Encapsulate ?

    Large OO projectsPitfalls and Tricks

    Summary and questions

    Why use Object Orientated Methodologies?

    OO Basics in ScriptDemo OO application Directory Compare

    Extend or Encapsulate ?

    Large OO projectsPitfalls and Tricks

    Summary and questions

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    42/45

    42

    SummarySummary

    OO is a simple, pain-free way of building andmaintaining large Domino Projects.

    OO should be part of your toolset duringapplication design

    Lotusscript can do large, serious and complexOO projects

    OO is a simple, pain-free way of building and

    maintaining large Domino Projects.

    OO should be part of your toolset duringapplication design

    Lotusscript can do large, serious and complexOO projects

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    43/45

    43

    Related Sessions and ResourcesRelated Sessions and ResourcesRedbook: Performance Considerations for Domino

    Applications Search for SG24-5602 at http://www.lotus.com/redbooks

    Notes.net Article: Using the object-orientated features of Lotusscript

    by Bruce Perry, from October 2001.Dev.kaangard.net

    http://dev.kanngard.net/dev/home.nsf/ArticlesByTitle/LSClass.html

    OpenNTF Check out OpenDom by Alain H Romedenne

    http://www.openntf.org

    Redbook: Performance Considerations for DominoApplications Search for SG24-5602 at http://www.lotus.com/redbooks

    Notes.net Article: Using the object-orientated features of Lotusscript

    by Bruce Perry, from October 2001.Dev.kaangard.net

    http://dev.kanngard.net/dev/home.nsf/ArticlesByTitle/LSClass.html

    OpenNTF Check out OpenDom by Alain H Romedenne http://www.openntf.org

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    44/45

  • 8/2/2019 Best Practices in OO Lotus Script Final Draft

    45/45

    45

    Questions?Questions?

    Please fill out your evaluations

    Remember you can ask me more questions in:

    Toucan 2 for the next hour

    Guru-Pazoola in the Swan at 10:30am

    all Best Practices Speakers will be there. By sending me mail to Bill at BillBuchan.com

    Check out our product iDM

    http://www.hadsl.com

    Thanks for coming!

    Please fill out your evaluations

    Remember you can ask me more questions in:

    Toucan 2 for the next hour

    Guru-Pazoola in the Swan at 10:30am

    all Best Practices Speakers will be there. By sending me mail to Bill at BillBuchan.com

    Check out our product iDM

    http://www.hadsl.com

    Thanks for coming!