辅导案例-3815ICT

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
2805ICT: System and Software Design
3815ICT Software Engineering
7805ICT Principles of Software Engineering
Workshop 07
Vladimir Estivill-Castro
Larry Wen
August 31, 2019
Objectives
1. Review software patterns in the context of web architecture.
2. Identify fundamental challenges of web architectures.
3. Review a MVC-framework for Web-architectures.
4. Discuss the issues regarding web architectures.
Software Patterns
Activity 1
Study the entry in Wikipedia for the “Command pattern”
(en.wikipedia.org/wiki/Command_pattern).
Review the following piece of code. Explain why this represents an anti-pattern:
if (op==1)
{ User u = new User( request.getAttribute("user"), request.getAttribute("pass"));
}
else if (op==2)
{ ... }
...
What are the disadvantages of the template suggested by the anti-pattern above?
1
Activity 2
Examine the code below that defines an abstract class. What part of the Command pattern
does this achieve? What does the constructor achieve?
//Action.java
public abstract class Action
{
protected Model model;
public Action(Model model)
{
this.model = model;
}
public abstract String getName();
public abstract Object perform(HttpServletRequest req);
}
Activity 3
Examine the code below that defines a concrete class. What part of the Command pattern
does this achieve? What does the constructor achieve? Explain the method getName().
// CreateUserAction.java:
public class CreateUserAction extends Action
{
public CreateUserAction(Model model)
{
super(model);
}
public String getName()
{
return "createUser";
}
public Object perform(HttpServletRequest req)
{
return model.createUser(req.getAttribute("user"),req.getAttribute("pass"));
}
}
Activity 4
Examine the code below that defines a concrete class. What part of the Command pattern
does this achieve? Is this linked to some part of MVC?
public class ControllerServlet extends HttpServlet {
private HashMap actions;
public void init() throws ServletException {
actions = new HashMap();
CreateUserAction que = new CreateUserAction(model);
actions.put(que.getName(), que);
//... create and add more actions
}
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws IOException, ServletException {
// First identify operation "op" from URL.
// method getOperation() is defined elsewhere.
String op = getOperation(req.getRequestURL());
// Then find and execute corresponding Action
Action action = (Action)actions.get(op);
Object result = null;
try {
result = action.perform(req);
} catch (NullPointerException npx) { ... }
//determine next view result to determine next view
}
...
}
2
Web Architecture
Activity 5
Study the short entry in Wikipedia for the “Stateless protocol”
(en.wikipedia.org/wiki/Stateless_protocol).
Research the concept of session and discuss what are the implications that the HTTP
protocol of the Web is stateless with respect to sessions?
Activity 6
Frameworks for Web architectures are very varied. Even for Java Server pages there are
several variants. Browse over the chapter “The Spring Web MVC Framework” (available
at Learning@GU).
Identify 4 advantages that this chapter attributes to the Spring Web MVC Framework.
Activity 7
Attempt to complete the tutorial named “Introduction to Spring Web MVC”
(netbeans.org/kb/docs/web/quickstart-webapps-spring.html)
This tutorial can be followed with almost no background on Java Server Pages (JSP) or
java beans. Although learning about such technologies might be useful. The point of
competing such exercise is for you to experience a Web architecture based around Model
View Controller (MVC). In particular, several of the components are configured by setting
properties in XML-files, for example.
I recommend you follow this tutorial using NetBeans. You will probably find that you
should install some plug-ins so you can complete the tutorial. If you are trying to find
the category "java Web" to create a project of type "Web Application" you probably are
missing the “java EE Base”, and if you find that after creating some project you are
missing some libraries (a message about resources missing), you probably need the "EJB
and EAR" plug-in.
Similarly, as you develop the project, you will need a WEB server that support Java beans.
Chose the GlassFish server, and if it is not installed, NetBeans will fetch it and install it
for you.
The entire project will be made available for you in Learning@GU, but it is important
you attempt to follow the tutorial yourself. Also, you should introduce debugging print
statements so you can follow some of what is going on. The challenge is, how would you
represent the behavior with an UML sequence diagram?
Additional exercises for 3815ICT and 7805ICT
These activities do not earn specific marks, thy enable the marking; that is, if they are not completed
the assessment item is awarded zero regardless of the performance in the previous activities.
Activity 8 Write 15 lines of a reflective report on the previous activities. Analyse and evaluate thematch of the activities to the learning objectives proposed in this workshop/laboratory.
3
Additional exercises for 7805ICT
Activity 9
Design an open ended question (that means there may be several correct answers) that
evaluates the learning objectives of this workshop and could be suitable for
1. a midterm, or
2. a final exam, or
3. a job interview for software engineering.
4
51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468