PermaLinkShow 'n Tell Thursday #310:17:46 AM
Written By : Scott Good

Do you ever have applications that need to work in multiple environments? You know what I mean: Maybe you have separate Development and Production environments. Or, Development, Test, and Production.

Or, maybe, like us, you're a consultant and have your own internal environment plus the client's Development, Test, and Production environments.

If you have this situation (doesn't pretty much everybody?), you should write your applications to be able to work seamlessly when moved from one environment to the next.

Generally, that's pretty easy to do, but what do you do if you have to do lookups to outside reference databases? If you can be absolutely sure they are always in the same path with the same file name, you can hard-code the lookups, but that always makes me a little queasy.

Alternatively, you could make a keyword document which holds the path or replica id of the database being looked up but, as soon as you do that you've suddenly required double the lookups: one to look up the replica ID and the second to do the lookup to the database.

Not ideal, either.

A approach we often use in situations like this is to put a Computed For Display field on the form and compute out the correct replica ID to use for the lookup database based on the current server. Then, all your lookup formulas simply use the value in the field as the replica ID they're looking up to.

The code is simple and straightforward and saves a lot of time messing around as you move versions of the database from one environment to another:

Teamwork := "85256BD8:0057E563";
ClientDev := "852568CC:00523B4B";
ClientTest := "85256ADC:004B56D5";
ClientProduction := "852569CF:007CBB56";
REM;
Domain := @Domain;
REM;
@If(Domain = "AcmeTest"; ClientDev; Domain = "AcmeQA"; ClientTest; Domain = "Acme"; ClientProduction; Teamwork)

Like I said, simple and straightforward. Remember, though, not to do this with a Computed or Computed When Composed field. If you do, the value will be stored in the documents, which can cause you problems down the road.

Technorati tags: ,

Comments :v

1. Chad Schelfhout03/02/2006 01:14:15 PM
Homepage: http://www.chadsmiley.com


I remember doing that same thing, but now I use an alias and lookup the database or other information in documents. This allows me to make one change without having to re-compile, and it can be used in LotusScript, Java and Formula

Here is a better description and of it: http://www.chadsmiley.com/ReferenceLookup.




2. Andrew Brew03/15/2006 12:12:29 AM


I never much liked using replica Ids for lookups, because:
1) If there is a second replica on the right server (a restored copy or the like) it will break
2) If there is an icon pointer on users' workspaces to a server that no longer exists (more common that you might think) it will break
3) Even if you have control of the server environment, and are careful to avoid 1 and 2, it is hard-coding to a particular environment (in this case, environments, but it is still hard-coding), and when the environment changes, it will break

Having said all that, yes, it does save you a lookup (once per session, not once per document - naturally such lookup results would be cached). If you do find this technique useful, I would suggest using server:path pairs instead:
Teamwork := "Server1" : "dev\testlookupdb.nsf";
ClientDev := "Server2" : "dev\testlookupdb.nsf";
ClientTest := "Server3" : "lookupdb.nsf";
...etc.
This avoids problems 1 and 2, at least.




3. Scott Good03/15/2006 07:40:44 AM
Homepage: http://www.scottgood.com


Hi Andrew,

Everything you've said is true and your suggestion will work great. Where you're reluctant to use replica ids, I'm reluctant to use file paths. It seems more likely to me that servers will be reorganized and file paths adjusted than that databases' replica ids will be changed. Using replica ids, while the things you've pointed out are true, completely gets you around the problem of "where is the database and what is it called?"

As to avoiding the lookup, while that's not a terribly big deal if you (a) cache it and (b) do the lookup in a single field that's referenced by anything else in the form needing the replica id (or path), what makes me a little unhappy about keeping this information in lookup documents is (a) you have to either update the information every time you move the database between servers or make individual lookup documents for each environment, and (b) it's one more thing you have to remember to include in your database before it will work.

In any case, your way works as well as mine. Po-tay-toe or po-TAH-toe? Take your pick.

Scott




4. Bernard Horowitz08/07/2007 07:10:16 PM


Forgive me if I am wrong, but as an administrator I have always been taught that hard coding servers, paths etc was the wrong thing to do. I was always taught that the best practice is to code via RepID (servers change, paths change, but rep ID's stay the same unless you have a real good reason to change it).

I am in a discussion with my developers right now who are using letter combinations (like IS) to help lookup a path. They have some system that it goes to the first match of IS instead of a rep ID. With the onset of the ISPY database this screws them up and they want me to rename the databaes title so they can continue to code in the same manner. This seems really odd to me and against everything I have learned. What gives? Am I just old school and a hardass or are they doing this a bit whack?




5. Scott Good08/08/2007 08:55:04 AM
Homepage: http://www.scottgood.com


Bernard,

I'm just as old school about hard-coding server names and paths. Replica IDs are the best way to go, with a couple of possible exceptions.

The first is if you are referencing the current database. In that case, you can skip identifying the server : path/Replica ID altogether and insure you'll always find the right database even if it is someday copied and/or moved. This is a case where adding a replica ID actually makes the application slightly more likely to break.

The other place where I use paths is in situations where the file path is highly dependable. For instance, while it is possible to have address books with other file names, Names.NSF is pretty darned universal in Notes and I'd rather have a lookup pointed at that than at the Replica ID.

Similarly, we have a client that has two databases which contain, respectively, person and location information (address, various roles at each site, etc.). These databases were created to eliminate the need for all their application databases to duplicate more or less the same information for looking up workflow roles and the like. The client has a rule (which they also follow) that these two databases will be on EVERY server and will always have EXACTLY the same paths.

This is another place where we hard-code the path into lookups. Because of the absolute consistency of naming, this actually makes it easier to move from Development to Testing and then on to Production as these lookups don't ever have to change. So, this is a good place to use hard-coded names but it is also highly unusual.

The short version of this long answer (the exceptions noted above notwithstanding) is: I don't like to use paths in lookups. Keep pushing for replica IDs. That approach is a lot easier to get (and keep) right.

Scott




Enter Comments^


Email addresses provided are not made available on this site.





You can use UUB Code in your posts.

[b]bold[/b]  [i]italic[/i]  [u]underline[/u]  [s]strikethrough[/s]

URL's will be automatically converted to Links


:-) :cry: :-\ :huh: ;-) :cool: :grin: :emb: :laugh: :-p :lips: :-( :rolleyes: :-o :-D :angry: :-x
bold italic underline Strikethrough





Remember me    

Disclaimer & Copyright
Monthly Archive
Contact me...
Racing sponsors and such...

Thank you sponsors!

GABlogLogo.jpg

GOODAero

GOODAero specializes in building aerodynamic products for racing cars. Our first product, the GOODAero Raptor wing is available at a surprisingly reasonable price (under a grand) for a full carbon, full-sized, racing wing. Check it out.


Infinite Fiberworks Co, a great source for high-quality Porsche fiberglass parts

Infinite Fiberworks Co.

If you are looking for fiberglass for Porsches, IFC is the place to go. I have used parts from most of the major suppliers and IFC's are easily the highest quality and the most reasonably-priced. Contact Mike at Infinite Fiberworks for more information.

Located in Racine, OH (so far Southeast they're almost in West Virginia), IFC's goal is to be The Best. Give 'em a try.


Bent or ugly wheels? Call Wheel Medic!

Wheel Medic & The Round House

Whether you need to repair, repaint, refinish or just replace your wheels, the guys at Wheel Medic/Round House can get you back on the road in no time!

Wheel Medic, Inc is a family-owned company which specializes in the repair and restoration of aluminum wheels.

The Round House was founded to service Wheel Medic's clients looking for more than just repair work...from custom wheel colors to high-end wheel applications and body kits, the Round House is there to serve the discriminating automotive enthusiast.


Used Porsche parts, great prices!

A Part Above

Looking for used parts for 944s, 924s, 968s or other late-model water-cooled Porsches? Contact John at A Part Above.

Located in Strongsville, OH (20 miles south of Cleveland) their goal is to provide top quality parts and services. I can tell you, John is great to work with and the prices? Very hard to beat.


SMRT Motorsports wants you!

SMRT (that's short for Skid Mark Racing Team), a very-

loosely organized band of fun-loving friends who enjoy auto racing (heck, cars in general), and the occasional adult beverage, wants you to be a part of our team.

Go here to find cool T-shirts, sweatshirts, caps and mugs with the SMRT team logo.

The BlogRoll
Lotus Domino ND6 RSS News Feed RSS Comments Feed Geo URL RSS Validator Blog Admin Lotus Geek Open Notes Picture Database OpenNTF BlogSphere
Calendar
February 2012
Su
Mo
Tu
We
Th
Fr
Sa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
By Category
What I do for a living


I am the President of Teamwork Solutions a long-time Lotus, now IBM, Premier Partner.

With offices in Columbus and Cincinnati, Ohio, we specialize in custom application development for IBM Lotus Notes, Domino, and related technologies. Our software product, ProcessIt! (see below), is quite possibly the world's best, most powerful and easiest-to-use workflow tool for Notes and the web.

Our clients are some of the world's largest corporations along with others that aren't so big.

We do excellent work, quickly, and often on a fixed-fee basis. We'd love to talk to you about your next project.




I am a Contributing Author to Lotus Advisor Magazine, with more than 40 articles under my belt.

I've written how-to series (serieses?) on LotusScript, JavaScript, Cascading Style Sheets (CSS), and now, AJAX (Asynchronous JavaScript and XML), as well as a bit on miscellaneous web development topics.


TheView.jpg

I also write for The View as of the July/August issue where I showed how to take an ugly Notes applications and make it beautiful with just a few minutes' (careful) work.



I am the chief architect and one of two primary developers for what many consider the best all-around workflow tool for Notes/Domino, anywhere, regardless of price.

It's called ProcessIt!, and you can read all about it at www.notesworkflow.com but the bottom line is this: ProcessIt! is fast and easy to learn, extremely powerful, and can be used by mortals. Even--dare I say it?--common users.

You can spend a lot more on a workflow tool but you won't be able to do a lot more for all the extra money.

Don't believe me? Download and try it for free for 60 days.



GTSLogoSm.gif
Copyright Porsche and NASA...not me!

I race a Porsche 944 S2 in National Auto Sport Assocation events and am the 2008 National Champion in NASA's GTS2 class.

Blame this event, a few years ago, for starting that particular money drain all over again.

In support of my habit, I am the NASA Great Lakes Region's GTS (German Touring Series) Director.

I'm also a Nationally-Certified Instructor for the Porsche Club of America and am in charge of classroom sessions for the Mid-Ohio region when we are doing high performance driving events.

In a prior racing life, I was the Midwestern Regional Formula Atlantic Champion and, in 1991, the Ohio Vally Region of SCCA's Regional Driver of the Year (but that, alas, went away when my credit cards let go of the rope!).




I'm writing a book...or at least trying to.

It's murder mystery in which, not too surprisingly, the main character runs a small software company and races cars for fun. Oh yeah, and lives near where I do.

Just where do they come up with these crazy ideas?

Facebook