📄 lib0045.html
字号:
<html>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Architect's Exercise: ProjectTrak</title>
<link rel="STYLESHEET" type="text/css" href="images/xpolecat.css">
<link rel="STYLESHEET" type="text/css" href="images/ie.content.css">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/teamlib.gif" width="62" height="15" border="0" align="absmiddle" alt="Team LiB"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href="LiB0044.html"><img src="images/previous.gif" width="62" height="15" border="0" align="absmiddle" alt="Previous Section"></a>
<a href="LiB0046.html"><img src="images/next.gif" width="41" height="15" border="0" align="absmiddle" alt="Next Section"></a>
</div></td></tr></table>
<br>
<div class="chapter">
<a name="ch06"></a>
<div class="section">
<h2 class="first-section-title"><a name="210"></a><a name="ch06lev1sec7"></a>Architect's Exercise: ProjectTrak</h2><p class="first-para">Let's apply these concepts to the ProjectTrak example used in previous chapters. The following use case is from ProjectTrak:</p>
<ul class="itemizedlist">
<li class="first-listitem">
<p class="first-para">The system will allow users to define, edit, and display project tasks. A project task has a name, an estimate (in hours), percent complete, one assigned personnel resource, any number of dependent tasks, and a priority (high/medium/low).</p>
</li>
</ul>
<p class="para">Starting with the presentation layer, let's assume that the prototype informs us that there is one page for task definition, edit, and display, with a push-button control for the Save capability. The one display must be dynamically generated, so it can't be a static HTML page. We'll make it a JSP and call it <span class="fixed">TaskEditDisplayJSP</span> in our object model.</p>
<p class="para">Further, let's assume that there is a control on another page (out of scope of our example) that causes the task display/edit page to come up either with information from an existing task or blank (in the case of a new task). And let's assume that we're using Struts.</p>
<p class="para">We need an action to look up the existing task information and store it on the session for the <span class="fixed">TaskEditDisplayJSP</span>. If this is a new task, our action needs to initialize the appropriate variables on the session for the <span class="fixed">TaskEditDisplayJSP</span>. This action, like all actions, will extend <span class="fixed">org.apache.struts.action.Action</span>.</p>
<p class="para">The action, which we'll call <span class="fixed">TaskDisplayAction</span>, should call something in the deployment layer to get task information. Because this is a J2EE application and we don't need to support anything but Java clients, let's make this deployment layer object a session bean (we can choose between stateless and stateful later). We'll call it <span class="fixed">ProjectBean</span>. As discussed previously, let's create a client for the bean to make it easier for presentation-tier developers to call. We'll call that client proxy <span class="fixed">ProjectClient</span>.</p>
<p class="para">Further, we need a method on the bean and client that retrieves project task information. Let's identify that method as <span class="fixed">getProjectTask()</span>. As with <a name="211"></a><a name="IDX-82"></a>all get-type services, we need to pass an argument that identifies which task to retrieve, and we need a VO object to represent a project task returned.</p>
<p class="para">Our use case has enough detail to identify and define the <span class="fixed">ProjectTaskVO</span> object with all the attributes listed from the use-case definition. As discussed in the "<a href="LiB0044.html#207" target="_parent" class="chapterjump">Shortcuts</a>" section, we'll list only the attributes in the model, not the accessors and mutators. We can assume that the object will have <span class="fixed">getTaskId()</span> and <span class="fixed">setTaskId()</span> methods, even though we won't list them in the model. We also won't document the relationships between <span class="fixed">ProjectTaskVO</span> and all the objects that use it because it would make the model unreadable and not useful.</p>
<p class="para">
<span class="fixed">ProjectBean</span> will need to get project task information from an object in the business logic layer. The <span class="fixed">ProjectTaskBO</span> object in the business logic layer needs to access a DAO to look up the task.</p>
<p class="para">After users input or change task information, they have the option to save. We need an action in the presentation layer to initiate the save. Let's call it the <span class="fixed">TaskSaveAction</span>. The <span class="fixed">TaskSaveAction</span> should include something in the deployment layer to initiate the save. We also need a validation form to make sure users entered valid data. This form extends <span class="fixed">org.apache.struts.action.ActionForm</span>. Let's call it <span class="fixed">TaskEditValidationForm</span>.</p>
<p class="para">Following much the same logic that we used to identify the <span class="fixed">getProjectTask()</span> methods in our client proxy, enterprise bean, business object, and data access object, we can identify a <span class="fixed">saveProjectTask()</span> method to initiate save processing at all these levels.</p>
<p class="para">
<a class="internaljump" href="#ch06fig06">Figure 6.6</a> is an object model for everything we identified in this example.</p>
<div class="figure">
<a name="212"></a><a name="ch06fig06"></a><span class="figuremediaobject"><a href="images/fig99%5F01%5F0%2Ejpg" NAME="IMG_17" target="_parent"><img src="images/fig99_01.jpg" height="475" width="350" alt="Click To expand" border="0"></a></span>
<br style="line-height: 1">
<span class="figure-title"><span class="figure-titlelabel">Figure 6.6: </span>ProjectTrak Object Model</span>
</div>
<p class="last-para">Note that this model has something that's very extensible. If we need to support .Net clients at some point, we can create a Web service deployment for the <span class="fixed">PROJECT_BO</span>, and all other functionality remains the same. If we change our data storage mechanism, we can do so without affecting any other tier. The layering concept used here provides us insulation against change.</p>
</div>
</div><br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/teamlib.gif" width="62" height="15" border="0" align="absmiddle" alt="Team LiB"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href="LiB0044.html"><img src="images/previous.gif" width="62" height="15" border="0" align="absmiddle" alt="Previous Section"></a>
<a href="LiB0046.html"><img src="images/next.gif" width="41" height="15" border="0" align="absmiddle" alt="Next Section"></a>
</div></td></tr></table>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -