Saturday, May 24, 2008

Technical Articles - 2 :Coupling

Coupling:
Interfacing of 2 systems is called as coupling. Coupling is of 2 types
1 Tight Coupling
2 Loose Coupling


Tight Coupling:
In Tight Coupling, Computers are connected to each other through strictures of Custom made interface. In Distributed environment, it is not wrong. How ever, if you want to make any change in the interface it is either costly or too difficult.
Lets consider our previous case (Notes <-> LEI <-> DB2).

The user also has a SAP application. If he wants that integrate with the above, the he need to develop or procure some other interface which connects both DB2 and SAP with Lotus notes.

To put it in simple words, In Tight Coupling Change is expensive and time consuming.
In the below figure, we have interface (in dark blue color) which connects with all the 3 system. The interface converts each request in such a way that other systems can understand it.




Before talking about Loose Coupling, we can discuss why change is difficult in tight coupling.
Let’s take a real time example:
Currently I’m living at Bangalore, India. The official language here is Kannada, which I don’t know. If I go to a barbershop, I need to explain the barber about my hair style, so that he can continue in the same pattern.

I don’t know Kannada, and the barber knew only Kannada. He cannot understand what I try to convey. So I need to have a translator with me who can translate Tamil, the language that I speak, into Kannada, so that the barber can understand. Or I should learn to speak Kannada.

When I’m in Karnataka, I can use this translator. Consider if I have move to some other part where the people speak Marathi. The entire process repeats. Either I have to learn Marathi or I need to have a translator.

The same thing applies to the software too. Every OS/Software has its own set of standards, which need not to be compatible with other OS/Software. More clearly 2 different softwares cannot directly communicate with each other.

Learning a new language is some thing like developing a custom interface and having a translator is like buying some software from the market.



Loose Coupling:
In loose coupling, we can add any number of computers to the given network with minor/no modification.
As I said previously, each system has its own standard. But the problem with the tight coupling made the manufactures to think in a different way. Each system may have different standards but for communication all of the use the same standard.
Let’s have a real time example here for a better understanding:
My mother tongue is Tamil. I’m at barber shop. The barber’s mother tongue is Kannada. How can we communicate each other? Both of us know English. I would explain my requirements in English and as he too knows English he can understand what I want. So I no need to Learn Kannada or need not have Translator.
Following the same, all applications can do all their work in their own standard, but when they need to communicate with some other system, all the applications will/should follow a common standard/protocal.

Saturday, May 17, 2008

Technical Articles - 1

I have been working in IT industry for almost 3 years. I did my graduation in Electrical and Electronics Engineering. Of the 45 + papers that I had in my under graduation, only 3 papers were related to IT. They are Programming in C & UNIX (No practical or lab classes. Only theory classes), Object Oriented Programming (No practical or lab classes. Only theory classes) and Software Engineering. And during my college days the only paper that I failed to pass at the first attempt is Object Oriented Programming. Failing in a paper doesn’t mean that I don’t have any knowledge about that paper. I have written the exam well and I don’t know why I couldn’t clear. After a short stint in construction industry I joined the IT industry.



I started my IT carrier with a startup organization. The advantage working in startup organization is we had the chance to work on several emerging technologies. Often my boss would insist us to learn/practice some new technology. At times, what he speaks would be like a Greek and Latin to me. And my boss, when talking to us, he often use the words SOAP, Ajax, Web services, SOA, XML, DXL XSLT, Web2.0 etc. In free time I will search in Google / wikipedia for the terms that my boss used. If I search for some terms, it will lead me to some other term. If I search for the other term it will lead to some other term. It will be an infinite loop. It took several days for me to understand what each term means. How can we use it in our day to day programming.



For guys like me, without the basic functional knowledge, I would like to share what I know. The basics of computer, Internet and some other programming practices. I cannot assure that what ever I write is correct. It’s just my understanding. Since I work mostly on collaboration and internet technologies, most of the articles will be related to that. In this post I will write some thing about Distributed Computing and Interfaces.



1. Distributed Computing:
A software/hardware architecture where more than 1 computer is involved in completion of a task.
Let’s have a simple example:
A food processing company has a DB2 database to store the stock details. And a Lotus notes application to handle the order. When there is new order, the lotus notes application needs to check the DB2 for the available stocks and process the order. So we have 2 different systems, interacting with each other and complete the task. This is called distributed computing



2. Interface :
Interface is hardware/software component which is used to connect to 2 or more computers.
Let’s consider the previous case.
Lotus notes and Db2 needs to work in sync for successful completion of the task. As Lotus notes and DB2 has different architecture they cannot be directly connected. Instead we need a middle man who takes the responsibility of connecting the different system. The middle man understands the query from the lotus notes application and translates it into such a manner that the DB2 can understand. And vice versa. The middle man is considered as the interface. In our case we used Lotus Enterprise Integrator (LEI) as the middle man (Interface)
I hope the above is clear.

Tuesday, May 13, 2008

Chaning the datatype

When we change the data type of a field, then the new data type will not reflected in old documents. To change the data type in the existing documents we have 2 options
1. Open and Save all the documents.
2. We can have background agent to do this.
Here is the logic,
  • Create an item for the existing field
  • Copy the items content
  • Delete the item
  • Create a new item for the same field (The new item will have the new data type)
  • Set the old value in the new item
  • Save the document.

Thursday, May 8, 2008

Why I’m a better software developer than you

What makes one developer better than another? Shouldn’t we all be performing at the same level? Of course not, we’re not sewing buttons on an assembly line. We’re using every bit of our intelligence to create something that we can only begin to understand.
  • I constantly look for better ways of doing things. I subscribe to a good number of development blogs. I alone cannot always come up with the best way to solve a problem, but somebody somewhere probably can.
  • I don’t stop thinking about problems and how to solve them through automation. Sometimes I’ll wake up in the middle of the night, and I can’t get back to sleep until I write some code that I can’t get out of my head.

more........

Wednesday, May 7, 2008

NNOTESWS.DLL - File Open and File Save

Normally when we want to open/save a file through lotus script we will be using the open file dialog and save file dialog. Here is an API alternative for that.

NNOTESWS.DLL is part of the Lotus Notes software and handles the interface side of the Notes client like file open dialog, file save dialog, progress bar etc..

Please Note: I have tried the below code on Version 6.5.4. I haven't tried it on other versions.

Open File Dialog

'Declartion
Declare Function NEMGetFile Lib "nnotesws" ( wHandle As Integer, Byval szFileName As String, Byval szFilter As String, Byval szTitle As String ) As Integer
'On Click
'Declare variables...
Dim szFileName As String*256
Dim szTitle As String
Dim szFilter As String
Dim szSelectedFile As String

Set values...
szFilename = Chr(0)
szTitle = "Open File"
szFilter = "All Files *.* Word Document *.docText Files*.txt" ' a pipe symbol should come after every entry. (szFilter = "All Files pipe *.* pipe Word Document pipe *.doc pipe Text Filespipe .txt pipe"). The symbol gets missed when i publish.
If NEMGetFile( 0, szFileName, szFilter, szTitle) <> 0 Then
szSelectedFile = szFileName
End If

Save As Dialog:

'Declaration
Declare Function NEMPutFile Lib "nnotesws" ( wHandle As Integer, Byval szFileName As String, Byval szFilter As String, Byval szTitle As String ) As Integer
'On Click
'Declare variables...
Dim szFileName As String*256
Dim szTitle As String
Dim szFilter As String

Set values...
szFilename = Chr(0)
szTitle = "Save File"
szFilter = "All Files *.*Word Document *.docText Files*.txt" 'a pipe symbol should come after every entry. (szFilter = "All Files pipe *.* pipe Word Document pipe *.doc pipe Text Filespipe .txt pipe"). The symbol gets missed when i publish.
If NEMPutFile( 0, szFileName, szFilter, szTitle) <> 0 Then
szSaveFile = szFileName
End If

Tuesday, May 6, 2008

Pivot table

http://www.martinscott.com/designlibrary.nsf/scategory/672C7A8D4679A60685256C08001DF4A3?opendocument

Excel Export-1. OLE/COM tip

From LDD..
http://www-10.lotus.com/ldd/46dom.nsf/DateAllFlatweb/dc09168723293c9885256b9e004dd58b?OpenDocument

Here's an OLE/COM tip for you all: How to get around the ":=" that VB uses to set parameters in Lotus NotesPosted by Brandt S Fundak on 17.Apr.02 at 10:10 AM using a Web browserCategory: Domino Designer -- LotusScriptRelease: All ReleasesPlatform: All Platforms

There have been a few questions about how to get around parameters in Visual Basic methods and properties (set through recording macros in excel, word and powerpoint, among others) that are set with the ":=" operator in the past few weeks, so I thought I would post this tip on how to get around it. Maybe this will help someone when using the forum search.We've all heard that most of the stuff that you can do in Visual Basic we can do in LotusScript, but are often stymied by the ":=" operator, which LotusScript does not recognize. It is not that LotusScript can not use those parameters, but we must know HOW to tell LotusScript what the parameters are.Since LotusScript will not recognize the ":=" operator, we must use the only method of passing parameters that LotusScript knows: Parentheses "()"So let's say you have a method in Excel that has parameters. Let's say we use the Add method of the worksheets object in Excel. If we look at the help file on the Add method we find this syntax:expression.Add(Before, After, Count, Type)Of course, this is syntax is something that Notes can understand. However, when we go into the help example to see how we set our parameters, we are confronted with this:This example adds a new worksheet after the last worksheet in the active workbook.Worksheets.Add.Move after:=Worksheets(Worksheets.Count)Now we have a quandry. Let's say I want to follow the example and have the after parameter put my new worksheet after all existing sheets. LotusScript doesn't understand ":=" and if I follow the syntax as listed above, like so:expression.Add(After)it still drops the sheet BEFORE my existing sheets.We're really confronted by two problems here. First, we have to figure out how to set the After parameter. Since it is a variant object that is supposed to represent an existing sheet, we can easily set the after parameter the same way we set xlsheet objects in LotusScript:Dim after as variant...set after = xlapp.workbooks(1).worksheets("existingsheet")Now we have our after worksheet set, but when I use the line:xlapp.workbooks(1).worksheets.Add(after)it STILL puts the worksheet before the existing sheets. this is because the "before" parameter is not optional. Instead of the above you must instead use this:xlapp.workbooks(1).worksheets.Add(NULL,after)This line will correctly set the sheet. Passing NULL to the parameter will notify the program that there is no "Before" parameter. [Note: You do not have to name the parameters "before" or "after". They can be anything you want...they just have to be in the right location in the parameter listing.]The above translation of VB's ":=" operator works for any OLE method and property that has parameters. If you see ":=" in a recorded macro's code, find out what data type you are working with (the Object Browser help file is really helpful here) and then modify the code to set the variable. Unless the value is a constant (in which case you would have to pass the actual constant value, and not the constant) this will work.A good way to think of it is that when you see ":=" it's usually the equivalent of the LotusScript keyword "Set." So if you see the ":=" operator, just figure out how you can change the line to reflect the "Set" keyword instead, like in the example above.For reference, here are some of my other posts on the subject in the last couple of weeks (as well as one from about a year ago.)sample script for Excel:http://www.notes.net/46dom.nsf/55c38d716d632d9b8525689b005ba1c0/9dd101c8a69d20ec852569af0065ad88?OpenDocument&Highlight=0,excel,brandtan explanation of the above script (most of the information duplicated here):http://www.notes.net/46dom.nsf/ShowMyTopicsAllFlatweb/ffaaf962e0e171ba85256b9000665cec?OpenDocumenta discussion on how to use the above techniques in powerpoint:http://www.notes.net/46dom.nsf/ShowMyTopicsAllFlatweb/c2d7c421890934ea85256b9c00534e4e?OpenDocumentI hope someone finds this helpful.brandt