SlideShare ist ein Scribd-Unternehmen logo
1 von 44
®
AD507 – Leveraging the Power of Object
Oriented Programming in LotusScript
Jens-B. Augustiny – LIGONET GmbH
Bill Buchan – HADSL
Agenda
Introductions
Why Object Orientated Programming
Basic OO techniques
An Object Orientated Project
Encapsulating Classes
Extending Classes
Summary
Questions and Answers
Introductions
Who are we ?
Jens-B. Augustiny, LIGONET GmbH
25 years IT experience, 12 with Lotus Notes
Dual PCLP v4, v5, v6, v7
Founder and CTO of a Business Partner – LIGONET – in Switzerland
Bill Buchan, HADSL
23 years IT experience, 12 with Lotus Notes
Dual PCLP in v3, v4, v5, v6, v7
Founder and CEO of a Business Partner – HADSL – in the UK
Who are you ?
A LotusScript developer
You wish to improve your code, write more efficiently, & write more robust code
Agenda
Introductions
Why Object Orientated Programming
Basic OO techniques
An Object Orientated Project
Encapsulating Classes
Extending Classes
Summary
Questions and Answers
Why Object Orientated Programming?
Object Orientated Programming:
Allows you to design higher-level objects.
Allows far more code-reuse.
Allows you to write less code.
And therefore leads to easier maintenance.
What does this presentation deliver ?
We aim to show a typical application, and how OO techniques help the design
process.
We show basic and more complex design techniques during the development of
the application.
And we show common questions and answers as the presentation unfolds.
Agenda
Introductions
Why Object Orientated Programming
Basic OO techniques
An Object Orientated Project
Encapsulating Classes
Extending Classes
Summary
Questions and Answers
Object Orientated Programming:
Conceptually
An object is a collection of properties (data) and methods (code) which
encapsulates a logical entity.
For instance, a Car is made up of objects –
4 instances of “wheel”, 1 instance of “engine”, etc.
This allows us to break our problem set into logical units – objects.
In LotusScript, we express this as a “class”.
Our consumer code then creates new instances of classes – objects – that we
then utilise.
Remember – NotesSession, NotesDocument – are all classes!
Public and Private:
An object has to have
some public methods (functions/subs).
may have public members (variables).
Internal code for the object need not be exposed
“Code Hiding” means not showing the consumer more than he needs to see.
Importantly – the consumer now codes to the public interface of that object.
NotesSession
CurrentDatabase
SendConsoleCommand()InternalVariable
InternalFunction()
How to design an Object Orientated Application
Decide which objects make sense in terms of the problem space.
Make the object represent logical entities within the application.
“Person”, “PersonCollection”, “Transaction”, etc are good examples.
Write these object names down on separate pieces of paper
Perform an application “walk through”
This will quickly show which objects need to perform particular operations, and
which objects interact with other objects.
This helps define the “public” interface to the Object.
Don’t worry as to how operations within objects are performed at this stage.
Note:
This is a very simplistic approach, and far more approaches exist. Remember,
OO programming is common in other environments.
OOP & LotusScript
To create a class in LotusScript, wrap code and data around “class”
definitions. Such as:
And consume it with:
Class Person
Private nnName as NotesName
Public strInternetAddress as String
Sub new(doc as NotesDocument)
Set nnName = doc.GetitemValue(“FullName”)(0)
me.strInternetAddress = doc.getItemValue(“InternetAddress”)(0)
End sub
Public function getName
If (me.nnName is nothing) then exit function
getName = nnName.Abbreviated
End function
End class
Dim P as new Person(doc)
Print “Person: “ + P.getName()
Why does that help ?
It helps us construct complex (and possibly interconnected) in-
memory data structures
It sites the code for that data structure alongside the data structure
Making maintenance easier
We can use these complex data structures to represent far more
complex algorithms.
We can architect solutions at a far higher level, using objects
(instances of these classes).
Classes can inherit from other classes, thus aiding code re-
use(dramatically).
Where does this help us ?
Complex code.
Large applications.
Applications that have or may change data structure frequently.
Groups of applications that share common data structures.
Examples:
Directory Comparison tools.
Its far faster to read multiple directories into memory and perform comparisons
between in-memory objects.
Workflow systems
Where you can “hide” the complexity of the workflow from other code.
Interfaces to External Systems
Where the Interface can be complex.
Or where you wish to support multiple interfaces.
Where you are attempting to perform complex relational
operations.
Agenda
Introductions
Why Object Orientated Programming
Basic OO techniques
An Object Orientated Project
Encapsulating Classes
Extending Classes
Summary
Questions and Answers
Customer Specification
Our Company – Cheese International – is going through a sensitive
“media event” after the leader of a (large, dangerous and heavily
armed) country almost choked to death on some “stinking bishop”.
We have therefore been tasked with writing a Notes database
which will read all on-line news sites looking for mention of our
company.
This database will then be replicated to all the people in our
Marketing department, who can then respond.
Today.
This sounds hard, right ?
High Level Architecture
This may be a little simpler than we thought.
All our targeted news sites allow people to use RSS:
Really Simple Syndication.
It’s a way of downloading a summary of their site by HTTP (the same protocol
that a web browser uses), in XML format.
So what we need to do is
1. construct a database with a list of RSS URL’s.
2. scan these URL’s.
3. Open up the RSS feed.
4. Download the XML.
5. Parse the XML.
6. Extract the news Items
7. Write them to documents.
8. Go down the pub.
Remember the golden rule:
We construct business
applications from pre-existing
components.
We do NOT construct new
technology if at all possible.
Design Considerations:
The only part that we cant do within LotusScript is the
Use Http to download XML
We could parse XML within LotusScript from version 6 onwards.
After extensive research (10 minutes on Google.com)
We find the MSXML v6 Software Development Kit.
It can download XML, parse it and uses the COM interface.
So we can use “CreateObject” within LotusScript to interface with it.
Its built into IE7 and Vista
But we don’t have that.
But you can install it on the client (and/or server)
Its platform specific – to windows.
In this case, so are we.
Pitfalls
You have to instantiate new Objects within COM, and make
absolutely sure that these are deallocated.
Classes can help with that
Classes Support Constuctors and Destructors
We’re keeping a complex relationship between Sites and their news
stories
Classes can help there too!
Implementation Design
Lets have a class for a site
It can allocate all our COM stuff and make sure its shut down
properly
It can then keep track of all News Items for that site.
It can write out new Notes Documents for new News items
Maintaining a unique reference for each story is actually easy, as each story will
have its own unique URL.
First Attempt at our Site Class
A first
attempt at
our “Site”
class could
be:
Class SiteClass
Private strSiteName as String
Private strURL as String
private msXml as Variant
sub new(doc as NotesDocument)
‘ get the site name and URL from the document
‘ Instantiate the COM objects
‘ Open up the Site and get the XML
‘ Parse the XML, and for each News Story,
‘ Do something…
end sub
sub delete()
set msXML = nothing
end sub
End class
First Attempt at our Site Class….
And we’d use this class by:
Dim sSession as new NotesSession
Dim dbThis as NotesDatabase
Set dbThis = sSession.currentDatabase
Dim vLookup as NotesView
Set vLookup = dbThis.getView(“Sites”)
Dim doc as NotesDocument
Set doc = vLookup.getFirstDocument
While not doc is nothing
dim S as new SiteClass(doc)
set doc = vLookup.getNextDocument(doc)
wend
Example:
Lets see how this works….
First Demonstration of our Application
Results:
We’re clearly getting the XML back from the site
We are not yet parsing the Stories out of the site XML information
What to do with the stories themselves ?
It’s a relational construct
One site can have zero or more stories
Classes to the rescue ?
But how ?
Agenda
Introductions
Why Object Orientated Programming
Basic OO techniques
An Object Orientated Project
Encapsulating Classes
Extending Classes
Summary
Questions and Answers
Encapsulating Classes
So far we now understand how to use a single class by itself.
How do we include - encapsulate - other classes within the first
class ?
Can we encapsulate a collection of other objects – instances of
classes within this class ?
Lists
Lists. A collection construct that’s been in LotusScript since
LotusScript was born.
It allows you to construct a memory construct where you have zero
or more items in a list, and each item is referenced by a lookup
value. Like an in-memory “view”.
How many people know how to use lists ?
Resources:
The View – December 2006 article.
http://www.billbuchan.com/web.nsf/htdocs/BBUN67JJCV.htm
Can Lists work with Classes ?
Of course!
A List of Classes.
In fact, we can have a list of classes. For instance:
Dim sSession as new NotesSession
Dim dbThis as NotesDatabase
Set dbThis = sSession.currentDatabase
Dim vLookup as NotesView
Set vLookup = dbThis.getView(“Sites”)
Dim doc as NotesDocument
Dim Sites list as SiteClass
Set doc = vLookup.getFirstDocument
While not doc is nothing
dim S as new SiteClass(doc)
Set Sites( S.getname() ) = S
set doc = vLookup.getNextDocument(doc)
wend
Lets define our Item Class
This class will hold each News Item:
Class ItemClass
Private strTitle as String
Private strLink as String
private strDescription as String
sub new(Story as Variant)
‘ populate this
‘ object from the variant
end sub
End class
Class SiteClass
…
Private Items List as ItemClass
…
End class
Lets see this in Action
Second Application Demonstration
Agenda
Introductions
Why Object Orientated Programming
Basic OO techniques
An Object Orientated Project
Encapsulating Classes
Extending Classes
Summary
Questions and Answers
Extending Classes
Classes can be extended from other classes, and inherit
code+properties.
This leads to code-reuse.
Example:
Class baseClass
…
Private Function log(msg as String)
…
end function
End class
Class SiteClass as BaseClass
….
sub new(doc as NotesDocument)
….
call me.log(“Started”)
….
end sub
End class
UserCreateRequestClassv6
UserCreateRequestClass
UserMoveRequestClass
UserRenameRequestClass
UserDeleteRequestClass
UserCreateUIClass
UserMoveUIClass
UserRenameUIClass
UserDeleteUIClass
Extending Classes…
When one class is extended from another class
It inherits all code and data from that original class
It can execute “private” methods and access private “members”
There is no limit to the level of inheritance
But don’t go mad
For instance:
FactoryClassRequestClassUIClass
BaseClass
Production Quality
How can we make this application more “production quality ? “
Adding a logging subsystem.
But we don’t want to make significant changes to the existing code
We can do this by creating a “BaseClass”, and have the other
classes inherit from that.
Our BaseClass can incorporate a common logging subsystem
And any other code we wish to use.
Site
BaseClass
BaseClass Specification
However, Since we shall have an object in memory for:
Each Site
Each story
Our Baseclass cannot create a new NotesAgentLog class for each
instance.
We need to only create ONE single instance of our NotesAgentLog class.
Site
BaseClass
SiteClass
BaseClass
Item
BaseClass
Item
BaseClass
Item
BaseClass
ItemClass
BaseClass
LogClass
Singleton
“Singleton” is a design pattern which ensures that ONLY one copy
of an object exists at one time:
Class baseClass
private log as variant
Sub new()
set log = getNewLog()
End sub
Private Function log(msg as String)
call log.writeMsg(msg)
end function
End class
Private globalLog as Variant
Public Function getNewLog() as variant
if (isEmpty(globalLog)) then
set globalLog = new logClass
end if
set getNewLog = globalLog
End function
Class logClass
public Function writeMsg(msg as String)
…
end function
End class
Lets incorporate BaseClass
Third Application Demonstration
Agenda
Introductions
Why Object Orientated Programming
Basic OO techniques
An Object Orientated Project
Encapsulating Classes
Extending Classes
Summary
Questions and Answers
Summary
Object Orientated Programming in LotusScript:
Is easy.
Allows far more code reuse.
Allows you to focus on the design.
It’s a stepping stone to other Object Orientated Languages
Java, anyone ?
Java as a language is NOT DIFFICULT
Its the Object Orientated Part that traditional LotusScript programmers find
hard.
Some Resources
Notes Designer help: look for "class statement", "custom classes", "derived
classes" ... and more
LotusScript Programmer's Guide, Developer Works
http://www-10.lotus.com/ldd/notesua.nsf
Dynamic Loading
http://www.hadsl.com/hadslblog.nsf/d6plinks/RCAS-6VDQV4
Article "Creating Custom Classes in LS" by Johan Känngård
http://dev.kanngard.net/dev/home.nsf/ArticlesByTitle/LSClass.html
Teamstudio ScriptBrowser:
http://blogs.teamstudio.com
OpenDom Blog
http://opendom.blogspot.com/ - Alain H Romedenne
Related Sessions at Lotusphere 2007
BP301 Advanced Object Oriented Programming for LotusScript
Bill Buchan
AD506 Intermediate LotusScript
John Dillon
BP308 Leverage DXL and OOP to Build Powerful Tools
Mikkel Heisterberg
AD504 What's New in the IBM Lotus Domino Objects?
James Cooper
Agenda
Introductions
Why Object Orientated Programming
Basic OO techniques
An Object Orientated Project
Encapsulating Classes
Extending Classes
Summary
Questions and Answers
Questions and Answers
We are:
Jens-B Augustini – LIGONET Gmbh:
http://www.ligonet.ch - Augustiny.j@ligonet.ch
Bill Buchan – HADSL
http://www.hadsl.com - bill.buchan@hads.com
This was:
AD507 - Leveraging the Power of Object Oriented Programming in LotusScript
Remember to fill in your Evaluations.
This is how YOU influence Lotusphere 2008!
Limited Time for Questions
We’re available in the speaker room immediately after this session.
© IBM Corporation 2007. All Rights Reserved.
The workshops, sessions and materials have been prepared by IBM or the session speakers and reflect their own views. They are provided
for informational purposes only, and are neither intended to, nor shall have the effect of being, legal or other guidance or advice to any
participant. While efforts were made to verify the completeness and accuracy of the information contained in this presentation, it is
provided AS IS without warranty of any kind, express or implied. IBM shall not be responsible for any damages arising out of the use of,
or otherwise related to, this presentation or any other materials. Nothing contained in this presentation is intended to, nor shall have the
effect of, creating any warranties or representations from IBM or its suppliers or licensors, or altering the terms and conditions of the
applicable license agreement governing the use of IBM software.
References in this presentation to IBM products, programs, or services do not imply that they will be available in all countries in which IBM
operates. Product release dates and/or capabilities referenced in this presentation may change at any time at IBM’s sole discretion based
on market opportunities or other factors, and are not intended to be a commitment to future product or feature availability in any way.
Nothing contained in these materials is intended to, nor shall have the effect of, stating or implying that any activities undertaken by you
will result in any specific sales, revenue growth or other results.
Performance is based on measurements and projections using standard IBM benchmarks in a controlled environment. The actual throughput
or performance that any user will experience will vary depending upon many factors, including considerations such as the amount of
multiprogramming in the user's job stream, the I/O configuration, the storage configuration, and the workload processed. Therefore, no
assurance can be given that an individual user will achieve results similar to those stated here.
All customer examples described are presented as illustrations of how those customers have used IBM products and the results they may
have achieved. Actual environmental costs and performance characteristics may vary by customer.
IBM, the IBM logo, Lotus, Lotus Notes, Notes, Domino, Domino.Doc, Domino Designer, Lotus Enterprise Integrator, Lotus Workflow,
Lotusphere, QuickPlace, Sametime, WebSphere, Workplace, Workplace Forms, Workplace Managed Client, Workplace Web Content
Management, AIX, AS/400, DB2, DB2 Universal Database, developerWorks, eServer, EasySync, i5/OS, IBM Virtual Innovation Center,
iSeries, OS/400, Passport Advantage, PartnerWorld, Rational, Redbooks, Software as Services, System z, Tivoli, xSeries, z/OS and zSeries
are trademarks of International Business Machines Corporation in the United States, other countries, or both.
Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.
Microsoft and Windows are trademarks of Microsoft Corporation in the United States, other countries, or both.
Intel and Pentium are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

Weitere ähnliche Inhalte

Ähnlich wie Ad507

C# classes
C#   classesC#   classes
C# classesTiago
 
Generic Repository Pattern in MVC3 Application with Entity Framework
Generic Repository Pattern in MVC3 Application with Entity FrameworkGeneric Repository Pattern in MVC3 Application with Entity Framework
Generic Repository Pattern in MVC3 Application with Entity FrameworkAkhil Mittal
 
Introduction to mean and mern || Event by DSC UNIDEB
Introduction to mean and mern || Event by DSC UNIDEBIntroduction to mean and mern || Event by DSC UNIDEB
Introduction to mean and mern || Event by DSC UNIDEBMuhammad Raza
 
epicenter2010 Open Xml
epicenter2010   Open Xmlepicenter2010   Open Xml
epicenter2010 Open XmlCraig Murphy
 
CSc investigatory project
CSc investigatory projectCSc investigatory project
CSc investigatory projectDIVYANSHU KUMAR
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxdanhaley45372
 
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...Karen Thompson
 
Dita for the web: Make Adaptive Content Simple for Writers and Developer
Dita for the web: Make Adaptive Content Simple for Writers and DeveloperDita for the web: Make Adaptive Content Simple for Writers and Developer
Dita for the web: Make Adaptive Content Simple for Writers and DeveloperDon Day
 
Case Study: Putting The Watson Developer Cloud to Work - by Doron Katz & Luci...
Case Study: Putting The Watson Developer Cloud to Work - by Doron Katz & Luci...Case Study: Putting The Watson Developer Cloud to Work - by Doron Katz & Luci...
Case Study: Putting The Watson Developer Cloud to Work - by Doron Katz & Luci...Carlos Tomas
 
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Luis Valencia
 
Adopting AnswerModules ModuleSuite
Adopting AnswerModules ModuleSuiteAdopting AnswerModules ModuleSuite
Adopting AnswerModules ModuleSuiteAnswerModules
 
Cs6301 programming and datastactures
Cs6301 programming and datastacturesCs6301 programming and datastactures
Cs6301 programming and datastacturesK.s. Ramesh
 
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010vchircu
 
Designing A Project Using Java Programming
Designing A Project Using Java ProgrammingDesigning A Project Using Java Programming
Designing A Project Using Java ProgrammingKaty Allen
 
Serverless by Example: Building a Real-Time Chat System
Serverless by Example: Building a Real-Time Chat SystemServerless by Example: Building a Real-Time Chat System
Serverless by Example: Building a Real-Time Chat SystemAmazon Web Services
 

Ähnlich wie Ad507 (20)

C# classes
C#   classesC#   classes
C# classes
 
Sda 9
Sda   9Sda   9
Sda 9
 
Generic Repository Pattern in MVC3 Application with Entity Framework
Generic Repository Pattern in MVC3 Application with Entity FrameworkGeneric Repository Pattern in MVC3 Application with Entity Framework
Generic Repository Pattern in MVC3 Application with Entity Framework
 
Introduction to mean and mern || Event by DSC UNIDEB
Introduction to mean and mern || Event by DSC UNIDEBIntroduction to mean and mern || Event by DSC UNIDEB
Introduction to mean and mern || Event by DSC UNIDEB
 
epicenter2010 Open Xml
epicenter2010   Open Xmlepicenter2010   Open Xml
epicenter2010 Open Xml
 
CSc investigatory project
CSc investigatory projectCSc investigatory project
CSc investigatory project
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docx
 
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...
 
Dita for the web: Make Adaptive Content Simple for Writers and Developer
Dita for the web: Make Adaptive Content Simple for Writers and DeveloperDita for the web: Make Adaptive Content Simple for Writers and Developer
Dita for the web: Make Adaptive Content Simple for Writers and Developer
 
Case Study: Putting The Watson Developer Cloud to Work - by Doron Katz & Luci...
Case Study: Putting The Watson Developer Cloud to Work - by Doron Katz & Luci...Case Study: Putting The Watson Developer Cloud to Work - by Doron Katz & Luci...
Case Study: Putting The Watson Developer Cloud to Work - by Doron Katz & Luci...
 
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
 
Entity Framework 4
Entity Framework 4Entity Framework 4
Entity Framework 4
 
Adopting AnswerModules ModuleSuite
Adopting AnswerModules ModuleSuiteAdopting AnswerModules ModuleSuite
Adopting AnswerModules ModuleSuite
 
The mean stack
The mean stackThe mean stack
The mean stack
 
django
djangodjango
django
 
Cs6301 programming and datastactures
Cs6301 programming and datastacturesCs6301 programming and datastactures
Cs6301 programming and datastactures
 
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Designing A Project Using Java Programming
Designing A Project Using Java ProgrammingDesigning A Project Using Java Programming
Designing A Project Using Java Programming
 
Serverless by Example: Building a Real-Time Chat System
Serverless by Example: Building a Real-Time Chat SystemServerless by Example: Building a Real-Time Chat System
Serverless by Example: Building a Real-Time Chat System
 

Mehr von Bill Buchan

Dummies guide to WISPS
Dummies guide to WISPSDummies guide to WISPS
Dummies guide to WISPSBill Buchan
 
WISP for Dummies
WISP for DummiesWISP for Dummies
WISP for DummiesBill Buchan
 
WISP Worst Practices
WISP Worst PracticesWISP Worst Practices
WISP Worst PracticesBill Buchan
 
Marykirk raft race presentation night 2014
Marykirk raft race presentation night 2014Marykirk raft race presentation night 2014
Marykirk raft race presentation night 2014Bill Buchan
 
Dev buchan best practices
Dev buchan best practicesDev buchan best practices
Dev buchan best practicesBill Buchan
 
Dev buchan leveraging
Dev buchan leveragingDev buchan leveraging
Dev buchan leveragingBill Buchan
 
Dev buchan leveraging the notes c api
Dev buchan leveraging the notes c apiDev buchan leveraging the notes c api
Dev buchan leveraging the notes c apiBill Buchan
 
Dev buchan everything you need to know about agent design
Dev buchan everything you need to know about agent designDev buchan everything you need to know about agent design
Dev buchan everything you need to know about agent designBill Buchan
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tipsBill Buchan
 
Entwicker camp2007 calling-the-c-api-from-lotusscript
Entwicker camp2007 calling-the-c-api-from-lotusscriptEntwicker camp2007 calling-the-c-api-from-lotusscript
Entwicker camp2007 calling-the-c-api-from-lotusscriptBill Buchan
 
Entwicker camp2007 blackberry-workshop
Entwicker camp2007 blackberry-workshopEntwicker camp2007 blackberry-workshop
Entwicker camp2007 blackberry-workshopBill Buchan
 
Admin2012 buchan web_services-v101
Admin2012 buchan web_services-v101Admin2012 buchan web_services-v101
Admin2012 buchan web_services-v101Bill Buchan
 
Reporting on your domino environment v1
Reporting on your domino environment v1Reporting on your domino environment v1
Reporting on your domino environment v1Bill Buchan
 
12 Step Guide to Lotuscript
12 Step Guide to Lotuscript12 Step Guide to Lotuscript
12 Step Guide to LotuscriptBill Buchan
 
Everything you ever wanted to know about lotus script
Everything you ever wanted to know about lotus scriptEverything you ever wanted to know about lotus script
Everything you ever wanted to know about lotus scriptBill Buchan
 
Admin camp 2011-domino-sso-with-ad
Admin camp 2011-domino-sso-with-adAdmin camp 2011-domino-sso-with-ad
Admin camp 2011-domino-sso-with-adBill Buchan
 
Softsphere 08 web services bootcamp
Softsphere 08 web services bootcampSoftsphere 08 web services bootcamp
Softsphere 08 web services bootcampBill Buchan
 
Connections Lotusphere Worst Practices 2013
Connections Lotusphere Worst Practices 2013Connections Lotusphere Worst Practices 2013
Connections Lotusphere Worst Practices 2013Bill Buchan
 
Lotusphere 2009 The 11 Commandments
Lotusphere 2009 The 11 CommandmentsLotusphere 2009 The 11 Commandments
Lotusphere 2009 The 11 CommandmentsBill Buchan
 

Mehr von Bill Buchan (20)

Dummies guide to WISPS
Dummies guide to WISPSDummies guide to WISPS
Dummies guide to WISPS
 
WISP for Dummies
WISP for DummiesWISP for Dummies
WISP for Dummies
 
WISP Worst Practices
WISP Worst PracticesWISP Worst Practices
WISP Worst Practices
 
Marykirk raft race presentation night 2014
Marykirk raft race presentation night 2014Marykirk raft race presentation night 2014
Marykirk raft race presentation night 2014
 
Dev buchan best practices
Dev buchan best practicesDev buchan best practices
Dev buchan best practices
 
Dev buchan leveraging
Dev buchan leveragingDev buchan leveraging
Dev buchan leveraging
 
Dev buchan leveraging the notes c api
Dev buchan leveraging the notes c apiDev buchan leveraging the notes c api
Dev buchan leveraging the notes c api
 
Dev buchan everything you need to know about agent design
Dev buchan everything you need to know about agent designDev buchan everything you need to know about agent design
Dev buchan everything you need to know about agent design
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tips
 
Entwicker camp2007 calling-the-c-api-from-lotusscript
Entwicker camp2007 calling-the-c-api-from-lotusscriptEntwicker camp2007 calling-the-c-api-from-lotusscript
Entwicker camp2007 calling-the-c-api-from-lotusscript
 
Entwicker camp2007 blackberry-workshop
Entwicker camp2007 blackberry-workshopEntwicker camp2007 blackberry-workshop
Entwicker camp2007 blackberry-workshop
 
Ad505 dev blast
Ad505 dev blastAd505 dev blast
Ad505 dev blast
 
Admin2012 buchan web_services-v101
Admin2012 buchan web_services-v101Admin2012 buchan web_services-v101
Admin2012 buchan web_services-v101
 
Reporting on your domino environment v1
Reporting on your domino environment v1Reporting on your domino environment v1
Reporting on your domino environment v1
 
12 Step Guide to Lotuscript
12 Step Guide to Lotuscript12 Step Guide to Lotuscript
12 Step Guide to Lotuscript
 
Everything you ever wanted to know about lotus script
Everything you ever wanted to know about lotus scriptEverything you ever wanted to know about lotus script
Everything you ever wanted to know about lotus script
 
Admin camp 2011-domino-sso-with-ad
Admin camp 2011-domino-sso-with-adAdmin camp 2011-domino-sso-with-ad
Admin camp 2011-domino-sso-with-ad
 
Softsphere 08 web services bootcamp
Softsphere 08 web services bootcampSoftsphere 08 web services bootcamp
Softsphere 08 web services bootcamp
 
Connections Lotusphere Worst Practices 2013
Connections Lotusphere Worst Practices 2013Connections Lotusphere Worst Practices 2013
Connections Lotusphere Worst Practices 2013
 
Lotusphere 2009 The 11 Commandments
Lotusphere 2009 The 11 CommandmentsLotusphere 2009 The 11 Commandments
Lotusphere 2009 The 11 Commandments
 

Kürzlich hochgeladen

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 

Kürzlich hochgeladen (20)

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 

Ad507

  • 1. ® AD507 – Leveraging the Power of Object Oriented Programming in LotusScript Jens-B. Augustiny – LIGONET GmbH Bill Buchan – HADSL
  • 2. Agenda Introductions Why Object Orientated Programming Basic OO techniques An Object Orientated Project Encapsulating Classes Extending Classes Summary Questions and Answers
  • 3. Introductions Who are we ? Jens-B. Augustiny, LIGONET GmbH 25 years IT experience, 12 with Lotus Notes Dual PCLP v4, v5, v6, v7 Founder and CTO of a Business Partner – LIGONET – in Switzerland Bill Buchan, HADSL 23 years IT experience, 12 with Lotus Notes Dual PCLP in v3, v4, v5, v6, v7 Founder and CEO of a Business Partner – HADSL – in the UK Who are you ? A LotusScript developer You wish to improve your code, write more efficiently, & write more robust code
  • 4. Agenda Introductions Why Object Orientated Programming Basic OO techniques An Object Orientated Project Encapsulating Classes Extending Classes Summary Questions and Answers
  • 5. Why Object Orientated Programming? Object Orientated Programming: Allows you to design higher-level objects. Allows far more code-reuse. Allows you to write less code. And therefore leads to easier maintenance. What does this presentation deliver ? We aim to show a typical application, and how OO techniques help the design process. We show basic and more complex design techniques during the development of the application. And we show common questions and answers as the presentation unfolds.
  • 6. Agenda Introductions Why Object Orientated Programming Basic OO techniques An Object Orientated Project Encapsulating Classes Extending Classes Summary Questions and Answers
  • 7. Object Orientated Programming: Conceptually An object is a collection of properties (data) and methods (code) which encapsulates a logical entity. For instance, a Car is made up of objects – 4 instances of “wheel”, 1 instance of “engine”, etc. This allows us to break our problem set into logical units – objects. In LotusScript, we express this as a “class”. Our consumer code then creates new instances of classes – objects – that we then utilise. Remember – NotesSession, NotesDocument – are all classes!
  • 8. Public and Private: An object has to have some public methods (functions/subs). may have public members (variables). Internal code for the object need not be exposed “Code Hiding” means not showing the consumer more than he needs to see. Importantly – the consumer now codes to the public interface of that object. NotesSession CurrentDatabase SendConsoleCommand()InternalVariable InternalFunction()
  • 9. How to design an Object Orientated Application Decide which objects make sense in terms of the problem space. Make the object represent logical entities within the application. “Person”, “PersonCollection”, “Transaction”, etc are good examples. Write these object names down on separate pieces of paper Perform an application “walk through” This will quickly show which objects need to perform particular operations, and which objects interact with other objects. This helps define the “public” interface to the Object. Don’t worry as to how operations within objects are performed at this stage. Note: This is a very simplistic approach, and far more approaches exist. Remember, OO programming is common in other environments.
  • 10. OOP & LotusScript To create a class in LotusScript, wrap code and data around “class” definitions. Such as: And consume it with: Class Person Private nnName as NotesName Public strInternetAddress as String Sub new(doc as NotesDocument) Set nnName = doc.GetitemValue(“FullName”)(0) me.strInternetAddress = doc.getItemValue(“InternetAddress”)(0) End sub Public function getName If (me.nnName is nothing) then exit function getName = nnName.Abbreviated End function End class Dim P as new Person(doc) Print “Person: “ + P.getName()
  • 11. Why does that help ? It helps us construct complex (and possibly interconnected) in- memory data structures It sites the code for that data structure alongside the data structure Making maintenance easier We can use these complex data structures to represent far more complex algorithms. We can architect solutions at a far higher level, using objects (instances of these classes). Classes can inherit from other classes, thus aiding code re- use(dramatically).
  • 12. Where does this help us ? Complex code. Large applications. Applications that have or may change data structure frequently. Groups of applications that share common data structures.
  • 13. Examples: Directory Comparison tools. Its far faster to read multiple directories into memory and perform comparisons between in-memory objects. Workflow systems Where you can “hide” the complexity of the workflow from other code. Interfaces to External Systems Where the Interface can be complex. Or where you wish to support multiple interfaces. Where you are attempting to perform complex relational operations.
  • 14. Agenda Introductions Why Object Orientated Programming Basic OO techniques An Object Orientated Project Encapsulating Classes Extending Classes Summary Questions and Answers
  • 15. Customer Specification Our Company – Cheese International – is going through a sensitive “media event” after the leader of a (large, dangerous and heavily armed) country almost choked to death on some “stinking bishop”. We have therefore been tasked with writing a Notes database which will read all on-line news sites looking for mention of our company. This database will then be replicated to all the people in our Marketing department, who can then respond. Today. This sounds hard, right ?
  • 16. High Level Architecture This may be a little simpler than we thought. All our targeted news sites allow people to use RSS: Really Simple Syndication. It’s a way of downloading a summary of their site by HTTP (the same protocol that a web browser uses), in XML format. So what we need to do is 1. construct a database with a list of RSS URL’s. 2. scan these URL’s. 3. Open up the RSS feed. 4. Download the XML. 5. Parse the XML. 6. Extract the news Items 7. Write them to documents. 8. Go down the pub.
  • 17. Remember the golden rule: We construct business applications from pre-existing components. We do NOT construct new technology if at all possible.
  • 18. Design Considerations: The only part that we cant do within LotusScript is the Use Http to download XML We could parse XML within LotusScript from version 6 onwards. After extensive research (10 minutes on Google.com) We find the MSXML v6 Software Development Kit. It can download XML, parse it and uses the COM interface. So we can use “CreateObject” within LotusScript to interface with it. Its built into IE7 and Vista But we don’t have that. But you can install it on the client (and/or server) Its platform specific – to windows. In this case, so are we.
  • 19. Pitfalls You have to instantiate new Objects within COM, and make absolutely sure that these are deallocated. Classes can help with that Classes Support Constuctors and Destructors We’re keeping a complex relationship between Sites and their news stories Classes can help there too!
  • 20. Implementation Design Lets have a class for a site It can allocate all our COM stuff and make sure its shut down properly It can then keep track of all News Items for that site. It can write out new Notes Documents for new News items Maintaining a unique reference for each story is actually easy, as each story will have its own unique URL.
  • 21. First Attempt at our Site Class A first attempt at our “Site” class could be: Class SiteClass Private strSiteName as String Private strURL as String private msXml as Variant sub new(doc as NotesDocument) ‘ get the site name and URL from the document ‘ Instantiate the COM objects ‘ Open up the Site and get the XML ‘ Parse the XML, and for each News Story, ‘ Do something… end sub sub delete() set msXML = nothing end sub End class
  • 22. First Attempt at our Site Class…. And we’d use this class by: Dim sSession as new NotesSession Dim dbThis as NotesDatabase Set dbThis = sSession.currentDatabase Dim vLookup as NotesView Set vLookup = dbThis.getView(“Sites”) Dim doc as NotesDocument Set doc = vLookup.getFirstDocument While not doc is nothing dim S as new SiteClass(doc) set doc = vLookup.getNextDocument(doc) wend
  • 23. Example: Lets see how this works…. First Demonstration of our Application
  • 24. Results: We’re clearly getting the XML back from the site We are not yet parsing the Stories out of the site XML information What to do with the stories themselves ? It’s a relational construct One site can have zero or more stories Classes to the rescue ? But how ?
  • 25. Agenda Introductions Why Object Orientated Programming Basic OO techniques An Object Orientated Project Encapsulating Classes Extending Classes Summary Questions and Answers
  • 26. Encapsulating Classes So far we now understand how to use a single class by itself. How do we include - encapsulate - other classes within the first class ? Can we encapsulate a collection of other objects – instances of classes within this class ?
  • 27. Lists Lists. A collection construct that’s been in LotusScript since LotusScript was born. It allows you to construct a memory construct where you have zero or more items in a list, and each item is referenced by a lookup value. Like an in-memory “view”. How many people know how to use lists ? Resources: The View – December 2006 article. http://www.billbuchan.com/web.nsf/htdocs/BBUN67JJCV.htm Can Lists work with Classes ? Of course!
  • 28. A List of Classes. In fact, we can have a list of classes. For instance: Dim sSession as new NotesSession Dim dbThis as NotesDatabase Set dbThis = sSession.currentDatabase Dim vLookup as NotesView Set vLookup = dbThis.getView(“Sites”) Dim doc as NotesDocument Dim Sites list as SiteClass Set doc = vLookup.getFirstDocument While not doc is nothing dim S as new SiteClass(doc) Set Sites( S.getname() ) = S set doc = vLookup.getNextDocument(doc) wend
  • 29. Lets define our Item Class This class will hold each News Item: Class ItemClass Private strTitle as String Private strLink as String private strDescription as String sub new(Story as Variant) ‘ populate this ‘ object from the variant end sub End class Class SiteClass … Private Items List as ItemClass … End class
  • 30. Lets see this in Action Second Application Demonstration
  • 31. Agenda Introductions Why Object Orientated Programming Basic OO techniques An Object Orientated Project Encapsulating Classes Extending Classes Summary Questions and Answers
  • 32. Extending Classes Classes can be extended from other classes, and inherit code+properties. This leads to code-reuse. Example: Class baseClass … Private Function log(msg as String) … end function End class Class SiteClass as BaseClass …. sub new(doc as NotesDocument) …. call me.log(“Started”) …. end sub End class
  • 33. UserCreateRequestClassv6 UserCreateRequestClass UserMoveRequestClass UserRenameRequestClass UserDeleteRequestClass UserCreateUIClass UserMoveUIClass UserRenameUIClass UserDeleteUIClass Extending Classes… When one class is extended from another class It inherits all code and data from that original class It can execute “private” methods and access private “members” There is no limit to the level of inheritance But don’t go mad For instance: FactoryClassRequestClassUIClass BaseClass
  • 34. Production Quality How can we make this application more “production quality ? “ Adding a logging subsystem. But we don’t want to make significant changes to the existing code We can do this by creating a “BaseClass”, and have the other classes inherit from that. Our BaseClass can incorporate a common logging subsystem And any other code we wish to use.
  • 35. Site BaseClass BaseClass Specification However, Since we shall have an object in memory for: Each Site Each story Our Baseclass cannot create a new NotesAgentLog class for each instance. We need to only create ONE single instance of our NotesAgentLog class. Site BaseClass SiteClass BaseClass Item BaseClass Item BaseClass Item BaseClass ItemClass BaseClass LogClass
  • 36. Singleton “Singleton” is a design pattern which ensures that ONLY one copy of an object exists at one time: Class baseClass private log as variant Sub new() set log = getNewLog() End sub Private Function log(msg as String) call log.writeMsg(msg) end function End class Private globalLog as Variant Public Function getNewLog() as variant if (isEmpty(globalLog)) then set globalLog = new logClass end if set getNewLog = globalLog End function Class logClass public Function writeMsg(msg as String) … end function End class
  • 37. Lets incorporate BaseClass Third Application Demonstration
  • 38. Agenda Introductions Why Object Orientated Programming Basic OO techniques An Object Orientated Project Encapsulating Classes Extending Classes Summary Questions and Answers
  • 39. Summary Object Orientated Programming in LotusScript: Is easy. Allows far more code reuse. Allows you to focus on the design. It’s a stepping stone to other Object Orientated Languages Java, anyone ? Java as a language is NOT DIFFICULT Its the Object Orientated Part that traditional LotusScript programmers find hard.
  • 40. Some Resources Notes Designer help: look for "class statement", "custom classes", "derived classes" ... and more LotusScript Programmer's Guide, Developer Works http://www-10.lotus.com/ldd/notesua.nsf Dynamic Loading http://www.hadsl.com/hadslblog.nsf/d6plinks/RCAS-6VDQV4 Article "Creating Custom Classes in LS" by Johan Känngård http://dev.kanngard.net/dev/home.nsf/ArticlesByTitle/LSClass.html Teamstudio ScriptBrowser: http://blogs.teamstudio.com OpenDom Blog http://opendom.blogspot.com/ - Alain H Romedenne
  • 41. Related Sessions at Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript Bill Buchan AD506 Intermediate LotusScript John Dillon BP308 Leverage DXL and OOP to Build Powerful Tools Mikkel Heisterberg AD504 What's New in the IBM Lotus Domino Objects? James Cooper
  • 42. Agenda Introductions Why Object Orientated Programming Basic OO techniques An Object Orientated Project Encapsulating Classes Extending Classes Summary Questions and Answers
  • 43. Questions and Answers We are: Jens-B Augustini – LIGONET Gmbh: http://www.ligonet.ch - Augustiny.j@ligonet.ch Bill Buchan – HADSL http://www.hadsl.com - bill.buchan@hads.com This was: AD507 - Leveraging the Power of Object Oriented Programming in LotusScript Remember to fill in your Evaluations. This is how YOU influence Lotusphere 2008! Limited Time for Questions We’re available in the speaker room immediately after this session.
  • 44. © IBM Corporation 2007. All Rights Reserved. The workshops, sessions and materials have been prepared by IBM or the session speakers and reflect their own views. They are provided for informational purposes only, and are neither intended to, nor shall have the effect of being, legal or other guidance or advice to any participant. While efforts were made to verify the completeness and accuracy of the information contained in this presentation, it is provided AS IS without warranty of any kind, express or implied. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, this presentation or any other materials. Nothing contained in this presentation is intended to, nor shall have the effect of, creating any warranties or representations from IBM or its suppliers or licensors, or altering the terms and conditions of the applicable license agreement governing the use of IBM software. References in this presentation to IBM products, programs, or services do not imply that they will be available in all countries in which IBM operates. Product release dates and/or capabilities referenced in this presentation may change at any time at IBM’s sole discretion based on market opportunities or other factors, and are not intended to be a commitment to future product or feature availability in any way. Nothing contained in these materials is intended to, nor shall have the effect of, stating or implying that any activities undertaken by you will result in any specific sales, revenue growth or other results. Performance is based on measurements and projections using standard IBM benchmarks in a controlled environment. The actual throughput or performance that any user will experience will vary depending upon many factors, including considerations such as the amount of multiprogramming in the user's job stream, the I/O configuration, the storage configuration, and the workload processed. Therefore, no assurance can be given that an individual user will achieve results similar to those stated here. All customer examples described are presented as illustrations of how those customers have used IBM products and the results they may have achieved. Actual environmental costs and performance characteristics may vary by customer. IBM, the IBM logo, Lotus, Lotus Notes, Notes, Domino, Domino.Doc, Domino Designer, Lotus Enterprise Integrator, Lotus Workflow, Lotusphere, QuickPlace, Sametime, WebSphere, Workplace, Workplace Forms, Workplace Managed Client, Workplace Web Content Management, AIX, AS/400, DB2, DB2 Universal Database, developerWorks, eServer, EasySync, i5/OS, IBM Virtual Innovation Center, iSeries, OS/400, Passport Advantage, PartnerWorld, Rational, Redbooks, Software as Services, System z, Tivoli, xSeries, z/OS and zSeries are trademarks of International Business Machines Corporation in the United States, other countries, or both. Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both. Microsoft and Windows are trademarks of Microsoft Corporation in the United States, other countries, or both. Intel and Pentium are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries.