📄 lib0092.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="LiB0091.html"><img src="images/previous.gif" width="62" height="15" border="0" align="absmiddle" alt="Previous Section"></a>
<a href="LiB0093.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="ch13"></a>
<div class="section">
<h2 class="first-section-title"><a name="444"></a><a name="ch13lev1sec3"></a>Architect's Exercise: ProjectTrak</h2><p class="first-para">Given the somewhat simple use cases for the first release of the product, we've identified four publishable business objects. These objects are listed in the model shown in <a class="internaljump" href="#ch13fig02">figure 13.2</a>.</p>
<div class="figure">
<a name="445"></a><a name="ch13fig02"></a><span class="figuremediaobject"><a href="images/fig198%5F01%5F0%2Ejpg" NAME="IMG_37" target="_parent"><img src="images/fig198_01.jpg" height="319" width="281" alt="Click To expand" border="0"></a></span>
<br style="line-height: 1">
<span class="figure-title"><span class="figure-titlelabel">Figure 13.2: </span>Business Logic Layer Object Model</span>
</div>
<p class="para">Of the four objects, the <span class="fixed">ProjectBO</span>, <span class="fixed">ResourceBO</span>, and <span class="fixed">SkillSetBO</span> objects are mostly transactional in nature. They are primarily concerned with maintaining the integrity of data recorded in a relational database. The <span class="fixed">TaskSchedulerBO</span> is more complex. This class does the work of determining the work schedule given the constraints that users have input.</p>
<a name="446"></a><a name="IDX-183"></a>
<p class="para">
<span class="fixed">TaskSchedulerBO</span> manages the process that derives the start and end dates for each task in a way that enforces the project's dependencies. <span class="fixed">TaskSchedulerBO</span> will probably need more design work than what's documented in the model presented in <a class="internaljump" href="#ch13fig02">figure 13.2</a>.</p>
<p class="para">Rather than drag the whole team through determining the work-scheduling algorithm and what additional support classes might be needed, the architect should work with a smaller group of developers (maybe even just one senior developer) to figure out the algorithm and then report back to the whole team. The more complex the problem, the longer it will take a large group to solve.</p>
<p class="para">The use-case text that is causing us to write a task scheduler is the following:</p>
<ul class="itemizedlist">
<li class="first-listitem">
<p class="first-para">The system will compute work schedule information about project tasks. A projected start date and end date will be computed for each task. This date range will be consistent with the number of working hours available for the assigned resource. This projected date range will not conflict with the range generated for other tasks assigned to the resource.</p>
</li>
<li class="listitem">
<p class="first-para">The order that tasks are completed will be consistent with their priority assignment.</p>
</li>
<li class="listitem">
<p class="first-para">The order that tasks are completed will be consistent with the dependent tasks.</p>
</li>
</ul>
<p class="para">The use case tells us what the scheduler needs to do, but it really doesn't tell us how. This is as it should be, but it does give us a practical problem. I can think of several algorithms we can use to determine the schedule, but they will likely all produce a different result. For example, we could use an iterative algorithm that starts with the current day and iterates through, looking for free resources to assume tasks. Or we could use an algorithm that expresses these constraints as a classic linear programming problem. Linear programming is a branch of operations research that uses matrix algebra to solve optimization problems such as scheduling.</p>
<p class="para">It is also highly likely that users will discover additional constraints after testing our scheduler and watching it do something they didn't agree with. After we change a scheduler, it would be handy to review the effects of the change on several projects to see if we're making the scheduler better or worse. Testers and developers will need an easy way to compare work schedules determined by different schedulers.</p>
<a name="447"></a><a name="IDX-184"></a>
<p class="para">Assuming for a moment that we could get users to agree to the additional use case that would provide users the ability to choose among several schedulers, it would be a prime candidate for the strategy pattern described in <a href="LiB0030.html#129" target="_parent" class="chapterjump">chapter 5</a>. The algorithm candidates we have are different, but they all have the same inputs and outputs. <a class="internaljump" href="#ch13fig03">Figure 13.3</a> is an example of applying the strategy model to ProjectTrak. The strategy pattern works by having <span class="fixed">TaskSchedulerBO</span> rely on an interface, not a concrete class. We can then make the choice of scheduler data driven (e.g., from a user's choice).</p>
<div class="figure">
<a name="448"></a><a name="ch13fig03"></a><span class="figuremediaobject"><a href="images/fig200%5F01%5F0%2Ejpg" NAME="IMG_38" target="_parent"><img src="images/fig200_01.jpg" height="184" width="350" alt="Click To expand" border="0"></a></span>
<br style="line-height: 1">
<span class="figure-title"><span class="figure-titlelabel">Figure 13.3: </span>Sample ProjectTrak Strategy Pattern</span>
</div>
</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="LiB0091.html"><img src="images/previous.gif" width="62" height="15" border="0" align="absmiddle" alt="Previous Section"></a>
<a href="LiB0093.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 + -