0

Please correct me if I am misunderstanding the two concepts. Polymorphism seems to be representing an object in many forms, such that user could be a base class and student or teacher would be a subclass. They would still be of the type user, but have their own implementations. An Interface provides an outline for interacting with a base class from a subclass. Polymorphism can be used in conjunction with an Interface and can sometimes be necessary.

With that understanding, I am creating an add-on to an existing learning management system. It has its own libraries to interact with different object such as users, grades, or course information. Some of the objects from the libraries are coupled with other objects from the library to be instantiated or produce a value. An example is needing the course ID number to get grade information. The API for the libraries are vague or none existent. Would Polymorphism and/or an Interface make it easier to use these libraries in my project even though I am not so sure about the API? What would unit testing be like using Polymorphism and/or an Interface on this type of project? In general, what is the best practice when developing with third party libraries that have poor documentation?

eparham7861
  • 205
  • 3
  • 12

2 Answers2

0

The Blackboard Building Block APIs are meant to be instantiated and methods called to access data. There are instances when extending a Blackboard class make sense, but in general, they simply exist to give you access to data.

In full disclosure, I work for Blackboard and I recently joined the documentation team to help continue to build out the Developer Documentation and Resources section at https://help.blackboard.com.

There are a number of documents available under Learn->Administrator->April Release->Developer Resources. We also hold Developer Office Hours every other Wednesday at 11am EDT. The Community folder under Developer Resources will give you the information you need to join. They are free and open to anyone.

0

Would Polymorphism and/or an Interface make it easier to use these libraries in my project even though I am not so sure about the API?

Not really, the documentation around an API and the API's deisgn are the primary ways an API becomes easier to use. Using an API is a learning task, and the documentation is like a good tutorial or lesson while improvements in the API design is like simplifying the material to be learned.

What would unit testing be like using Polymorphisim and/or an Interface on this type of project?

For the most part, the unit testing would be similar, in the sense you would call a method, or several methods on an object and check the results.

Using Polymorphisim, you mostly test the classes at the bottom of the inheritance tree, using an Interface, again you mostly test the classes at the bottom of the inheritance tree. That is because you really cannot instantiate an abstract class or an interface in a way that makes sense when unit testing.

In general, what is the best practice when developing with third party libraries that have poor documentation?

In general, the best practice is to write small pieces of code that validate your assumptions, and then running them to see if your assumptions are correct about how you think their library works.

Other techniques include downloading the library's source code and reading it, if it is available. Writing Unit tests to "test the library" can be of use in this manner, but sometimes the library is not structured nicely to make this easy.

Sometimes the documentation is available by other means, for example by purchasing a book that introduces you to the library. Sometimes you can take "training" classes from the vendor of the library. Sometimes you can find other people who are using the library and ask them questions (this often includes library specific user groups or mailing lists). Sometimes you have access to the library's bug tracking system and can find details from the bug submissions (or the rejections of bug submissions which indicate the proper way to use a function, etc). Sometimes you can find other projects using the same library and read their source code to determine usage patterns that seem to work.

Libraries are typically written to be used, but not everyone is as good at writing a library to be used. Sometimes the authors provide the information and you just don't know where it is, other times the authors lack the necessary ability to have a different point of view and never show you how to use it effectively. Generally, libraries that are far too hard to use get used very little, and eventually are forgotten and unused.

Edwin Buck
  • 69,361
  • 7
  • 100
  • 138
  • Polymorphisim and Inheritance go hand-in-hand, and are two aspects of object-oriented programming, not to replaceable technologies. Sort of like color and height are not replacements for each other. To get polymorphic behavior, you generally use something in an abstract way but it behaves in a specific way. You use it in an abstract way `animal.makeSound()` which requires Inheritance, and it behaves specifically (since `new Dog()` was assigned to animal, `animal.makeSound()` made the sound `bark` instead of `moo`. – Edwin Buck Apr 04 '15 at 15:40