Home > Uncategorized > daily 05/16/2015

daily 05/16/2015

    • Chapter 3: Data Formats
    • Many new APIs have adopted JSON as a format because it’s built on the popular Javascript programming language, which is ubiquitous on the web and usable on both the front- and back-end of a web app or service. JSON is a very simple format that has two pieces: keys and values. Keys represent an attribute about the object being described. A pizza order can be an object. It has attributes (keys), such as crust type, toppings, and order status. These attributes have corresponding values (thick crust, pepperoni, and out-for-delivery).
    • Sometimes, you want to use an object as the value for a key. Let’s extend our pizza order with customer details so you can see what this might look like:


      • The key terms we learned were:



        • JSON: JavaScript Object Notation

        • Object: a thing or noun (person, pizza order…)

        • Key: an attribute about an object (color, toppings…)

        • Value: the value of an attribute (blue, pepperoni…)

        • Associative array: a nested object

        • XML: Extensible Markup Language

    • Computers have a similar etiquette, though it goes by the term “protocol.” A computer protocol is an accepted set of rules that govern how two computers can speak to each other
    • Communication in HTTP centers around a concept called the Request-Response Cycle. The client sends the server a request to do something. The server, in turn, sends the client a response saying whether or not the server could do what the client asked.
    • APIs extend this idea a bit further to include nouns like customers, products, and tweets. In doing so, URLs become an easy way for the client to tell the server which thing it wants to interact with. Of course, APIs also do not call them “things”, but give them the technical name “resources.”
      • The four methods most commonly seen in APIs are:



        • GET – Asks the server to retrieve a resource

        • POST – Asks the server to create a new resource

        • PUT – Asks the server to edit/update an existing resource

        • DELETE – Asks the server to delete a resource


    • Here’s an example to help illustrate these methods. Let’s say there is a pizza parlor with an API you can use to place orders. You place an order by making a POST request to the restaurant’s server with your order details, asking them to create your pizza. As soon as you send the request, however, you realize you picked the wrong style crust, so you make a PUT request to change it.


      While waiting on your order, you make a bunch of GET requests to check the status. After an hour of waiting, you decide you’ve had enough and make a DELETE request to cancel your order.

    • The status code behind this response is 404, which means “Not Found.” Whenever the client makes a request for a resource that does not exist, the server responds with a 404 status code to let the client know: “that resource doesn’t exist, so please don’t ask for it again!”
    • This versatility in the HTTP protocol extends to other parts of a request, too. Some APIs require a particular header, while others require specific information inside the request body. Being able to use APIs hinges on knowing how to make the correct HTTP request to get the result you want.
    • If all goes well, the U.S. Air Force’s mysterious X-37B will blast off into space for the fourth time on May 20. But for the first time, they’re actually telling us what the space plane will be doing—well, some of it anyway.


    • LINQ is in most cases a significantly more productive querying language than SQL.
    • Another benefit of LINQ is that you can query across relationships without having  to join. For instance, suppose we want to list all purchases of $1000 or greater made  by customers who live in Washington. To make it interesting, we’ll assume purchases are  itemized (the classic Purchase / PurchaseItem scenario) and that we also want to include cash sales (with no customer).  This requires querying across four tables (Purchase, Customer, Address and PurchaseItem). In LINQ,  the query is effortless:
    • tuples
    • forced   denormalization is often undesirable:
    • For example, suppose we want to retrieve  a selection of customers, each with their high-value purchases. In LINQ, you can do this:

Posted from Diigo. The rest of my favorite links are here.

Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: