nashdl / bookclub

Notes/Discussions for NashDL Book Club
8 stars 4 forks source link

Value Objects #5

Closed vinbarnes closed 10 years ago

vinbarnes commented 10 years ago

There was a good discussion of Value Objects during the meetup today. Here are my quick and dirty notes that missed a lot of the finer points of the discussion. Please add your notes/thoughts.

kamarcum commented 10 years ago

I meant to ask @jfryman whether puppet has enough OO kicking around to do Value Objects.

This also reminded me of Avdi's recent post on Erlang. One of his takeaways was essentially that Value Objects help with discoverability of functionality.

I believe a good example of Value Objects being taken a bit too far is the Apache HttpClient. An example (credit: http://www.mkyong.com/java/apache-httpclient-examples/):

HttpPost post = new HttpPost(url);

    // add header
    post.setHeader("Host", "accounts.google.com");
    post.setHeader("User-Agent", USER_AGENT);
    post.setHeader("Accept", 
             "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
    post.setHeader("Accept-Language", "en-US,en;q=0.5");
    post.setHeader("Cookie", getCookies());
    post.setHeader("Connection", "keep-alive");
    post.setHeader("Referer", "https://accounts.google.com/ServiceLoginAuth");
    post.setHeader("Content-Type", "application/x-www-form-urlencoded");

    post.setEntity(new UrlEncodedFormEntity(postParams));

    HttpResponse response = client.execute(post);

    int responseCode = response.getStatusLine().getStatusCode();
       //snip
bval commented 10 years ago

Puppet's abstraction of providers is a good example of a value object. When writing puppet you don't want to make implicit in your domain knowledge of how to install a package, so you delegate that to a package provider value object.

arafatm commented 10 years ago

I meant to bring this up again in the live discussion. However, I think we flogged it sufficiently in the intitial discussion.