2. Jakob Majkilde
Education: Data Engineer
Lotus Notes Developer since 1992 (release 2.1)
Certified administrator and instructor (early releases) and 8.5 Developer
Certified Scrum Master, Certified Java Developer
Founder of notesnet.dk
Blogs
XPages.dk
Lotusscript.dk
Majkilde.com
Book reader, because programming is a lot more than syntax …
Refactoring, Domain Driven Design, Clean Code, The Art of Unit Testing, Extreme Programming, Design
Patterns, Working with Legacy Code, Psychology of Computer Programming, The Pragmatic Programmer,
The Mythical Man Month, Effective Java, Mastering XPages, Portable command Guide, XPages Ext Lib,
and more …
3. Basic setup
As a developer you need to be ‘in flow’. An interruption and you will have to start all over
Use the fastest PC possible – a SSD disk is required
Work in a silent office (no phones). Disable email and skype popups
Max. 5 seconds from code to test = instant deployment
Build and run
Not: build, replicate, refresh design, sign …
You need at least Notes 8.5.3 to run XPages (but 9.0.1 is a lot better)
Do yourself a favor: use 2 (or 3) monitors
No matter what the admin says: You do need access and permission to install your own tools and
software on your PC
The Programmer’s Bill of Rights
4. Learn the DDE
Tweak it: http://xpages.dk/?p=1075
Memory settings in lotusnotesframeworkrcpdeployjvm.properties
vmarg.Xmx=-Xmx1024m
vmarg.Xms=-Xms512m
Use shortcuts
Open Type: Ctrl+Shift+T
Open Resource: Ctrl+Shift+R
Open Declaration: F3 (or Ctrl+Click)
Last Edit Location: Ctrl+Q
Rename: Shift+Alt+R
And of course:
Ctrl+D, Ctrl+M, Ctrl+F8, Ctrl+Shift+7, …
Use code templates!
5. Use a local server
Local server
Build times will be too slow on a central Domino server (Notes uses a lot of network bandwidth)
XPages only works for one developer at a time
If you have a compiler error – then nobody else can build
SessionAsSigner requires one signer only
Only one debugger session at a time
You need access to the log files
You must be able to restart the http task at will
You need access (java.policy, ext folder, etc)
Don’t ever use a production server
Disable all tasks but HTTP
Update,Replica,Router,AMgr,AdminP,CalConn,Sched,RnRMgr,Catalog,Design,UpdAll,Statlog
Also recommended by Paul Withers and Nathan Freeman
The blagger’s guide to XPages Domino Administraion
6. Source control is a must
If you are the only developer – then you could just replicate, but
Source control gives you
Full tracking and version control
When your boss asks: when, why, who made the change? You have the answer!
Shared code (across domains) / several developers
Branching
Make a hotfix to the current version and work on the new version on the same time
Backup
Delete or refactor code. No problem – you can always go back
With two developers, both having there own local server
How do you think Notes handles replication conflicts?
Answer: newest change will win – the older is lost.
Solution: Source Control (e.g. git)
7. Source control
We use git, SourceTree and Bitbucket
It’s all free, but other options are available too
But, keep making manual backups of your files in the beginning – there is a learning curve!
Tips
Use a .gitignore file
Handle line breaks with ‘Autocrlf = true’ – we had problems in a mixed Windows/Mac environment
See David Leedys video, Per Henrik Laustens presentation or
my blog entry: http://xpages.dk/?p=690. Best practice here (pending)
8. Source Control Settings
Preferences, General, Workspace:
Refresh Automatically: Yes
Build Automatically: Yes
Auto build no longer changes the signatures
Encoding: Default (Cp1252)
Because that’s what others do
Preferences, Domino Designer, Source Control
Automatic Import/Export: No
Auto build is required
Use Binary DXL: Yes
important that everybody does the same
Notice:
The auto refresh doesn’t work on network drives. Do a manual refresh (F9) from Package Explorer
Think ‘Auto Refresh’ is required when using ‘Auto
import/export’, otherwise strange things might
happen if the ODP is not in sync with the disk.
Yes to ‘Auto refresh’ – but not with the ‘Auto
import/export’ as this will start an indefinite
refresh/rebuild loop
9. Source Control Tips
On-Disc-Project
Prefix the project name with ODP or GIT
Makes it easier to distinguish them from your nsf files
Make a folder for the project
And one (or more) sub folders for the nsf file(s)
Use Git Flow
http://nvie.com/posts/a-successful-git-branching-model/
New project
Enable Git flow
Make a initial commit
Then start coding
10. Unit testing
In the book “Working Effectively with legacy code”, Michael Feathers wrote:
“Legacy code is simply code without tests”
Pros
Better Design / better structure
You can change your code without breaking it (refactoring)
10 more reasons here
Bottom line: better code with fewer bugs in less time !
Links
Unit testing in XPages with JUnit: http://xpages.dk/?p=1162
The Art of Unit Testning
Unit testning: Why bother?
11. Reuse
Lots of great open source code on the internet
OpenNTF.org
XSnippets
XPages Designer Import Tool: http://xpages.dk/?p=1098
ExtLib
Domino API
Apache.org
The FREE Java toolbox you didn’t know you had
File handling, String handling, Validators, Office Integration (POI), PDF generation (FOP)
Beware of the security settings: http://xpages.dk/?p=1373
Code everything in Java using Design Patterns and MVC (more on frostillic and Pipalia)
14. Need help?
Contact the ‘Gang of four’
Jakob Majkilde: majkilde.dk
Per Henrik Lausten: phl-consult.dk
John Dalsgaard: dalsgaard-data.dk
John Foldager: izone.dk