3 ms·
This example does not look convincing: website.createUrl("styles.css").getHttpContent(60).assertContains("img.jpg"); My preference would be: var styles
by ivan_gammel 3y ago
This example does not look convincing:
website.createUrl("styles.css").getHttpContent(60).assertContains("img.jpg");
My preference would be:
var stylesheet = http.get(website.resolve(“style.css”)).asString();
assertThat(stylesheet, contains(“img.jpg”));
Why? Fluent interfaces are good as internal DSL, where semantics of calls are clear and where readability is improved, because it looks closer to the natural language. This means that subject remains the same if you use multiple verbs. Just chaining several imperative statements does not add much value and only complicates debugging.
- latchkey 3y ago.resolve seems like the wrong verb here though. What are you passing into http.get? a url, not something resolved.
- ivan_gammel 3y agoHow would you call a process of determining a correct URL for a request from a base URL and an arbitrary string? This is a quite common name for it, e.g. https://www.npmjs.com/package/resolve-url https://www.npmjs.com/package/resolve-url