In simple terms, "its made programming fun again", and with that, I am applying this new knowledge to my projects.
I realize Java is not a fully functional language, like Clojure, Haskell or even Scala; however, it has some functional aspects that get you moving in the functional language direction without having to make a programming change, while trying to understand the new paradigm.
The example below, the getFile function takes a WebDriver and returns a File, while using a predicate to test the instance of the driver. Base on the outcome, an additional function is called accepting the driver and returns a File.
Function<WebDriver,File> getFile = driver -> instanceOfRemoteDriver.test(driver) ? remoteDriverScreenshotFile.apply(driver) : webDriverScreenshotFile.apply(driver); |
As this shift continues to grow and gather momentum, Java automation engineers will start to feel the pressure to make a change. In my observations, QA automation engineers tend to lag behind the latest trends within his/her respected language. With that said, I created a GitHub project to share ideas and concepts around functional programming using Java and WebDriver (and in the future Scala).
Examples can be found @ functional-programming-selenium-examples
http://images.techhive.com/images/article/2014/03/first-class-functions-1-100251684-medium.idge.png
http://images.techhive.com/images/article/2014/03/first-class-functions-1-100251684-medium.idge.png
No comments:
Post a Comment