<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Architecture Rules - Blog &#187; tutorial</title>
	<atom:link href="http://blog.architecturerules.org/tag/tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.architecturerules.org</link>
	<description>"Assert Your Architecture"</description>
	<lastBuildDate>Thu, 20 Aug 2009 11:24:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Architecture Rules Tutorial: 102</title>
		<link>http://blog.architecturerules.org/architecture-rules-tutorial-102/</link>
		<comments>http://blog.architecturerules.org/architecture-rules-tutorial-102/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 00:48:23 +0000</pubDate>
		<dc:creator>MikeNereson</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.architecturerules.org/?p=76</guid>
		<description><![CDATA[This is the second part in an introduction to Architecture Rules. In this tutorial we show how to tune the exceptions that Architecture Rules can throw under specific conditions.]]></description>
			<content:encoded><![CDATA[<p>This is the second part in an introduction to Architecture Rules.</p>
<p>The first part, <a href="architecture-rules-tutorial-101">Architecture Rules 101</a> went over a short, sweet, and simple configuration.</p>
<h3>Reminder</h3>
<p>So remember, the basics of Architecture Rules is that it is</p>
<ul>
<li>Java.</li>
<li><a href="http://www.apache.org/licenses/LICENSE-2.0">Open Source</a>.</li>
<li>Asserts architectural rules via unit tests.</li>
<li>You write your rules in <a href="http://wiki.architecturerules.org/index.php?title=SampleConfiguration">XML</a>.</li>
<li>Your run your tests with junit, <a href="http://architecturerules.googlecode.com/svn/docs/run.html#ant-task">ant</a>, or a continuous integration server.</li>
</ul>
<h3>Source Locations</h3>
<p>In this second installment of introductions to Architecture Rules, we&#8217;re going to go over source locations which enables the tool to support multi-module projects, and allows you to define when a particular source must exist, or may be optional.</p>
<p>By allowing a source to be optional, you can have different developers with different modules of code. So while one developer may have all eight modules of a project, another developer may only need to work on two or three of the modules.</p>
<h3>Configuration</h3>
<p>Here is an example that uses all of the current features supported by <strong>Architecture Rules 2.0.3</strong>.</p>
<pre class="brush: xml;">
&lt;configuration&gt;

&lt;sources no-packages=&quot;exception&quot;&gt;
&lt;source not-found=&quot;exception&quot;&gt;coretargetclasses&lt;/source&gt;
&lt;source not-found=&quot;ignore&quot;&gt;webtargetclasses&lt;/source&gt;
&lt;source not-found=&quot;ignore&quot;&gt;wstargetclasses&lt;/source&gt;
&lt;/sources&gt;

&lt;/configuration&gt;
</pre>
<p>The first property that we see is the <tt>sources no-packages="exception"</tt>. This tells Architecture Rule that, after reading all of the defined source directories, if no classes are found, then throw an Exception, more specifically, a <a href="http://wiki.architecturerules.org/index.php?title=Exceptions#NoPackagesFoundException">NoPackagesFoundException</a>. Here are the configuration options for <tt>no-packages</tt>:</p>
<table class="api_table" border="0">
<caption>sources no-packages values</caption>
<tbody>
<tr>
<th style="width: 100px;">Value</th>
<th>Description</th>
</tr>
</tbody>
<tbody>
<tr class="odd">
<td>exception</td>
<td>causes a NoPackagesFoundException when zero classes are found among all of the defined sources</td>
</tr>
<tr class="even">
<td>ignore</td>
<td><strong>default</strong> all test continue although there are no classes to test</td>
</tr>
</tbody>
</table>
<p>The next interesting thing that we come across is <tt>&lt;source not-found="ignore"&gt;</tt> This configuration causes a <a href="http://wiki.architecturerules.org/index.php?title=Exceptions#SourceNotFoundException">SourceNotFoundException</a> when the given path can not be found on the file system. This allows you to ensure that specific modules are present in the test. Alternatively, if you don&#8217;t particularly care if some source path is present, you can use the ignore value, which happens to be the default value. In the example above, the core module must be present for the tests to continue. The web and web services (ws) modules are optional.</p>
<table class="api_table" border="0">
<caption>source not-found values</caption>
<tbody>
<tr>
<th style="width: 100px;">Value</th>
<th>Description</th>
</tr>
</tbody>
<tbody>
<tr class="odd">
<td>exception</td>
<td>causes a SourceNotFoundException when the path does not exist</td>
</tr>
<tr class="even">
<td>ignore</td>
<td><strong>default</strong> all test continue although the classes at the given path will not be included in the test</td>
</tr>
</tbody>
</table>
<p>So, after showing the simplistic configuration in Architecture Rules 101, we have now shown how you can customize your configuration to fit your needs with little work.</p>
<p>In the next Architecture Rules lesson, we&#8217;ll demonstrate how to get the Configuration and show how easy it is to provide programmatic configuration instead of or in addition to the XML configuration. Also coming up right after that, we&#8217;ll finally introduce the Maven 2 Architecture Rules plugin that Mykola has been working on for the past couple of months.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fblog.architecturerules.org%2Farchitecture-rules-tutorial-102%2F&amp;linkname=Architecture%20Rules%20Tutorial%3A%20102">Share/Save</a><h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://blog.architecturerules.org/architecture-rules-tutorial-101/" title="Architecture Rules Tutorial: 101">Architecture Rules Tutorial: 101</a></li></ul><hr />
<p><small>&copy; MikeNereson for <a href="http://blog.architecturerules.org">Architecture Rules - Blog</a>, 2008. |
<a href="http://blog.architecturerules.org/architecture-rules-tutorial-102/">Permalink</a> |
<a href="http://blog.architecturerules.org/architecture-rules-tutorial-102/#comments">One comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://blog.architecturerules.org/architecture-rules-tutorial-102/&amp;title=Architecture Rules Tutorial: 102">del.icio.us</a>
<br/>
Post tags: <a href="http://blog.architecturerules.org/tag/tutorial/" rel="tag">tutorial</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.architecturerules.org/architecture-rules-tutorial-102/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Architecture Rules Tutorial: 101</title>
		<link>http://blog.architecturerules.org/architecture-rules-tutorial-101/</link>
		<comments>http://blog.architecturerules.org/architecture-rules-tutorial-101/#comments</comments>
		<pubDate>Thu, 03 Apr 2008 00:55:43 +0000</pubDate>
		<dc:creator>MikeNereson</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.architecturerules.org/?p=87</guid>
		<description><![CDATA[A short sweet tutorial to get you started with a simple XML configuration.]]></description>
			<content:encoded><![CDATA[<p>How about a short, sweet introduction to <a href="http://architecturerules.org">Architecture Rules</a>.</p>
<h3>The Basics</h3>
<ul>
<li>Java.</li>
<li><a href="http://www.apache.org/licenses/LICENSE-2.0">Open Source</a>.</li>
<li>Asserts architectural rules via unit tests.</li>
<li>Write your rules in <a href="http://wiki.architecturerules.org/index.php?title=SampleConfiguration">XML</a>.</li>
<li>Run your tests with junit, <a href="http://architecturerules.googlecode.com/svn/docs/run.html#ant-task">ant</a>, or a continuous integration server.</li>
</ul>
<h3>Your Rules</h3>
<p>You define your rules. For example, if you are developing n-tiered software, you probably have three layers. A DAO/integration layer, a service/business layer, and a presentation layer. Generally, the presentation layer does not interact directly with the integration layer. You could describe this rule as:  <tt>com.company.project.presentation</tt> can not depend on the <tt>com.company.project.integration</tt> package.  Its that easy.</p>
<h3>The XML</h3>
<p>The XML is in <em>architecture-rules.xml</em> and contains two section: <tt>&lt;configuration&gt;</tt> and <tt>&lt;rules&gt;</tt>. Configuration describes where your files are, and the rules simply describe a package, and one or more packages that it can not depend on.</p>
<pre class="brush: xml;">
&lt;architecture&gt;

&lt;configuration&gt;
&lt;sources&gt;
&lt;source&gt;targetclasses&lt;/source&gt;
&lt;/sources&gt;
&lt;/configuration&gt;

&lt;rules&gt;

&lt;rule id=&quot;dao&quot;&gt;
&lt;packages&gt;
&lt;package&gt;
com.company.project.presentation
&lt;/package&gt;
&lt;/packages&gt;
&lt;violations&gt;
&lt;violation&gt;
com.company.project.integration
&lt;/violation&gt;
&lt;/violations&gt;
&lt;/rule&gt;

&lt;/rules&gt;

&lt;/architecture&gt;
</pre>
<p>Thats it. You have a simple <em>architecture-rules.xml.</em></p>
<h3>The Unit Test</h3>
<p>Just extend and run your tests.</p>
<pre class="brush: java;">
public class SimpleArchitectureTest
extends AbstractArchitectureRulesConfigurationTest {

public String getConfigurationFileName() {
return &quot;architecture-rules.xml&quot;;
}

public void testArchitecture() {
assertTrue(doTests());
}
}
</pre>
<h3>More Features</h3>
<p>In Architecture Rules 201, we&#8217;ll show you how to check for cycles (<a href="http://wiki.architecturerules.org/index.php?title=CyclicDependencies">cyclic dependencies</a>), write more action-packed rules, and describe how to handle source paths that can&#8217;t be found.  We can also take a gander at the various <a href="http://wiki.architecturerules.org/index.php?title=Exceptions">Exceptions</a> that can be thrown when rules are broken.</p>
<h3>Go Get It</h3>
<p>The next thing to do, is to go get it and try it out. <a href="http://wiki.architecturerules.org/index.php?title=DownloadFromGoogle">Download</a>, <a href="http://wiki.architecturerules.org/index.php?title=SVN">svn checkout</a>, or put it in your pom.xml. Just add this repository:</p>
<pre class="brush: xml;">
&lt;repository&gt;
&lt;id&gt;architect-rules-repo&lt;/id&gt;
&lt;name&gt;
architecture-rules hosted by code.google.com
&lt;/name&gt;
&lt;layout&gt;default&lt;/layout&gt;
&lt;url&gt;

http://architecturerules.googlecode.com/svn/maven2/

&lt;/url&gt;
&lt;releases&gt;
&lt;checksumPolicy&gt;ignore&lt;/checksumPolicy&gt;
&lt;/releases&gt;
&lt;snapshots&gt;
&lt;checksumPolicy&gt;ignore&lt;/checksumPolicy&gt;
&lt;/snapshots&gt;
&lt;/repository&gt;
</pre>
<p>And this dependency:</p>
<pre class="brush: xml;">
&lt;dependency&gt;
&lt;groupId&gt;com.seventytwomiles&lt;/groupId&gt;
&lt;artifactId&gt;architecture-rules&lt;/artifactId&gt;
&lt;version&gt;2.0.3&lt;/version&gt;
&lt;/dependency&gt;
</pre>
<p><a title="architecture rules xml by 72miles, on Flickr" href="http://www.flickr.com/photos/25114327@N04/2383685309/"><img src="http://farm4.static.flickr.com/3234/2383685309_6fb415ca1e_m.jpg" alt="architecture rules xml" width="210" height="160" /></a> <a title="architecture rules java by 72miles, on Flickr" href="http://www.flickr.com/photos/25114327@N04/2384515078/"><img src="http://farm3.static.flickr.com/2138/2384515078_6124049618_m.jpg" alt="architecture rules java" width="210" height="160" /></a></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fblog.architecturerules.org%2Farchitecture-rules-tutorial-101%2F&amp;linkname=Architecture%20Rules%20Tutorial%3A%20101">Share/Save</a><h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://blog.architecturerules.org/architecture-rules-tutorial-102/" title="Architecture Rules Tutorial: 102">Architecture Rules Tutorial: 102</a></li></ul><hr />
<p><small>&copy; MikeNereson for <a href="http://blog.architecturerules.org">Architecture Rules - Blog</a>, 2008. |
<a href="http://blog.architecturerules.org/architecture-rules-tutorial-101/">Permalink</a> |
<a href="http://blog.architecturerules.org/architecture-rules-tutorial-101/#comments">2 comments</a> |
Add to
<a href="http://del.icio.us/post?url=http://blog.architecturerules.org/architecture-rules-tutorial-101/&amp;title=Architecture Rules Tutorial: 101">del.icio.us</a>
<br/>
Post tags: <a href="http://blog.architecturerules.org/tag/tutorial/" rel="tag">tutorial</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.architecturerules.org/architecture-rules-tutorial-101/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
