WebFund 2015W: Assignment 1: Difference between revisions

From Soma-notes
No edit summary
No edit summary
 
Line 20: Line 20:
# jQuery is normally used with client-side JavaScript because jQuery is primarily used to access and manipulate the DOM, and the DOM is only defined in a browser's JavaScript environment. [one point for client-side JS, one for the explanation]
# jQuery is normally used with client-side JavaScript because jQuery is primarily used to access and manipulate the DOM, and the DOM is only defined in a browser's JavaScript environment. [one point for client-side JS, one for the explanation]
# You could list almost any standard HTTP request header.  A few easy ones would be Accept-Encoding (tells the server what compression it can use on the returned document), Authorization (tells the server whether the requester is authorized to access the requested document).  Essentially all request headers can potentially be used by the web server to customize its responses.  Indeed, that is why they are sent to the server in the first place!  (Response headers don't make sense for this question because they are the output, not the input, of the web server.) [one point for each explanation]
# You could list almost any standard HTTP request header.  A few easy ones would be Accept-Encoding (tells the server what compression it can use on the returned document), Authorization (tells the server whether the requester is authorized to access the requested document).  Essentially all request headers can potentially be used by the web server to customize its responses.  Indeed, that is why they are sent to the server in the first place!  (Response headers don't make sense for this question because they are the output, not the input, of the web server.) [one point for each explanation]
#
# Web applications use template languages for generating HTML documents because generating HTML from scratch is awkward in standard programming languages and because it normally makes sense to separate data (page templates) from the logic of the application. [Two points for a reasonable quality explanation.]
#
# JavaScript is a loosely typed language, NOT an untyped language.  Every value has an associated type.  In an untyped language data has no inherent type.  Because JavaScript is loosely typed, a variable can hold data of any type.  Any such value, though, does have a specific type (e.g., numeric, string, object, function).  [One point for saying JavaScript is typed, one for the explanation]

Latest revision as of 17:12, 24 January 2015

Answer the following questions about the material covered in the first two weeks of lecture, Tutorial 1, the assigned lessons from Code Academy. There are 10 points in 5 questions. There is also 1 point for a bonus question. This assignment is due by 10 AM on Monday, January 19, 2015.

Please submit your answers as a single text or PDF file called "<username>-comp2406-assign1.txt" or "<username>-comp2406-assign1.pdf", where username is your MyCarletonOne username. The first four lines of this file should be "COMP 2406 Assignment 1", your name, student number, and the date. You may wish to format answers.txt in Markdown to improve its appearance. If you do so, you may convert your text file to PDF using pandoc.

No other formats will be accepted. Submitting in another format will likely result in your assignment not being graded and you receiving no marks for this assignment. In particular do not submit an MS Word or OpenOffice file as your answers document!


Questions

  1. [2] When a web browser loads a standard web page, what type of HTTP request does it make of the server? And, if the requested URL is valid, what is the standard response code?
  2. [2] Would you normally use jQuery with client side or server side JavaScript? Why?
  3. [2] Briefly explain how the values of two HTTP header fields are used by standard web servers to customize their responses. You may choose any two standard HTTP headers.
  4. [2] Why do web applications often use a separate template language to generate web pages (such as Jade) rather than using the language of the application (e.g., Java, Python, JavaScript)? (Note that PHP is an exception to this!)
  5. [2] Is JavaScript an untyped language? Explain briefly.
  6. [BONUS 1] What do you find most confusing about the material covered so far in COMP 2406? Note you do NOT get a bonus mark for saying "nothing"!

Solutions

  1. The web browser makes an HTTP GET request to load a standard web page. If the URL is valid, the response will be 200 (OK). [one point for GET, one for 200]
  2. jQuery is normally used with client-side JavaScript because jQuery is primarily used to access and manipulate the DOM, and the DOM is only defined in a browser's JavaScript environment. [one point for client-side JS, one for the explanation]
  3. You could list almost any standard HTTP request header. A few easy ones would be Accept-Encoding (tells the server what compression it can use on the returned document), Authorization (tells the server whether the requester is authorized to access the requested document). Essentially all request headers can potentially be used by the web server to customize its responses. Indeed, that is why they are sent to the server in the first place! (Response headers don't make sense for this question because they are the output, not the input, of the web server.) [one point for each explanation]
  4. Web applications use template languages for generating HTML documents because generating HTML from scratch is awkward in standard programming languages and because it normally makes sense to separate data (page templates) from the logic of the application. [Two points for a reasonable quality explanation.]
  5. JavaScript is a loosely typed language, NOT an untyped language. Every value has an associated type. In an untyped language data has no inherent type. Because JavaScript is loosely typed, a variable can hold data of any type. Any such value, though, does have a specific type (e.g., numeric, string, object, function). [One point for saying JavaScript is typed, one for the explanation]