Top Banner
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
31

CS 160: Software Engineering September 3 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak mak.

Jan 17, 2016

Download

Documents

Flora Carroll
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript

CS 160: Software Engineering

CS 160: Software EngineeringSeptember 3 Class MeetingDepartment of Computer ScienceSan Jose State University

Fall 2014Instructor: Ron Makwww.cs.sjsu.edu/~mak

Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak2

First Page: HTML

Murach's Java Servlets and JSP

Join our email list To join our email list, enter your name and email address below.
Then, click on the Submit button. First name: Last name: Email address:

User inputStatic page!Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak3Dynamic Response Page

Dynamically generated content!Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. MakWhat 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._4Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. MakWhat is a Servlet? contdWhen 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 its Java code!_5Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak6Response Page as a Servletpackage email;

import java.io.*;import javax.servlet.*;import javax.servlet.http.*;

import business.User;import data.UserIO;

public class AddToEmailListServlet extends HttpServlet{ protected void doPost(HttpServletRequest request, HttpServletResponse response) 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 datafor the dynamicallygenerated content.Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak7Response Page as a Servlet, contd// Send response to browser.response.setContentType("text/html;charset=UTF-8");out.println( "\n" + "\n" + "\n" + " Murach's Java Servlets and JSP\n" + "\n" + "\n" + "Thanks for joining our email list\n" + "Here is the information that you entered:\n" + " \n" + " First name:\n" + " " + firstName + "\n" + " \n" + " Last name:\n" + " " + lastName + "\n" + " \n" + " Email address:\n" + " " + emailAddress + "\n" + " \n" + " \n"

Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak8Response Page as a Servlet, contd + "To enter another email address, click on the Back
\n" + "button in your browser or the Return button shown
\n" + "below.\n" + "\n" + " \n" + "\n" + "\n" + "\n"); out.close(); } protected void doGet( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); }}

In this example, method doGet() simply calls method doPost()and passes the request and response parameters.Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak9What 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.

Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak10What is a JavaServer Page? contdA JSP is invoked by a URL.

The first time its 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._Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak11Response Page as a JSP

Murach's Java Servlets and JSP

Get the datafor the dynamicallygenerated content.Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak12Response Page as a JSP, contdThanks for joining our email list

Here is the information that you entered:

First name: Last name: Email address:

Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak13Response Page as a JSP, contd To enter another email address, click on the Back
button in your browser or the Return button shown
below.

The first time this JSP isinvoked, Tomcat will compile it into a servletthat is similar to the oneyou saw earlier.Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak14Unified Modeling Language (UML)A standardized diagramming notation.

Model the structure and behavior of systems.

system = a set of interacting componentsPhysical, conceptual, or software components.The system can be complex.

model = an abstraction of a systemDeal with complexity by leaving out irrelevant details.Model object-oriented software systems.Model real-world systems._Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak15Unified Modeling Language (UML)Different types of UML diagrams

Class diagramsObject diagramsActivity diagramsUse case diagramsSequence diagramsand others ...Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak16UML Class Diagram Example #1OrganizationTeamMember(Participant)**containsconsists of0, 1, or more(multiplicity)classTeam-BasedOrganizationComputer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak17UML Class Diagram Example #2ProjectPhase(Activity)*DemoReviewMemberTimeEquipmentSpecificationDesignPlanCode*ArtifactproducesResources*consumesTask*Presentationpresents*subclass ofComputer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak18Project PhasesRequirements elicitationDesignImplementationTestingDeploymentMaintenance

How do we accomplish these phases?_Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak19Ye Olde Waterfall ModelRequirementsDesignImplementationTestingComputer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak20The Waterfall Model, contdMake 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 ModelComputer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak21The Waterfall Model, contdThe waterfall model has been mostly discredited.

It doesnt work!But its still commonly practiced.

RequirementsDesignImplementationTestingComputer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak22The Agile Manifesto for Software DevelopmentWe 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 tools Working software over comprehensive documentation Customer collaboration over contract negotiation Responding 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/Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak23Agile Software DevelopmentIterative and incremental development.

Each iteration is a mini waterfall:

plan (with new requirements)refine designadd new codeunit and integration testing

Iterations are short: weeks rather than months._

RequirementsDesignImplementationTestingComputer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak24Agile Software DevelopmentThe 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)._Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak25Agile Software Development, contdThe 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)._Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak26Project Phases, contd

Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak27Project Phases, contdDevelopment is a series of iterations.Each iteration is a mini waterfall consisting of design, code (implementation), and test.Extreme programmers say: design, test, code

Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak28Requirements ElicitationRequires communication among the developers, clients, and users.

Clients can validate the requirements.

Creates a contract between the client and the developers.

Result: a Functional Specification that the clients can understand._

Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak29Functional RequirementsWhat the system shall be able to do or allow users to do.

The phone shall use GPS to determine the wearers 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._Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak30Nonfunctional RequirementsUsability, 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._Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak31Bridging the GapClients and usersHave a general idea of what the system should do.Have little experience with software development.Are experts in their domain.

Software developersMay have little knowledge of the application domain.Have experience with software technology.Are geeks with poor social skills._Computer Science Dept.Fall 2014: September 3CS 160: Software Engineering R. Mak