Lecture 9.1 (March 22)
- Return Quiz 2
- Overall scores not as bad as it sounds like people feared
- We will be dropping lowest quiz
- Quiz 3 is on Thursday
- P1 and P2 grades are up
- A1 is b0rken.
I understand that there's a fair amount of ‘what are we doing?’.
For one thing, we're running very high on the abstraction stack. A lot of your future work will be at a high level like this.
Also, lectures are not enough to learn. They cannot be.
- Read the Wiley textbooks
- Read the documentation
The documentation is not an afterthought, or just supplemental material. In order to succeed in programming, and in this class, you need to read it. Fortunately, several of the tools we are using have very good documentation.
Sadly, others do not.
I'm happy to spend time in lecture or office ours talking about points that are confusing in the docs.
Where are we at?
- Python and Flask
- Serving over HTTP
- Storing data in the database
Review Data Storage and Access
Look at the Python code from ‘animals’ about how to work with relationships.
- backref creates a field on the other object
Refresh how to add and save objects.
We can't store lists directly in a field — limitation of the relational database model underlying SQL.
We need to use multiple tables and relationships.
Example: tags, like for a blog post
- add tags to the Animal example
Like Python, variables have no types.
Unlike Python, variables must be declared (if you don't, it works, but is probably not what you intend).
Useful tool: JSHint will check your code for common problems.
- Continued improvements, some in engines, others standardized
The most recent version of the standard is ES6 (ECMAScript version 6.0, 2015). This provides a number of nice features. Two particularly useful ones:
- arrow functions make it easier to write inline functions
classprovides more familiar syntax for defining object behavior
However, these features are still missing from key browsers, so we can't depend on them in the production Web yet, and we're not going to mess with transpilers for this class.
We have an exam on Thursday!
- Review past material! (URLs, HTTP, CSS, HTML)
- Cookies and sessions
- What does it mean that HTTP is stateless?
- How do cookies and sessions deal with that?
- Data storage
- How do you create and add an object?
- CSRF tokens
- Hashing passwords (use bcrypt, PB-KDF2, or scrypt)