Aug. 19th, 2013
the way I code these days
Aug. 19th, 2013 11:51 am// returning value = withSelector("body", 1) { // waits until <body> is available on the page FillFormField("body", "#FilterUC_hdn_Fromdate", yearAgoAsString). withErrorMessage("The page is in bad shape, could not set From Date") <*> withSelector("body", 1) {// takes forever to boot FillFormField("body", "#FilterUC_hdn_Todate", todayAsString). withErrorMessage("The page is in bad shape, could not set To Date") } }
What happens here:
-
withSelector
waits for the element to load (in this case body
is kind of trivial to wait); why do I need it? bad web design, they refresh the page on every form field change...- and then it calls the method in curlies; result is of type
Result[String]
- the call
.withErrorMessage
means that we add an explanation to possible errors;- the same thing happens for another element
- two results are blended ("tensor product", omfg) via <*>, which means that:
if both are good, we have
Good(("OK","OK"))
, otherwise we have
Bad(...)
with a list of error messages inside (with provided explanations);Questions? Obvious? Funny? Weird?
I just love this style. But if you think there's a better form of expressing things...
Take 2:
whenSelectorAvailable("body", 1) { // waits until <body> is available on the page FillFormField("body", "#FilterUC_hdn_Fromdate", yearAgoShortString). orCommentTheError("The page is in bad shape, could not set From Date") } <*> whenSelectorAvailable("body", 1) {// takes forever to boot FillFormField("body", "#FilterUC_hdn_Todate", todayShortString). orCommentTheError("The page is in bad shape, could not set To Date") }
the first mention of Scala?
Aug. 19th, 2013 04:05 pm"
Thinking in Scala
Bill Clementson made a catalog of a weblog called THECLAPP. I suspect that it's an acronym, but haven't puzzled it out. The "CL" part is probably for Common Lisp. The author of that weblog was going through Bruce Eckel's "Thinking in Java" and doing the exercises in both Java and Common Lisp. Maybe I can make the time to do something similar in Scala."
This is year 2004, ancient history more or less.
Thinking in Scala
Bill Clementson made a catalog of a weblog called THECLAPP. I suspect that it's an acronym, but haven't puzzled it out. The "CL" part is probably for Common Lisp. The author of that weblog was going through Bruce Eckel's "Thinking in Java" and doing the exercises in both Java and Common Lisp. Maybe I can make the time to do something similar in Scala."
This is year 2004, ancient history more or less.