All entries tagged with polymorphism
Of all the terms in programming I think polymorphism is one of the coolest. While I cannnot include eclipse plug-in developer on my resume, I think being able to feature a cool term like polymorphism on my resume must be worth an extra $10 for my hourly rate!!!
Polymorphism is a common feature available in most object oriented programming languages such as java, c#, and VB.Net. Search the Domino designer help and you will not find any mentions of this term. In the limited coverage given to classes there are no hints as to polymorphism being available. And yet, it does seem that LotusScript can perform a limited amount of polymorphism.
If you are a LotusScript developer you may not have had the need to ever understand polymorphism (even if it did add $10 to your hourly rate). Consider a simple HR database such as the following:-
Class Person ' ... End Class
Class Associate As Person ' ... End Class
Class Contractor As Person ' ... End Class
Class Manager As Associate ' ... End Class I could read a document from a Notes HR-related database and then assign it to a variable that is any one of the above classes. But what if I then wanted to start treating that variable like it belonged to one of the related classes? In C# this can be achieved using casting. It turns out that with LotusScript that the following code is possible:-
Dim Employee As Person Set Employee = New Person(Doc) Call Employee.Update() Set Employee = New Manager(Doc) Call Employee.Update() In the above... The first time the Update method is invoked it will call the method defined in the Person class. The second time the update method is called it invokes the method defined in the Manager class (assuming it exists). There are some limitations with this approach. In particular, the properties/methods must all be defined in the base class.
The .Domino Framework provides 100+ custom classes defined so the need for polymorphism does arise periodically and will now be implemented using the above technique (for no other reason than to add polymorphism to my resume).
|
Ratings
0
|