<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mafashin</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mafashin"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Mafashin"/>
	<updated>2026-09-11T17:34:21Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5e_mf&amp;diff=42332</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5e mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5e_mf&amp;diff=42332"/>
		<updated>2010-11-23T03:10:24Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=The Dependency Injection Pattern=&lt;br /&gt;
&lt;br /&gt;
==An explanation by way of example==&lt;br /&gt;
&lt;br /&gt;
The [http://martinfowler.com/articles/injection.html#FormsOfDependencyInjection dependency injection] pattern is a design pattern for fully decoupling a class from the creation of other classes upon which it depends.  In this sense, it is similar to the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki3_6_Factory_Design_Pattern factory] and [http://martinfowler.com/articles/injection.html#UsingAServiceLocator service locator] patterns which are also concerned with abstracting object creation away from the dependent class.  The utility of and differences between these patterns is subtle and difficult to explain without a lot of jargon.  So the concepts will be demonstrated through example.  Suppose, that Syd has a [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch3_3h_az strategy] for making statements about objects illustrated in the following Ruby code.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# A strategy for remarking on things.&lt;br /&gt;
class Syd&lt;br /&gt;
  def remark&lt;br /&gt;
    if @thing.got_it?&lt;br /&gt;
      puts &amp;quot;I've got a #{@thing}.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      puts &amp;quot;I know a #{@thing}.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this method, Syd can make a statement about any object thing that implements the methods got_it? and to_s.  The Bike class shown below is an example.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# An example of a thing upon which to remark.&lt;br /&gt;
class Bike&lt;br /&gt;
  def to_s&lt;br /&gt;
    &amp;quot;bike&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
  def got_it?&lt;br /&gt;
    return true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Direct instantiation===&lt;br /&gt;
&lt;br /&gt;
In order for Syd to use his strategy, he must get ahold of a thing.  The simplest way to do this is to instantiate a thing directly.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# An example of direct object instantiation.&lt;br /&gt;
class Syd&lt;br /&gt;
  def initialize&lt;br /&gt;
    @thing = Bike.new&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, now all that Syd can talk about is his bike.  This is because, although Syd has a strategy for talking about a wide variety of things, Syd depends on the concrete class Bike for thing creation.&lt;br /&gt;
&lt;br /&gt;
===The factory pattern===&lt;br /&gt;
&lt;br /&gt;
A common technique for encapsulating object instantiation is the factory pattern.  The following example uses a factory to allow Syd to talk about an array of things.  In this case, thing creation is random, but a more complex factory might be configurable through constructor arguments or some external resource like an XML file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# An example of the factory pattern.&lt;br /&gt;
class ThingFactory&lt;br /&gt;
  def initialize&lt;br /&gt;
    # An array of thing classes.&lt;br /&gt;
    @things = [Bike, Cloak, Mouse, GingerbreadMen, Room]&lt;br /&gt;
  end&lt;br /&gt;
  def create_random_thing&lt;br /&gt;
    # Pick a random thing and create an instance of it.&lt;br /&gt;
    @things.sort_by { rand }[0].new&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
$thing_factory = ThingFactory.new&lt;br /&gt;
&lt;br /&gt;
class Syd&lt;br /&gt;
  def initialize&lt;br /&gt;
    # Use the factory to create a random thing&lt;br /&gt;
    @thing = $thing_factory.create_random_thing&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One major drawback of using the factory pattern is that each abstraction needs its own factory.  In this case, the only abstraction is thing, but if there were many abstractions this could lead to a lot of unnecessary code duplication, since factories are often similar to one another.  This may result in code that is difficult to maintain.  Consider the case where object instantiation is configured by some outside resource like an XML file.  If each factory must independently obtain information from this resource, then every time that the format of the XML file changes, every factory implementation must be modified as well.  &lt;br /&gt;
&lt;br /&gt;
===The service locator pattern===&lt;br /&gt;
&lt;br /&gt;
The service locator pattern addresses the problem of factory proliferation by centralizing object instantiation.  In a sense, the service locator consolidates a collection of factories into a single repository from which other objects may request dependencies.  However, the role of the service locator is somewhat different from the factory.  Whereas factories are specifically concerned with object [http://en.wikipedia.org/wiki/Creational_pattern creation,] the service locator is concerned with supplying dependencies to objects.  Consider several classes which all depend on a common abstraction.  Whereas a factory would typically create an instance of the abstraction for each of the classes, the service locator might create a single instance and supply it to all of the classes.&lt;br /&gt;
&lt;br /&gt;
The example problem is not complex enough to truly benefit from a service locator, but the following example code demonstrates how a service locator can facilitate code reuse.  The class_eval method is used to add methods procedurally for each of the abstractions (&amp;quot;services&amp;quot;) that the service locator provides.  If the method of random object creation needs to be modified at some point in the future, there is only a single definition that needs to be changed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# An example of the service locator pattern.&lt;br /&gt;
class ServiceLocator&lt;br /&gt;
  def initialize&lt;br /&gt;
    # Several arrays of abstractions&lt;br /&gt;
    @things = [Bike, Cloak, Mouse, GingerbreadMen, Room]&lt;br /&gt;
    @charms = [Heart, Star, Horseshoe, Clover]&lt;br /&gt;
    @triffles = [Tiramisu, StrawberryShortcake, TipsyLaird]&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
# Add a get_random method for each abstraction&lt;br /&gt;
[:thing, :charm, :trifle].each do |abstraction|&lt;br /&gt;
  ServiceLocator.class_eval &amp;quot;def get_random_#{abstraction}&lt;br /&gt;
      @#{abstraction}s.sort_by { rand }[0].new&lt;br /&gt;
    end&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
$service_locator = ServiceLocator.new&lt;br /&gt;
&lt;br /&gt;
class Syd&lt;br /&gt;
  def initialize&lt;br /&gt;
    # Use the service locator to get a random thing&lt;br /&gt;
    @thing = $service_locator.get_random_thing&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, the factory and service locator patterns share a common disadvantage.  Namely, a class which uses a factory or a service locator necessarily depends on the factory or service locator.  This has potentially serious implications for code maintainability.  A class which uses a service locator must know the name and calling conventions of the service locator in order to use it.  If the name or calling conventions of the service locator are modified, all classes which use the service locator must also be modified.  The same is true of factories.&lt;br /&gt;
&lt;br /&gt;
===The dependency injection pattern===&lt;br /&gt;
&lt;br /&gt;
Dependency injection eliminates the dependency between a class and the mechanism used to supply its dependencies.  Rather than make an object responsible for acquiring its own dependencies (directly, through factories, or through a service locator), dependency injection places the responsibility on the code that uses the object to provide the dependencies that the object needs.  This is usually accomplished either by passing dependencies as arguments to the object's constructor or to a setter method.  The following code example accepts both forms of dependency injection.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# An example of the dependency injection pattern.&lt;br /&gt;
class Syd&lt;br /&gt;
  attr_writer :thing&lt;br /&gt;
  def initialize(thing)&lt;br /&gt;
    # Constructor injection.&lt;br /&gt;
    @thing = thing&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Dependency injection is an example of the [http://martinfowler.com/bliki/InversionOfControl.html inversion of control] principle.  Rather than giving a class control of the creation of its own dependencies, control is abstracted out to higher-level code (an &amp;quot;assembler&amp;quot;) which creates the dependencies and provides them to the class.&lt;br /&gt;
&lt;br /&gt;
This method of decoupling a class from its dependencies makes the dependency injection pattern fundamentally different from the factory and service locator patterns.  Whereas the factory and service locator patterns encapsulate object instantiation so as to hide the concrete class from the dependent object, the dependency injection pattern pulls the act of object instantiation outside of the dependent object through inversion of control.&lt;br /&gt;
&lt;br /&gt;
==Dependency injection and duck typing==&lt;br /&gt;
&lt;br /&gt;
It is worth noting that the example code for the dependency injection pattern is much simpler than for the factory and service locator patterns.  This is partly because the logic of object instantiation has been pulled outside the example, but it is also because dependency injection fits in well in [http://en.wikipedia.org/wiki/Duck_typing duck-typed] languages like Ruby.&lt;br /&gt;
&lt;br /&gt;
Duck typing means that any object may be passed as an argument to a method and, so long as it possesses the necessary methods and attributes, the program will execute properly.  In the previous code example, there is no interface or abstract base class from which objects inherit.  Any object which implements the got_it? and to_s methods may be used as a thing.  This makes it easy to create new classes and modify existing classes to be used as things.&lt;br /&gt;
&lt;br /&gt;
Dependency injection complements duck typing nicely, because any object with the methods necessary to meet the needs of the dependent class may be injected.  Objects which were never explicitly designed to satisfy a dependency can be used to meet it with little or no modification.  In contrast, a factory or service locator would have to be modified to support supplying the new class of object.&lt;br /&gt;
&lt;br /&gt;
==Real applications of dependency injection==&lt;br /&gt;
&lt;br /&gt;
===Software frameworks===&lt;br /&gt;
&lt;br /&gt;
Dependency injection is a key feature of many software frameworks.  [http://www.springsource.org/ Spring] is a notable example.  A software framework is essentially an application skeleton with a well-specified application programming interface (API) intended to serve as an extensible base for developing a fully-fleshed out application.  Since library methods are called by an application, the application controls the flow of execution.  This means that typically a significant amount of an application developed using libraries must be implemented before the application will be capable of doing anything useful.&lt;br /&gt;
&lt;br /&gt;
In contrast, a software framework is already a functional piece of software before the application developers writes any code.  Application developers override or specialize parts of the framework in order to extend its functionality.  This is possible because frameworks follow the design principle of inversion of control.  Rather than allow the application code to dictate the path of execution, the framework controls it.&lt;br /&gt;
&lt;br /&gt;
Since software frameworks employ inversion of control, dependency injection is a natural fit.  If a framework specifies an appropriate set of conventions to application developers, the framework can infer the dependencies of application code and inject them into it.  Which classes the framework will use to fulfill the application dependencies and how it will initialize them is typically controllable through some form of configuration file.  However, many frameworks follow a [http://en.wikipedia.org/wiki/Convention_over_configuration convention over configuration] philosophy and will infer parameters which are not specified by the developer.&lt;br /&gt;
&lt;br /&gt;
===PicoContainer===&lt;br /&gt;
&lt;br /&gt;
[http://www.picocontainer.org/ PicoContainer] is another example of a real world application of dependency injection.  PicoContainer provides a container class to which one may add arbitrary Java classes.  If the constructors of some of these classes depend on interfaces implemented by other classes, PicoContainer will infer these dependencies and use instantiations of objects which implement the required interfaces in order to instantiate other objects.  Consider the following example code take from the [http://www.picocontainer.org/introduction.html PicoContainer website.]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source: http://www.picocontainer.org/introduction.html&lt;br /&gt;
&lt;br /&gt;
public interface Peelable {&lt;br /&gt;
  void peel();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class Apple implements Peelable {&lt;br /&gt;
  public void peel() {&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class Peeler implements Startable {  &lt;br /&gt;
  private final Peelable peelable;&lt;br /&gt;
&lt;br /&gt;
  public Peeler(Peelable peelable) {&lt;br /&gt;
    this.peelable = peelable;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void start() {&lt;br /&gt;
    peelable.peel();&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  public void stop() {&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class Juicer {&lt;br /&gt;
  private final Peelable peelable;&lt;br /&gt;
  private final Peeler peeler;&lt;br /&gt;
&lt;br /&gt;
  public Juicer(Peelable peelable, Peeler peeler) {&lt;br /&gt;
    this.peelable = peelable;&lt;br /&gt;
    this.peeler = peeler;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The classes given above may be added to an instance of PicoContainer.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source: http://www.picocontainer.org/introduction.html&lt;br /&gt;
&lt;br /&gt;
MutablePicoContainer pico = new DefaultPicoContainer();  &lt;br /&gt;
pico.addComponent(Apple.class);&lt;br /&gt;
pico.addComponent(Juicer.class);&lt;br /&gt;
pico.addComponent(Peeler.class);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PicoContainer infers how to instantiate these classes from their constructors.  The instantiations may then be retrieved from the PicoContainer.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source: http://www.picocontainer.org/introduction.html&lt;br /&gt;
&lt;br /&gt;
Juicer juicer = (Juicer) pico.getComponent(Juicer.class);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The class definitions given above are interdependent and these dependencies may be satisfied through construction injection.  By requiring developers to write classes which follow this relatively simple convention (constructor injection of interfaces), PicoContainer is able to resolve the dependencies automatically for the developer.  Under the hood, PicoContainer is doing something roughly like the following code.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source: http://www.picocontainer.org/introduction.html&lt;br /&gt;
&lt;br /&gt;
Peelable peelable = new Apple();&lt;br /&gt;
Peeler peeler = new Peeler(peelable);&lt;br /&gt;
Juicer juicer = new Juicer(peelable, peeler);&lt;br /&gt;
return juicer;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This process would be much more complicated if not impossible using the factory or service locator pattern, since the class dependencies would be hidden inside the classes rather than exposed in their constructors.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2004.  [http://martinfowler.com/articles/injection.html Inversion of control containers and the dependency injection pattern.]  In ''Martin Fowler's Bliki.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2005.  [http://martinfowler.com/bliki/InversionOfControl.html Inversion of control.]  In ''Martin Fowler's Bliki.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;HELLESOY, A., AND TIRSEN, J.  [http://www.picocontainer.org/introduction.html PicoContainer introduction.]  In ''PicoContainer.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;JOHNSON, R., ET AL.  2010.  [http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/ Spring framework: reference documentation.]  In ''SpringSource.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5e_mf&amp;diff=42327</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5e mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5e_mf&amp;diff=42327"/>
		<updated>2010-11-23T02:58:55Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=The Dependency Injection Pattern=&lt;br /&gt;
&lt;br /&gt;
==An explanation by way of example==&lt;br /&gt;
&lt;br /&gt;
The [http://martinfowler.com/articles/injection.html#FormsOfDependencyInjection dependency injection] pattern is a design pattern for fully decoupling a class from the creation of other classes upon which it depends.  In this sense, it is similar to the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki3_6_Factory_Design_Pattern factory] and [http://martinfowler.com/articles/injection.html#UsingAServiceLocator service locator] patterns which are also concerned with abstracting object creation away from the dependent class.  The utility of and differences between these patterns is subtle and difficult to explain without a lot of jargon.  So the concepts will be demonstrated through example.  Suppose, that Syd has a [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch3_3h_az strategy] for making statements about objects illustrated in the following Ruby code.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# A strategy for remarking on things.&lt;br /&gt;
class Syd&lt;br /&gt;
  def remark&lt;br /&gt;
    if @thing.got_it?&lt;br /&gt;
      puts &amp;quot;I've got a #{@thing}.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      puts &amp;quot;I know a #{@thing}.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this method, Syd can make a statement about any object thing that implements the methods got_it? and to_s.  The Bike class shown below is an example.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# An example of a thing upon which to remark.&lt;br /&gt;
class Bike&lt;br /&gt;
  def to_s&lt;br /&gt;
    &amp;quot;bike&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
  def got_it?&lt;br /&gt;
    return true&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Direct instantiation===&lt;br /&gt;
&lt;br /&gt;
In order for Syd to use his strategy, he must get ahold of a thing.  The simplest way to do this is to instantiate a thing directly.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# An example of direct object instantiation.&lt;br /&gt;
class Syd&lt;br /&gt;
  def initialize&lt;br /&gt;
    @thing = Bike.new&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, now all that Syd can talk about is his bike.  This is because, although Syd has a strategy for talking about a wide variety of things, Syd depends on the concrete class Bike for thing creation.&lt;br /&gt;
&lt;br /&gt;
===The factory pattern===&lt;br /&gt;
&lt;br /&gt;
A common technique for encapsulating object instantiation is the factory pattern.  The following example uses a factory to allow Syd to talk about an array of things.  In this case, thing creation is random, but a more complex factory might be configurable through constructor arguments or some external resource like an XML file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# An example of the factory pattern.&lt;br /&gt;
class ThingFactory&lt;br /&gt;
  def initialize&lt;br /&gt;
    # An array of thing classes.&lt;br /&gt;
    @things = [Bike, Cloak, Mouse, GingerbreadMen, Room]&lt;br /&gt;
  end&lt;br /&gt;
  def create_random_thing&lt;br /&gt;
    # Pick a random thing and create an instance of it.&lt;br /&gt;
    @things.sort_by { rand }[0].new&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
$thing_factory = ThingFactory.new&lt;br /&gt;
&lt;br /&gt;
class Syd&lt;br /&gt;
  def initialize&lt;br /&gt;
    # Use the factory to create a random thing&lt;br /&gt;
    @thing = $thing_factory.create_random_thing&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One major drawback of using the factory pattern is that each abstraction needs its own factory.  In this case, the only abstraction is thing, but if there were many abstractions this could lead to a lot of unnecessary code duplication, since factories are often similar to one another.  This may result in code that is difficult to maintain.  Consider the case where object instantiation is configured by some outside resource like an XML file.  If each factory must independently obtain information from this resource, then every time that the format of the XML file changes, every factory implementation must be modified as well.  &lt;br /&gt;
&lt;br /&gt;
===The service locator pattern===&lt;br /&gt;
&lt;br /&gt;
The service locator pattern addresses the problem of factory proliferation by centralizing object instantiation.  In a sense, the service locator consolidates a collection of factories into a single repository from which other objects may request dependencies.  However, the role of the service locator is somewhat different from the factory.  Whereas factories are specifically concerned with object [http://en.wikipedia.org/wiki/Creational_pattern creation,] the service locator is concerned with supplying dependencies to objects.  Consider several classes which all depend on a common abstraction.  Whereas a factory would typically create an instance of the abstraction for each of the classes, the service locator might create a single instance and supply it to all of the classes.&lt;br /&gt;
&lt;br /&gt;
The example problem is not complex enough to truly benefit from a service locator, but the following example code demonstrates how a service locator can facilitate code reuse.  The class_eval method is used to add methods procedurally for each of the abstractions (&amp;quot;services&amp;quot;) that the service locator provides.  If the method of random object creation needs to be modified at some point in the future, there is only a single definition that needs to be changed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# An example of the service locator pattern.&lt;br /&gt;
class ServiceLocator&lt;br /&gt;
  def initialize&lt;br /&gt;
    # Several arrays of abstractions&lt;br /&gt;
    @things = [Bike, Cloak, Mouse, GingerbreadMen, Room]&lt;br /&gt;
    @charms = [Heart, Star, Horseshoe, Clover]&lt;br /&gt;
    @triffles = [Tiramisu, StrawberryShortcake, TipsyLaird]&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
# Add a get_random method for each abstraction&lt;br /&gt;
[:thing, :charm, :trifle].each do |abstraction|&lt;br /&gt;
  ServiceLocator.class_eval &amp;quot;def get_random_#{abstraction}&lt;br /&gt;
      @#{abstraction}s.sort_by { rand }[0].new&lt;br /&gt;
    end&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
$service_locator = ServiceLocator.new&lt;br /&gt;
&lt;br /&gt;
class Syd&lt;br /&gt;
  def initialize&lt;br /&gt;
    # Use the service locator to get a random thing&lt;br /&gt;
    @thing = $service_locator.get_random_thing&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, the factory and service locator patterns share a common disadvantage.  Namely, a class which uses a factory or a service locator necessarily depends on the factory or service locator.  This has potentially serious implications for code maintainability.  A class which uses a service locator must know the name and calling conventions of the service locator in order to use it.  If the name or calling conventions of the service locator are modified, all classes which use the service locator must also be modified.  The same is true of factories.&lt;br /&gt;
&lt;br /&gt;
===The dependency injection pattern===&lt;br /&gt;
&lt;br /&gt;
Dependency injection eliminates the dependency between a class and the mechanism used to supply its dependencies.  Rather than make an object responsible for acquiring its own dependencies (directly, through factories, or through a service locator), dependency injection places the responsibility on the code that uses the object to provide the dependencies that the object needs.  This is usually accomplished either by passing dependencies as arguments to the object's constructor or to a setter method.  The following code example accepts both forms of dependency injection.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# An example of the dependency injection pattern.&lt;br /&gt;
class Syd&lt;br /&gt;
  attr_writer :thing&lt;br /&gt;
  def initialize(thing)&lt;br /&gt;
    # Constructor injection.&lt;br /&gt;
    @thing = thing&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Dependency injection is an example of the [http://martinfowler.com/bliki/InversionOfControl.html inversion of control] principle.  Rather than giving a class control of the creation of its own dependencies, control is abstracted out to higher-level code (an &amp;quot;assembler&amp;quot;) which creates the dependencies and provides them to the class.&lt;br /&gt;
&lt;br /&gt;
This method of decoupling a class from its dependencies makes the dependency injection pattern fundamentally different from the factory and service locator patterns.  Whereas the factory and service locator patterns encapsulate object instantiation so as to hide the concrete class from the dependent object, the dependency injection pattern pulls the act of object instantiation outside of the dependent object through inversion of control.&lt;br /&gt;
&lt;br /&gt;
==Dependency injection and duck typing==&lt;br /&gt;
&lt;br /&gt;
It is worth noting that the example code for the dependency injection pattern is much simpler than for the factory and service locator patterns.  This is partly because the logic of object instantiation has been pulled outside the example, but it is also because dependency injection fits in well in [http://en.wikipedia.org/wiki/Duck_typing duck-typed] languages like Ruby.&lt;br /&gt;
&lt;br /&gt;
Duck typing means that any object may be passed as an argument to a method and, so long as it possesses the necessary methods and attributes, the program will execute properly.  In the previous code example, there is no interface or abstract base class from which objects inherit.  Any object which implements the got_it? and to_s methods may be used as a thing.  This makes it easy to create new classes and modify existing classes to be used as things.&lt;br /&gt;
&lt;br /&gt;
Dependency injection complements duck typing nicely, because any object with the methods necessary to meet the needs of the dependent class may be injected.  Objects which were never explicitly designed to satisfy a dependency can be used to meet it with little or no modification.  In contrast, a factory or service locator would have to be modified to support supplying the new class of object.&lt;br /&gt;
&lt;br /&gt;
==Real applications of dependency injection==&lt;br /&gt;
&lt;br /&gt;
===Software frameworks===&lt;br /&gt;
&lt;br /&gt;
Dependency injection is a key feature of many software frameworks.  [http://www.springsource.org/ Spring] is a notable example.  A software framework is essentially an application skeleton with a well-specified application programming interface (API) intended to serve as an extensible base for developing a fully-fleshed out application.  Since library methods are called by an application, the application controls the flow of execution.  This means that typically a significant amount of an application developed using libraries must be implemented before the application will be capable of doing anything useful.&lt;br /&gt;
&lt;br /&gt;
In contrast, a software framework is already a functional piece of software before the application developers writes any code.  Application developers override or specialize parts of the framework in order to extend its functionality.  This is possible because frameworks follow the design principle of inversion of control.  Rather than allow the application code to dictate the path of execution, the framework controls it.&lt;br /&gt;
&lt;br /&gt;
Since software frameworks employ inversion of control, dependency injection is a natural fit.  If a framework specifies an appropriate set of conventions to application developers, the framework can infer the dependencies of application code and inject them into it.  Which classes the framework will use to fulfill the application dependencies and how it will initialize them is typically controllable through some form of configuration file.  However, many frameworks follow a [http://en.wikipedia.org/wiki/Convention_over_configuration convention over configuration] philosophy and will infer parameters which are not specified by the developer.&lt;br /&gt;
&lt;br /&gt;
===PicoContainer===&lt;br /&gt;
&lt;br /&gt;
[http://www.picocontainer.org/ PicoContainer] is another example of a real world application of dependency injection.  PicoContainer provides a container class to which one may add arbitrary Java classes.  If the constructors of some of these classes depend on interfaces implemented by other classes, PicoContainer will infer these dependencies and use instantiations of objects which implement the required interfaces in order to instantiate other objects.  Consider the following example code take from the [http://www.picocontainer.org/introduction.html PicoContainer website.]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source: http://www.picocontainer.org/introduction.html&lt;br /&gt;
&lt;br /&gt;
public interface Peelable {&lt;br /&gt;
  void peel();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class Apple implements Peelable {&lt;br /&gt;
  public void peel() {&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class Peeler implements Startable {  &lt;br /&gt;
  private final Peelable peelable;&lt;br /&gt;
&lt;br /&gt;
  public Peeler(Peelable peelable) {&lt;br /&gt;
    this.peelable = peelable;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void start() {&lt;br /&gt;
    peelable.peel();&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  public void stop() {&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class Juicer {&lt;br /&gt;
  private final Peelable peelable;&lt;br /&gt;
  private final Peeler peeler;&lt;br /&gt;
&lt;br /&gt;
  public Juicer(Peelable peelable, Peeler peeler) {&lt;br /&gt;
    this.peelable = peelable;&lt;br /&gt;
    this.peeler = peeler;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The classes given above may be added to an instance of PicoContainer.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source: http://www.picocontainer.org/introduction.html&lt;br /&gt;
&lt;br /&gt;
MutablePicoContainer pico = new DefaultPicoContainer();  &lt;br /&gt;
pico.addComponent(Apple.class);&lt;br /&gt;
pico.addComponent(Juicer.class);&lt;br /&gt;
pico.addComponent(Peeler.class);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PicoContainer infers how to instantiate these classes from their constructors.  The instantiations may then be retrieved from the PicoContainer.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source: http://www.picocontainer.org/introduction.html&lt;br /&gt;
&lt;br /&gt;
Juicer juicer = (Juicer) pico.getComponent(Juicer.class);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The class definitions given above are interdependent and these dependencies may be satisfied through construction injection.  By requiring developers to write classes which follow this relatively simple convention (constructor injection of interfaces), PicoContainer is able to resolve the dependencies automatically for the developer.  Under the hood, PicoContainer is doing something roughly like the following code.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source: http://www.picocontainer.org/introduction.html&lt;br /&gt;
&lt;br /&gt;
Peelable peelable = new Apple();&lt;br /&gt;
Peeler peeler = new Peeler(peelable);&lt;br /&gt;
Juicer juicer = new Juicer(peelable, peeler);&lt;br /&gt;
return juicer;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This process would be much more complicated if not impossible using the factory or service locator pattern, since the class dependencies would be hidden inside the classes rather than exposed in their constructors.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2004.  [http://martinfowler.com/articles/injection.html Inversion of control containers and the dependency injection pattern.]  In ''Martin Fowler's Bliki.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2005.  [http://martinfowler.com/bliki/InversionOfControl.html Inversion of control.]  In ''Martin Fowler's Bliki.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41752</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41752"/>
		<updated>2010-11-18T00:54:37Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Conclusion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The principle advantage of domain modelling is that it [http://en.wikipedia.org/wiki/Separation_of_concerns separates the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Understanding the problem domain is critical to developing a good domain model.  Well-designed software should exist to solve a problem.  The problem domain encompasses all the entities, relationships, data, rules, and logic that are necessary to solve the problem.  Conversely, entities, relationships, data, rules, and logic which are not necessary to solve the problem are outside the problem domain.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx &amp;quot;The mythical business layer.&amp;quot;]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (a TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.  Understanding which issues are specific and relevant to the problem domain and which are not is essential to developing a good domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic domain models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html anemic domain model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;br /&gt;
&lt;br /&gt;
For example, consider the business logic example given above.  One could create a service object CancellationRequestIssuer like the one diagrammed below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequestIssuer'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issue(employee : Manager, item : TransferableReceivable) : CancellationRequest &amp;lt;br&amp;gt; issue(employee : Executive, item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This may seem like a reasonable way to avoid code duplication, since presumably a CancellationRequest issued by a Manager will be more or less identical to one issued by an Executive.  However, there is an additional bit of logic in the domain model for a Manager which this design pushes into the service layer.  Namely, before allowing a Manager to issue a Cancellation request, the application must check that the Manager attribute hasVoidApproval equals true.&lt;br /&gt;
&lt;br /&gt;
Putting this logic in CancellationRequestIssuer violates the encapsulation of hasVoidApproval within Manager.  In addition, stripping this logic out of Manager reduces [http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29 cohesion.]  Furthermore, with this design, CancellationRequestIssuer is responsible for assuring that all domain objects which may issue a CancellationRequest are authorized to do so.  This means that CancellationRequestIssuer is tightly-coupled with these domain objects (in the sense that it needs information encapsulated within them to authorize requests).&lt;br /&gt;
&lt;br /&gt;
A better design keeps the domain object-specific logic in the domain model.  One way to accomplish this and still use the service object above is to add a mayIssueCancellationRequests() method to domain objects which may be passed to a CancellationRequestIssuer which returns true if they are authorized to issue a CancellationRequest and false if they are not.  This allows domain objects to encapsulate their own specific logic, while allowing CancellationRequestIssuer to generalize the actual issuance of a CancellationRequest.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
Domain modelling is a useful technique for separating problem domain-specific concerns from concerns which are unrelated to the problem domain, like user interfaces and databases.  Developing a good domain model requires a thorough understanding of what is and what is not part of the problem domain.  Good candidates for inclusion in a domain model are real-world entities related to the problem the software solves, the relationships between those entities, and the behaviours and data associated with those entities.&lt;br /&gt;
&lt;br /&gt;
A good domain model is only weakly-coupled with other parts of an application.  This allows domain-specific logic and entities to vary without affecting other system components and vice versa.  However, a good domain model is still cohesive.  Separating responsibilities from domain objects unnecessarily produces the anemic domain model anti-pattern in which service objects are tightly-coupled with domain objects and domain objects lack cohesion.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;AMBLER, S.  2010.  [http://www.agiledata.org/essays/agileDataModeling.html Agile/evolutionary data modeling: from domain modeling to physical modeling.]  In ''Agile Data.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;CHIN, P.-T.  2008.  [http://www.hostfrontier.com/index.php/200811029/agile-methodology/domain-modelling-using-color-uml.html Domain modelling using color UML.]  In ''TechnoGeek.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2002.  ''Patterns of Enterprise Application Architecture.''  Addison-Wesley Professional.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2003.  [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic domain model.]  In ''Martin Fowler's Bliki.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;OLDFIELD, P.  2002.  [http://www.aptprocess.com/whitepapers/DomainModelling.pdf Domain modelling.]  White paper, Mentors of Cally Ltd.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;PAPADIMOULIS, A.  2007.  [http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The mythical business layer.]  In ''The Daily WTF.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41750</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41750"/>
		<updated>2010-11-18T00:53:51Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Conclusion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The principle advantage of domain modelling is that it [http://en.wikipedia.org/wiki/Separation_of_concerns separates the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Understanding the problem domain is critical to developing a good domain model.  Well-designed software should exist to solve a problem.  The problem domain encompasses all the entities, relationships, data, rules, and logic that are necessary to solve the problem.  Conversely, entities, relationships, data, rules, and logic which are not necessary to solve the problem are outside the problem domain.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx &amp;quot;The mythical business layer.&amp;quot;]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (a TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.  Understanding which issues are specific and relevant to the problem domain and which are not is essential to developing a good domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic domain models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html anemic domain model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;br /&gt;
&lt;br /&gt;
For example, consider the business logic example given above.  One could create a service object CancellationRequestIssuer like the one diagrammed below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequestIssuer'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issue(employee : Manager, item : TransferableReceivable) : CancellationRequest &amp;lt;br&amp;gt; issue(employee : Executive, item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This may seem like a reasonable way to avoid code duplication, since presumably a CancellationRequest issued by a Manager will be more or less identical to one issued by an Executive.  However, there is an additional bit of logic in the domain model for a Manager which this design pushes into the service layer.  Namely, before allowing a Manager to issue a Cancellation request, the application must check that the Manager attribute hasVoidApproval equals true.&lt;br /&gt;
&lt;br /&gt;
Putting this logic in CancellationRequestIssuer violates the encapsulation of hasVoidApproval within Manager.  In addition, stripping this logic out of Manager reduces [http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29 cohesion.]  Furthermore, with this design, CancellationRequestIssuer is responsible for assuring that all domain objects which may issue a CancellationRequest are authorized to do so.  This means that CancellationRequestIssuer is tightly-coupled with these domain objects (in the sense that it needs information encapsulated within them to authorize requests).&lt;br /&gt;
&lt;br /&gt;
A better design keeps the domain object-specific logic in the domain model.  One way to accomplish this and still use the service object above is to add a mayIssueCancellationRequests() method to domain objects which may be passed to a CancellationRequestIssuer which returns true if they are authorized to issue a CancellationRequest and false if they are not.  This allows domain objects to encapsulate their own specific logic, while allowing CancellationRequestIssuer to generalize the actual issuance of a CancellationRequest.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
Domain modelling is a useful technique for separating problem domain-specific concerns from concerns which are unrelated to the problem domain, like user interfaces and databases.  Developing a good domain model requires a thorough understanding of what is and what is not part of the problem domain.  Good candidates for inclusion in a domain model are real-world entities related to the problem the software solves, the relationships between those entities, and the behaviours and data associated with those entities.&lt;br /&gt;
&lt;br /&gt;
A good domain model is only weakly-coupled with other parts of an application.  This allows domain-specific logic to vary without affecting other system components and vice versa.  However, a good domain model is still cohesive.  Separating responsibilities from domain objects unnecessarily produces the anemic domain model anti-pattern in which service objects are tightly-coupled with domain objects and domain objects lack cohesion.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;AMBLER, S.  2010.  [http://www.agiledata.org/essays/agileDataModeling.html Agile/evolutionary data modeling: from domain modeling to physical modeling.]  In ''Agile Data.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;CHIN, P.-T.  2008.  [http://www.hostfrontier.com/index.php/200811029/agile-methodology/domain-modelling-using-color-uml.html Domain modelling using color UML.]  In ''TechnoGeek.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2002.  ''Patterns of Enterprise Application Architecture.''  Addison-Wesley Professional.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2003.  [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic domain model.]  In ''Martin Fowler's Bliki.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;OLDFIELD, P.  2002.  [http://www.aptprocess.com/whitepapers/DomainModelling.pdf Domain modelling.]  White paper, Mentors of Cally Ltd.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;PAPADIMOULIS, A.  2007.  [http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The mythical business layer.]  In ''The Daily WTF.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41729</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41729"/>
		<updated>2010-11-18T00:43:18Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The principle advantage of domain modelling is that it [http://en.wikipedia.org/wiki/Separation_of_concerns separates the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Understanding the problem domain is critical to developing a good domain model.  Well-designed software should exist to solve a problem.  The problem domain encompasses all the entities, relationships, data, rules, and logic that are necessary to solve the problem.  Conversely, entities, relationships, data, rules, and logic which are not necessary to solve the problem are outside the problem domain.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx &amp;quot;The mythical business layer.&amp;quot;]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (a TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.  Understanding which issues are specific and relevant to the problem domain and which are not is essential to developing a good domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic domain models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html anemic domain model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;br /&gt;
&lt;br /&gt;
For example, consider the business logic example given above.  One could create a service object CancellationRequestIssuer like the one diagrammed below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequestIssuer'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issue(employee : Manager, item : TransferableReceivable) : CancellationRequest &amp;lt;br&amp;gt; issue(employee : Executive, item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This may seem like a reasonable way to avoid code duplication, since presumably a CancellationRequest issued by a Manager will be more or less identical to one issued by an Executive.  However, there is an additional bit of logic in the domain model for a Manager which this design pushes into the service layer.  Namely, before allowing a Manager to issue a Cancellation request, the application must check that the Manager attribute hasVoidApproval equals true.&lt;br /&gt;
&lt;br /&gt;
Putting this logic in CancellationRequestIssuer violates the encapsulation of hasVoidApproval within Manager.  In addition, stripping this logic out of Manager reduces [http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29 cohesion.]  Furthermore, with this design, CancellationRequestIssuer is responsible for assuring that all domain objects which may issue a CancellationRequest are authorized to do so.  This means that CancellationRequestIssuer is tightly-coupled with these domain objects (in the sense that it needs information encapsulated within them to authorize requests).&lt;br /&gt;
&lt;br /&gt;
A better design keeps the domain object-specific logic in the domain model.  One way to accomplish this and still use the service object above is to add a mayIssueCancellationRequests() method to domain objects which may be passed to a CancellationRequestIssuer which returns true if they are authorized to issue a CancellationRequest and false if they are not.  This allows domain objects to encapsulate their own specific logic, while allowing CancellationRequestIssuer to generalize the actual issuance of a CancellationRequest.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
Domain modelling is a useful technique for separating problem domain-specific concerns from concerns which are unrelated to the problem domain, like user interfaces and databases.  Developing a good domain model requires a thorough understanding of what is and what is not part of the problem domain.  As such, a good domain model is only weakly-coupled with other parts of an application.  This allows domain-specific logic to vary without affecting other system components and vice versa.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;AMBLER, S.  2010.  [http://www.agiledata.org/essays/agileDataModeling.html Agile/evolutionary data modeling: from domain modeling to physical modeling.]  In ''Agile Data.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;CHIN, P.-T.  2008.  [http://www.hostfrontier.com/index.php/200811029/agile-methodology/domain-modelling-using-color-uml.html Domain modelling using color UML.]  In ''TechnoGeek.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2002.  ''Patterns of Enterprise Application Architecture.''  Addison-Wesley Professional.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2003.  [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic domain model.]  In ''Martin Fowler's Bliki.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;OLDFIELD, P.  2002.  [http://www.aptprocess.com/whitepapers/DomainModelling.pdf Domain modelling.]  White paper, Mentors of Cally Ltd.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;PAPADIMOULIS, A.  2007.  [http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The mythical business layer.]  In ''The Daily WTF.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41711</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41711"/>
		<updated>2010-11-18T00:32:31Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Anemic domain models */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The principle advantage of domain modelling is that it [http://en.wikipedia.org/wiki/Separation_of_concerns separates the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Understanding the problem domain is critical to developing a good domain model.  Well-designed software should exist to solve a problem.  The problem domain encompasses all the entities, relationships, data, rules, and logic that are necessary to solve the problem.  Conversely, entities, relationships, data, rules, and logic which are not necessary to solve the problem are outside the problem domain.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx &amp;quot;The mythical business layer.&amp;quot;]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (a TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.  Understanding which issues are specific and relevant to the problem domain and which are not is essential to developing a good domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic domain models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html anemic domain model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;br /&gt;
&lt;br /&gt;
For example, consider the business logic example given above.  One could create a service object CancellationRequestIssuer like the one diagrammed below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequestIssuer'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issue(employee : Manager, item : TransferableReceivable) : CancellationRequest &amp;lt;br&amp;gt; issue(employee : Executive, item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This may seem like a reasonable way to avoid code duplication, since presumably a CancellationRequest issued by a Manager will be more or less identical to one issued by an Executive.  However, there is an additional bit of logic in the domain model for a Manager which this design pushes into the service layer.  Namely, before allowing a Manager to issue a Cancellation request, the application must check that the Manager attribute hasVoidApproval equals true.&lt;br /&gt;
&lt;br /&gt;
Putting this logic in CancellationRequestIssuer violates the encapsulation of hasVoidApproval within Manager.  In addition, stripping this logic out of Manager reduces [http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29 cohesion.]  Furthermore, with this design, CancellationRequestIssuer is responsible for assuring that all domain objects which may issue a CancellationRequest are authorized to do so.  This means that CancellationRequestIssuer is tightly-coupled with these domain objects (in the sense that it needs information encapsulated within them to authorize requests).&lt;br /&gt;
&lt;br /&gt;
A better design keeps the domain object-specific logic in the domain model.  One way to accomplish this and still use the service object above is to add a mayIssueCancellationRequests() method to domain objects which may be passed to a CancellationRequestIssuer which returns true if they are authorized to issue a CancellationRequest and false if they are not.  This allows domain objects to encapsulate their own specific logic, while allowing CancellationRequestIssuer to generalize the actual issuance of a CancellationRequest.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;AMBLER, S.  2010.  [http://www.agiledata.org/essays/agileDataModeling.html Agile/evolutionary data modeling: from domain modeling to physical modeling.]  In ''Agile Data.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;CHIN, P.-T.  2008.  [http://www.hostfrontier.com/index.php/200811029/agile-methodology/domain-modelling-using-color-uml.html Domain modelling using color UML.]  In ''TechnoGeek.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2002.  ''Patterns of Enterprise Application Architecture.''  Addison-Wesley Professional.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2003.  [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic domain model.]  In ''Martin Fowler's Bliki.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;OLDFIELD, P.  2002.  [http://www.aptprocess.com/whitepapers/DomainModelling.pdf Domain modelling.]  White paper, Mentors of Cally Ltd.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;PAPADIMOULIS, A.  2007.  [http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The mythical business layer.]  In ''The Daily WTF.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41709</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41709"/>
		<updated>2010-11-18T00:29:49Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* An example of business logic */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The principle advantage of domain modelling is that it [http://en.wikipedia.org/wiki/Separation_of_concerns separates the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Understanding the problem domain is critical to developing a good domain model.  Well-designed software should exist to solve a problem.  The problem domain encompasses all the entities, relationships, data, rules, and logic that are necessary to solve the problem.  Conversely, entities, relationships, data, rules, and logic which are not necessary to solve the problem are outside the problem domain.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx &amp;quot;The mythical business layer.&amp;quot;]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (a TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.  Understanding which issues are specific and relevant to the problem domain and which are not is essential to developing a good domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic domain models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html anemic domain model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;br /&gt;
&lt;br /&gt;
For example, consider the business logic example given above.  One could create a service object CancellationRequestIssuer like the one diagrammed below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequestIssuer'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issue(employee : Manager, item : TransferableReceivable) : CancellationRequest &amp;lt;br&amp;gt; issue(employee : Executive, item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This may seem like a reasonable way to avoid code duplication, since presumably a CancellationRequest issued by a Manager will be more or less identical to one issued by an Executive.  However, there is an additional bit of logic in the domain model for a Manager which this design pushes into the service layer.  Namely, before allowing a Manager to issue a Cancellation request, the application must check that the Manager attribute hasVoidApproval equals true.&lt;br /&gt;
&lt;br /&gt;
Putting this logic in CancellationRequestIssuer violates the encapsulation of hasVoidApproval within Manager.  In addition, stripping this logic out of Manager reduces [http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29 cohesion.]  Furthermore, with this design, CancellationRequestIssuer is responsible for assuring that all domain objects which may issue a CancellationRequest are authorized to do so.  This means that CancellationRequestIssuer is tightly-coupled with these domain objects (in the sense that it needs information encapsulated within them to authorize requests).&lt;br /&gt;
&lt;br /&gt;
A better design keeps the domain object-specific logic in the domain model.  One way to accomplish this and still use the service object above is to add a mayIssueCancellationRequests() method to domain objects which may be passed to a CancellationRequestIssuer.  This allows domain objects to encapsulate their own specific logic, while allowing CancellationRequestIssuer to generalize the actual issuance of a CancellationRequest.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;AMBLER, S.  2010.  [http://www.agiledata.org/essays/agileDataModeling.html Agile/evolutionary data modeling: from domain modeling to physical modeling.]  In ''Agile Data.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;CHIN, P.-T.  2008.  [http://www.hostfrontier.com/index.php/200811029/agile-methodology/domain-modelling-using-color-uml.html Domain modelling using color UML.]  In ''TechnoGeek.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2002.  ''Patterns of Enterprise Application Architecture.''  Addison-Wesley Professional.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2003.  [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic domain model.]  In ''Martin Fowler's Bliki.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;OLDFIELD, P.  2002.  [http://www.aptprocess.com/whitepapers/DomainModelling.pdf Domain modelling.]  White paper, Mentors of Cally Ltd.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;PAPADIMOULIS, A.  2007.  [http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The mythical business layer.]  In ''The Daily WTF.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41705</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41705"/>
		<updated>2010-11-18T00:27:42Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The principle advantage of domain modelling is that it [http://en.wikipedia.org/wiki/Separation_of_concerns separates the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Understanding the problem domain is critical to developing a good domain model.  Well-designed software should exist to solve a problem.  The problem domain encompasses all the entities, relationships, data, rules, and logic that are necessary to solve the problem.  Conversely, entities, relationships, data, rules, and logic which are not necessary to solve the problem are outside the problem domain.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx &amp;quot;The mythical business layer.&amp;quot;]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.  Understanding which issues are specific and relevant to the problem domain and which are not is essential to developing a good domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic domain models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html anemic domain model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;br /&gt;
&lt;br /&gt;
For example, consider the business logic example given above.  One could create a service object CancellationRequestIssuer like the one diagrammed below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequestIssuer'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issue(employee : Manager, item : TransferableReceivable) : CancellationRequest &amp;lt;br&amp;gt; issue(employee : Executive, item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This may seem like a reasonable way to avoid code duplication, since presumably a CancellationRequest issued by a Manager will be more or less identical to one issued by an Executive.  However, there is an additional bit of logic in the domain model for a Manager which this design pushes into the service layer.  Namely, before allowing a Manager to issue a Cancellation request, the application must check that the Manager attribute hasVoidApproval equals true.&lt;br /&gt;
&lt;br /&gt;
Putting this logic in CancellationRequestIssuer violates the encapsulation of hasVoidApproval within Manager.  In addition, stripping this logic out of Manager reduces [http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29 cohesion.]  Furthermore, with this design, CancellationRequestIssuer is responsible for assuring that all domain objects which may issue a CancellationRequest are authorized to do so.  This means that CancellationRequestIssuer is tightly-coupled with these domain objects (in the sense that it needs information encapsulated within them to authorize requests).&lt;br /&gt;
&lt;br /&gt;
A better design keeps the domain object-specific logic in the domain model.  One way to accomplish this and still use the service object above is to add a mayIssueCancellationRequests() method to domain objects which may be passed to a CancellationRequestIssuer.  This allows domain objects to encapsulate their own specific logic, while allowing CancellationRequestIssuer to generalize the actual issuance of a CancellationRequest.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;AMBLER, S.  2010.  [http://www.agiledata.org/essays/agileDataModeling.html Agile/evolutionary data modeling: from domain modeling to physical modeling.]  In ''Agile Data.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;CHIN, P.-T.  2008.  [http://www.hostfrontier.com/index.php/200811029/agile-methodology/domain-modelling-using-color-uml.html Domain modelling using color UML.]  In ''TechnoGeek.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2002.  ''Patterns of Enterprise Application Architecture.''  Addison-Wesley Professional.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2003.  [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic domain model.]  In ''Martin Fowler's Bliki.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;OLDFIELD, P.  2002.  [http://www.aptprocess.com/whitepapers/DomainModelling.pdf Domain modelling.]  White paper, Mentors of Cally Ltd.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;PAPADIMOULIS, A.  2007.  [http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The mythical business layer.]  In ''The Daily WTF.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41677</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41677"/>
		<updated>2010-11-18T00:05:01Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* An example of business logic */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The principle advantage of domain modelling is that it [http://en.wikipedia.org/wiki/Separation_of_concerns separates the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Understanding the problem domain is critical to developing a good domain model.  Well-designed software should exist to solve a problem.  The problem domain encompasses all the entities, relationships, data, rules, and logic that are necessary to solve the problem.  Conversely, entities, relationships, data, rules, and logic which are not necessary to solve the problem are outside the problem domain.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx &amp;quot;The mythical business layer.&amp;quot;]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.  Understanding which issues are specific and relevant to the problem domain and which are not is essential to developing a good domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic domain models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html anemic domain model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;br /&gt;
&lt;br /&gt;
For example, consider the business logic example given above.  One could create a service object CancellationRequestIssuer like the one diagrammed below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequestIssuer'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issue(employee : Manager, item : TransferableReceivable) : CancellationRequest &amp;lt;br&amp;gt; issue(employee : Executive, item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This may seem like a reasonable way to avoid code duplication, since presumably a CancellationRequest issued by a Manager will be more or less identical to one issued by an Executive.  However, there is an additional bit of logic in the domain model for a Manager which this design pushes into the service layer.  Namely, before allowing a Manager to issue a Cancellation request, the application must check that the Manager attribute hasVoidApproval equals true.&lt;br /&gt;
&lt;br /&gt;
Putting this logic in CancellationRequestIssuer violates the encapsulation of hasVoidApproval within Manager.  In addition, stripping this logic out of Manager reduces [http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29 cohesion.]  Furthermore, with this design, CancellationRequestIssuer is responsible for assuring that all domain objects which may issue a CancellationRequest are authorized to do so.  This means that CancellationRequestIssuer is tightly-coupled with these domain objects (in the sense that it needs information encapsulated within them to authorize requests).&lt;br /&gt;
&lt;br /&gt;
A better design keeps the domain object-specific logic in the domain model.  One way to accomplish this and still use the service object above is to add a mayIssueCancellationRequests() method to domain objects which may be passed to a CancellationRequestIssuer.  This allows domain objects to encapsulate their own specific logic, while allowing CancellationRequestIssuer to generalize the actual issuance of a CancellationRequest.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;CHIN, P.-T.  2008.  [http://www.hostfrontier.com/index.php/200811029/agile-methodology/domain-modelling-using-color-uml.html Domain modelling using color UML.]  In ''TechnoGeek.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2002.  ''Patterns of Enterprise Application Architecture.''  Addison-Wesley Professional.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2003.  [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic domain model.]  In ''Martin Fowler's Bliki.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;OLDFIELD, P.  2002.  [http://www.aptprocess.com/whitepapers/DomainModelling.pdf Domain modelling.]  White paper, Mentors of Cally Ltd.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;PAPADIMOULIS, A.  2007.  [http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The mythical business layer.]  In ''The Daily WTF.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41672</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41672"/>
		<updated>2010-11-18T00:04:17Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Anemic domain models */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The principle advantage of domain modelling is that it [http://en.wikipedia.org/wiki/Separation_of_concerns separates the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Understanding the problem domain is critical to developing a good domain model.  Well-designed software should exist to solve a problem.  The problem domain encompasses all the entities, relationships, data, rules, and logic that are necessary to solve the problem.  Conversely, entities, relationships, data, rules, and logic which are not necessary to solve the problem are outside the problem domain.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.  Understanding which issues are specific and relevant to the problem domain and which are not is essential to developing a good domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic domain models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html anemic domain model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;br /&gt;
&lt;br /&gt;
For example, consider the business logic example given above.  One could create a service object CancellationRequestIssuer like the one diagrammed below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequestIssuer'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issue(employee : Manager, item : TransferableReceivable) : CancellationRequest &amp;lt;br&amp;gt; issue(employee : Executive, item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This may seem like a reasonable way to avoid code duplication, since presumably a CancellationRequest issued by a Manager will be more or less identical to one issued by an Executive.  However, there is an additional bit of logic in the domain model for a Manager which this design pushes into the service layer.  Namely, before allowing a Manager to issue a Cancellation request, the application must check that the Manager attribute hasVoidApproval equals true.&lt;br /&gt;
&lt;br /&gt;
Putting this logic in CancellationRequestIssuer violates the encapsulation of hasVoidApproval within Manager.  In addition, stripping this logic out of Manager reduces [http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29 cohesion.]  Furthermore, with this design, CancellationRequestIssuer is responsible for assuring that all domain objects which may issue a CancellationRequest are authorized to do so.  This means that CancellationRequestIssuer is tightly-coupled with these domain objects (in the sense that it needs information encapsulated within them to authorize requests).&lt;br /&gt;
&lt;br /&gt;
A better design keeps the domain object-specific logic in the domain model.  One way to accomplish this and still use the service object above is to add a mayIssueCancellationRequests() method to domain objects which may be passed to a CancellationRequestIssuer.  This allows domain objects to encapsulate their own specific logic, while allowing CancellationRequestIssuer to generalize the actual issuance of a CancellationRequest.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;CHIN, P.-T.  2008.  [http://www.hostfrontier.com/index.php/200811029/agile-methodology/domain-modelling-using-color-uml.html Domain modelling using color UML.]  In ''TechnoGeek.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2002.  ''Patterns of Enterprise Application Architecture.''  Addison-Wesley Professional.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2003.  [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic domain model.]  In ''Martin Fowler's Bliki.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;OLDFIELD, P.  2002.  [http://www.aptprocess.com/whitepapers/DomainModelling.pdf Domain modelling.]  White paper, Mentors of Cally Ltd.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;PAPADIMOULIS, A.  2007.  [http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The mythical business layer.]  In ''The Daily WTF.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41671</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41671"/>
		<updated>2010-11-18T00:03:57Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The principle advantage of domain modelling is that it [http://en.wikipedia.org/wiki/Separation_of_concerns separates the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Understanding the problem domain is critical to developing a good domain model.  Well-designed software should exist to solve a problem.  The problem domain encompasses all the entities, relationships, data, rules, and logic that are necessary to solve the problem.  Conversely, entities, relationships, data, rules, and logic which are not necessary to solve the problem are outside the problem domain.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.  Understanding which issues are specific and relevant to the problem domain and which are not is essential to developing a good domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic domain models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic Domain Model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;br /&gt;
&lt;br /&gt;
For example, consider the business logic example given above.  One could create a service object CancellationRequestIssuer like the one diagrammed below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequestIssuer'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issue(employee : Manager, item : TransferableReceivable) : CancellationRequest &amp;lt;br&amp;gt; issue(employee : Executive, item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This may seem like a reasonable way to avoid code duplication, since presumably a CancellationRequest issued by a Manager will be more or less identical to one issued by an Executive.  However, there is an additional bit of logic in the domain model for a Manager which this design pushes into the service layer.  Namely, before allowing a Manager to issue a Cancellation request, the application must check that the Manager attribute hasVoidApproval equals true.&lt;br /&gt;
&lt;br /&gt;
Putting this logic in CancellationRequestIssuer violates the encapsulation of hasVoidApproval within Manager.  In addition, stripping this logic out of Manager reduces [http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29 cohesion.]  Furthermore, with this design, CancellationRequestIssuer is responsible for assuring that all domain objects which may issue a CancellationRequest are authorized to do so.  This means that CancellationRequestIssuer is tightly-coupled with these domain objects (in the sense that it needs information encapsulated within them to authorize requests).&lt;br /&gt;
&lt;br /&gt;
A better design keeps the domain object-specific logic in the domain model.  One way to accomplish this and still use the service object above is to add a mayIssueCancellationRequests() method to domain objects which may be passed to a CancellationRequestIssuer.  This allows domain objects to encapsulate their own specific logic, while allowing CancellationRequestIssuer to generalize the actual issuance of a CancellationRequest.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;CHIN, P.-T.  2008.  [http://www.hostfrontier.com/index.php/200811029/agile-methodology/domain-modelling-using-color-uml.html Domain modelling using color UML.]  In ''TechnoGeek.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2002.  ''Patterns of Enterprise Application Architecture.''  Addison-Wesley Professional.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2003.  [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic domain model.]  In ''Martin Fowler's Bliki.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;OLDFIELD, P.  2002.  [http://www.aptprocess.com/whitepapers/DomainModelling.pdf Domain modelling.]  White paper, Mentors of Cally Ltd.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;PAPADIMOULIS, A.  2007.  [http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The mythical business layer.]  In ''The Daily WTF.''&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41663</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41663"/>
		<updated>2010-11-17T23:58:47Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The principle advantage of domain modelling is that it [http://en.wikipedia.org/wiki/Separation_of_concerns separates the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Understanding the problem domain is critical to developing a good domain model.  Well-designed software should exist to solve a problem.  The problem domain encompasses all the entities, relationships, data, rules, and logic that are necessary to solve the problem.  Conversely, entities, relationships, data, rules, and logic which are not necessary to solve the problem are outside the problem domain.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.  Understanding which issues are specific and relevant to the problem domain and which are not is essential to developing a good domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic domain models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic Domain Model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;br /&gt;
&lt;br /&gt;
For example, consider the business logic example given above.  One could create a service object CancellationRequestIssuer like the one diagrammed below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequestIssuer'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issue(employee : Manager, item : TransferableReceivable) : CancellationRequest &amp;lt;br&amp;gt; issue(employee : Executive, item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This may seem like a reasonable way to avoid code duplication, since presumably a CancellationRequest issued by a Manager will be more or less identical to one issued by an Executive.  However, there is an additional bit of logic in the domain model for a Manager which this design pushes into the service layer.  Namely, before allowing a Manager to issue a Cancellation request, the application must check that the Manager attribute hasVoidApproval equals true.&lt;br /&gt;
&lt;br /&gt;
Putting this logic in CancellationRequestIssuer violates the encapsulation of hasVoidApproval within Manager.  In addition, stripping this logic out of Manager reduces [http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29 cohesion.]  Furthermore, with this design, CancellationRequestIssuer is responsible for assuring that all domain objects which may issue a CancellationRequest are authorized to do so.  This means that CancellationRequestIssuer is tightly-coupled with these domain objects (in the sense that it needs information encapsulated within them to authorize requests).&lt;br /&gt;
&lt;br /&gt;
A better design keeps the domain object-specific logic in the domain model.  One way to accomplish this and still use the service object above is to add a mayIssueCancellationRequests() method to domain objects which may be passed to a CancellationRequestIssuer.  This allows domain objects to encapsulate their own specific logic, while allowing CancellationRequestIssuer to generalize the actual issuance of a CancellationRequest.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;CHIN, P.-T.  2008.  [http://www.hostfrontier.com/index.php/200811029/agile-methodology/domain-modelling-using-color-uml.html Domain modelling using color UML.]  TechnoGeek.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;FOWLER, M.  2002.  ''Patterns of Enterprise Application Architecture.''  Addison-Wesley Professional.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;OLDFIELD, P.  2002.  [http://www.aptprocess.com/whitepapers/DomainModelling.pdf Domain modelling.]  White paper, Mentors of Cally Ltd.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41660</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41660"/>
		<updated>2010-11-17T23:55:03Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The principle advantage of domain modelling is that it [http://en.wikipedia.org/wiki/Separation_of_concerns separates the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Understanding the problem domain is critical to developing a good domain model.  Well-designed software should exist to solve a problem.  The problem domain encompasses all the entities, relationships, data, rules, and logic that are necessary to solve the problem.  Conversely, entities, relationships, data, rules, and logic which are not necessary to solve the problem are outside the problem domain.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.  Understanding which issues are specific and relevant to the problem domain and which are not is essential to developing a good domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic domain models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic Domain Model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;br /&gt;
&lt;br /&gt;
For example, consider the business logic example given above.  One could create a service object CancellationRequestIssuer like the one diagrammed below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequestIssuer'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issue(employee : Manager, item : TransferableReceivable) : CancellationRequest &amp;lt;br&amp;gt; issue(employee : Executive, item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This may seem like a reasonable way to avoid code duplication, since presumably a CancellationRequest issued by a Manager will be more or less identical to one issued by an Executive.  However, there is an additional bit of logic in the domain model for a Manager which this design pushes into the service layer.  Namely, before allowing a Manager to issue a Cancellation request, the application must check that the Manager attribute hasVoidApproval equals true.&lt;br /&gt;
&lt;br /&gt;
Putting this logic in CancellationRequestIssuer violates the encapsulation of hasVoidApproval within Manager.  In addition, stripping this logic out of Manager reduces [http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29 cohesion.]  Furthermore, with this design, CancellationRequestIssuer is responsible for assuring that all domain objects which may issue a CancellationRequest are authorized to do so.  This means that CancellationRequestIssuer is tightly-coupled with these domain objects (in the sense that it needs information encapsulated within them to authorize requests).&lt;br /&gt;
&lt;br /&gt;
A better design keeps the domain object-specific logic in the domain model.  One way to accomplish this and still use the service object above is to add a mayIssueCancellationRequests() method to domain objects which may be passed to a CancellationRequestIssuer.  This allows domain objects to encapsulate their own specific logic, while allowing CancellationRequestIssuer to generalize the actual issuance of a CancellationRequest.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CHIN, P.-T.  2008.  [http://www.hostfrontier.com/index.php/200811029/agile-methodology/domain-modelling-using-color-uml.html Domain modelling using color UML.]  TechnoGeek.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
FOWLER, M.  2002.  ''Patterns of Enterprise Application Architecture.''  Addison-Wesley Professional.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
OLDFIELD, P.  2002.  [http://www.aptprocess.com/whitepapers/DomainModelling.pdf Domain modelling.]  White paper, Mentors of Cally Ltd.&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41658</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41658"/>
		<updated>2010-11-17T23:52:03Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The principle advantage of domain modelling is that it [http://en.wikipedia.org/wiki/Separation_of_concerns separates the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Understanding the problem domain is critical to developing a good domain model.  Well-designed software should exist to solve a problem.  The problem domain encompasses all the entities, relationships, data, rules, and logic that are necessary to solve the problem.  Conversely, entities, relationships, data, rules, and logic which are not necessary to solve the problem are outside the problem domain.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.  Understanding which issues are specific and relevant to the problem domain and which are not is essential to developing a good domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic domain models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic Domain Model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;br /&gt;
&lt;br /&gt;
For example, consider the business logic example given above.  One could create a service object CancellationRequestIssuer like the one diagrammed below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequestIssuer'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issue(employee : Manager, item : TransferableReceivable) : CancellationRequest &amp;lt;br&amp;gt; issue(employee : Executive, item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This may seem like a reasonable way to avoid code duplication, since presumably a CancellationRequest issued by a Manager will be more or less identical to one issued by an Executive.  However, there is an additional bit of logic in the domain model for a Manager which this design pushes into the service layer.  Namely, before allowing a Manager to issue a Cancellation request, the application must check that the Manager attribute hasVoidApproval equals true.&lt;br /&gt;
&lt;br /&gt;
Putting this logic in CancellationRequestIssuer violates the encapsulation of hasVoidApproval within Manager.  In addition, stripping this logic out of Manager reduces [http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29 cohesion.]  Furthermore, with this design, CancellationRequestIssuer is responsible for assuring that all domain objects which may issue a CancellationRequest are authorized to do so.  This means that CancellationRequestIssuer is tightly-coupled with these domain objects (in the sense that it needs information encapsulated within them to authorize requests).&lt;br /&gt;
&lt;br /&gt;
A better design keeps the domain object-specific logic in the domain model.  One way to accomplish this and still use the service object above is to add a mayIssueCancellationRequests() method to domain objects which may be passed to a CancellationRequestIssuer.  This allows domain objects to encapsulate their own specific logic, while allowing CancellationRequestIssuer to generalize the actual issuance of a CancellationRequest.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
FOWLER, M.  2002.  ''Patterns of Enterprise Application Architecture.''  Addison-Wesley Professional.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
OLDFIELD, P.  2002.  [http://www.aptprocess.com/whitepapers/DomainModelling.pdf Domain modelling.]  White paper, Mentors of Cally Ltd.&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41646</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41646"/>
		<updated>2010-11-17T23:45:40Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Domain Models */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The principle advantage of domain modelling is that it [http://en.wikipedia.org/wiki/Separation_of_concerns separates the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Understanding the problem domain is critical to developing a good domain model.  Well-designed software should exist to solve a problem.  The problem domain encompasses all the entities, relationships, data, rules, and logic that are necessary to solve the problem.  Conversely, entities, relationships, data, rules, and logic which are not necessary to solve the problem are outside the problem domain.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.  Understanding which issues are specific and relevant to the problem domain and which are not is essential to developing a good domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic domain models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic Domain Model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;br /&gt;
&lt;br /&gt;
For example, consider the business logic example given above.  One could create a service object CancellationRequestIssuer like the one diagrammed below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequestIssuer'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issue(employee : Manager, item : TransferableReceivable) : CancellationRequest &amp;lt;br&amp;gt; issue(employee : Executive, item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This may seem like a reasonable way to avoid code duplication, since presumably a CancellationRequest issued by a Manager will be more or less identical to one issued by an Executive.  However, there is an additional bit of logic in the domain model for a Manager which this design pushes into the service layer.  Namely, before allowing a Manager to issue a Cancellation request, the application must check that the Manager attribute hasVoidApproval equals true.&lt;br /&gt;
&lt;br /&gt;
Putting this logic in CancellationRequestIssuer violates the encapsulation of hasVoidApproval within Manager.  In addition, stripping this logic out of Manager reduces [http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29 cohesion.]  Furthermore, with this design, CancellationRequestIssuer is responsible for assuring that all domain objects which may issue a CancellationRequest are authorized to do so.  This means that CancellationRequestIssuer is tightly-coupled with these domain objects (in the sense that it needs information encapsulated within them to authorize requests).&lt;br /&gt;
&lt;br /&gt;
A better design keeps the domain object-specific logic in the domain model.  One way to accomplish this and still use the service object above is to add a mayIssueCancellationRequests() method to domain objects which may be passed to a CancellationRequestIssuer.  This allows domain objects to encapsulate their own specific logic, while allowing CancellationRequestIssuer to generalize the actual issuance of a CancellationRequest.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
FOWLER, M.  2002.  ''Patterns of Enterprise Application Architecture.''  Addison-Wesley Professional.&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41641</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41641"/>
		<updated>2010-11-17T23:39:54Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* An example of business logic */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The principle advantage of domain modelling is that it [http://en.wikipedia.org/wiki/Separation_of_concerns separates the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Understanding the problem domain is critical to developing a good domain model.  Well-designed software should exist to solve a problem.  The problem domain encompasses all the entities, relationships, data, rules, and logic that are necessary to solve the problem.  Conversely, entities, relationships, data, rules, and logic which are not necessary to solve the problem are outside the problem domain.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.  Understanding which issues are specific and relevant to the problem domain and which are not is essential to developing a good domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic domain models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic Domain Model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;br /&gt;
&lt;br /&gt;
For example, consider the business logic example given above.  One could create a service object CancellationRequestIssuer like the one diagrammed below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequestIssuer'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issue(employee : Manager, item : TransferableReceivable) : CancellationRequest &amp;lt;br&amp;gt; issue(employee : Executive, item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This may seem like a reasonable way to avoid code duplication, since presumably a CancellationRequest issued by a Manager will be more or less identical to one issued by an Executive.  However, there is an additional bit of logic in the domain model for a Manager which this design pushes into the service layer.  Namely, before allowing a Manager to issue a Cancellation request, the application must check that the Manager attribute hasVoidApproval equals true.&lt;br /&gt;
&lt;br /&gt;
Putting this logic in CancellationRequestIssuer violates the encapsulation of hasVoidApproval within Manager.  In addition, stripping this logic out of Manager reduces [http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29 cohesion.]  Furthermore, with this design, CancellationRequestIssuer is responsible for assuring that all domain objects which may issue a CancellationRequest are authorized to do so.  This means that CancellationRequestIssuer is tightly-coupled with these domain objects (in the sense that it needs information encapsulated within them to authorize requests).&lt;br /&gt;
&lt;br /&gt;
A better design keeps the domain object-specific logic in the domain model.  One way to accomplish this and still use the service object above is to add a mayIssueCancellationRequests() method to domain objects which may be passed to a CancellationRequestIssuer.  This allows domain objects to encapsulate their own specific logic, while allowing CancellationRequestIssuer to generalize the actual issuance of a CancellationRequest.&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41634</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41634"/>
		<updated>2010-11-17T23:37:20Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The principle advantage of domain modelling is that it [http://en.wikipedia.org/wiki/Separation_of_concerns separates the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Understanding the problem domain is critical to developing a good domain model.  Well-designed software should exist to solve a problem.  The problem domain encompasses all the entities, relationships, data, rules, and logic that are necessary to solve the problem.  Conversely, entities, relationships, data, rules, and logic which are not necessary to solve the problem are outside the problem domain.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic domain models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic Domain Model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;br /&gt;
&lt;br /&gt;
For example, consider the business logic example given above.  One could create a service object CancellationRequestIssuer like the one diagrammed below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequestIssuer'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issue(employee : Manager, item : TransferableReceivable) : CancellationRequest &amp;lt;br&amp;gt; issue(employee : Executive, item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This may seem like a reasonable way to avoid code duplication, since presumably a CancellationRequest issued by a Manager will be more or less identical to one issued by an Executive.  However, there is an additional bit of logic in the domain model for a Manager which this design pushes into the service layer.  Namely, before allowing a Manager to issue a Cancellation request, the application must check that the Manager attribute hasVoidApproval equals true.&lt;br /&gt;
&lt;br /&gt;
Putting this logic in CancellationRequestIssuer violates the encapsulation of hasVoidApproval within Manager.  In addition, stripping this logic out of Manager reduces [http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29 cohesion.]  Furthermore, with this design, CancellationRequestIssuer is responsible for assuring that all domain objects which may issue a CancellationRequest are authorized to do so.  This means that CancellationRequestIssuer is tightly-coupled with these domain objects (in the sense that it needs information encapsulated within them to authorize requests).&lt;br /&gt;
&lt;br /&gt;
A better design keeps the domain object-specific logic in the domain model.  One way to accomplish this and still use the service object above is to add a mayIssueCancellationRequests() method to domain objects which may be passed to a CancellationRequestIssuer.  This allows domain objects to encapsulate their own specific logic, while allowing CancellationRequestIssuer to generalize the actual issuance of a CancellationRequest.&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41630</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41630"/>
		<updated>2010-11-17T23:32:50Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Understanding the problem domain is critical to developing a good domain model.  Well-designed software should exist to solve a problem.  The problem domain encompasses all the entities, relationships, data, rules, and logic that are necessary to solve the problem.  Conversely, entities, relationships, data, rules, and logic which are not necessary to solve the problem are outside the problem domain.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic domain models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic Domain Model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;br /&gt;
&lt;br /&gt;
For example, consider the business logic example given above.  One could create a service object CancellationRequestIssuer like the one diagrammed below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequestIssuer'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issue(employee : Manager, item : TransferableReceivable) : CancellationRequest &amp;lt;br&amp;gt; issue(employee : Executive, item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This may seem like a reasonable way to avoid code duplication, since presumably a CancellationRequest issued by a Manager will be more or less identical to one issued by an Executive.  However, there is an additional bit of logic in the domain model for a Manager which this design pushes into the service layer.  Namely, before allowing a Manager to issue a Cancellation request, the application must check that the Manager attribute hasVoidApproval equals true.&lt;br /&gt;
&lt;br /&gt;
Putting this logic in CancellationRequestIssuer violates the encapsulation of hasVoidApproval within Manager.  In addition, stripping this logic out of Manager reduces [http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29 cohesion.]  Furthermore, with this design, CancellationRequestIssuer is responsible for assuring that all domain objects which may issue a CancellationRequest are authorized to do so.  This means that CancellationRequestIssuer is tightly-coupled with these domain objects (in the sense that it needs information encapsulated within them to authorize requests).&lt;br /&gt;
&lt;br /&gt;
A better design keeps the domain object-specific logic in the domain model.  One way to accomplish this and still use the service object above is to add a mayIssueCancellationRequests() method to domain objects which may be passed to a CancellationRequestIssuer.  This allows domain objects to encapsulate their own specific logic, while allowing CancellationRequestIssuer to generalize the actual issuance of a CancellationRequest.&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41618</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41618"/>
		<updated>2010-11-17T23:22:44Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Anemic Domain Models */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic domain models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic Domain Model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;br /&gt;
&lt;br /&gt;
For example, consider the business logic example given above.  One could create a service object CancellationRequestIssuer like the one diagrammed below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequestIssuer'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issue(employee : Manager, item : TransferableReceivable) : CancellationRequest &amp;lt;br&amp;gt; issue(employee : Executive, item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This may seem like a reasonable way to avoid code duplication, since presumably a CancellationRequest issued by a Manager will be more or less identical to one issued by an Executive.  However, there is an additional bit of logic in the domain model for a Manager which this design pushes into the service layer.  Namely, before allowing a Manager to issue a Cancellation request, the application must check that the Manager attribute hasVoidApproval equals true.&lt;br /&gt;
&lt;br /&gt;
Putting this logic in CancellationRequestIssuer violates the encapsulation of hasVoidApproval within Manager.  In addition, stripping this logic out of Manager reduces [http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29 cohesion.]  Furthermore, with this design, CancellationRequestIssuer is responsible for assuring that all domain objects which may issue a CancellationRequest are authorized to do so.  This means that CancellationRequestIssuer is tightly-coupled with these domain objects (in the sense that it needs information encapsulated within them to authorize requests).&lt;br /&gt;
&lt;br /&gt;
A better design keeps the domain object-specific logic in the domain model.  One way to accomplish this and still use the service object above is to add a mayIssueCancellationRequests() method to domain objects which may be passed to a CancellationRequestIssuer.  This allows domain objects to encapsulate their own specific logic, while allowing CancellationRequestIssuer to generalize the actual issuance of a CancellationRequest.&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41615</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41615"/>
		<updated>2010-11-17T23:21:37Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Anemic Domain Models */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic Domain Models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic Domain Model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;br /&gt;
&lt;br /&gt;
For example, consider the business logic example given above.  One could create a service object CancellationRequestIssuer like the one diagrammed below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequestIssuer'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issue(employee : Manager, item : TransferableReceivable) : CancellationRequest &amp;lt;br&amp;gt; issue(employee : Executive, item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This may seem like a reasonable way to avoid code duplication, since presumably a CancellationRequest issued by a Manager will be more or less identical to one issued by an Executive.  However, there is an additional bit of logic in the domain model for a Manager which this design pushes into the service layer.  Namely, before allowing a Manager to issue a Cancellation request, the application must check that the Manager attribute hasVoidApproval equals true.&lt;br /&gt;
&lt;br /&gt;
Putting this logic in CancellationRequestIssuer violates the encapsulation of hasVoidApproval within Manager.  In addition, stripping this logic out of Manager reduces [http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29 cohesion.]  Furthermore, with this design, CancellationRequestIssuer is responsible for assuring that all domain objects which may issue a CancellationRequest are authorized to do so.  This means that CancellationRequestIssuer is tightly-coupled with these domain objects (in the sense that it needs information encapsulated within them to authorize requests).&lt;br /&gt;
&lt;br /&gt;
A better design keeps the domain object-specific logic in the domain model.  One way to accomplish this and still use the service object above is to add a mayIssueCancellationRequests() method to domain objects which may be passed to a CancellationRequestIssuer.  This allows domain objects to encapsulate their own specific logic, while allowing CancellationRequestIssuer to generalize the actual issuance of a CancellationRequest.&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41609</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41609"/>
		<updated>2010-11-17T23:19:12Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Anemic Domain Models */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic Domain Models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic Domain Model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;br /&gt;
&lt;br /&gt;
For example, consider the business logic example given above.  One could create a service object CancellationRequestIssuer like the one diagrammed below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequestIssuer'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issue(employee : Manager, item : TransferableReceivable) : CancellationRequest &amp;lt;br&amp;gt; issue(employee : Executive, item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This may seem like a reasonable way to avoid code duplication, since presumably a CancellationRequest issued by a Manager will be more or less identical to one issued by an Executive.  However, there is an additional bit of logic in the domain model for a Manager which this design pushes into the service layer.  Namely, before allowing a Manager to issue a Cancellation request, the application must check that the Manager attribute hasVoidApproval equals true.&lt;br /&gt;
&lt;br /&gt;
Putting this logic in CancellationRequestIssuer violates the encapsulation of hasVoidApproval within Manager.  In addition, stripping this logic out of Manager reduces [http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29 cohesion.]  Furthermore, with this design, CancellationRequestIssuer is responsible for assuring that all domain objects which may issue a CancellationRequest are authorized to do so.  This means that CancellationRequestIssuer is tightly-coupled with these domain objects (in the sense that it needs information encapsulated within them to authorize requests).&lt;br /&gt;
&lt;br /&gt;
A better design keeps the business logic in the domain model.  One way to accomplish this and still use the service object introduced above is to add a mayIssueCancellationRequests() method to domain objects which may be passed to a CancellationRequestIssuer.  This allows domain objects to encapsulate their own specific business logic, while allowing CancellationRequestIssuer to generalize the actual issuance of a CancellationRequest.&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41605</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41605"/>
		<updated>2010-11-17T23:15:37Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Anemic Domain Models */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic Domain Models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic Domain Model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;br /&gt;
&lt;br /&gt;
For example, consider the business logic example given above.  One could create a service object CancellationRequestIssuer like the one diagrammed below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequestIssuer'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issue(employee : Manager, item : TransferableReceivable) : CancellationRequest &amp;lt;br&amp;gt; issue(employee : Executive, item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This may seem like a reasonable way to avoid code duplication, since presumably a CancellationRequest issued by a Manager will be more or less identical to one issued by an Executive.  However, there is an additional bit of logic in the domain model for a Manager which this design pushes into the service layer.  Namely, before allowing a Manager to issue a Cancellation request, the application must check that the Manager attribute hasVoidApproval equals true.&lt;br /&gt;
&lt;br /&gt;
Putting this logic in CancellationRequestIssuer violates the encapsulation of hasVoidApproval within Manager.  In addition, stripping this logic out of Manager reduces [http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29 cohesion.]  Furthermore, with this design, CancellationRequestIssuer is responsible for assuring that all domain objects which may issue a CancellationRequest are authorized to do so.  This means that CancellationRequestIssuer is tightly-coupled with these domain objects (in the sense that it needs information encapsulated within them to authorize requests).&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41579</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41579"/>
		<updated>2010-11-17T23:02:52Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic Domain Models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic Domain Model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;br /&gt;
&lt;br /&gt;
For example, consider the business logic example given above.  One could create a service object CancellationRequestIssuer like the one diagrammed below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequestIssuer'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issue(employee : Manager, item : TransferableReceivable) : CancellationRequest &amp;lt;br&amp;gt; issue(employee : Executive, item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This may seem like a reasonable way to avoid code duplication, since presumably a CancellationRequest issued by a Manager will be more or less identical to one issued by an Executive.  However, there is an additional bit of logic in the domain model for a Manager which this design pushes into the service layer.  Namely, before allowing a Manager to issue a Cancellation request, the application must check that the Manager attribute hasVoidApproval equals true.&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41551</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41551"/>
		<updated>2010-11-17T22:55:02Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Anemic Domain Models */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic Domain Models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic Domain Model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;br /&gt;
&lt;br /&gt;
For example, consider the business logic example given above.  One could create a service object CancellationRequestIssuer with the methods issue(employee : Manager, item : TransferableReceivable)&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41542</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41542"/>
		<updated>2010-11-17T22:51:24Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Anemic Domain Models */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic Domain Models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic Domain Model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  However, the domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41538</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41538"/>
		<updated>2010-11-17T22:49:36Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Anemic Domain Models */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic Domain Models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic Domain Model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  The domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41536</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41536"/>
		<updated>2010-11-17T22:49:13Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Anemic Domain Models */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic Domain Models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic Domain Model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom is the presence of a domain layer and a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  The domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41531</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41531"/>
		<updated>2010-11-17T22:48:52Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Anemic Domain Models */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic Domain Models==&lt;br /&gt;
&lt;br /&gt;
When domain models fail to encapsulate behavior as well as entities and data, the [http://martinfowler.com/bliki/AnemicDomainModel.html Anemic Domain Model] [http://en.wikipedia.org/wiki/Anti-pattern anti-pattern] results.  One symptom of this anti-pattern is the presence of a domain layer and a [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer] which provides methods which operate on the objects in the domain model.  Adding a service layer can reduce code duplication, especially if there are many different domain objects with similar behaviours.  The domain model becomes anemic when the service layer unnecessarily subsumes behaviours from the domain model.&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41486</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41486"/>
		<updated>2010-11-17T22:27:16Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* An example of business logic */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Has-a relationships are represented through attributes.  Is-a relationships are not explored.  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic Domain Models==&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41482</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41482"/>
		<updated>2010-11-17T22:25:06Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* An example of business logic */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that could be represented in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Relationships are not represented.  Sale has a one-to-many has-a relationship with TransferableReceivable (an item that is included in the sale).  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic Domain Models==&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41478</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41478"/>
		<updated>2010-11-17T22:24:21Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Domain_model domain model] is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that might be representing in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Relationships are not represented.  Sale has a one-to-many has-a relationship with TransferableReceivable (an item that is included in the sale).  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic Domain Models==&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41475</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41475"/>
		<updated>2010-11-17T22:23:22Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* An example of business logic */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The domain model is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that might be representing in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  Potential domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Possible class diagrams for the domain objects are presented in UML below.  Relationships are not represented.  Sale has a one-to-many has-a relationship with TransferableReceivable (an item that is included in the sale).  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice how these class diagrams encapsulate entities (domain objects), data (attributes), and behaviour (methods) which are relevant and specific to the business problem that the application solves, namely cancelling items from a sale which has been cleared.  This domain model does not address how information is presented to the user or how information is made persistent.  These are issues which are not specific to the problem domain and are therefore addressed outside the domain model.&lt;br /&gt;
&lt;br /&gt;
==Anemic Domain Models==&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41463</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41463"/>
		<updated>2010-11-17T22:17:05Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* An example of business logic */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The domain model is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that might be representing in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  The domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Class diagrams for the domain objects are presented in UML below.  Relationships are not represented.  Sale has a one-to-many has-a relationship with TransferableReceivable (an item that is included in the sale).  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
| item : TransferableReceivable&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Anemic Domain Models==&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41457</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41457"/>
		<updated>2010-11-17T22:15:00Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Business Logic */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The domain model is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==An example of business logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that might be representing in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  The domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Class diagrams for the domain objects are presented in UML below.  Relationships are not represented.  Sale has a one-to-many has-a relationship with TransferableReceivable (an item that is included in the sale).  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Anemic Domain Models==&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41454</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41454"/>
		<updated>2010-11-17T22:14:40Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Business Logic */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The domain model is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==Business Logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that might be representing in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  The domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
Class diagrams for the domain objects are presented in UML below.  Relationships are not represented.  Sale has a one-to-many has-a relationship with TransferableReceivable (an item that is included in the sale).  It would stand to reason that Manager and Executive both inherit from an Employee class, but this is not modelled below.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Anemic Domain Models==&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41427</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41427"/>
		<updated>2010-11-17T22:03:53Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Business Logic */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The domain model is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==Business Logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that might be representing in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances of the cancellation of an item (TransferableReceivable) from a sale.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  The domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
| items : TransferableReceivable[]&lt;br /&gt;
|-&lt;br /&gt;
| clear()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval : Boolean&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(item : TransferableReceivable) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing() &amp;lt;br&amp;gt; issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus : Enum &amp;lt;br&amp;gt; expenseAllocationType : Enum&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Anemic Domain Models==&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41401</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41401"/>
		<updated>2010-11-17T21:42:41Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Business Logic */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The domain model is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==Business Logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that might be representing in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances under which a sale may be cancelled.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  The domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is issueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Sale'''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| clear() : TransferableReceivable&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Manager'''&lt;br /&gt;
|-&lt;br /&gt;
| hasVoidApproval&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(sale : Sale) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''Executive'''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| issueACancellationRequest(sale : Sale) : CancellationRequest&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''CancellationRequest'''&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| issueForProcessing()&lt;br /&gt;
| issueForApproval()&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| '''TransferableReceivable'''&lt;br /&gt;
|-&lt;br /&gt;
| propagationStatus &amp;lt;br&amp;gt; expenseAllocationType&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Anemic Domain Models==&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41351</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41351"/>
		<updated>2010-11-17T21:16:15Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Business Logic */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The domain model is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==Business Logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that might be representing in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example dictates the circumstances under which a sale may be cancelled.  An example of a rule contained in the statement is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;  The domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a behaviour that a Manager may exhibit is IssueACancellationRequest().  An example of domain-specific data is hasVoidApproval which is an attribute of a Manager.&lt;br /&gt;
&lt;br /&gt;
==Anemic Domain Models==&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41338</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41338"/>
		<updated>2010-11-17T21:10:27Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Business Logic */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The domain model is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==Business Logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that might be representing in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
''When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.''&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, the domain objects are Sale, Manager, Executive, CancellationRequest, and TransferableReceivable.  An example of a rule is that &amp;quot;only Managers with Void Approval... may issue a Cancellation Request.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==Anemic Domain Models==&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41303</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41303"/>
		<updated>2010-11-17T20:47:09Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The domain model is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
==Business Logic==&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that might be representing in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Anemic Domain Models==&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41301</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41301"/>
		<updated>2010-11-17T20:46:16Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Domain Model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Models=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The domain model is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person, an important abstraction in the domain model, does not even appear in the PetClinic database.  This is because the database is primarily concerned with storing and retrieving application data.  Abstractions are relevant to the domain model, but the database only needs to represent concrete data.&lt;br /&gt;
&lt;br /&gt;
The PetClinic example is useful for understanding domain objects and the relationships between them, but another important aspect of the domain model is that it represents rules and logic that are specific to the problem domain.  The following example of some business logic that might be representing in a domain model appears in&lt;br /&gt;
[http://thedailywtf.com/Articles/The-Mythical-Business-Layer.aspx The Mythical Business Layer.]&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41259</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41259"/>
		<updated>2010-11-17T19:57:20Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Domain Model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Model=&lt;br /&gt;
&lt;br /&gt;
The domain model is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.  These relationships are of little relevance to the user interface.  In the database, some relationships, particularly has-a relationships, must be represented.  However, others, like is-a relationships, typically do not.  For example, the base class Person does not even appear in the PetClinic database.&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41248</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41248"/>
		<updated>2010-11-17T19:52:14Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Domain Model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Model=&lt;br /&gt;
&lt;br /&gt;
The domain model is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  The essential elements of the domain model are represented in UML in the figure below.  The domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
[[Image:Pet_clinic_uml.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Pet_clinic_uml.png&amp;diff=41233</id>
		<title>File:Pet clinic uml.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Pet_clinic_uml.png&amp;diff=41233"/>
		<updated>2010-11-17T19:48:05Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: A simple UML representation of the domain model from the Spring Framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A simple UML representation of the domain model from the Spring Framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application.&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41216</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41216"/>
		<updated>2010-11-17T19:32:26Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Domain Model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Model=&lt;br /&gt;
&lt;br /&gt;
The domain model is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  In this application, the domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
In addition to representing real world entities (domain objects), domain models also represent the relationships between these entities.  For example, an Owner has an [http://en.wikipedia.org/wiki/Is-a is-a] relationship with a Person and a [http://en.wikipedia.org/wiki/Has-a has-a] relationship with a Pet.&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41215</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41215"/>
		<updated>2010-11-17T19:27:54Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Domain Model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Model=&lt;br /&gt;
&lt;br /&gt;
The domain model is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application, which is a simple example of a three-tier architecture.  In this application, the domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41205</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41205"/>
		<updated>2010-11-17T19:22:04Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Domain Model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Model=&lt;br /&gt;
&lt;br /&gt;
The domain model is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modelling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of domain-specific problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier (domain model) is responsible for solving problems in the specific domain of the application (often a business domain, hence the term business logic).  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;br /&gt;
&lt;br /&gt;
The three-tier architecture illustrates how domain modelling helps achieve separation of concerns.  The presentation tier could be implemented in a number of different ways.  For example, it could be a command-line interface (CLI), a graphical user interface (GUI), or a web-based interface.  It might be desirable to support several different types of user interfaces.  However, the type of interface and its implementation is largely independent from the problem domain.  Separating the behaviour and data of the user interface from the behaviour and data of domain model enables developers to reuse domain-specific code while implementing various user interfaces.  In addition, weak coupling between the user interface and domain model allows the domain-specific code to vary with negligible effect on the user interface code.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application.  In this application, the domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with GUI objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41160</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41160"/>
		<updated>2010-11-17T18:03:29Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Domain Model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Model=&lt;br /&gt;
&lt;br /&gt;
The domain model is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modeling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application.  In this application, the domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with graphical user interface (GUI) objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), business tier, and logic tier.  Many of these terms are used when describing [http://en.wikipedia.org/wiki/Multitier_architecture multi-tier architectures.]  The canonical example is the three-tier architecture composed of the a presentation tier, logic tier, and data tier.  The presentation tier is responsible for the user interface.  The logic tier is responsible for solving problems in the specific domain of the application.  The data tier is responsible for storing and retrieving information, typically to and from a database.&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41150</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41150"/>
		<updated>2010-11-17T17:55:47Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: /* Domain Model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Model=&lt;br /&gt;
&lt;br /&gt;
The domain model is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modeling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application.  In this application, the domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with graphical user interface (GUI) objects like buttons and text fields which are not relevant to the problem domain (in this case, operating a veterinary clinic).&lt;br /&gt;
&lt;br /&gt;
A number of different terms are used to refer to the domain model and related concepts.  These include Domain Object Model (DOM), domain layer, business layer, business logic, business logic layer (BLL), and business tier.&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41146</id>
		<title>CSC/ECE 517 Fall 2010/ch6 6h mf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch6_6h_mf&amp;diff=41146"/>
		<updated>2010-11-17T17:46:21Z</updated>

		<summary type="html">&lt;p&gt;Mafashin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Domain Model=&lt;br /&gt;
&lt;br /&gt;
The domain model is an [http://en.wikipedia.org/wiki/Object_model object model] that encapsulates the rules, logic, and data associated with the [http://en.wikipedia.org/wiki/Problem_domain problem domain.]  The purpose of domain modeling is to [http://en.wikipedia.org/wiki/Separation_of_concerns separate the concern] of problem solving from other concerns like the user interface and persistent storage.&lt;br /&gt;
&lt;br /&gt;
Domain objects represent real world entities, both tangible and intangible, encountered in the problem domain.  For example, consider the Spring framework [http://static.springsource.org/docs/petclinic.html PetClinic] sample application.  In this application, the domain objects include Person, Vet, Owner, Pet, and Visit.  Visit is an example of an intangible entity, in other words an abstract concept, that is part of the problem domain.  Contrast these domain objects with graphical user interface (GUI) objects like buttons and text fields which are not relevant to the problem domain.&lt;/div&gt;</summary>
		<author><name>Mafashin</name></author>
	</entry>
</feed>