Hons. B.Sc. Degree in Software Engineering/Development Web and Cloud Development Summer 2012 Instructions to candidates: Answer any four questions all questions carry equal marks. Start your answer at the top of a new page in your answer booklet. Be sure to read each question carefully, noting the marks allocated to each part. Software Engineering/Software Development Page 1 of 5 Summer 2012
Question 1. (a) The MVC pattern is generally regarded as the best model to follow when doing web development. Describe each of the components of MVC in general, then relate each MVC component to Google's App Engine technology in particular. [9] (b) What is a templating system, and what benefits can it bring to a web-based development effort (identify 2 benefits). Illustrate your answer with a small example snippet of code. [5] (c) How does a templating system relate to the MVC pattern? [1] (d) Identify and describe five differences between traditional SQL-based storage technologies (such as MySQL) and the App Engine DataStore. [10] Question 2. (a) Moving to a cloud computing infrastructure is a no-brainer. If you are involved in a web development project that includes a significant big-data component, then the cloud is the only way to go. The age of do-everything, roll-your-own web development efforts is over. You are to provide two one-page arguments relating to the above statement. The first is to present an argument in favour of the statement, while the second is to present an argument against the statement. Be sure to justify the points you make with examples where appropriate. [20] (b) With reference to a cloud computing technology that you know, identify three advantages to using the technology, as well as two disadvantages. [5] Question 3. (a) Provide a brief description of each of following technologies, being sure to clearly indicate the role played by the technology as it relates to web development: 1. JavaScript 2. HTML5 3. CSS3 4. JSON [12] (b) With reference to the Python programming language, describe a possible alternative to the standard JSON technology. Be sure to discuss and describe one disadvantage and one advantage of the Python technology (with reference to JSON). [6] (c) Provide a brief description of what you believe to be the most important additions to the HTML standards as manifested in HTML5. [6] (d) Describe how does JavaScript relates to HTML5. [1] Software Engineering/Software Development Page 2 of 5 Summer 2012
Question 4. (a) Consider the following source code (where the line-numbers are for illustration purposes only): 1. import cgi 2. import datetime 3. import urllib 4. import webapp2 5. from google.appengine.ext import db 6. from google.appengine.api import users 7. class Greeting(db.Model): 8. author = db.userproperty() 9. content = db.stringproperty(multiline=true) 10. date = db.datetimeproperty(auto_now_add=true) 11. def guestbook_key(guestbook_name=none): 12. return db.key.from_path('guestbook', guestbook_name or 'default_guestbook') 13. class MainPage(webapp2.RequestHandler): def get(self): self.response.out.write('<html><body>') 14. guestbook_name=self.request.get('guestbook_name') 15. greetings = db.gqlquery("select * " "FROM Greeting " "WHERE ANCESTOR IS :1 " "ORDER BY date DESC LIMIT 10", guestbook_key(guestbook_name)) 16. for greeting in greetings: if greeting.author: self.response.out.write('<b>%s</b> wrote:' % greeting.author.nickname()) else: self.response.out.write('an anonymous person wrote:') 17. self.response.out.write('<blockquote>%s</blockquote>' % cgi.escape(greeting.content)) 18. self.response.out.write(""" <form action="/sign?%s" method="post"> <div><textarea name="content" rows="3" cols="60"></textarea></div> <div><input type="submit" value="sign Guestbook"></div> </form> <hr> <form>guestbook name: <input value="%s" name="guestbook_name"> <input type="submit" value="switch"></form> </body> </html>""" % (urllib.urlencode({'guestbook_name': guestbook_name}), cgi.escape(guestbook_name))) 19. class Guestbook(webapp2.RequestHandler): def post(self): 20. guestbook_name = self.request.get('guestbook_name') greeting = Greeting(parent=guestbook_key(guestbook_name)) if users.get_current_user(): 21. greeting.author = users.get_current_user() 22. greeting.content = self.request.get('content') 23. greeting.put() 24. self.redirect('/?' + urllib.urlencode({'guestbook_name': guestbook_name})) 25. app = webapp2.wsgiapplication([('/', MainPage), ('/sign', Guestbook)], debug=true) Provide a detailed description for each of the numbered statements (and be sure to note that some statements extend over a number of lines). [25] Software Engineering/Software Development Page 3 of 5 Summer 2012
Question 5. (a) With reference to non-relational database technologies (also known as NoSQL ), provide a brief description for each of the following NoSQL terms: 1. Document 2. Schema-less Structure 3. Collection [3] (b) Why do you think NoSQL database technologies are particularly associated with web-based applications? [2] (c) Consider the following Python code (where the line-numbers are for illustration purposes only) and answer the questions at the bottom of this page: 1. import sys 2. from datetime import datetime 3. from pymongo import Connection 4. from pymongo.errors import ConnectionFailure 5. def main(): 6. try: 7. c = Connection(host="localhost", port=27017) 8. except ConnectionFailure, e: 9. sys.stderr.write("could not connect to MongoDB: %s" % e) 10. sys.exit(1) 11. dbh = c["mydb"] 12. assert dbh.connection == c 14. user_doc = { 15. "username" : "janedoe", 16. "firstname" : "Jane", 17. "surname" : "Doe", 18. "dateofbirth" : datetime(1974, 4, 12), 19. "email" : "janedoe74@example.com", 20. "score" : 0 21. } 22. dbh.users.insert(user_doc, safe=true) 23. print "Successfully inserted document: %s" % user_doc 24. if name == " main ": 25. main() 1. What is the significance of the port=27017 part of line 7? [2] 2. Describe what line 11 does. [3] 3. Why do you think the programmer has included an assertion on line 12? [2] 4. What is the generic Python name for the data structure on lines 14-21 and what does this data structure correspond to within a MongoDB database? [3] 5. On line 22 the programmer has chosen to use insert() to add data to his collection. What other method could the programmer have used for this purpose? [2] 6. Staying with line 22, what is the purpose of the safe=true parameter? [2] 7. What could happen if the safe=true parameter was removed from line 22? [3] 8. What impact does the code on lines 24-25 have on this program's behaviour? [3] Software Engineering/Software Development Page 4 of 5 Summer 2012
Question 6. (a) You have been hired by a small software development company that specializes in building one-off custom network-based applications using Java and Oracle technologies. Like a lot of companies of its type, it has decided to move it's product offerings to a more web and Internet-focused platform. The company's management has decided to target a programming technology platform that is based on Python, JavaScript, HTML5/CSS3 and MongoDB. You have been asked to prepare a presentation to be delivered to the company's programming staff which highlights the benefits of moving to this new platform. Provide the content that you would put on each of the slides of your presentation, as well as any notes that you would include when delivering your talk. Note that you are expected to have at least 10 slides. [20] (b) The company has asked you to recommend either Python 2 or Python 3 as their main target server-side programming technology. Indicate your recommendation, and support it with five reasons for your choice. [5] Software Engineering/Software Development Page 5 of 5 Summer 2012