<?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>smartcodellc.com</title>
	<atom:link href="http://smartcodellc.com/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://smartcodellc.com/html</link>
	<description></description>
	<lastBuildDate>Sat, 17 Jul 2010 13:40:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Using QoS as a guide to partitioning your application and scaling your architecture</title>
		<link>http://smartcodellc.com/html/2010/07/17/using-qos-as-a-guide-to-partitioning-your-application-and-scaling-your-architecture/</link>
		<comments>http://smartcodellc.com/html/2010/07/17/using-qos-as-a-guide-to-partitioning-your-application-and-scaling-your-architecture/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 13:39:27 +0000</pubDate>
		<dc:creator>Dushyanth (Dee) Inguva</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Accidental Architecture]]></category>
		<category><![CDATA[Technical Debt]]></category>

		<guid isPermaLink="false">http://smartcodellc.com/html/?p=55</guid>
		<description><![CDATA[Enterprise Applications typically have a lot of moving parts. This includes a lot of components with typically different QoS (Quality of Service) requirements. When you have to split your application, it often makes sense to identify components that have different QoS requirements and use that as a guiding line to split your application. It is [...]]]></description>
			<content:encoded><![CDATA[<p>Enterprise Applications typically have a lot of moving parts. This includes a lot of components with typically different QoS (Quality of Service) requirements. When you have to split your application, it often makes sense to identify components that have different QoS requirements and use that as a guiding line to split your application.</p>
<p>It is common for many Enterprise Applications to grow over time resulting in an <a href="http://thinking.bigskyassociates.com/2008/06/soa-cure-for-accidental-architecture.html">accidental architecture</a>. Accidental architecture is not entirely preventable. Deadlines, delivery schedule changes and other factors might force you to accrue technical debt. I am a firm believer of agile methodologies where you address the problem at hand and then come back and refactor when you have to address a new issue. I am definitely not advocating doing no design or architecture up front. As Uncle Bob Martin puts it, <a href="http://blog.objectmentor.com/articles/2009/04/25/the-scatology-of-agile-architecture">BDUF (Big Design Up Front) is bad but LDUF (Little Design Up Front) is good</a>. Even when you follow these advices, it is entirely possible and normal to accrue <a href="http://www.martinfowler.com/bliki/TechnicalDebt.html">Technical Debt</a> and the solution is to embrace refactoring. </p>
<p>Once you do have a system with an accidental architecture in place, and you have to refactor it, part of that refactoring process will involve splitting your now monolithic application into individual services that can be scaled independently. Even if you have been modularizing your application well and have designed your application to use multiple services, your services could still be deployed in the same process or virtual machine.</p>
<p>As previously stated, Enterprise Applications typically have several moving parts. In addition to request processing, additional tasks your application is already performing may include Email Jobs, Reporting, Reconciliation jobs, Data processing tasks like risk analysis, even indexing and searching. A reconciliation task has a different Quality of Service requirement than regular request processing. If you are thinking of splitting your application, it makes sense to identify tasks that your application is already performing that have different QoS to the main functionality of your application and use that to split the tasks into independent services that live on your network.</p>
<p>Recently, at one of my clients, a reconciliation task built into the application was chocking up regular request processing in terms of memory. Splitting it into an independent service freed up the main server to provide much better response times. Pay attention to QoS requirements, identify services with different QoS requirements and use that to scale your architecture.</p>
]]></content:encoded>
			<wfw:commentRss>http://smartcodellc.com/html/2010/07/17/using-qos-as-a-guide-to-partitioning-your-application-and-scaling-your-architecture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Case Against a Purely Interface based domain object model</title>
		<link>http://smartcodellc.com/html/2010/07/13/case-against-an-interface-based-domain-object-model/</link>
		<comments>http://smartcodellc.com/html/2010/07/13/case-against-an-interface-based-domain-object-model/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 02:44:15 +0000</pubDate>
		<dc:creator>Dushyanth (Dee) Inguva</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Domain Modelling]]></category>

		<guid isPermaLink="false">http://smartcodellc.com/html/?p=43</guid>
		<description><![CDATA[When designing a domain model in an object oriented language such as Java, one way to design is to model the entire domain model using just interfaces and then create concrete Impl classes that implement each interface. While this sounds tempting because of it&#8217;s added layer of abstraction, it is counter productive almost all of [...]]]></description>
			<content:encoded><![CDATA[<div>When designing a domain model in an object oriented language such as Java, one way to design is to model the entire domain model using just interfaces and then create concrete Impl classes that implement each interface. While this sounds tempting because of it&#8217;s added layer of abstraction, it is counter productive almost all of the time. Let us see why.</p>
<p>Since we have an interface for each and every domain object, the concrete Java classes are never exposed to the rest of the application except during the creation phase. Often, a factory (or abstract factory) pattern is also used to entirely abstract the Java classes away from the rest of the application.</p>
<p>Let us consider an example where we are modeling a CheckingAccount and SavingsAccount objects. We can define 3 interfaces that look like:<br />
<code>public interface Account {<br />
// accessors...<br />
}</p>
<p>public interface SavingsAccount extends Account {<br />
// accessors...<br />
}</p>
<p>public interface CheckingAccount extends Account {<br />
// accessors...<br />
}</code></p>
<p>Further, we define 3 Impl classes that implement each of these interfaces</p>
<p><code>public abstract class AccountImpl implements Account {<br />
// accessor implementation<br />
}</p>
<p>public class SavingsAccountImpl implements SavingsAccount {<br />
// accessor implementation<br />
}</p>
<p>public class CheckingAccountImpl implements CheckingAccount {<br />
// accessor implementation<br />
}</code></p>
<p>Another way of implementing would be to use a <a href="http://download.oracle.com/docs/cd/E17409_01/javase/6/docs/api/java/lang/reflect/Proxy.html">java.lang.reflect.Proxy</a> based dynamic Proxy to provide implementation to the domain interfaces. In this case, you will just code the interfaces and will rely on a factory to generate the implementations on the fly. While this method of implementation reduces the number of classes that you have to code, it suffers from the same problems that the above example does. Let us see why in the section below.</p>
<p>Just to clarify what I am making a case against, using interfaces/abstract classes to denote abstract concepts in the domain model is a perfectly valid use case. Example to that would be to define the account type from above as an interface or abstract class and define CheckingAccount and SavingAccount as concrete classes. But creating 2 parallel hierarchies one full of interfaces and one full of impl concrete classes each of which implement one interface is just redundant.</p>
<p>We typically use interfaces to achieve one or more of the following:<br />
1. Provide multiple implementations if needed.<br />
2. Abstract away creation from usage and use a factory.<br />
3. Proxy and add functionality.<br />
4. As poor man&#8217;s closures.<br />
5. Expose a smaller subset of functionality outside a module.</p>
<p>Now let us consider the each of these</p>
<p><strong>1. Provide multiple implementations if needed:<br />
</strong>In any non trivial project, it is generally a good practice to keep any business rules and technical functionality away from domain objects and that means staying clear of patterns like the <a href="http://martinfowler.com/eaaCatalog/activeRecord.html">ActiveRecord</a>. I would recommend using a clean domain model where the domain objects are pure POJOs that denote object relationships with other domain objects. If your domain objects are clean with no functionality, there is little point in creating multiple implementations of it.</p>
<p><strong>2. Abstract away creation from usage and use a factory:<br />
</strong>If you are designing an API or are building a large framework for your application, sometimes it does make sense to restrict the number of objects created for various reasons. I am usually not a fan of Object Pools but there are use cases where it may make sense. Even in this case, interfaces are not absolutely necessary for the domain objects as the number of object instances can be controlled by using a static factory method. The new JSR 310 &#8211; Date and Time API uses this approach. For example, take a look at the <a href="https://jsr-310.dev.java.net/nonav/doc-2010-06-22/javax/time/calendar/LocalDate.html">LocalDate</a> class (pre-release at the time of this writing, so this link may expire) it does not expose constructors but exposes a few static factory methods to create objects.</p>
<p><strong>3. Proxy and add functionality:<br />
</strong>One advantage that interfaces provide is the ability to easily proxy the implementation and add functionality. This is useful if you have to implement hibernate style lazy loading. Even for this, there is little point creating a parallel interface hierarchy as cglib based proxies can easily handle this case. And, this is what hibernate does as well. Hibernate does not force you to create a parallel interface hierarchy for your domain objects.</p>
<p><strong>4. As poor man&#8217;s closures:<br />
</strong>Another reason why we typically use interfaces is as a poor man&#8217;s closures <img src='http://smartcodellc.com/html/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . We pass an interface as a callback so the caller can invoke our methods. This doesn&#8217;t even apply in our case as we tend not to implement any functionality inside of our domain objects.</p>
<p><strong>5. Expose a smaller subset of functionality outside a module:<br />
</strong>Interfaces also allow you to expose a smaller functionality than that is implemented by the underlying class. I have come across domain models that expose just the getters in their interfaces and implement setters in the concrete implementations. This in theory provides read only access to the API users. This might be dangerous at times because from the client&#8217;s perspective, the domain object is immutable but from the API&#8217;s side it is not. I&#8217;d suggest using<a href="http://www.gridshore.nl/2009/04/06/the-power-of-immutability-in-a-rich-domain-model/"> immutable domain objects</a> instead of faking immutability.</p>
<p>In APIs that deal with a rich domain model, it might be necessary to support different versions for different clients. The parallel interface layer for the domain model doesn&#8217;t really help us here. If we really need to support multiple versions with type safety, we will end up creating multiple domain models one for each version.</p>
<p>I have had to work on a couple of projects with domain objects that already had a domain model designed using the parallel interface hierarchy pattern, and in each of them the pattern offered no additional benefits and was a pain to maintain in the long term which eventually led to refactoring. I hope I made a solid enough case against the pattern. If you had different experiences with it and would like to add, please feel free to do so in the comments.
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://smartcodellc.com/html/2010/07/13/case-against-an-interface-based-domain-object-model/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to get started with Cassandra and Hector</title>
		<link>http://smartcodellc.com/html/2010/07/06/how-to-get-started-with-cassandra-and-hector/</link>
		<comments>http://smartcodellc.com/html/2010/07/06/how-to-get-started-with-cassandra-and-hector/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 08:19:28 +0000</pubDate>
		<dc:creator>Richard L. Burton III</dc:creator>
				<category><![CDATA[Cassandra]]></category>
		<category><![CDATA[Hector]]></category>
		<category><![CDATA[NoSQL]]></category>
		<category><![CDATA[cassandra]]></category>
		<category><![CDATA[hector]]></category>
		<category><![CDATA[nosql]]></category>

		<guid isPermaLink="false">http://smartcodellc.com/html/?p=25</guid>
		<description><![CDATA[Recently I started playing with Cassandra and felt it would be useful to share my experience in getting started. If you&#8217;re like me, then having something working that you can play with is essential in the learning process. So this posting is aimed at getting you up and running in the shortest time possible. First, [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I started playing with <a href="http://cassandra.apache.org/" target="_blank">Cassandra</a> and felt it would be useful to share my experience in getting started. If you&#8217;re like me, then having something working that you can play with is essential in the learning process. So this posting is aimed at getting you up and running in the shortest time possible.</p>
<p><strong>First, preparing Cassandra</strong></p>
<p>First, download a copy of <a href="http://cassandra.apache.org/" target="_blank">Cassandra</a> and unzip it in the location of your choice, I&#8217;ll refer to this location as <strong>$CASSANDRA_HOME</strong>. We&#8217;re going to make a minor change to the <strong>$CASSANDRA_HOME</strong>/conf/storage-conf.xml file in order to create up a custom <a href="http://wiki.apache.org/cassandra/DataModel" target="_blank">Keyspace</a> for this example called &#8220;ExampleKeyspace&#8221;. In between the <em>&lt;Keyspaces/&gt;</em> node, insert the following code fragment:</p>
<p><script src="http://pastebin.com/embed_js.php?i=BnQQiNGM"></script>Now that we finished defining the Keyspace and the ColumnFamily we&#8217;re going to use, let&#8217;s validate that the configuration file by starting Cassandra. In order to start Cassandra, run the following script $CASSANDRA_HOME/bin/cassandra  You&#8217;ll know when <a href="http://cassandra.apache.org/" target="_blank">Cassandra</a> is a happy lady if you see &#8220;<em>Binding thrift service to localhost/127.0.0.1:9160</em>&#8220; in the console. If you see &#8220;<em>Bad configuration; unable to start server</em>&#8220;, then the storage-conf.xml isn&#8217;t correct, please verify it.</p>
<p><strong>How to verify that the storage-conf.xml changes were accepted</strong></p>
<p>There are a few ways to verify that the configuration change we&#8217;ve made has taken place. If you&#8217;re a command-line person, execute the <strong>$CASSANDR_HOME</strong>/bin/cassandra-cli which will start the Cassandra command-line interface. Now that the shell is running, let&#8217;s connect to our instance that&#8217;s running by executing the following command within the <a href="http://wiki.apache.org/cassandra/CassandraCli" target="_blank">cassandra-cli</a> shell</p>
<p><em>connect localhost/9160</em></p>
<p>We&#8217;re using the default port since that remains untouched by us. Now that we&#8217;re connected, let&#8217;s describe our newly created Keystore by issuing the following command within the shell.</p>
<p><em>describe keyspace ExampleKeyspace</em></p>
<p>The output of the following command should look something like the one below:  <script src="http://pastebin.com/embed_js.php?i=Yc1rquNz"></script></p>
<p>This tells us that Cassandra has configured our custom Keyspace and we&#8217;re ready to rock!</p>
<p><strong>How to insert data into Cassandra using Hector</strong></p>
<p><a href="http://github.com/rantav/hector" target="_blank">Hector</a> is a Java framework that can be used to communicate with Cassandra. In this example, we&#8217;re going to take a brief look at how to write a simple row that storages a new user. Please note, this example does not leverage any advance features of <a href="http://github.com/rantav/hector" target="_blank">Hector</a>. The purpose of the follow example is to demonstrate how to use <a href="http://github.com/rantav/hector" target="_blank">Hector</a> in order to insert data.</p>
<p><script src="http://pastebin.com/embed_js.php?i=iXt806a8"></script></p>
<p><strong>How do I verify the data is in Cassandra?</strong></p>
<p>Now that we have Cassandra up and running, let&#8217;s visually inspect our newly created record. We could use the <a href="http://wiki.apache.org/cassandra/CassandraCli" target="_blank">cassandra-cli</a> tool, but it&#8217;s not not an elegant solution for this particular use-case. Instead we&#8217;re going to use <a href="http://code.google.com/p/cassandra-gui/" target="_blank">cassandra-gui</a> which is a graphical application that will allow us to inspect the database. Simply download the cassandra-gui.jar and double click on it. It&#8217;ll prompt you for the host and port of our Cassandra instance. The one thing to keep in mind when using this tool is that in order to see the records, you must right click on the tree node and select &#8220;<em>show 1000 rows</em>&#8220;. The panel on the right hand side should then refresh and allow you to explore it.</p>
<p>I hope this article helps to get you started in working with Cassandra and Hector!</p>
<p><strong> More recommended reading</strong></p>
<ul>
<li><a href="http://bit.ly/jOcjo" target="_blank">Cassandra &#8211; Data Modeling</a></li>
<li><a href="http://bit.ly/dbkaJT" target="_blank">Cassandra Basics by Benjamin Black</a></li>
<li><a href="http://bit.ly/bXW5In" target="_blank">Cassandra&#8217;s data model cheat sheet by Charker Nakhli</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://smartcodellc.com/html/2010/07/06/how-to-get-started-with-cassandra-and-hector/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
