I am experiencing the pain of developing an API based on (Selenium2) Webdriver and here is my dilemma.
I have basically 4 packages:
com.example.qa.pageobject
com.exmaple.qa.setup
com.example.qa.test
com.example.qa.utils
In com.example.qa.test, i have test classes that “USE” classes from other packages.
I am ending up in the following test method.
@Test
public void testScenario16786() {
Login login = new Login();
login.setUp();
AddSingleDomain asd = new AddSingleDomain();
asd.addSingleDomain();
AddARecord ar = new AddARecord();
ar.AddARecordTest();
}
Now, this seems to be a very bad example of developing in Java, which almost seems procedural. Is there any other way of doing it ? Are there some RULES that i need to be aware of while designing an API, which will be used by others ? i am sure that this is somewhat of a classical problem and has been solved before, i just want to know what are the many ways of resolving this, like:
One resolution, could be to use Factory Pattern, and based on a key, a specific class is instantiated, which is good but is there a more elegant way ?
You might find the presentation “How to Design a Good API & Why it Matters” by Joshua Bloch to be helpful.