⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lib0042.html

📁 java外企软件工程师就业班 J2EE方向 《J2EE架构师手册》 电子书
💻 HTML
字号:
<html>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Identifying Attributes</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="LiB0041.html"><img src="images/previous.gif" width="62" height="15" border="0" align="absmiddle" alt="Previous Section"></a>
<a href="LiB0043.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="202"></a><a name="ch06lev1sec4"></a>Identifying Attributes</h2><p class="first-para">Attributes are fields that a class contains. At a code level, attributes are instance-level variable declarations. Most attribution occurs with VOs, with other object types receiving little attribution.</p>
<a name="203"></a><a name="IDX-78"></a>
<p class="para">Ideally, attributes should be base, not derived. A <b class="bold">base attribute</b> is atomic&#8212;that is, its value is not derived from the value of other elements or the result of a calculation. Conversely, a <b class="bold">derived attribute</b> is made up of the values of other elements. For example, consider a <span class="fixed">CustomerVO</span> class that has <span class="fixed">firstName</span>, <span class="fixed">lastName</span>, and <span class="fixed">fullName</span> attributes. The attribute <span class="fixed">fullName</span> is derived because it is made up of the first and last names.</p>
<p class="last-para">
<b class="bold">Avoid declaring derived attributes.</b> Derived attributes, like <span class="fixed">fullName</span> mentioned in the previous paragraph, only give you more to maintain. If a customer changes his or her last name, the values of two attributes need to change. Instead of making <span class="fixed">fullName</span> an attribute, it would be better to create a method, such as <span class="fixed">getFullName()</span>, that does the concatenation.</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="LiB0041.html"><img src="images/previous.gif" width="62" height="15" border="0" align="absmiddle" alt="Previous Section"></a>
<a href="LiB0043.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 + -