ICS 32 Fall 2018 |??|??|??|??|??|?
ICS 32 Fall 2018
Project #3:?Jack of All Trades
Due date and time:?Wednesday, November 14, 11:59pm
This project is to be done individually
We saw in the previous project that our Python programs are capable of connecting to the “outside world” around them — to other programs running on the same machine, or even to other programs running on different machines in faraway places. This is a powerful thing for a program to be able to do, because it is no longer limited to taking its input from a user or from a file stored locally; its input is now potentially anything that’s accessible via the Internet, making it possible to solve a vast array of new problems and process a much broader collection of information. Once you have the ability to connect your programs to others, a whole new world opens up. Suddenly, the idea that you should be able to write a program that combines, say, Google search queries, the Internet Movie Database, and your favorite social network to find people who like movies similar to the ones you like doesn’t seem so far-fetched.
But we also saw that getting programs to share information is tricky, for (at least) two reasons. Firstly, there’s a software engineering problem: A protocol has to be designed that both programs can use to have their conversation. Secondly, there’s a social problem: If the same person (or group of people) isn’t writing both programs, it’s necessary for them to agree on the protocol ahead of time, then to implement it. This second problem has a potentially catastrophic effect on our ability to make things work — how could you ever convince Google to agree to use your protocol just to communicate with you?
In practice, both of these problems are largely solved by the presence of?standards, such as those defined by the??and the?. Standards help by providing detailed communication protocols whose details have already been hammered out, with the intention of handling the most common set of needs that will arise in programs. This eliminates the need to design one’s own protocol (where the standard protocols will suffice, which is more often than you might think) and allows programs to be combined in arbitrary ways; as long as they support the protocol, they’ve taken a big step toward being able to interoperate with each other. What’s more, standard protocols often have standard implementations, so that you won’t have to code up the details yourself as you did in the previous project. For example, Python has built-in support for a number of standard Internet protocols, including HTTP (HyperText Transfer Protocol, the protocol that your browser uses to download web pages) among others.
At first blush, HTTP doesn’t seem all that important. It appears to be a protocol that will allow you to write programs that download web pages (i.e., that allow you to write programs that play the same role that web browsers do). But it turns out that HTTP is a lot more important than that, since it is the protocol that underlies a much wider variety of traffic on the Internet than you might first imagine. This is not limited only to the conversation that your browser has with a web server in order to download a web page, though that conversation most often uses HTTP (or its more secure variant, HTTPS). HTTP also underlies a growing variety of program-to-program communications using web protocols, where web sites or other software systems communicate directly with what are broadly called?web services, fetching data and also making changes to it. This is why you can post tweets to Twitter using either their web site, a client application on your laptop, or a smartphone app; all of these applications use the same protocol to communicate with the Twitter service, differing only in the form of user interface they provide.
Fortunately, since HTTP support is built directly into Python, we can write programs that use these web services without having to handle low-level details of the protocol, though there are some details that you’ll need to be familiar with if you want to use the provided implementation effectively. We’ll be discussing some of these details in lecture soon, and these will be accompanied by a?, which will give you some background in the tools you’ll need to solve these kinds of problems in Python.
This project gives you the opportunity to explore a small part of the vast sea of possibilities presented by web APIs and web services. You’ll likely find that you spend a fair amount of your time in this project understanding the web API you’ll need — being able to navigate technical documentation and gradually build an understanding of another system is a vital skill in building real software — and that the amount of code you need might not be as much as you expect when you first read the project write-up. As always, work incrementally rather than trying to work on the entire project all at once; there is partial credit available for a partial solution, as long as the portions that you’ve finished are stable and correct. When you’re done, you’ll have taken a valuable step toward being able to build Python programs that interact with web services, which opens up your ability to write programs for yourself that are real and useful.
Additionally, you’ll get what might be your first experience with writing classes in Python, which will broaden your ability to write clean, expressive Python programs, a topic we’ll continue revisiting and refining throughout the rest of this course. Along with that, you’ll learn about why it can be a powerful technique to write multiple, similar classes in a way that leaves them intentionally identical in at least one aspect.