1 / 31

CS 160: Software Engineering September 3 Class Meeting

CS 160: Software Engineering September 3 Class Meeting. Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak www.cs.sjsu.edu/~ mak. First Page: HTML. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head>

vaughan
Download Presentation

CS 160: Software Engineering September 3 Class Meeting

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 160: Software EngineeringSeptember 3 Class Meeting Department of Computer ScienceSan Jose State UniversityFall 2014Instructor: Ron Mak www.cs.sjsu.edu/~mak

  2. First Page: HTML <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Murach's Java Servlets and JSP</title> </head> <body> <h1>Join our email list</h1> <p>To join our email list, enter your name and email address below. <br> Then, click on the Submit button.</p> <form action="addToEmailList" method="get"> <table cellspacing="5" border="0"> <tr> <td align="right">First name:</td> <td><input type="text" name="fName"></td> </tr> <tr> <td align="right">Last name:</td> <td><input type="text" name="lName"></td> </tr> <tr> <td align="right">Email address:</td> <td><input type="text" name="eAddress"></td> </tr> <tr> <td></td> <td><br><input type="submit" value="Submit"></td> </tr> </table> </form> </body> </html> User input Static page!

  3. Dynamic Response Page Dynamically generated content!

  4. What is a Servlet? • A servlet is a Java class that extends HttpServlet. • Servlets reside on the server computer in a directory that is controlled by Tomcat. • Recall that Tomcat is our JSP/servlet engine. • A servlet object is invoked by a URL. • URL = Uniform Resource Locator (i.e., a web address) • Servlet objects run on the server computer._

  5. What is a Servlet? cont’d • When invoked, a servlet object can: • Dynamically generate HTML that will be returned to the client as part of an HTTP response. • Perform any application logic. • Access the back-end database. • Whatever – it’s Java code!_

  6. Response Page as a Servlet package email; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import business.User; import data.UserIO; public class AddToEmailListServletextendsHttpServlet { protected void doPost(HttpServletRequestrequest, HttpServletResponseresponse) throws ServletException, IOException { // Get parameters from the request. String firstName = request.getParameter("fName"); String lastName = request.getParameter("lName"); String emailAddress = request.getParameter("eAddress"); Get the data for the dynamically generated content.

  7. Response Page as a Servlet, cont’d // Send response to browser. response.setContentType("text/html;charset=UTF-8"); out.println( "<!doctype html public \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n" + "<html>\n" + "<head>\n" + " <title>Murach's Java Servlets and JSP</title>\n" + "</head>\n" + "<body>\n" + "<h1>Thanks for joining our email list</h1>\n" + "<p>Here is the information that you entered:</p>\n" + " <table cellspacing=\"5\" cellpadding=\"5\" border=\"1\">\n" + " <tr><td align=\"right\">First name:</td>\n" + " <td>" + firstName + "</td>\n" + " </tr>\n" + " <tr><td align=\"right\">Last name:</td>\n" + " <td>" + lastName + "</td>\n" + " </tr>\n" + " <tr><td align=\"right\">Email address:</td>\n" + " <td>" + emailAddress + "</td>\n" + " </tr>\n" + " </table>\n"

  8. Response Page as a Servlet, cont’d + "<p>To enter another email address, click on the Back <br>\n" + "button in your browser or the Return button shown <br>\n" + "below.</p>\n" + "<form action=\"join_email_list.html\" " + " method=\"post\">\n" + " <input type=\"submit\" value=\"Return\">\n" + "</form>\n" + "</body>\n" + "</html>\n"); out.close(); } protected void doGet( HttpServletRequestrequest, HttpServletResponseresponse) throws ServletException, IOException { doPost(request, response); } } In this example, method doGet() simply calls method doPost() and passes the request and response parameters.

  9. What is a JavaServer Page (JSP)? • A JSP is a file that looks a lot like the HTML that the web server will return to the client as part of an HTTP response. • JSPs reside on the server computer in a directory that is controlled by Tomcat. • Special tags in the file represent where dynamically-generated content will appear. • A plain HTML page is static. • A JSP represents an HTML page that is dynamically generated.

  10. What is a JavaServerPage? cont’d • A JSP is invoked by a URL. • The first time it’s invoked, a JSP is compiled by the JSP/servlet engine (e.g., Tomcat) into a servlet. • A JSP is a much easier way to code a servlet whose main purpose is to return HTML to the client. • JSPs are often coded by web page designers who know HTML but not Java._

  11. Response Page as a JSP <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Murach's Java Servlets and JSP</title> </head> <body> <!-- import packages and classes needed by the scripts --> <%@ page import="business.*, data.*, java.util.Date" %> <% // Get parameters from the request. String firstName = request.getParameter("fName"); String lastName = request.getParameter("lName"); String emailAddress = request.getParameter("eAddress"); %> Get the data for the dynamically generated content.

  12. Response Page as a JSP, cont’d <h1>Thanks for joining our email list</h1> <p>Here is the information that you entered:</p> <table cellspacing="5" cellpadding="5" border="1"> <tr> <td align="right">First name:</td> <td><%= firstName %></td> </tr> <tr> <td align="right">Last name:</td> <td><%= lastName %></td> </tr> <tr> <td align="right">Email address:</td> <td><%= emailAddress %></td> </tr> </table>

  13. Response Page as a JSP, cont’d <p>To enter another email address, click on the Back <br> button in your browser or the Return button shown <br> below.</p> <form action="join_email_list.html" method="get"> <input type="submit" value="Return"> </form> </body> </html> The first time this JSP is invoked, Tomcat will compile it into a servlet that is similar to the one you saw earlier.

  14. Unified Modeling Language (UML) • A standardized diagramming notation. • Model the structure and behavior of systems. • system = a set of interacting components • Physical, conceptual, or software components. • The system can be complex. • model = an abstraction of a system • Deal with complexity by leaving out irrelevant details. • Model object-oriented software systems. • Model real-world systems._

  15. Unified Modeling Language (UML) • Different types of UML diagrams • Class diagrams • Object diagrams • Activity diagrams • Use case diagrams • Sequence diagrams • and others ...

  16. UML Class Diagram Example #1 class “contains”“consists of” “0, 1, or more”(multiplicity) Organization * Team Team-Based Organization * Member(Participant)

  17. * Phase (Activity) “subclass of” * produces consumes * * Artifact Task Resources presents Specification Member * Presentation Design Time Review Plan Equipment Demo Code UML Class Diagram Example #2 Project

  18. Project Phases • Requirements elicitation • Design • Implementation • Testing • Deployment • Maintenance • How do we accomplish these phases?_

  19. Design Implementation Testing Ye Olde Waterfall Model Requirements

  20. The Waterfall Model, cont’d • Make sure each phase is 100% complete and absolutely correct before proceeding to the next phase. • Big Design Up Front (BDUF) • Set requirements in stone before starting the design. • Otherwise, you might waste design work on “incorrect”requirements. • Spend extra time at the beginning to make sure that the requirements and design are absolutely correct. Source: Wikipedia article on “Waterfall Model”

  21. Requirements Design Implementation Testing The Waterfall Model, cont’d • The waterfall model has been mostly discredited. • It doesn’t work! • But it’s still commonly practiced.

  22. The Agile Manifesto for Software Development We are uncovering better ways of developing software by doing it and helping others do it. Through this work we have come to value: Individuals and interactions over processes and toolsWorking software over comprehensive documentationCustomer collaboration over contract negotiationResponding to change over following a plan That is, while there is value in the items on the right, we value the items on the left more. Source: http://agilemanifesto.org/

  23. Requirements Design Implementation Testing Agile Software Development • Iterative and incremental development. • Each iteration is a “mini waterfall”: • plan (with new requirements) • refine design • add new code • unit and integration testing • Iterations are short: weeks rather than months._

  24. Agile Software Development • The initial iteration produces a conceptual design and a prototype. • Subsequent iterations refine the design and incrementally build the actual product. • Each subsequent iteration may also include a prototype that is quickly produced (rapid prototyping)._

  25. Agile Software Development, cont’d • The initial iteration Prototyping and iterative development are the foundation for Rapid Application Development (RAD) tools. • Agile methodologies range from Extreme Programming (XP) to the Rational Unified Process (RUP)._

  26. Project Phases, cont’d

  27. Project Phases, cont’d • Development is a series of iterations. • Each iteration is a “mini waterfall” consisting of design, code (implementation), and test. • Extreme programmers say: design, test, code

  28. Requirements Elicitation • Requirescommunication among the developers, clients, and users. • Clients can validate the requirements. • Creates acontract between the client and the developers. • Result: a Functional Specification that the clients can understand._

  29. Functional Requirements • What the system shall be able to do orallow users to do. • “The phone shall use GPS to determine the wearer’s location.” • “Users shall be able to choose either Option A or Option B.” • Describe the interactions between the system and its environment independent of its implementation._

  30. Nonfunctional Requirements • Usability, reliability, performance, supportability, etc. • “The system must respond to the user within 15 seconds.” • “The system shall run on Windows and Linux servers.” • “The new GUI must resemble the existing GUI.” • Constraints that the system must meet._

  31. Bridging the Gap • Clients and users • Have a general idea of what the system should do. • Have little experience with software development. • Are experts in their domain. • Software developers • May have little knowledge of the application domain. • Have experience with software technology. • Are geeks with poor social skills._

More Related