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

📄 13_5.htm

📁 翁剀JAVA语言那门课程的教案 很多人都看多他的视频教程可惜没有ppt的教案
💻 HTM
字号:
<HTML>
<HEAD>
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
   <META NAME="Author" CONTENT="Weng Kai">
   <META NAME="GENERATOR" CONTENT="Mozilla/4.01 [en] (Win95; I) [Netscape]">
   <TITLE>Separating business logic from UI logic</TITLE>
</HEAD>
<BODY>

<H2>
13.5 Separating business logic from UI logic</H2>

<HR WIDTH="100%">
<BR>In general you'll want to design your classes so that each one does
"only one thing." This is particularly important when user-interface code
is concerned, since it's easy to wrap up "what you're doing" with "how
you're displaying it." This kind of coupling prevents code reuse. It's
much more desirable to separate your "business logic" from the GUI. This
way, you can not only reuse the business logic more easily, it's also easier
to reuse the GUI.

<P>Another issue is multi-tiered systems, where the "business objects"
reside on a completely separate machine. This central location of the business
rules allows changes to be instantly effective for all new transactions,
and is thus a compelling way to set up a system. However, these business
objects can be used in many different applications and so should not be
tied to any particular mode of display. They should just perform the business
operations and nothing more.

<P>The following example shows how easy it is to separate the business
logic from the GUI code:

<P>Case Study: <A HREF="case/Separation.java">Separation.java</A>

<P>You can see that BusinessLogic is a straightforward class that performs
its operations without even a hint that it might be used in a GUI environment.
It just does its job. Separation keeps track of all the UI details, and
it talks to BusinessLogic only through its public interface. All the operations
are centered around getting information back and forth through the UI and
the BusinessLogic object. So Separation, in turn, just does its job. Since
Separation knows only that it's talking to a BusinessLogic object (that
is, it isn't highly coupled), it could be massaged into talking to other
types of objects without much trouble. Thinking in terms of separating
UI from business logic also makes life easier when you're adapting legacy
code to work with Java.
<BR>
<HR WIDTH="100%">
<DIV ALIGN=right><A HREF="13_6.htm">Next Page</A></DIV>

</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -