Professional Documents
Culture Documents
Agenda
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
What is OO Programming?
Its a way of writing large, complex systems in a more 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 in order 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 well architected system)
3
Some 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 robust applications, and less effort.
Agenda
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
OO Basics
Classes are defined by wrapping them with Classes are defined by wrapping them with
The sub new() function (the constructor) is called for this class, and all its parent-classes
The top-most parent class constructor is called firstWhen The top-most parent class constructor is called firstWhen
a class is deleted a class is deleted
OO 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)
10
11
Use Me. to resolve ambiguity You can use property get & set constructs.
Functions that look like class properties Advise against it
Agenda
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
13
14
15
Agenda
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
16
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 other classes within it
17
18
19
20
21
22
An interesting observation
Class PersonCollection Class PersonCollection public Function loadAllDocsInView(mV as Variant) public Function loadAllDocsInView(mV as Variant) dim doc as NotesDocument dim doc as NotesDocument set doc = mV.getFirstDocument set doc = mV.getFirstDocument while Not (doc is nothing) while Not (doc is nothing) dim P as new Person(doc) dim P as new Person(doc) me.addPerson(P) me.addPerson(P) set doc = mV.getNextDocument(doc) set doc = mV.getNextDocument(doc) wend wend end function end function end class end class
23
24
Agenda
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
25
Large OO Projects
How to design large OO projects Consider various approaches, and iterate towards a good OO architecture. Good design and architecture is better than coding Use skeleton classes to mimic behaviour
Allows early integration Allows you to finalise class structure quickly
26
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!
Agenda
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
28
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 The time taken to load all modules, and to resolve all variables. In traditional compiled programs, this was performed by the linker at traditional compiled programs, this was performed by the linker at executable build time. executable build time.
29
Fixup time ?
Fixup time vs Complexity Fixup time vs Complexity
Complexity Complexity
30
31
32
There are no constructor arguments being passed to class fred. This will have to be changed if you choose to add constructor arguments.
34
35
36
Compilation Woes
Expect Compilation Complexity. For instance, consider the fairly simple class structure
Agent 1 Agent 2 Agent 3 Agent 4
38
Compilation Woes
Change a subclass deep in the inheritance hierarchy and you Change a subclass deep in the inheritance hierarchy and you will probably: will probably:
Tools, Compile all Lotusscript. Similar to Java. Most java IDEs will rebuild all when significant change is spotted.
39
Code Hiding
The Hide Design database property can sometimes be too restrictive. Should all of your commercial code be in script libraries, then:
Find the script librarys design document Find the script librarys design document Replace item ScriptLib with some text such as Replace item ScriptLib with some text such as MyName, 2004 MyName, 2004 The end-user cannot recompile the library and cannot The end-user cannot recompile the library and cannot see your code. see your code. Warning. No way back (obviously). So do this on your Warning. No way back (obviously). So do this on your BUILD copies of templates, not your development BUILD copies of templates, not your development templates templates
40
Agenda
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
41
Summary
OO is a simple, pain-free way of building and maintaining large Domino Projects. OO should be part of your toolset during application design Lotusscript can do large, serious and complex OO projects
42
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
43
44
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
45