<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>agile-code.com</title>
	
	<link>http://www.agile-code.com/blog</link>
	<description>Adventures in software architecture and design</description>
	<lastBuildDate>Thu, 23 May 2013 22:28:12 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/agile-code" /><feedburner:info uri="agile-code" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>agile-code</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>SQL Server ghost records – succintly</title>
		<link>http://feedproxy.google.com/~r/agile-code/~3/liKc-2gWNI0/</link>
		<comments>http://www.agile-code.com/blog/sql-server-ghost-records-succintly/#comments</comments>
		<pubDate>Thu, 23 May 2013 22:28:12 +0000</pubDate>
		<dc:creator>Zoran Maksimovic</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[ghost records]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.agile-code.com/blog/?p=2475</guid>
		<description><![CDATA[<br/>I was completely unaware of the SQL Server &#8220;ghost records&#8221; until recently I&#8217;ve started using a table in SQL Server database to temporarily store and then delete generated PDF documents as part of a nightly job. Because of a large amount of data being processed (inserted and then deleted) few days later our DBA realized <a href='http://www.agile-code.com/blog/sql-server-ghost-records-succintly/' class='excerpt-more'>[... read more]</a>]]></description>
				<content:encoded><![CDATA[<br/><p>I was completely unaware of the SQL Server &#8220;ghost records&#8221; until recently I&#8217;ve started using a table in SQL Server database to temporarily store and then delete generated PDF documents as part of a nightly job. Because of a large amount of data being processed (inserted and then deleted) few days later our DBA realized that the database data files started growing in a rhythm of 10GB per day without any apparent reasons.</p>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzA1L2dob3N0YnVzdGVyLWxvZ28uanBn"><img src="http://i1.wp.com/www.agile-code.com/blog/wp-content/uploads/2013/05/ghostbuster-logo.jpg?w=200" alt="ghostbuster-logo" class="aligncenter size-full wp-image-2486" data-recalc-dims="1" /></a></p>
<h3>What is a Ghost Record</h3>
<p>&#8220;Ghost Records&#8221; are records that have been <strong>logically</strong> but not <strong>physically</strong> deleted from the leaf level of an index. Such a delete operation never physically removes records from pages but it only <strong>marks</strong> them as having been deleted, or ghosted!</p>
<p>Ghost Records have been introduced as a performance optimization that makes the delete operations quicker. Rolling back delete operations are quicker because the only things that needs to happen is to un-mark the records as being deleted/ghosted, instead of having to reinsert the deleted records. </p>
<div class="highlight">
An practical example:<br />
&#8220;imagine you have a unique index on an integer and the index contains the values 1, 30, and 100. If you delete 30, SQL Server will need to lock (and prevent inserts into) the entire range between 1 and 100. With ghosted records, the 30 is still visible to be used as an endpoint of a key-range lock so that during the delete transaction, SQL Server can allow inserts for any value other than 30 to proceed.&#8221;
</div>
<h3>Ghost Records removal</h3>
<p>There are several ways of cleaning out the ghost records, among which :</p>
<ol>
<li>If a new record that has the same key value as the deleted record is re-inserted in a table</li>
<li>The Ghost cleanup task (scheduled to run once every 5 seconds)</li>
<li>If the page needs to be split, the ghost records will be handled</li>
</ol>
<p>In my case, because the database in question is SQL Server 2005, the most effective way of cleaning up the database was:</p>
<ol>
<li>Drop and recreate the table (very ugly!)</li>
<li>Shrink the database</li>
<li>Rebuild indexes</li>
<li>Recompile all of the stored procedures (for quicker response time after shrinking)</li>
</ol>
<p>The recommended way to do this is to <strong>rebuild indexes</strong> on table that has problems, but for unknown reason this didn&#8217;t work properly for me.</p>
<h3>How to find out about ghost records</h3>
<pre class='brush: sql'>
SELECT	ghost_record_count ,
        version_ghost_record_count , 
        *
FROM	sys.dm_db_index_physical_stats(DB_ID('DATABASE_NAME_HERE'),
        OBJECT_ID('TABLE_NAME_HERE'), NULL, NULL, 'DETAILED')
</pre>
<p>Columns: <code>ghost_record_count</code> and <code>version_ghost_record_count </code> will indicate a number of ghost records associated with the given database table.</p>
<h3>Final thoughts</h3>
<p>The topic is quite deep and unfortunately not so well documented, so I collected some useful urls that could be of benefit posted below.<br />
I think that it worth trying and checking if your database is affected by this, especially if you see the database growing for unknown reason.</p>
<h3>Further reads:</h3>
<ol>
<li><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2Jsb2dzLm1zZG4uY29tL2Ivc3Fsc2VydmVyc3RvcmFnZWVuZ2luZS9hcmNoaXZlLzIwMDYvMDYvMjMvNjQ0NjA3LmFzcA==" title=\"http://blogs.msdn.com/b/sqlserverstorageengine/archive/2006/06/23/644607.asp\" target=\"_blank\">http://blogs.msdn.com/b/sqlserverstorageengine/archive/2006/06/23/644607.asp</a>x</li>
<li><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5zcWxzZXJ2ZXJnZWVrcy5jb20vYXJ0aWNsZXMvc3FsLXNlcnZlci1iaS8xNC9naG9zdC1yZWNvcmRzLWluLXNxbC1zZXJ2ZXItbm93LXdoYXRzLXRoYXQ=" title=\"http://www.sqlservergeeks.com/articles/sql-server-bi/14/ghost-records-in-sql-server-now-whats-that\" target=\"_blank\">http://www.sqlservergeeks.com/articles/sql-server-bi/14/ghost-records-in-sql-server-now-whats-that</a></li>
<li><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5zcWxza2lsbHMuY29tL2Jsb2dzL3BhdWwvaW5zaWRlLXRoZS1zdG9yYWdlLWVuZ2luZS1naG9zdC1jbGVhbnVwLWluLWRlcHRoLw==" title=\"http://www.sqlskills.com/blogs/paul/inside-the-storage-engine-ghost-cleanup-in-depth/\" target=\"_blank\">http://www.sqlskills.com/blogs/paul/inside-the-storage-engine-ghost-cleanup-in-depth/</a></li>
<li><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3NxbHNlcnZlcnBlZGlhLmNvbS9ibG9nL3NxbC1zZXJ2ZXItc2VydmljZS1pbnRlcm5hbHMtYW5kLWFyY2hpdGVjdHVyZS8xNjQv" title=\"http://sqlserverpedia.com/blog/sql-server-service-internals-and-architecture/164/\" target=\"_blank\">http://sqlserverpedia.com/blog/sql-server-service-internals-and-architecture/164/</a></li>
</ol>
 <img src="http://www.agile-code.com/blog/?feed-stats-post-id=2475" width="1" height="1" style="display: none;" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/agile-code?a=liKc-2gWNI0:cZkFMHMw-M0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=liKc-2gWNI0:cZkFMHMw-M0:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=liKc-2gWNI0:cZkFMHMw-M0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/agile-code?i=liKc-2gWNI0:cZkFMHMw-M0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=liKc-2gWNI0:cZkFMHMw-M0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/agile-code?i=liKc-2gWNI0:cZkFMHMw-M0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=liKc-2gWNI0:cZkFMHMw-M0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/agile-code?i=liKc-2gWNI0:cZkFMHMw-M0:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=liKc-2gWNI0:cZkFMHMw-M0:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/agile-code?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=liKc-2gWNI0:cZkFMHMw-M0:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/agile-code?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/agile-code/~4/liKc-2gWNI0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.agile-code.com/blog/sql-server-ghost-records-succintly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.agile-code.com/blog/sql-server-ghost-records-succintly/</feedburner:origLink></item>
		<item>
		<title>What’s new in Google DataTable .NET Wrapper v3.1.0</title>
		<link>http://feedproxy.google.com/~r/agile-code/~3/gUIBJp0qKRc/</link>
		<comments>http://www.agile-code.com/blog/whats-new-in-google-datatable-net-wrapper-v3-1-0/#comments</comments>
		<pubDate>Mon, 06 May 2013 23:18:12 +0000</pubDate>
		<dc:creator>Zoran Maksimovic</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ASP.NET Web API]]></category>
		<category><![CDATA[Google DataTable .Net Wrapper]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[json]]></category>

		<guid isPermaLink="false">http://www.agile-code.com/blog/?p=2453</guid>
		<description><![CDATA[<br/>After quite a long time there is a small update on the Google DataTable .NET Wrapper library. For those who are new to the library please check the two previous posts: How to use the Google DataTable .Net Wrapper Library What&#8217;s new in Google DataTable .NET Wrapper v3.0.0 What is new? First of all I <a href='http://www.agile-code.com/blog/whats-new-in-google-datatable-net-wrapper-v3-1-0/' class='excerpt-more'>[... read more]</a>]]></description>
				<content:encoded><![CDATA[<br/><p>After quite a long time there is a small update on the Google DataTable .NET Wrapper library.</p>
<p>For those who are new to the library please check the two previous posts:</p>
<ul>
<li>
<a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3VzaW5nLXRoZS1nb29nbGUtZGF0YXRhYmxlLW5ldC13cmFwcGVyLw==" title=\"Using the Google DataTable .Net Wrapper\">How to use the Google DataTable .Net Wrapper Library</a>
</li>
<li>
<a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3doYXRzLW5ldy1pbi1nb29nbGUtZGF0YXRhYmxlLW5ldC13cmFwcGVyLXYzLTAtMC8=" title=\"What’s new in Google DataTable .NET Wrapper v3.0.0\">What&#8217;s new in Google DataTable .NET Wrapper v3.0.0</a>
</li>
</ul>
<h2>What is new?</h2>
<p>First of all I would like to thank <strong>Tom Ziesmer</strong> who has substantially contributed the code and ideas (suggestiongs) of this minor release.</p>
<h3>IEnumerable<T> converter to DataTable</h3>
<p>Tom was very kind to contribute his code for the new extension method.<br />
The extension method is mainly responsible for transforming any kind of IEnumerable<T> object into the <code>Google.DataTable.Net.Wrapper.DataTable</code> object.<br />
It equally works with anonymous as with strongly typed kind of IEnumerable<T> objects.</p>
<p>The example below is showing how to use the new extension method that is part of the new namespace <code>Google.DataTable.Net.Wrapper.Extension</code></p>
<pre>
var list = new[]
                {
                    new {Name = "Dogs", Count = 5},
                    new {Name = "Cats", Count = 2}
                };

var json = list.ToGoogleDataTable()
               .NewColumn(new Column(ColumnType.String, "Name"), x => x.Name)
               .NewColumn(new Column(ColumnType.Number, "Count"), x => x.Count)
               .Build()
               .GetJson();
</pre>
<p>this generates the following output:</p>
<pre>
{
"cols": [
	    {"type": "string", "id": "Name"},
	    {"type": "number", "id": "Count"}
	],

"rows": [
	    {"c": [{ "v": "Dogs" }, {"v": 5}]},
	    {"c": [{ "v": "Cats" }, {"v": 2}]}
	]
}
</pre>
<p>The <code>NewColumn</code> method offers a great way of customizing the output. But in case there is an object that is already &#8220;ready&#8221; to be used then the same result can be obtained by not calling the &#8220;NewColumn&#8221; method at all  </p>
<pre>
var list = new[]
                {
                    new {Name = "Dogs", Count = 5},
                    new {Name = "Cats", Count = 2}
                };

var json = list.ToGoogleDataTable()
               //.NewColumn(new Column(ColumnType.String, "Name"), x => x.Name)
               //.NewColumn(new Column(ColumnType.Number, "Count"), x => x.Count)
               .Build()
               .GetJson();
</pre>
<p>produces the following output, which is substantially the same as the one above.</p>
<pre>
{
"cols": [
		{"type": "string","id": "Name", "label": "Name" },
		{"type": "number","id": "Count","label": "Count"}
	],
"rows": [
		{ "c": [{"v": "Dogs"},{"v": 5}]},
		{ "c": [{"v": "Cats"},{	"v": 2}]}
	]
}
</pre>
<h3>System.Data.DataTable extension method</h3>
<p>As shown in the below example, a new extension method for System.Data.DataTable has been introduced. This is mainly a wrapper to the existing SystemDataTableConverter, but is just handier to use.<br />
This code demonstrate it&#8217;s usage:</p>
<pre>
using (var sysDt = new System.Data.DataTable())
{
    sysDt.Columns.Add("firstcolumn", typeof(string));
    sysDt.Columns.Add("secondcolumn", typeof(int));
    sysDt.Columns.Add("thirdcolumn", typeof(decimal));
    sysDt.Locale = CultureInfo.InvariantCulture;

    var row1 = sysDt.NewRow();
    row1[0] = "Ciao";
    row1[1] = 10;
    row1[2] = 2.2;
    sysDt.Rows.Add(row1);

    var dataTable = sysDt.ToGoogleDataTable();    
    
    var json = dataTable.GetJson();
}
</pre>
<h2>How to install</h2>
<p>To download or consult the latest source code please visit the <a title=\"googledatatablelib\" href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2dvb2dsZWRhdGF0YWJsZWxpYi5jb2RlcGxleC5jb20=" target=\"_blank\">project&#8217;s CodePlex page</a>&nbsp;or install it directly from Visual Studio by using Nuget</p>
<div class="nuget-badge"><code>PM&gt; Install-Package Google.DataTable.Net.Wrapper</code></div>
<h2>Contribute</h2>
<p>This project is open for contribution and new ideas, so you are very welcome to contact me!</p>
 <img src="http://www.agile-code.com/blog/?feed-stats-post-id=2453" width="1" height="1" style="display: none;" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/agile-code?a=gUIBJp0qKRc:9CCfMCWwlds:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=gUIBJp0qKRc:9CCfMCWwlds:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=gUIBJp0qKRc:9CCfMCWwlds:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/agile-code?i=gUIBJp0qKRc:9CCfMCWwlds:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=gUIBJp0qKRc:9CCfMCWwlds:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/agile-code?i=gUIBJp0qKRc:9CCfMCWwlds:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=gUIBJp0qKRc:9CCfMCWwlds:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/agile-code?i=gUIBJp0qKRc:9CCfMCWwlds:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=gUIBJp0qKRc:9CCfMCWwlds:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/agile-code?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=gUIBJp0qKRc:9CCfMCWwlds:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/agile-code?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/agile-code/~4/gUIBJp0qKRc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.agile-code.com/blog/whats-new-in-google-datatable-net-wrapper-v3-1-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.agile-code.com/blog/whats-new-in-google-datatable-net-wrapper-v3-1-0/</feedburner:origLink></item>
		<item>
		<title>Key design principles in Software Development</title>
		<link>http://feedproxy.google.com/~r/agile-code/~3/877GzdWomXw/</link>
		<comments>http://www.agile-code.com/blog/key-design-principles-in-software-development/#comments</comments>
		<pubDate>Thu, 14 Mar 2013 23:53:45 +0000</pubDate>
		<dc:creator>Zoran Maksimovic</dc:creator>
				<category><![CDATA[Software Architecture]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[Object Oriented Programming]]></category>
		<category><![CDATA[Software Methodology]]></category>
		<category><![CDATA[Software Patterns]]></category>

		<guid isPermaLink="false">http://www.agile-code.com/blog/?p=2389</guid>
		<description><![CDATA[<br/>Software Development is so many things; to have a good start creativity, passion and methodology have to be a perfect match. While the creativity and the passion are subjective and personal, the methodology is something that can be learnt, developed, enhanced and shared. Like mathematics, it can be seen as an universal language. Principles When <a href='http://www.agile-code.com/blog/key-design-principles-in-software-development/' class='excerpt-more'>[... read more]</a>]]></description>
				<content:encoded><![CDATA[<br/><p>Software Development is so many things; to have a good start creativity, passion and methodology have to be a perfect match.</p>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzAzL3NvZnR3YXJlLnBuZw=="><img src="http://i1.wp.com/www.agile-code.com/blog/wp-content/uploads/2013/03/software.png?w=300" alt="software" class="aligncenter size-full wp-image-2390" data-recalc-dims="1" /></a></p>
<p>While the creativity and the passion are subjective and personal, the methodology is something that can be learnt, developed, enhanced and shared. Like mathematics, it can be seen as an universal language.</p>
<h2>Principles</h2>
<p>When developing software there are some best-practices and principles that should be followed so that every software developer should be able to read and understand the application quite quickly.<br />
In general, the principles, when applied, should be able to (and not only)</p>
<ol>
<li>minimize maintenance requirements</li>
<li>minimizes costs</li>
<li>promote usability and extensibility</li>
<li>promote testability and correctness of the application</li>
</ol>
<p>Some of the key principles are as follows:</p>
<h3>Separation of concerns</h3>
<p>Expressed in a simple sentence: &#8220;Divide your application into distinct sections with as little overlap in functionality as possible.&#8221;. Easy to say, difficult to achieve.<br />
Separation of Concerns is one of the fundamental tenants in object oriented programming and, when applied correctly, promotes <a href="http sion-vs-coupling-separate-concerns/" title=\"Cohesion vs Coupling – Separate Concerns\">loose coupling and high cohesion</a>, which are two very important principles to be aware of.<br />
<a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzAyL0xheWVyZWQtQXJjaGl0ZWN0dXJlLnBuZw=="><img src="http://i1.wp.com/www.agile-code.com/blog/wp-content/uploads/2013/02/Layered-Architecture.png?fit=695%2C200" alt="Layered Architecture" class="alignleft size-full wp-image-2281" data-recalc-dims="1" /></a><br />
Separating the application into several layers, is already a good start, but then one should also follow the same principle into each of the layers. Presentation layer shouldn&#8217;t do what Data Access Layer does and vice-versa. For instance <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9Eb21haW4tZHJpdmVuX2Rlc2lnbg==" title=\"Domain Driven Design\" target=\"_blank\">Domain Driven Design</a> helps and promotes the separation of concerns.</p>
<h3>Single Responsibility principle</h3>
<p>The term was introduced by Robert C. Martin. Martin defines a <strong>responsibility</strong> as a reason to change, and concludes that a class or module should have <strong>one</strong>, and only one, reason to change.</p>
<p>In the (very simple) example below it is pretty much clear that the <code>GetCustomerById()</code> shouldn&#8217;t be par of the Person class. </p>
<pre lang="csharp">
public class Person
{
    public Person GetPersonById(){/*...*/}
    public Customer GetCustomerById(){/*...*/}
}
</pre>
<p>This should be a much better design:</p>
<pre lang="csharp">
public class Person
{
    public Person GetPersonById(){/*...*/}
}

public class Customer
{
    public Customer GetCustomerById(){/*...*/}
}
</pre>
<h3>Principle of Least Knowledge </h3>
<p>(also known as the Law of Demeter or LoD). </p>
<blockquote><p>A component or object should not know about internal details of other components or objects.</p></blockquote>
<p>Example:</p>
<pre lang="csharp">

//this should be avoided:
    customer.wallet.totalMoney;
    customer.apartment.bedroom.mattress.totalMoney;
    customer.apartment.kitchen.kitchenCabinet.totalMoney;

//instead this could be an idea of usage.
    customer.GetPayment(/*...*/)
</pre>
<p>Check this amazing <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5jY3MubmV1LmVkdS9yZXNlYXJjaC9kZW1ldGVyL2RlbWV0ZXItbWV0aG9kL0xhd09mRGVtZXRlci9wYXBlci1ib3kvZGVtZXRlci5wZGY=" title=\"Law of Demeter\" target=\"_blank\">paper</a> that explains in detail what is the Law of Demeter all about.</p>
<h3>Don’t repeat yourself (DRY)</h3>
<p>You should only need to specify intent in one place. When the DRY principle is applied successfully, a modification of any single element of a system does not require a change in other unrelated elements. Additionally, elements that are logically related all change predictably and uniformly, and are thus kept in sync.</p>
<h3>Minimize upfront design</h3>
<p>This principle is sometimes known as YAGNI (&#8220;You ain’t gonna need it&#8221;) and it&#8217;s about designing only what is strictly necessary in order to achieve the goal.<br />
A good example is the incremental development, where the system get&#8217;s enriched &#8220;on going&#8221; rather than planned (heavily) upfront, as during the application lifecycle the requirements often change too often.<br />
In Agile development, you can avoid big design upfront (BDUF). If your application requirements are unclear, or if there is a possibility of the design evolving over time, avoid making a large design effort prematurely. </p>
<h2>Final Thoughts</h2>
<p>As usually, I just scratched the surface of the issue and there are many more items to add, but that could be part of another post.<br />
I invite you to read about the above concepts as it would improve your application.</p>
 <img src="http://www.agile-code.com/blog/?feed-stats-post-id=2389" width="1" height="1" style="display: none;" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/agile-code?a=877GzdWomXw:lGAzfP1APFI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=877GzdWomXw:lGAzfP1APFI:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=877GzdWomXw:lGAzfP1APFI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/agile-code?i=877GzdWomXw:lGAzfP1APFI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=877GzdWomXw:lGAzfP1APFI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/agile-code?i=877GzdWomXw:lGAzfP1APFI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=877GzdWomXw:lGAzfP1APFI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/agile-code?i=877GzdWomXw:lGAzfP1APFI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=877GzdWomXw:lGAzfP1APFI:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/agile-code?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=877GzdWomXw:lGAzfP1APFI:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/agile-code?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/agile-code/~4/877GzdWomXw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.agile-code.com/blog/key-design-principles-in-software-development/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.agile-code.com/blog/key-design-principles-in-software-development/</feedburner:origLink></item>
		<item>
		<title>What makes an IT Project successful?</title>
		<link>http://feedproxy.google.com/~r/agile-code/~3/JKij_S91bZg/</link>
		<comments>http://www.agile-code.com/blog/what-makes-an-it-project-successful/#comments</comments>
		<pubDate>Sun, 10 Mar 2013 21:48:33 +0000</pubDate>
		<dc:creator>Zoran Maksimovic</dc:creator>
				<category><![CDATA[Project Management]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[Scrum]]></category>
		<category><![CDATA[Software Methodology]]></category>
		<category><![CDATA[Test Driven Development.]]></category>

		<guid isPermaLink="false">http://www.agile-code.com/blog/?p=2359</guid>
		<description><![CDATA[<br/>In one of my earlier posts I tried to describe what kind of attributes a leader should have to be successful, and in this post I would like to go a big further and try to define what should make an IT project a success. Wikipedia says that In project management a project consists of <a href='http://www.agile-code.com/blog/what-makes-an-it-project-successful/' class='excerpt-more'>[... read more]</a>]]></description>
				<content:encoded><![CDATA[<br/><p>In one of my earlier posts I tried to describe what kind of attributes a <a title=\"7 people skills every team leader should possess\" href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nLzctcGVvcGxlLXNraWxscy1ldmVyeS10ZWFtLWxlYWRlci1zaG91bGQtcG9zc2Vzcy8=">leader should have </a> to be successful, and in this post I would like to go a big further and try to define what should make an IT project a success.</p>
<p>Wikipedia says that</p>
<blockquote><p>In project management a project consists of a temporary endeavor undertaken to create a unique product, service or result.</p></blockquote>
<p>By reading the above definition, there are two ingredients that define a project:</p>
<ol>
<li>A project is a <strong>temporary action</strong>, therefore every project has a start and an end.</li>
<li>It has an <strong>output</strong>: product, service or a result</li>
</ol>
<h2>A perfect project</h2>
<p>Let&#8217;s start with some statistics:</p>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzAzL3Byb2plY3Qtc3VjY2Vzcy1mYWlsdXJlLnBuZw=="><img class="aligncenter size-full wp-image-2385" alt="project-success-failure" src="http://i1.wp.com/www.agile-code.com/blog/wp-content/uploads/2013/03/project-success-failure.png?w=600" data-recalc-dims="1" /></a></p>
<p>This chart data is based upon The Standish Group report. The Standish Group is a Massachusetts-based consultancy responsible for publishing the CHAOS reports since 1994. The reports are based on studies of IT projects and track the success, challenged and failure outcomes of each project.</p>
<p>It&#8217;s not hard to see that in average, since 1994 &#8220;only&#8221; <strong>~27% of all the project is successful</strong>. In other words, there is a higher chance that your project is <strong>not</strong> going to be successful than that it would. Which is <strong>scary</strong>.</p>
<h3>Project Management</h3>
<p>Usually, a project is run by a <code>project manager</code> and the typical project manager has lots of <code>responsibility</code> and very little <code>authority</code>, which implies that  the person that runs the project in cannot fully control it. A <code>project plan</code> in this circumstances can but not necessarily does represent the reality.<br />
Under these conditions, to run and to achieve a successful outcome can be really challenging.</p>
<p><strong>So, what would be the common project &#8220;attributes&#8221; that would make project &#8220;a success&#8221;?</strong></p>
<p>There is a list of goals that every project would need to meet in order to be a success:</p>
<ol>
<li>Meet the business requirements</li>
<li>Deliver and maintain on schedule</li>
<li>Delivered and maintained within budget, and</li>
<li>Deliver the <strong>expected</strong> business value and return on investment.</li>
</ol>
<p>Needless to say that one has to work really hard in order to achieve all the objectives. In order to achieve the points of the above list, there are some best-practices* should be followed and that could help the positive outcome of the project.</p>
<ol>
<li>Clear and clearly articulated goals</li>
<li>Comprehensive, long-term, planning, when possible</li>
<li>Early definition of deliverable quality criteria</li>
<li>Active executive support with a shared vision throughout the project’s life</li>
<li>Carefully planned implementation</li>
<li>Concise, consistent, complete, and unambiguous business and technical requirements</li>
<li>Realistic estimates and schedules</li>
<li>Early risk analysis and ongoing risk management</li>
<li>Planning for business process change management</li>
<li>Proactive issue resolution</li>
<li>Stakeholder involvement throughout the life cycle</li>
<li>Defined and consistently executed change management to minimize scope increases</li>
<li>A skilled Project Manager experienced in the execution of project management best practices</li>
<li>Standard software infrastructure</li>
<li>Execution of a formal system development methodology (such as the State’s System Development Life Cycle)</li>
<li>A competent team</li>
<li>Commitment to success</li>
</ol>
<p>The above points are taken from the Marylend&#8217;s Department of Technology and could be downloaded by following this <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2RvaXQubWFyeWxhbmQuZ292L1NETEMvRG9jdW1lbnRzL1doYXQlMjBNYWtlcyUyMGElMjBTdWNjZXNzZnVsJTIwUHJvamVjdC5wZGY=" title=\"SDLC What makes a project a success.\" target=\"_blank\">link</a>.</p>
<h2>Agile Project Management</h2>
<p>An alternative to the &#8220;classical&#8221; project management is ,now not so new, agile project management, that I really believe is the &#8220;right thing&#8221; if adopted correctly. I am mentioning the Agile Project Management as I believe that is more suitable for a modern and a dynamic way of managing projects, at least when it comes to the IT industry, where I&#8217;ve got most of my experience.</p>
<p>In one sentence, if that&#8217;s even possible, what is the definition of the agile project management:</p>
<blockquote><p>
Agile project management is a value-driven approach that allows Project Managers to deliver high-priority, high-quality work–and look like rock stars to their stakeholders. It’s nothing like the plodding, costly and error-prone approach to project management, which has delivered inconsistent results for years&#8230;</p>
<p>Agile Project Management reduces complexity by breaking down the many months long cycle of building requirements for the whole project, building the entire product and then testing to find hundreds of product flaws. Instead, small usable segments of the software product are specified, developed and tested in manageable, two to four week cycles.<br />
&#8211; Source: http://www.versionone.com/agile-project-management/
</p></blockquote>
<p>So, instead of having long running projects, with an unknown outcome, let&#8217;s have smaller chunks of perfectly managed iterations that would lead to a higher degree of success.</p>
<p>Unfortunately, I couldn&#8217;t find any reference on internet that would judge what is the degree of success of the agile projects alone, but eventually this will be published by some research companies. Please let me know if you find some!</p>
<h2>Final thoughts</h2>
<p>In this post I&#8217;ve mentioned the principal points that would make a project successful, together with a list of best-practices that, if followed correctly, could lead to a project success. Unfortunately, historically and statistically there are higher chances that the project fails and hopefully with new techniques  (agile!?) this could be avoided, or to some degree improved. What do you think about it?</p>
 <img src="http://www.agile-code.com/blog/?feed-stats-post-id=2359" width="1" height="1" style="display: none;" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/agile-code?a=JKij_S91bZg:PgkzshZ1nD0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=JKij_S91bZg:PgkzshZ1nD0:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=JKij_S91bZg:PgkzshZ1nD0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/agile-code?i=JKij_S91bZg:PgkzshZ1nD0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=JKij_S91bZg:PgkzshZ1nD0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/agile-code?i=JKij_S91bZg:PgkzshZ1nD0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=JKij_S91bZg:PgkzshZ1nD0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/agile-code?i=JKij_S91bZg:PgkzshZ1nD0:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=JKij_S91bZg:PgkzshZ1nD0:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/agile-code?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=JKij_S91bZg:PgkzshZ1nD0:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/agile-code?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/agile-code/~4/JKij_S91bZg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.agile-code.com/blog/what-makes-an-it-project-successful/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.agile-code.com/blog/what-makes-an-it-project-successful/</feedburner:origLink></item>
		<item>
		<title>Microsoft.NET O/R mapper: choose your own!</title>
		<link>http://feedproxy.google.com/~r/agile-code/~3/dVH5LuseD0U/</link>
		<comments>http://www.agile-code.com/blog/microsoft-net-or-mapper-choose-your-own/#comments</comments>
		<pubDate>Tue, 05 Mar 2013 23:17:21 +0000</pubDate>
		<dc:creator>Zoran Maksimovic</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software Architecture]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[Microsoft SQL Server]]></category>
		<category><![CDATA[NHibernate]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[ORM]]></category>

		<guid isPermaLink="false">http://www.agile-code.com/blog/?p=2310</guid>
		<description><![CDATA[<br/>Only few years ago I was not such a big fan of Object-Relational mapping tools (ORM), but now I have to admit that when starting a new project I&#8217;m always thinking whether it makes sense to use it or not. Compared to &#8220;traditional&#8221; coding techniques, Object-Relational mapping often reduces the amount of code that needs <a href='http://www.agile-code.com/blog/microsoft-net-or-mapper-choose-your-own/' class='excerpt-more'>[... read more]</a>]]></description>
				<content:encoded><![CDATA[<br/><p>Only few years ago I was not such a big fan of Object-Relational mapping tools (ORM), but now I have to admit that when starting a new project I&#8217;m always thinking whether it makes sense to use it or not.</p>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzAzL09STU1hcHBpbmcucG5n"><img src="http://i0.wp.com/www.agile-code.com/blog/wp-content/uploads/2013/03/ORMMapping.png?resize=695%2C356" alt="ORMMapping" class="aligncenter size-full wp-image-2348" data-recalc-dims="1" /></a></p>
<p>Compared to &#8220;traditional&#8221; coding techniques, Object-Relational mapping often reduces the amount of code that needs to be written, but I would add as well that a new kind of problems arise too, especially in some more complex scenarios. So particular attention should be taken on the cost/benefit side, like for anything else.</p>
<div class="highlight">
Whatever approach is taken, please create <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL2xvZ2ljLWluLXRoZS1kYXRhYmFzZS10by1iZS1vci1ub3QtdG8tYmUv" title=\"Logic in the database, to be or not to be?\">different application layers</a>, and especially for the data access, use the <code>Repository pattern</code>. Repository Pattern offers a great way of decoupling the data access from the application logic.<br />
So, the golden rule is: do not mix the business logic with the data access code. <a rel=\"nofollow\" href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2dvLmxpbmt0b3R3ZWV0LmNvbS9RNVNTOUhDSA==">[<-tweet this]</a>
</div>
<h2>What is an Object-Relational Mapper</h2>
<p>Let&#8217;s start with a simple definition. </p>
<blockquote><p>Object-relational mapping (ORM, O/RM, and O/R mapping) in computer software is a programming technique for converting data between incompatibletype systems in object-oriented programming languages. This creates, in effect, a “virtual object database” that can be used from within the programming language.<br />
&#8211;Wikipedia
</p></blockquote>
<h2>List of things to consider</h2>
<p>There are many things that one should consider before adopting a particular library. Here is perhaps a short list of questions to be answered before choosing:</p>
<ol>
<li>Is it free (and open source) or commercial</li>
<li>What is the support given by the company or the community?</li>
<li>Does it have an active community?</li>
<li>Can it handle enterprise class ORM problems?</li>
<li>Does it support LINQ?</li>
<li>What databases does it support out of the box?</li>
<li>A part direct table access, does it support querying  of views, stored procedure or functions?</li>
<li>Is there any caching mechanism?</li>
<li>Does it support lazy-loading?</li>
<li>Does it support batching mode (updating many items at once)?</li>
</ol>
<h3>ORM Mapping Costs</h3>
<p>As mentioned earlier, there are some costs to consider when adopting an ORM. Please consider the following:</p>
<h4>Needless Repetition</h4>
<p>Usually the table structure and table relations are stored both in the DB and in the ORM mapping files. This can cause a maintenance problem as one need to make sure that both versions of the meta-data don&#8217;t get out of sync. So, every change on the database usually means recompiling the application.</p>
<h4>Mapping itself</h4>
<p>Mapping it is not always a trivial task. Because of the &#8220;Object-relational impedance mismatch&#8221; there could be issues in transforming the database structure in the object oriented compatible way.</p>
<h4>Performance problems</h4>
<p>As the ORM tool is usually generating the SQL code to be executed on the database, this queries are often not fully optimized, and often could be rewritten in a much more optimized way if written manually. I mentioned often, as this is not always the case. Usually this can be solved by instead of querying the table directly, to query some specialized views that could optimize some code. </p>
<h2>Microsoft.NET ORM tools</h2>
<p>There is a quite big list of ORM tools, and here I am mentioning the ones I believe are among the most important ones.<br />
I personally have experience with the Entity Framework and NHibernate, and I would leave the tough job of choosing one to you directly. </p>
<h4>Microsoft&#8217;s Entity Framework</h4>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL21zZG4ubWljcm9zb2Z0LmNvbS9lbi11cy9kYXRhL2VmLmFzcHg=" title=\"Microsoft Entity  Framework\" target=\"_blank\">Entity Framework (EF)</a> is an <strong>free</strong> and <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2VudGl0eWZyYW1ld29yay5jb2RlcGxleC5jb20v" target=\"_blank\">open source</a> object-relational mapper that enables .NET developers to work with relational data using domain-specific objects. It eliminates the need for most of the data-access code that developers usually need to write.<br />
Entity Framework allows you to create a model by writing code or using boxes and lines in the EF Designer. Both of these approaches can be used to target an existing database or create a new database.<br />
Entity Framework is actively developed by the Entity Framework team which is assigned to the Microsoft Open Tech Hub and in collaboration with a community of open source developers.</p>
<h4>Linq To SQL</h4>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL21zZG4ubWljcm9zb2Z0LmNvbS9lbi11cy9saWJyYXJ5L2JiMzg2OTc2LmFzcHg=" title=\"Linq to SQL\" target=\"_blank\">LINQ to SQL</a> is a <strong>free</strong> component of .NET Framework version 3.5 that provides a run-time infrastructure for managing relational data as objects.<br />
In LINQ to SQL, the data model of a relational database is mapped to an object model expressed in the programming language of the developer. When the application runs, LINQ to SQL translates into SQL the language-integrated queries in the object model and sends them to the database for execution. When the database returns the results, LINQ to SQL translates them back to objects that you can work with in your own programming language.</p>
<p>I would personally not use Linq to Sql as it seems that  not much effort is placed into enhancing the current technology.</p>
<h4>Nhibernate</h4>
<p>NHibernate is a <strong>free</strong> object-relational mapping (ORM) solution for the Microsoft .NET platform: it provides a framework for mapping an object-oriented domain model to a traditional relational database. Its purpose is to relieve the developer from a significant portion of relational data persistence-related programming tasks. NHibernate is free as open source software that is distributed under the GNU Lesser General Public License. NHibernate is a port of the popular Java O/R mapper Hibernate to .NET.</p>
<h4>DataObjects.Net</h4>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2RhdGFvYmplY3RzLm5ldC8=" title=\"DataObjects.NET\" target=\"_blank\">DataObjects.Net</a> is a commercial persistence and object-relational mapping framework for Microsoft.NET. It allows developers to define persistent objects as well as business logic directly in C#, Visual Basic or F#. The persistent objects can be retrieved by LINQ queries. Persistent data can be stored in SQL Servers. In contrast to many other ORM frameworks the database model is generated and maintained automatically.<br />
It supports most of the mainstream databases.</p>
<h4>Telerik&#8217;s OpenAccess ORM</h4>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy50ZWxlcmlrLmNvbS9wcm9kdWN0cy9vcm0uYXNweA==" title=\"OpenAccess ORM\" target=\"_blank\">OpenAccess ORM</a> is Telerik&#8217;s <strong>free</strong> object-relational mapping tool that will generate the data access layer for your applications after just a few mouse clicks. All you have to do is to create the data model of your application and the tool will do the rest!<br />
OpenAccess ORM supports: Database-First (Reverse) Mapping, Model-First (Forward) Mapping, Round-Trip (Mixed Mode) Mapping, Code Only Mapping (Fluent API), Mapping Stored Procedures, Views and Tables.<br />
It supports most of the mainstream databases (Microsoft SQL Server, Oracle, Sybase, MySql, PostgreSQL, Firebird,&#8230;</p>
<h4>BLToolkit</h4>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2JsdG9vbGtpdC5uZXQvZGVmYXVsdC5hc3B4P0FzcHhBdXRvRGV0ZWN0Q29va2llU3VwcG9ydD0x" title=\"BLToolkit\" target=\"_blank\">Business Logic Toolkit</a> is a set of components to simplify .NET application development. BLToolkit is provided as source code that you can use &#8220;as is&#8221; or customize for your applications. It is written in C# and compatible with .NET Frameworks 3.5 and 4.0, Silverlight 4, and Mono.</p>
<h4>LBLGen Pro</h4>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5sbGJsZ2VuLmNvbS8=" title=\"LBLGen Pro\" target=\"_blank\">LBLGen Pro </a>is a data-access solution.<br />
You use the LLBLGen Pro Designer to create the entity/domain model, define the mappings and generate source-code for one of the four supported O/R mapping frameworks: Entity Framework, NHibernate, Linq to SQL or the LLBLGen Pro Runtime Framework.<br />
You use the generated source-code combined with the O/R mapping framework of your choice to access your database and consume the data in that database.</p>
<p>When, for whatever reason, you have to change the O/R mapper for your project, you can simply switch the chosen target framework in the LLBLGen Pro designer, re-generate code and you&#8217;re done (give or take some minor changes if the newly chosen O/R mapper doesn&#8217;t support a feature the old one does). Of course your own code has to be migrated, but your entity model, mappings and the like all stay the same.</p>
<h4>LinqConnect</h4>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5kZXZhcnQuY29tL2xpbnFjb25uZWN0Lw==" title=\"LinqConnect\" target=\"_blank\">LinqConnect </a>is a commecial, fast, lightweight, and easy to use LINQ to SQL-compatible ORM solution, supporting SQL Server, Oracle, MySQL, PostgreSQL, and SQLite. It allows you to use efficient and powerful data access for your .NET Framework, Metro, Silverlight, or Windows Phone applications supporting Code-First, Model-First, Database-First or mixed approaches.<br />
nqConnect was developed closely to LINQ to SQL and retains full compatibility with it. Interface of the LinqConnect classes is compatible with LINQ to SQL ones. If you are a LINQ to SQL developer, you don&#8217;t need to learn much and can start developing with LinqConnect immediately.</p>
<p>Unlike LINQ to SQL, LinqConnect is an actively developed and supported product, and it offers a number of benefits over LINQ to SQL. It supports more database servers, more development platforms, more LINQ features, more mapping kinds, provides better performance, etc.</p>
<h2>Wrap it Up</h2>
<p>There is a large number of ORM implementations for Microsoft.NET and is not always easy to choose the right one. We have seen that even the fact of using an ORM tool has some additional costs when it comes to the application design and maintenance.<br />
All in all, I see in general more positive than negative aspects, once the learning curve and familiarity with the tool is not the problem.</p>
<p>Please suggest or comment what is your experience with the ORM tools, and why would you would(n&#8217;t) use one?</p>
 <img src="http://www.agile-code.com/blog/?feed-stats-post-id=2310" width="1" height="1" style="display: none;" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/agile-code?a=dVH5LuseD0U:AN8OiOo6ZHI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=dVH5LuseD0U:AN8OiOo6ZHI:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=dVH5LuseD0U:AN8OiOo6ZHI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/agile-code?i=dVH5LuseD0U:AN8OiOo6ZHI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=dVH5LuseD0U:AN8OiOo6ZHI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/agile-code?i=dVH5LuseD0U:AN8OiOo6ZHI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=dVH5LuseD0U:AN8OiOo6ZHI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/agile-code?i=dVH5LuseD0U:AN8OiOo6ZHI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=dVH5LuseD0U:AN8OiOo6ZHI:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/agile-code?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=dVH5LuseD0U:AN8OiOo6ZHI:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/agile-code?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/agile-code/~4/dVH5LuseD0U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.agile-code.com/blog/microsoft-net-or-mapper-choose-your-own/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.agile-code.com/blog/microsoft-net-or-mapper-choose-your-own/</feedburner:origLink></item>
		<item>
		<title>Logic in the database, to be or not to be?</title>
		<link>http://feedproxy.google.com/~r/agile-code/~3/0l2FjHAL_Ok/</link>
		<comments>http://www.agile-code.com/blog/logic-in-the-database-to-be-or-not-to-be/#comments</comments>
		<pubDate>Sat, 23 Feb 2013 00:02:55 +0000</pubDate>
		<dc:creator>Zoran Maksimovic</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software Architecture]]></category>
		<category><![CDATA[Microsoft SQL Server]]></category>
		<category><![CDATA[Web Service]]></category>

		<guid isPermaLink="false">http://www.agile-code.com/blog/?p=2208</guid>
		<description><![CDATA[<br/>Recently I have participated to a couple of discussions about whether the triggers or stored procedures should be used or not in a &#8220;real&#8221; project, so I decided to write this post to express my point of view. This said, I warn you, there is no a &#8220;right&#8221; answer, but most probably a &#8220;pro&#8221; and <a href='http://www.agile-code.com/blog/logic-in-the-database-to-be-or-not-to-be/' class='excerpt-more'>[... read more]</a>]]></description>
				<content:encoded><![CDATA[<br/><p>Recently I have participated to a couple of discussions about whether the <code>triggers</code> or <code>stored procedures</code> should be used or not in a &#8220;real&#8221; project, so I decided to write this post to express my point of view. This said, I warn you, there is no a &#8220;right&#8221; answer, but most probably a &#8220;pro&#8221; and &#8220;cons&#8221; about anything written in this post.</p>
<h2>An old problem</h2>
<p>There are more than a handful of developers who are not really clear (from the architectural point of view) when to use triggers, views, stored procedures,etc&#8230; let&#8217;s just call this &#8220;database logic&#8221;.<br />
Being so easy to change, and so close to the data, one is really tempted to go to the &#8220;source&#8221; and start coding.&nbsp;</p>
<div class="highlight">
As an alternative read, please check my previous article <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL2RpcmVjdC1zcWwtYWNjZXNzLXZzLXdlYi1zZXJ2aWNlLw==">Direct Sql Access vs Web Service</a>, where a very similar problematic is described, and applies perfectly to what discussed here.
</div>
<p>I think that conceptually all developers agree with &#8220;<em>using the right tool for the right job</em>&#8221; rule, but when it comes to put this law into a practice, then is where all the problems begin.</p>
<p>I think that in general there are three types of developers:</p>
<ul>
<li><strong>Database oriented developers</strong>: Usually this is someone that is very familiar with the database and thinks that the database is not merely a repository, but as well the place where to put all the logic.</li>
<li><strong>Code oriented developers</strong>: Would place everything outside the database (code, ORM, etc..). Usually this is a developer that is in love with ORM mappers, either because this is a trend or simply because don&#8217;t like working with SQL, because SQL is an old thing, isn&#8217;t it?</li>
<li><strong>Pragmatic developers</strong>:  A thinker that applies the knowledge in order to get the best out of the two worlds.</li>
</ul>
<p>Which of the three groups best describes you?</p>
<p>If you are reading this article you are a good candidate to become a <a title=\"The Pragmatic Programmer: From Journeyman to Master\" href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hbWF6b24uY29tL1ByYWdtYXRpYy1Qcm9ncmFtbWVyLUpvdXJuZXltYW4tTWFzdGVyL2RwLzAyMDE2MTYyMlg/dGFnPTY1MTk5ODY2OS0yMA==" target=\"_blank\">pragmatic programmer</a> or perhaps a <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2JsYWNrYmVsdHByb2dyYW1taW5nLmNvbS8=" title=\"Black Belt Programmer\" target=\"_blank\">black-belt programmer</a> with a Mission:</p>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2JsYWNrYmVsdHByb2dyYW1taW5nLmNvbS8="><img src="http://i0.wp.com/www.agile-code.com/blog/wp-content/uploads/2013/02/black-belt-programmer.png?resize=321%2C96" alt="black-belt-programmer" class="aligncenter size-full wp-image-2275" data-recalc-dims="1" /></a><br />
and I would add another point: to create a perfect architecture.</p>
<div class="highlight">&#8220;I suppose it is tempting, if the only tool you have is a hammer, to treat everything as if it were a nail.&#8221; [<a title=\"http://go.linktotweet.com/WQK16UTS\" href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2dvLmxpbmt0b3R3ZWV0LmNvbS9XUUsxNlVUUw==" target=\"_blank\">tweet this</a><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2dvLmxpbmt0b3R3ZWV0LmNvbS9XUUsxNlVUUw==">] </a></div>
<h2>Layered architecture to the resque</h2>
<p>Before start answering the original question, I have to mention the <code>layered architecture</code>. There are many types of applications out there, but it&#8217;s possible to have some sort of a formally accepted layers, otherwise we are going to have a <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9Nb25vbGl0aGljX2FwcGxpY2F0aW9u" title=\"monolithic application\" target=\"_blank\">monolithic application</a>.</p>
<p>There are many ways of naming those layers depending to who are you talking too, but in general we may distinguish the following:</p>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzAyL0xheWVyZWQtQXJjaGl0ZWN0dXJlLnBuZw=="><img src="http://i1.wp.com/www.agile-code.com/blog/wp-content/uploads/2013/02/Layered-Architecture.png?w=400" alt="Layered Architecture" class="aligncenter size-full wp-image-2281" data-recalc-dims="1" /></a></p>
<blockquote><p>A multilayered (software) architecture is using different layers for allocating the responsibilities of an application. <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2dvLmxpbmt0b3R3ZWV0LmNvbS9FMUpZTUQ4SA==">share this quote on twitter</a></p></blockquote>
<h3>Presentation Layer</h3>
<p>The presentation layer provides the application&#8217;s user interface (UI). Typically, this involves the use of Desktop/Mobile GUI (Windows Forms, IPhone/Android Shells etc..) or Web UI (ASP.NET, ASP.NET MVC, HTML,..) technologies for browser-based interaction.</p>
<h3>Business Layer</h3>
<p>The business layer implements the <strong>business functionality</strong> of the application. The <strong>domain layer</strong> is typically composed of a number of components implemented using one or more programming languages. These components may be augmented with distributed component solutions other kind of workflow orchestration.</p>
<h3>Data Layer</h3>
<p>The data layer provides access to external systems such as databases. When talking about Microsoft.NET the primary .NET technology involved at this layer is ADO.NET, but there are many other possibilities like using ORM mappers (Microsoft Entity Framework, NHibernate, etc..) or some other kind of &#8220;lightweight&#8221; database access libraries like <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy50b3B0ZW5zb2Z0d2FyZS5jb20vcGV0YXBvY28v" title=\"PetaPoco\" target=\"_blank\">PetaPoco</a>, <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cHM6Ly9naXRodWIuY29tL3JvYmNvbmVyeS9tYXNzaXZl" title=\"Massive Database Library\" target=\"_blank\">Massive</a>, or others&#8230;</p>
<h3>Database</h3>
<p>A repository of data.</p>
<h2>Various types of architectures.</h2>
<p>As we have seen above, there are several layers usually used within one application, and each layer has its own responsibility. The hearth of the application is the &#8220;Business Layer&#8221; because this is something that gives the meaning to the application.<br />
Unfortunately things are not that easy, because, yes, we may layer our application, but not every application is layered in the same way. </p>
<p>Let&#8217;s simply name a few typical kind of applications:</p>
<ol>
<li><strong>Client-Server applications</strong>: Usually this kind of application should contain all of the layers described above, but there are several variations depending on the complexity of the application. The point is that the database is running on a separate server from the GUI itself.</li>
<li><strong>Reporting applications</strong>: Usually simply display the data to the user in forms of reports. Typically here we can find the Presentation layer, but the business layer usually would stay in the database directly </li>
<li><strong>Web Application</strong>: A web application could be seen as a Client-Server application because at it&#8217;s heart is executing the code on the server and the database would be typically on another server. </li>
</ol>
<h2>Scalability</h2>
<p>The definition of the scalability is:</p>
<blockquote><p>A characteristic of a system, model or function that describes its capability to cope and perform under an increased or expanding workload. A system that scales well will be able to maintain or even increase its level of performance or efficiency when tested by larger operational demands.</p></blockquote>
<p>I really like this topic, and I think that is really important when it comes to the decision of putting the important part of the logic in the database. </p>
<p><strong>In general, RDBMS databases are not scalable!</strong></p>
<h3>Why RDBMS are not scalable?</h3>
<p>Let&#8217;s put it this way: The <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9DQVBfdGhlb3JlbQ==" title=\"CAP Theorem\" target=\"_blank\">CAP theorem</a> states that a distributed (i.e. scalable) system cannot guarantee all of the following properties at the same time:</p>
<ol>
<li>Consistency</li>
<li>Availability</li>
<li>Partition tolerance</li>
</ol>
<p>RDBMS systems guarantee consistency. That&#8217;s why a standard RDBMS cannot scale very well: it won&#8217;t be able to guarantee availability. And what good is a database if you can&#8217;t access it?</p>
<p>Database pioneer and researcher Michael Stonebraker co-wrote a <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2NzLXd3dy5jcy55YWxlLmVkdS9ob21lcy9kbmEvcGFwZXJzL29sdHBwZXJmLXNpZ21vZDA4LnBkZg==" target=\"_blank\">paper</a> that discusses the limitations of traditional database architectures. RDBMS <strong>scale up</strong> with more expensive hardware, but have difficulty <strong>scaling out</strong> with more commodity hardware in parallel. He contends that the BigData era requires multiple new database architectures that take advantage of modern infrastructure and optimize for a particular workload.</p>
<p>You may see straightforward one big limitation of the databases itself, as in some larger applications those can become a bottleneck, especially in the newest era of computing (see big data, social platforms like twitter, Facebook, google, that are mainly not using RDBMS&#8217;s for keeping their data)&#8230;</p>
<h3>What is the alternative?</h3>
<p>The alternative for some enterprise applications, is to have very well separated layers, and well separated tiers, that would be designed for scalability. </p>
<p>As shown in the diagram below:<br />
<a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEyLzA3L1dlYi1TZXJ2aWNlLVJldXNhYmlsaXR5LmpwZw=="><img src="http://i1.wp.com/www.agile-code.com/blog/wp-content/uploads/2012/07/Web-Service-Reusability.jpg?resize=650%2C251" alt="" title="Web Service Reusability" class="alignnone size-full wp-image-912" data-recalc-dims="1" /></a></p>
<p>Adding new &#8220;Web services&#8221; by increasing a number of servers where the most of calculations (business logic) would be placed, we remove the burden from the database that would be then able to do what it does best, collect and store the data in an consistent way, otherwise if we would put the calculation logic in the database, that would need to server thousands of concurrent transaction, this would soon be unusable.</p>
<p>That&#8217;s why it is very common to have the &#8220;reading&#8221; database separated from the &#8220;writing&#8221; database as shown in the image below.</p>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzAyL2RhdGEtcmVwbGljYXRpb24ucG5n"><img src="http://i2.wp.com/www.agile-code.com/blog/wp-content/uploads/2013/02/data-replication.png?resize=356%2C185" alt="data replication" class="aligncenter size-full wp-image-2295" data-recalc-dims="1" /></a></p>
<h2>Final Thoughts</h2>
<p>I think I just gave you an idea of why I think that the database should not contain business logic. This is based on my experience working on some large applications, where i see that the database becomes more increasingly a bottleneck and after some time it is really hard to detach and refactor the logic to some other layers, as there is another not written rule of &#8220;don&#8217;t change it if it works&#8221;. I am sure there is ton of people that doesn&#8217;t think it in this way (please comment this post then!), and there are tons of other reasons that would go against what described here. You decide ultimately!<br />
Let me know what do you think?</p>
 <img src="http://www.agile-code.com/blog/?feed-stats-post-id=2208" width="1" height="1" style="display: none;" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/agile-code?a=0l2FjHAL_Ok:X15CHRaOZMY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=0l2FjHAL_Ok:X15CHRaOZMY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=0l2FjHAL_Ok:X15CHRaOZMY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/agile-code?i=0l2FjHAL_Ok:X15CHRaOZMY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=0l2FjHAL_Ok:X15CHRaOZMY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/agile-code?i=0l2FjHAL_Ok:X15CHRaOZMY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=0l2FjHAL_Ok:X15CHRaOZMY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/agile-code?i=0l2FjHAL_Ok:X15CHRaOZMY:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=0l2FjHAL_Ok:X15CHRaOZMY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/agile-code?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=0l2FjHAL_Ok:X15CHRaOZMY:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/agile-code?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/agile-code/~4/0l2FjHAL_Ok" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.agile-code.com/blog/logic-in-the-database-to-be-or-not-to-be/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.agile-code.com/blog/logic-in-the-database-to-be-or-not-to-be/</feedburner:origLink></item>
		<item>
		<title>Selecting the Appropriate Juniper Certification Exam for Advancing Your Career</title>
		<link>http://feedproxy.google.com/~r/agile-code/~3/5qL8lKmYjwc/</link>
		<comments>http://www.agile-code.com/blog/selecting-the-appropriate-juniper-certification-exam-for-advancing-your-career/#comments</comments>
		<pubDate>Sun, 17 Feb 2013 19:37:28 +0000</pubDate>
		<dc:creator>Zoran Maksimovic</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.agile-code.com/blog/?p=2223</guid>
		<description><![CDATA[<br/>When choosing Juniper certification exams based on career advancement goals, there are a couple of things you need to keep in mind. The first is that Juniper exams are sequential in nature. In other words, you must work your way through exams from the associate level up in order to build your expertise and meet <a href='http://www.agile-code.com/blog/selecting-the-appropriate-juniper-certification-exam-for-advancing-your-career/' class='excerpt-more'>[... read more]</a>]]></description>
				<content:encoded><![CDATA[<br/><p>When choosing Juniper certification exams based on career advancement goals, there are a couple of things you need to keep in mind. The first is that <a title=\"http://www.testslive.com/juniper/\" href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy50ZXN0c2xpdmUuY29tL2p1bmlwZXIv" target=\"_blank\">Juniper exams</a> are sequential in nature. In other words, you must work your way through exams from the associate level up in order to build your expertise and meet prerequisite requirements for more advanced testing options through the organization.</p>
<p>The second point of importance in career advancement professional certification exam selection is to choose a certification path that will meet your current and your future goals. An Juniper exam that validates your level of expertise and your knowledge base for your current position is the first step in working toward a promotional opportunity or a new job in your field of focus. By demonstrating and documenting our current level of competency you make yourself a more valuable employee – both for your current employer and prospective employers.</p>
<p>From there, choosing the Juniper certification exam that’s best for advancing your career depends on your reason for pursuing testing. In other words, if you’re simply looking to validate your overall competencies in your role, then you’ll want to focus on the role-based exams offered through Juniper. However, if you’re concerned about validating your technology or product specific knowledge and skills for your current position or to achieve a promotion or other career advancement, you’ll want to review the testing options in your focus area.</p>
<p>Whichever exam or exams you choose to complete, spend the appropriate time studying to promote strong performance on your first attempt. Exam prep studies can include everything from formal training courses to self study tutorials to the use of practice exams, like those offered by providers like TestsLive (<a title=\"http://www.testslive.com\" href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy50ZXN0c2xpdmUuY29t" target=\"_blank\">click here</a>), for example.</p>
 <img src="http://www.agile-code.com/blog/?feed-stats-post-id=2223" width="1" height="1" style="display: none;" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/agile-code?a=5qL8lKmYjwc:3RzP1jiHi8E:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=5qL8lKmYjwc:3RzP1jiHi8E:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=5qL8lKmYjwc:3RzP1jiHi8E:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/agile-code?i=5qL8lKmYjwc:3RzP1jiHi8E:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=5qL8lKmYjwc:3RzP1jiHi8E:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/agile-code?i=5qL8lKmYjwc:3RzP1jiHi8E:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=5qL8lKmYjwc:3RzP1jiHi8E:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/agile-code?i=5qL8lKmYjwc:3RzP1jiHi8E:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=5qL8lKmYjwc:3RzP1jiHi8E:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/agile-code?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=5qL8lKmYjwc:3RzP1jiHi8E:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/agile-code?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/agile-code/~4/5qL8lKmYjwc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.agile-code.com/blog/selecting-the-appropriate-juniper-certification-exam-for-advancing-your-career/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.agile-code.com/blog/selecting-the-appropriate-juniper-certification-exam-for-advancing-your-career/</feedburner:origLink></item>
		<item>
		<title>MS SQL Server – Querying object info</title>
		<link>http://feedproxy.google.com/~r/agile-code/~3/AzxpVG-55tc/</link>
		<comments>http://www.agile-code.com/blog/ms-sql-server-querying-object-info/#comments</comments>
		<pubDate>Fri, 08 Feb 2013 09:55:51 +0000</pubDate>
		<dc:creator>Zoran Maksimovic</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Microsoft SQL Server]]></category>

		<guid isPermaLink="false">http://www.agile-code.com/blog/?p=2177</guid>
		<description><![CDATA[<br/>I am migrating some old posts to this blog, so I though it would be good to migrate this one too. This post has been originally written in February 2010, but still actual and valid. Today I run into a problem of finding out when was the last time a specific Stored Procedure (SP) has <a href='http://www.agile-code.com/blog/ms-sql-server-querying-object-info/' class='excerpt-more'>[... read more]</a>]]></description>
				<content:encoded><![CDATA[<br/><div class="highlight">I am migrating some old posts to this blog, so I though it would be good to migrate this one too. This post has been originally written in February 2010, but still actual and valid. </div>
<p>Today I run into a problem of finding out when was the last time a specific Stored Procedure (SP) has been changed.</p>
<p>Obviously, there are different ways to find out, but in this post I would like to introduce some of the possible solutions by using your lovely MS SQL Server Management studio query window. I hope you will find this info useful.</p>
<h2>Introduction</h2>
<p>Generally there are two ways to retrieve information about database objects. By using either the <code>Sys</code> or <code>INFORMATION_SCHEMA</code> schemas.</p>
<p>So, let’s start by saying that usually you would be too busy to look into the internal SQL Server system tables/views, but it worth mentioning that this is possible, and for sure you would like to get all this information in a really easy way.</p>
<h2>Sys.* objects</h2>
<p>Objects in this schema contains everything you need to know about the database, indeed, this gives us a direct view on SQL Server internal structure. <strong>Sys</strong> schema contains so called “System views”. Be aware that there is a large number of system views, and is out of scope of this post to list them all. Anyway, here listed are a couple of “System views” that you will be most probably looking into:</p>
<table border="1">
<tbody>
<tr>
<td><strong>Object Name</strong></td>
<td><strong>Description</strong></td>
</tr>
</tbody>
<tbody>
<tr>
<td><strong><code>sys.objects<</code>/strong></td>
<td>Contains a row for each user-defined, schema-scoped object that is created within a database</td>
</tr>
<tr>
<td><strong><code>sys.tables</code></strong></td>
<td>Contains a row foreach user-defined table</td>
</tr>
<tr>
<td><strong><code>sys.databases</code></strong></td>
<td>Contains a row foreach instance available database</td>
</tr>
</tbody>
</table>
<p>etc… I am sure you got the idea.</p>
<p>What you would probably like to know is how the SQL Server stores the “type” information about the particular object. Please find out the following list:</p>
<ul>
<li><strong>C:</strong> Check constraint</li>
<li><strong>D:</strong> Default constraint</li>
<li><strong>F:</strong> Foreign Key constraint</li>
<li><strong>L:</strong> Log</li>
<li><strong>P:</strong> Stored procedure</li>
<li><strong>PK:</strong> Primary Key constraint</li>
<li><strong>RF:</strong> Replication Filter stored procedure</li>
<li><strong>S:</strong> System table</li>
<li><strong>TR:</strong> Trigger</li>
<li><strong>U:</strong> User table</li>
<li><strong>UQ:</strong> Unique constraint</li>
<li><strong>V:</strong> View</li>
<li><strong>X:</strong> Extended stored procedure</li>
</ul>
<h2>Information Schema</h2>
<p>I am sure you will find very usefull the usage of <code>INFORMATION_SCHEMA</code> that contains a number of VIEWS to the internal database objects. The <code>INFORMATION_SCHEMA</code> is much more user friendly, but gives less information. Here below is a list of some views that <code>INFORMATION_SCHEMA</code> contains (total of 20 views):</p>
<table border="1">
<tbody>
<tr>
<td><strong>Object Name</strong></td>
<td><strong>Description</strong></td>
</tr>
</tbody>
<tbody>
<tr>
<td><strong>INFORMATION_SCHEMA.Tables</strong></td>
<td>Retrieves a list of database tables</td>
</tr>
<tr>
<td><strong>INFORMATION_SCHEMA.Columns</strong></td>
<td>Contains a list of columns and it’s relative table.</td>
</tr>
<tr>
<td><strong>INFORMATION_SCHEMA.Views</strong></td>
<td>Contains a row foreach instance available database</td>
</tr>
<tr>
<td><strong>INFORMATION_SCHEMA.ROUTINES</strong></td>
<td>Contains a list of Stored procedures and Functions</td>
</tr>
<tr>
<td><strong>INFORMATION_SCHEMA.ROUTINE_Columns</strong></td>
<td>Contains a list of parameters for a given stored procedure or function</td>
</tr>
</tbody>
</table>
<p>etc… again, you got the idea.</p>
<p>So, let’s finally start doing some queries:</p>
<h4>How to retrieve the Create and Modify date for a stored procedure</h4>
<pre class="brush:Sql; ruler: true;">
SELECT name, create_date, modify_date
FROM sys.objects
WHERE type = 'P' -- Stored Procedure
OR type = 'V' -- View
</pre>
<p>you may obtain the same thing by using the following query:</p>
<pre class="brush:Sql; ruler: true;">
SELECT SPECIFIC_NAME, CREATED, LAST_ALTERED
FROM INFORMATION_SCHEMA.ROUTINES
</pre>
<h4>How to retrieve the list of a Stored Procedure Parameters</h4>
<pre class="brush:Sql; ruler: true;">

SELECT sys.parameters.name, so.name , so.*
FROM sys.parameters
INNER JOIN sys.objects so ON so.object_id = sys.parameters.object_id
WHERE so.name = '<your proc name>'
</pre>
<p>you may obtain the same thing by using the following query:</p>
<pre class="brush:Sql; ruler: true;">

SELECT PARAMETER_NAME, SPECIFIC_NAME, Data_Type
FROM INFORMATION_SCHEMA.Parameters
WHERE SPECIFIC_NAME = '<your proc name>'

</pre>
<h2>Conclusion</h2>
<p>As you have seen, it is really easy to retrieve information about your database objects. This post was just to give an introduction on the subject, so I leave the tough work of discovering all the beauties of the SQL Server internals to you <img src='http://i0.wp.com/www.agile-code.com/blog/wp-includes/images/smilies/icon_smile.gif?w=695' alt=':)' class='wp-smiley' data-recalc-dims="1" /> </p>
 <img src="http://www.agile-code.com/blog/?feed-stats-post-id=2177" width="1" height="1" style="display: none;" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/agile-code?a=AzxpVG-55tc:byCFp2DB9Fg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=AzxpVG-55tc:byCFp2DB9Fg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=AzxpVG-55tc:byCFp2DB9Fg:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/agile-code?i=AzxpVG-55tc:byCFp2DB9Fg:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=AzxpVG-55tc:byCFp2DB9Fg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/agile-code?i=AzxpVG-55tc:byCFp2DB9Fg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=AzxpVG-55tc:byCFp2DB9Fg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/agile-code?i=AzxpVG-55tc:byCFp2DB9Fg:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=AzxpVG-55tc:byCFp2DB9Fg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/agile-code?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=AzxpVG-55tc:byCFp2DB9Fg:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/agile-code?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/agile-code/~4/AzxpVG-55tc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.agile-code.com/blog/ms-sql-server-querying-object-info/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.agile-code.com/blog/ms-sql-server-querying-object-info/</feedburner:origLink></item>
		<item>
		<title>Embedding SVN revision number at compile time with MsBuild</title>
		<link>http://feedproxy.google.com/~r/agile-code/~3/HOw7WS5ZB4w/</link>
		<comments>http://www.agile-code.com/blog/embedding-svn-revision-number-at-compile-time-with-msbuild/#comments</comments>
		<pubDate>Fri, 01 Feb 2013 23:04:42 +0000</pubDate>
		<dc:creator>Zoran Maksimovic</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Microsoft.NET]]></category>
		<category><![CDATA[msbuild]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://www.agile-code.com/blog/?p=2128</guid>
		<description><![CDATA[<br/>If you, like me, are using Subversion as your primary Version System and want to embed the SVN revision number directly in the assembly, but don&#8217;t know how, this post will try to explain it. What do you need? Before proceeding any further, you would need to download the following two packages (free!) MSBuild Community <a href='http://www.agile-code.com/blog/embedding-svn-revision-number-at-compile-time-with-msbuild/' class='excerpt-more'>[... read more]</a>]]></description>
				<content:encoded><![CDATA[<br/><p>If you, like me, are using Subversion as your primary Version System and want to embed the SVN revision number directly in the assembly, but don&#8217;t know how, this post will try to explain it.</p>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzAyL0VtYmVkZF9SZXZpc2lvbl9Jbl9Bc3NlbWJseV9Qcm9jZXNzLnBuZw=="><img src="http://i0.wp.com/www.agile-code.com/blog/wp-content/uploads/2013/02/Embedd_Revision_In_Assembly_Process.png?resize=695%2C257" alt="Embedd_Revision_In_Assembly_Process" class="aligncenter size-full wp-image-2136" data-recalc-dims="1" /></a></p>
<h2>What do you need?</h2>
<p>Before proceeding any further, you would need to download the following two packages (free!)</p>
<ul>
<li><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cHM6Ly9naXRodWIuY29tL2xvcmVzb2Z0L21zYnVpbGR0YXNrcw==">MSBuild Community Tasks</a></li>
<li><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5jb2xsYWIubmV0L2Rvd25sb2Fkcy9zdWJ2ZXJzaW9u">Subversion 1.7.8 (Windows 64/32-bit)</a></li>
</ul>
<div class="highlight">
I assume that you are familiar with MsBuild and how to work with SVN.
</div>
<h2>What is the process to follow</h2>
<p>In the explanation I assume the build process is made out of a Build Server (Hudson, Bamboo, Team City, or others..) but exactly the same process applies if the compilation is done manually.</p>
<p>In the image above, I am showing two different steps:</p>
<ol>
<li>Developer, committing the code in the SVN repository</li>
<li>In my case, a Continuous Integration server that compiles the project. Steps that the Build Service has to perform are:
<ul>
<li>Download the latest version of the source code</li>
<li>Change the AssemblyInfo.cs file with the Repository Revision number. I will show how to do this, just keep reading.</li>
<li>Compile the solution.</li>
</ul>
</li>
</ol>
<p>It&#8217;s pretty much clear and simple to follow this steps.</p>
<h2>Preprocessing the AssemblyInfo.cs in MsBuild</h2>
<p>The main point of the whole process in the building (compilation) of the project.<br />
The following MsBuild Target will help you with the &#8220;pre-processing&#8221;, which means, changing the AssemblyInfo.cs file <strong>before</strong> the code is compiled. In this way we are able to embed the revision number. </p>
<p>Two tasks are used from the MsBuild Community Tasks</p>
<ul>
<li>SvnVersion</li>
<li>FileUpdate</li>
</ul>
<p>so on top of your MsBuild file you would need to include the following declaration:</p>
<pre>
&lt;UsingTask TaskName=&quot;SvnVersion&quot; 
           AssemblyFile=&quot;MSBuild.Community.Tasks.dll&quot;/&gt;
                  
&lt;UsingTask TaskName=&quot;FileUpdate&quot;
           AssemblyFile=&quot;MSBuild.Community.Tasks.dll&quot;/&gt;
</pre>
<p>and use this target to be executed BEFORE the main compilation.<br />
For brevity I am including only the Target itself, as your build process could vary.</p>
<pre>
&lt;!-- ******************************
@@ PRE-BUILD PROCESSING
@@ Sets the revision version for the assemblies.
*********************************** --&gt;
&lt;Target Name=&quot;PreBuild&quot;&gt;             
  &lt;ItemGroup&gt;
      &lt;!-- find all the AssemblyInfo.cs files in the solution--&gt;
      &lt;AssemblyInfoFiles 
               Include=&quot;$(BuildPath)\*\Properties\AssemblyInfo.cs&quot;/&gt;
  &lt;/ItemGroup&gt;
       
  &lt;PropertyGroup&gt;
      &lt;SVNToolPath&gt;&lt;!--Path to the svnVersion.exe--&gt;&lt;/SVNToolPath&gt;
  &lt;/PropertyGroup&gt;
       
  &lt;!-- Getting the revision number from svn by using the svnVersion--&gt;       
  &lt;SvnVersion LocalPath=&quot;$(BuildPath)&quot; ToolPath=&quot;$(SVNToolPath)&quot; &gt;
      &lt;Output TaskParameter=&quot;Revision&quot; PropertyName=&quot;Revision&quot; /&gt;
  &lt;/SvnVersion&gt;
  &lt;Message Text=&quot;Revision: $(Revision)&quot;/&gt;

  &lt;!--uploading the AssemblyInfo.cs files--&gt;
  &lt;FileUpdate Files=&quot;@(AssemblyInfoFiles)&quot;
              Regex=&#039;(d+).(d+).(d+).(d+)&#039;
              ReplacementText=&quot;$1.$2.$3.$(Revision)&quot; /&gt;
&lt;/Target&gt;
</pre>
<p>Pretty much simple. Isn&#8217;t it?<br />
In my case the revision number is 5683 and you may see the end result in the picture below:<br />
<a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzAyL0ZpbGUtVmVyc2lvbi5wbmc="><img src="http://i1.wp.com/www.agile-code.com/blog/wp-content/uploads/2013/02/File-Version.png?resize=376%2C513" alt="File-Version" class="aligncenter size-full wp-image-2169" data-recalc-dims="1" /></a></p>
<h2>Conclusion</h2>
<p>I believe that this is a very effective and simple way of including the revision number directly in the assembly, which makes the revision tracking simpler overall.<br />
If you think there are other and more effective ways, please let me know!</p>
 <img src="http://www.agile-code.com/blog/?feed-stats-post-id=2128" width="1" height="1" style="display: none;" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/agile-code?a=HOw7WS5ZB4w:MQexIjg5tjY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=HOw7WS5ZB4w:MQexIjg5tjY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=HOw7WS5ZB4w:MQexIjg5tjY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/agile-code?i=HOw7WS5ZB4w:MQexIjg5tjY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=HOw7WS5ZB4w:MQexIjg5tjY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/agile-code?i=HOw7WS5ZB4w:MQexIjg5tjY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=HOw7WS5ZB4w:MQexIjg5tjY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/agile-code?i=HOw7WS5ZB4w:MQexIjg5tjY:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=HOw7WS5ZB4w:MQexIjg5tjY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/agile-code?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=HOw7WS5ZB4w:MQexIjg5tjY:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/agile-code?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/agile-code/~4/HOw7WS5ZB4w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.agile-code.com/blog/embedding-svn-revision-number-at-compile-time-with-msbuild/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.agile-code.com/blog/embedding-svn-revision-number-at-compile-time-with-msbuild/</feedburner:origLink></item>
		<item>
		<title>Syncfusion: ASP.NET MVC 4 Mobile Web Sites Succinctly</title>
		<link>http://feedproxy.google.com/~r/agile-code/~3/44WqotQGSPQ/</link>
		<comments>http://www.agile-code.com/blog/syncfusion-asp-net-mvc-4-mobile-web-sites-succinctly/#comments</comments>
		<pubDate>Fri, 25 Jan 2013 23:11:27 +0000</pubDate>
		<dc:creator>Zoran Maksimovic</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Microsoft.NET]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.agile-code.com/blog/?p=2108</guid>
		<description><![CDATA[<br/>Since 2001 Syncfusion provides the broadest range of enterprise-class software components and tools for the Microsoft .NET platform, so it&#8217;s not a surprise that as a Software Consultant several times in my working career I had to deal with their libraries and components which usually were reliable, good quality and easy to use. That said, <a href='http://www.agile-code.com/blog/syncfusion-asp-net-mvc-4-mobile-web-sites-succinctly/' class='excerpt-more'>[... read more]</a>]]></description>
				<content:encoded><![CDATA[<br/><p>Since 2001 Syncfusion provides the broadest range of enterprise-class software components and tools for the Microsoft .NET platform, so it&#8217;s not a surprise that as a Software Consultant several times in my working career I had to deal with their libraries and components which usually were reliable, good quality and easy to use.  </p>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzAxL3N1Y2NpbnRseS5wbmc="><img src="http://i2.wp.com/www.agile-code.com/blog/wp-content/uploads/2013/01/succintly.png?resize=570%2C211" alt="succintly" class="aligncenter size-full wp-image-2121" data-recalc-dims="1" /></a></p>
<p>That said, this blog post is not about their components, as there are plenty of information out there, but about what Syncfusion introduced in May 2012, which is what they call <code> Succinctly Series</code>, and in particular about the book called <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5zeW5jZnVzaW9uLmNvbS9yZXNvdXJjZXMvdGVjaHBvcnRhbC9lYm9va3MvYXNwbmV0bXZjNA==" title=\"ASP.NET MVC 4 Mobile Websites Succinctly\">ASP.NET MVC 4 Mobile Web Site by <em>Lyle Luppes</em></a></p>
<p>Let&#8217;s start from the beginning by introducing what <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5zeW5jZnVzaW9uLmNvbS9yZXNvdXJjZXMvdGVjaHBvcnRhbC9lYm9va3M=" title=\"Succinctly Series\" target=\"_blank\">Succinctly Series</a> is all about and the best thing would be to directly take a quote from the Syncfusion blog: </p>
<blockquote><p>
While a lot of information on application development is available on the internet and in books, that information is becoming harder to digest. If you do not enjoy reading several 500+ page books, or scouring the web for relevant blog posts and articles, you have come to the right place.<br />
Syncfusion publishes the Succinctly series concise technical books that target developers working on the Microsoft platform. Each book is around 100 pages and is guaranteed to enlighten you on the topic of interest. Download a copy, get a cup of your favorite beverage, and enjoy!
</p></blockquote>
<p>Isn&#8217;t that great? Syncfusion is offering for <strong>free</strong> high quality books that are condensed and go &#8220;straight to the point&#8221;, which saves long hours of reading that none of us really have.</p>
<h2>ASP.NET MVC 4 Mobile Web Sites Succinctly</h2>
<p>The book that I particularly liked as it goes beyond the classical &#8220;let&#8217;s develop in ASP.NET MVC framework&#8221; is the <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5zeW5jZnVzaW9uLmNvbS9yZXNvdXJjZXMvdGVjaHBvcnRhbC9lYm9va3MvYXNwbmV0bXZjNA==" title=\"ASP.NET MVC 4 Mobile Websites Succinctly\">ASP.NET MVC 4 Mobile Web Site Succinctly by <em>Lyle Luppes</em></a>, that describes how developers that are currently using ASP.NET MVC 3 can move to MVC 4 with minimal effort.<br />
I firmly believe that this book will offer you a great help when deciding about how to make a website with MVC 4 that can handle the unique challenges presented by <em>mobile</em> and <em>desktop</em> clients.<br />
Needless to say that the code samples are <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cHM6Ly9iaXRidWNrZXQub3JnL3N5bmNmdXNpb24vbW9iaWxlbXZjLXN1Y2NpbmN0bHk=" title=\"Mobile MVC - Succinctly\" target=\"_blank\">freely downloadable</a>.</p>
<div class="highlight" style="text-align:center">
Desktop != Tablet != Phone
</div>
<h4>Who should be interested in reading this book?</h4>
<p>This book is for developers who are currently using Microsoft ASP.NET and MVC to create websites, and who are interested in creating websites that play nicely with mobile devices.</p>
<h4>Purpose?</h4>
<p>It‘s designed to be a quick read for developers and to help them understand the concepts they need to know to improve their websites when it comes to dealing with mobile devices.</p>
<h4>Table of Contents</h4>
<ol>
<li>I Love MVC 4!</li>
<li>Why a Book about Mobile-Friendly Websites?</li>
<li>Designing Mobile-Friendly Websites</li>
<li>Building an MVC Mobile Website</li>
<li>Making It Mobile-Friendly</li>
<li>Making It Look Good</li>
<li>Using Mobile Device Meta Tags</li>
<li>Tips and Tricks</li>
<li>Enhancing Performance</li>
<li>Still Using MVC 3?</li>
<li>Conclusion</li>
</ol>
<h2>Conclusion</h2>
<p>If you are a ASP.NET MVC developer I strongly advise you to take a look at this book and perhaps to other great content that Syncfusion offers. As I started working on my new, side project, <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rdG90d2VldC5jb20=" title=\"LinkToTweet.com\" target=\"_blank\">www.linktotweet.com</a> I will definitively start applying some code found in the book in order to build a more mobile friendly version.<br />
Pleaset let me know what do you think about the book and would you advise it to others?</p>
 <img src="http://www.agile-code.com/blog/?feed-stats-post-id=2108" width="1" height="1" style="display: none;" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/agile-code?a=44WqotQGSPQ:E3gBKIkB3qs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=44WqotQGSPQ:E3gBKIkB3qs:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=44WqotQGSPQ:E3gBKIkB3qs:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/agile-code?i=44WqotQGSPQ:E3gBKIkB3qs:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=44WqotQGSPQ:E3gBKIkB3qs:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/agile-code?i=44WqotQGSPQ:E3gBKIkB3qs:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=44WqotQGSPQ:E3gBKIkB3qs:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/agile-code?i=44WqotQGSPQ:E3gBKIkB3qs:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=44WqotQGSPQ:E3gBKIkB3qs:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/agile-code?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=44WqotQGSPQ:E3gBKIkB3qs:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/agile-code?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/agile-code/~4/44WqotQGSPQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.agile-code.com/blog/syncfusion-asp-net-mvc-4-mobile-web-sites-succinctly/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.agile-code.com/blog/syncfusion-asp-net-mvc-4-mobile-web-sites-succinctly/</feedburner:origLink></item>
		<item>
		<title>Fix the WCF wsdl domain name when using IIS6 and HTTPS</title>
		<link>http://feedproxy.google.com/~r/agile-code/~3/jfrvCgn1Og4/</link>
		<comments>http://www.agile-code.com/blog/fix-the-wcf-wsdl-domain-name-when-using-iis6-and-https/#comments</comments>
		<pubDate>Thu, 17 Jan 2013 16:12:47 +0000</pubDate>
		<dc:creator>Zoran Maksimovic</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[Web Service]]></category>

		<guid isPermaLink="false">http://www.agile-code.com/blog/?p=2048</guid>
		<description><![CDATA[<br/>When exposing a WCF service and hosting it on IIS6, most probably you are going to get the error shown in the image below, where the address of the WSDL location is not properly exposed to the end clients. This post is specifically concentrating to the solution of the problem in case the HTTPS protocol <a href='http://www.agile-code.com/blog/fix-the-wcf-wsdl-domain-name-when-using-iis6-and-https/' class='excerpt-more'>[... read more]</a>]]></description>
				<content:encoded><![CDATA[<br/><p>When exposing a WCF service and hosting it on IIS6, most probably you are going to get the error shown in the image below, where the address of the WSDL location is not properly exposed to the end clients. </p>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzAxL0FkZHJlc3NfV3NkbF9ub3RfZXhwb3NlZF9jb3JyZWN0bHkucG5n"><img src="http://i2.wp.com/www.agile-code.com/blog/wp-content/uploads/2013/01/Address_Wsdl_not_exposed_correctly.png?w=600" alt="WCF wsdl address not exposed correctly." class="aligncenter size-full wp-image-2049" data-recalc-dims="1" /></a></p>
<div class="highlight">
This post is specifically concentrating to the solution of the problem in case the HTTPS protocol is used, as it has it&#8217;s own specific problems.
</div>
<p>As the following WSDL gets created (shown in the picture below), the consequence of this is that de-facto you are not able to expose your service to your clients without manually sending them the WSDL and correcting the location of the schema for the exposed types.</p>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzAxL1dzZGxfVHlwZXNfcG9pbnRpbmdfdG9fV3JvbmdfTG9jYXRpb24ucG5n"><img src="http://i2.wp.com/www.agile-code.com/blog/wp-content/uploads/2013/01/Wsdl_Types_pointing_to_Wrong_Location.png?w=600" alt="Wsdl_Types_pointing_to_Wrong_Location" class="aligncenter size-full wp-image-2057" data-recalc-dims="1" /></a></p>
<h2>How to fix this?</h2>
<p>Mainly, there are two ways of fixing this:</p>
<ol>
<li>Changing the web.config file (works only for .NET 4 and above)</li>
<li>Tweaking the IIS for version of .NET 3 and 3.5 </li>
</ol>
<h3>Web Config change</h3>
<p>Changing the <code>web.config</code> would work only for the <strong>.NET v4</strong> and above, as Microsoft introduced a fix for this.<br />
You should simply add the <code><useRequestHeadersForMetadataAddress></code> part as part of your <code>serviceBehaviors/behavior</code> and magically this is going to work.</p>
<pre>
&lt;behaviors&gt;
    &lt;serviceBehaviors&gt;
        &lt;behavior name=&quot;name of your behaviour&quot;&gt;
            &lt;useRequestHeadersForMetadataAddress&gt;
                &lt;defaultPorts&gt;
                    &lt;add scheme=&quot;https&quot; port=&quot;443&quot; /&gt;
                &lt;/defaultPorts&gt;
            &lt;/useRequestHeadersForMetadataAddress&gt;
        &lt;/behavior&gt;
    &lt;/serviceBehaviors&gt;
&lt;behaviors&gt;
</pre>
<h3>IIS Change</h3>
<p>The reason this problem happens in IIS 6 is because IIS 6 doesn&#8217;t expose the header name for the TSL/SSL (https) based web sites and therefore WCF is (was) not aware of the header that the web site where the WCF is hosted, responds to.</p>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzAxL0NvbmZpZ3VyaW5nLUhvc3QtSGVhZGVycy1mb3ItSHR0cHMuanBn"><img src="http://i2.wp.com/www.agile-code.com/blog/wp-content/uploads/2013/01/Configuring-Host-Headers-for-Https.jpg?resize=456%2C386" alt="Configuring Host Headers for Https" class="aligncenter size-full wp-image-2067" data-recalc-dims="1" /></a></p>
<p>In order to fix this, you should run the admin script to change your web site bindings, as this cannot be done anywhere else in the IIS Admin gui.</p>
<p>Script that changes the IIS binding:</p>
<pre>
cscript.exe //nologo %systemdrive%\inetpub\adminscripts\adsutil.vbs set W3SVC/<websiteidentifiergoeshere>/SecureBindings ":443:website.com"
</pre>
<p>To check if this really worked, change the <strong>set</strong> to <strong>get</strong>:</p>
<pre>
cscript.exe //nologo %systemdrive%\inetpub\adminscripts\adsutil.vbs get W3SVC/<websiteidentifiergoeshere>/SecureBindings ":443:website.com" 
</pre>
<h2>Conclusion</h2>
<p>I really hope that this info will be on your help as made me and my team spend quite a lot of time into finding out the solution. In our case the .NET 4 saved us from modifying directly the IIS bindings.</p>
 <img src="http://www.agile-code.com/blog/?feed-stats-post-id=2048" width="1" height="1" style="display: none;" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/agile-code?a=jfrvCgn1Og4:q_9_Lz3AjXo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=jfrvCgn1Og4:q_9_Lz3AjXo:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=jfrvCgn1Og4:q_9_Lz3AjXo:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/agile-code?i=jfrvCgn1Og4:q_9_Lz3AjXo:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=jfrvCgn1Og4:q_9_Lz3AjXo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/agile-code?i=jfrvCgn1Og4:q_9_Lz3AjXo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=jfrvCgn1Og4:q_9_Lz3AjXo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/agile-code?i=jfrvCgn1Og4:q_9_Lz3AjXo:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=jfrvCgn1Og4:q_9_Lz3AjXo:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/agile-code?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=jfrvCgn1Og4:q_9_Lz3AjXo:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/agile-code?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/agile-code/~4/jfrvCgn1Og4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.agile-code.com/blog/fix-the-wcf-wsdl-domain-name-when-using-iis6-and-https/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.agile-code.com/blog/fix-the-wcf-wsdl-domain-name-when-using-iis6-and-https/</feedburner:origLink></item>
		<item>
		<title>Import DB-IP.com database data to Microsoft Sql Server with ZORAN.DB.IP.Importer tool</title>
		<link>http://feedproxy.google.com/~r/agile-code/~3/dEseVYgj1Hs/</link>
		<comments>http://www.agile-code.com/blog/import-db-ip-com-database-data-to-microsoft-sql-server-with-zoran-db-ip-importer-tool/#comments</comments>
		<pubDate>Thu, 10 Jan 2013 22:43:15 +0000</pubDate>
		<dc:creator>Zoran Maksimovic</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[Microsoft SQL Server]]></category>

		<guid isPermaLink="false">http://www.agile-code.com/blog/?p=2019</guid>
		<description><![CDATA[<br/>Recently I started working on my side-hobby-project on the linktotweet.com web site, and one of the functionality I want to offer to site members is the possibility to track the statistics, and more precisely the location of their visitors. In other words, I need to translate the IP address to an actual location. While this <a href='http://www.agile-code.com/blog/import-db-ip-com-database-data-to-microsoft-sql-server-with-zoran-db-ip-importer-tool/' class='excerpt-more'>[... read more]</a>]]></description>
				<content:encoded><![CDATA[<br/><p>Recently I started working on my side-hobby-project on the <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rdG90d2VldC5jb20=" title=\"linktotweet.com\" target=\"_blank\">linktotweet.com</a> web site, and one of the functionality I want to offer to site members is the possibility to track the statistics, and more precisely the location of their visitors. In other words, I need to translate the IP address to an actual location.</p>
<p>While this is almost a trivial task for whoever is using the Google Analytics (like I do) that tracks the visitors, implementing it yourself is actually not such a trivial thing. Ok, it is not that complex too <img src='http://i0.wp.com/www.agile-code.com/blog/wp-includes/images/smilies/icon_smile.gif?w=695' alt=':)' class='wp-smiley' data-recalc-dims="1" /><br />
<a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEzLzAxL1pPUkFOLkRCXy5JUF8uSW1wb3J0ZXIucG5n"><img src="http://i1.wp.com/www.agile-code.com/blog/wp-content/uploads/2013/01/ZORAN.DB_.IP_.Importer.png?resize=423%2C89" alt="ZORAN.DB.IP.Importer" class="aligncenter size-full wp-image-2030" data-recalc-dims="1" /></a></p>
<h2>IP to Location database</h2>
<p>The first thing to find out is where to get this IP to Location data from!<br />
Mainly there are two possibilities.</p>
<ol>
<li>Use a third party web service that will translate the ip to a given location </li>
<li>Implement your own solution. Meaning, hosting the data on own servers.</li>
</ol>
<p>I chose to go with the second approach. While there are really many providers around, I wanted to use the most precise and <strong>free</strong> database. After many days of searching and trying out the solution, I came to the DB-IP.com provider. DB-IP.com is offering some free databases among their commercial versions&#8230; My choice was the &#8220;IP address to city&#8221;, which is really enough for the first version of the site.</p>
<h2>Importing tool</h2>
<p>While on the DB-IP.com there is a version of the code written in PHP that would import the database I wanted to create something on my own, and I&#8217;ve created a command line tool <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cHM6Ly9naXRodWIuY29tL3pvcmFubWF4L1pPUkFOLkRCLklQLkltcG9ydGVy" title=\"ZORAN.DB.IP.Importer tool\" target=\"_blank\">ZORAN.DB.IP.Importer</a> and have published it on git hub as a free download.</p>
<div class="highlight">
For the time being the tool allows the import of the free &#8220;Ip to Location (City)&#8221; Database only.
</div>
<h2>How to run the application?</h2>
<ol>
<li>Download the free database from this location <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5kYi1pcC5jb20vZGIvZG93bmxvYWQvY2l0eQ==" title=\"http://www.db-ip.com/db/download/city\" target=\"_blank\">http://www.db-ip.com/db/download/city</a>. The database comes in the CSV format.</li>
<li>Setup the <strong>Connection String</strong> in the ZORAN.DB-IP-Importer.exe.config file to point to the Microsoft SQL Server database. This is done by changing the value of the connection string named &#8220;DB_IP&#8221;</li>
<li>Once again, in the file ZORAN.DB-IP-Importer.exe.config, enter the path to the CSV file by changing the value of the AppSettings value &#8220;db-ip-file-path&#8221;</li>
<li>Run the two provided scripts <strong>dbip_city.sql</strong> and <strong>dbip_city_stage.sql</strong> against your database. This will create two tables (staging and the &#8220;live&#8221; table). Obviously this should be done only once , the first time you use the application.</li>
<li>Run the application.</li>
</ol>
<h2>Yes, but how does it work?</h2>
<p>In order to avoid any complex management of the inserts and updates of the already existing data, I&#8217;ve chosen the approach of the staging table and the &#8220;live&#8221; table.</p>
<p>The importing process operations are as follows:</p>
<ol>
<li>Read the CSV file</li>
<li>Truncate the data from the &#8220;Staging&#8221; table</li>
<li>Load the data from the CSV file to the &#8220;Staging&#8221; table</li>
<li>In a transaction, move all the data from the &#8220;staging&#8221; table to the &#8220;live&#8221; table.</li>
</ol>
<h2>Licence</h2>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hcGFjaGUub3JnL2xpY2Vuc2VzL0xJQ0VOU0UtMi4w" title=\"http://www.apache.org/licenses/LICENSE-2.0\" target=\"_blank\">http://www.apache.org/licenses/LICENSE-2.0</a></p>
<h2>External tools</h2>
<p>This project uses the external library CsvHelper which binaries are in this repository. For more info please visit the official site at <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cHM6Ly9naXRodWIuY29tL0pvc2hDbG9zZS9Dc3ZIZWxwZXI=" title=\"https://github.com/JoshClose/CsvHelper\" target=\"_blank\">https://github.com/JoshClose/CsvHelper</a></p>
<h2>Downloads</h2>
<p>Download the first version of the compiled application from <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2JpdC5seS9XemppZmc=" target=\"_blank\">ZORAN.DB-IP-Importer_v1.0.0.zip</a></p>
<p>If you think you need any help with the tool please <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL2NvbnRhY3Qv" title=\"Contact\" target=\"_blank\">let me know</a>.</p>
 <img src="http://www.agile-code.com/blog/?feed-stats-post-id=2019" width="1" height="1" style="display: none;" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/agile-code?a=dEseVYgj1Hs:LwogmaXwAL8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=dEseVYgj1Hs:LwogmaXwAL8:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=dEseVYgj1Hs:LwogmaXwAL8:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/agile-code?i=dEseVYgj1Hs:LwogmaXwAL8:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=dEseVYgj1Hs:LwogmaXwAL8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/agile-code?i=dEseVYgj1Hs:LwogmaXwAL8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=dEseVYgj1Hs:LwogmaXwAL8:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/agile-code?i=dEseVYgj1Hs:LwogmaXwAL8:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=dEseVYgj1Hs:LwogmaXwAL8:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/agile-code?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=dEseVYgj1Hs:LwogmaXwAL8:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/agile-code?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/agile-code/~4/dEseVYgj1Hs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.agile-code.com/blog/import-db-ip-com-database-data-to-microsoft-sql-server-with-zoran-db-ip-importer-tool/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.agile-code.com/blog/import-db-ip-com-database-data-to-microsoft-sql-server-with-zoran-db-ip-importer-tool/</feedburner:origLink></item>
		<item>
		<title>What’s new in Google DataTable .NET Wrapper v3.0.0</title>
		<link>http://feedproxy.google.com/~r/agile-code/~3/USxix171iXA/</link>
		<comments>http://www.agile-code.com/blog/whats-new-in-google-datatable-net-wrapper-v3-0-0/#comments</comments>
		<pubDate>Tue, 08 Jan 2013 23:40:15 +0000</pubDate>
		<dc:creator>Zoran Maksimovic</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ASP.NET Web API]]></category>
		<category><![CDATA[Google DataTable .Net Wrapper]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[json]]></category>

		<guid isPermaLink="false">http://www.agile-code.com/blog/?p=2016</guid>
		<description><![CDATA[<br/>Google DataTable .NET Wrapper library got its third version (v3.0.0). In this post I will highlight the changes. For basic information about the library check a previous post of how to use the Google DataTable .Net Wrapper Library To download or consult the source code please visit the project&#8217;s CodePlex page&#160;or install directly from Visual <a href='http://www.agile-code.com/blog/whats-new-in-google-datatable-net-wrapper-v3-0-0/' class='excerpt-more'>[... read more]</a>]]></description>
				<content:encoded><![CDATA[<br/><p><em>Google DataTable .NET Wrapper</em> library got its third version (v3.0.0). In this post I will highlight the changes.</p>
<p>For basic information about the library check a previous post of <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3VzaW5nLXRoZS1nb29nbGUtZGF0YXRhYmxlLW5ldC13cmFwcGVyLw==" title=\"Using the Google DataTable .Net Wrapper\">how to use the Google DataTable .Net Wrapper Library</a> </p>
<p>To download or consult the source code please visit the <a title=\"googledatatablelib\" href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2dvb2dsZWRhdGF0YWJsZWxpYi5jb2RlcGxleC5jb20=" target=\"_blank\">project&#8217;s CodePlex page</a>&nbsp;or install directly from Visual Studio by using Nuget</p>
<div class="nuget-badge"><code>PM&gt; Install-Package Google.DataTable.Net.Wrapper</code></div>
<h2>Custom object properties</h2>
<p>Version 3.0.0 mainly brings a unified way of managing custom properties that could be attached to the <code>Column</code>, <code>Row</code> or <code>Cell</code> objects. Of course, depending of the chart type you are using, those will be supported or not.</p>
<p>The (breaking) change here is that instead of having a simple <code>String</code> property (previously known as Properties), now a List type have been introduced for all the above three types of objects.</p>
<p>Let&#8217;s see what would be a very common usage:</p>
<pre>
DataTable dt = new DataTable();

var row = dt.NewRow();

//Previously you had to manually format the output for the JSON string....
row.Properties = "\"style\": \"border:1\", \"cssStyle\": \"mystyle\"";

//Now you can use a much more user friendly....
row.AddProperty(new Property("style", "border:1"));
row.AddProperty(new Property("cssStyle", "mystyle");
</pre>
<p>As the same kind of logic has been used for <code>Cell</code>, <code>Column</code> and <code>Row</code>, the output is exactly the same in all the cases (the &#8220;p:&#8221; part). This is an example of the  JSON returned for the above Row example&#8230;</p>
<pre>
"rows" : 
[
	{
		"c" : [{"v": new Date(2013, 0, 7), "f": "Year"}, {"v": 0}], 
		<strong>"p" : {"style" : "border:1", "cssStyle" : "myStyle"}</strong>
	}
]
</pre>
<h3>PropertyMap</h3>
<p>In order to achieve this, I&#8217;ve introduced a very simple class called Property that would hold the values for a single entry.</p>
<pre>
public class Property
{
    public Property(string name, string value)
    {
        Name = name;
        Value = value;
    }

    public string Name { get; set; }

    public string Value { get; set; }
}

//and the signature for the objects is now...
public class Cell //Column and Row
{
//....
    public IEnumerable&lt;Property&gt; PropertyMap
    {
        get { return _propertyMap; }
    }

    public Property AddProperty(Property p)
    {
        _propertyMap.Add(p);
        return p;
    }

    public void RemoveProperty(Property p)
    {
        _propertyMap.Remove(p);
    }
//.... omitted for brevity
}
</pre>
<h2>SystemDataTableConverter</h2>
<p>This version introduced a new functionality implemented as a new type called <code>SystemDataTableConverter</code> which enables the conversion from the widely known Ado.NET System.Data.DataTable into our DataTable. This obviously gives a possibility to return a JSON string and it is very handy as a large amount of projects stilly use the <code>System.Data.DataTable</code> as the mean of transferring data.</p>
<h3>How to use the converter</h3>
<p>The following code is an example of how to use the converter:</p>
<pre>
System.Data.DataTable sysDt = new System.Data.DataTable();
sysDt.Columns.Add("firstcolumn", typeof(string));
sysDt.Columns.Add("secondcolumn", typeof(int));
sysDt.Columns.Add("thirdcolumn", typeof(decimal));

var row1 = sysDt.NewRow();
row1[0] = "Ciao";
row1[1] = 10;
row1[2] = 2.2;
sysDt.Rows.Add(row1);

var dataTable = SystemDataTableConverter.Convert(sysDt);
string jsonString = dataTable.GetJson();
</pre>
<p>this would be the output for the above code:</p>
<pre>
{
"cols": 
    [
	{"type": "string" ,"id": "firstcolumn" ,"label": "firstcolumn" }, 
	{"type": "number" ,"id": "secondcolumn","label": "secondcolumn"},
	{"type": "number" ,"id": "thirdcolumn" ,"label": "thirdcolumn" }
    ], 
"rows" : 
    [
	{
            "c" : [ {"v": "Ciao"}, {"v": 10}, {"v": 2.2} ]
        }
    ]
}
</pre>
<p>so, without any effort your existing DataTable will get serialized into JSON needed by the Google Javascript library.</p>
<h2>Column Role attribute</h2>
<p>As it is stated in the google datatable documentation at the following link <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cHM6Ly9kZXZlbG9wZXJzLmdvb2dsZS5jb20vY2hhcnQvaW50ZXJhY3RpdmUvZG9jcy9yb2xlcw==" title=\"Google DataTable Roles\" target=\"_blank\">Google DataTable Roles</a>, Column object should support the &#8220;Role&#8221;.</p>
<p>This version implements a new attribute for the Column, called indeed, <code>Role</code>.</p>
<p>Let&#8217;s see an example:</p>
<pre>
var column = new Column(ColumnType.String);

//please not the ColumnRole.Annotation 
column.Role = ColumnRole.Annotation;
</pre>
<p>Role is a string, and I&#8217;ve simply created a helper class <code>ColumnRole</code> that implements as attributes the currently available values that DataTable Column supports.<br />
this is absolutely a valid code instead:</p>
<pre>
var column = new Column(ColumnType.String);
column.Role = "annotation";
</pre>
<h2>Serialization of the Date() values</h2>
<p>The way of how the DateTime and Date type columns are serialized is changed slightly. In the earlier version indeed columns of Date and Datetime were not properly serialized, so this is  a bug fix.</p>
<p>While this would work when you are directly passing the literal string to the Javascript dataTable</p>
<pre>
 {c:[{v: 'c'}, {v: 3.0, f: 'Three'}, {v: new Date(2010, 3, 30, 0, 31, 26)}]}
</pre>
<p>it won&#8217;t work if you return a JSON in such a format, as JSON doesn&#8217;t support such a notation, so you should use instead</p>
<pre>
 {c:[{v: 'c'}, {v: 3.0, f: 'Three'}, {v: "Date(2010, 3, 30, 0, 31, 26)"}]}
</pre>
<p>the difference is the <code>new</code> keyword and the <strong>quotes</strong> around the value. </p>
<h2>Final Thoughts</h2>
<p>Please test out the new version and let me know if there are issues or if there are things that you would like to see in the new version by <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL2NvbnRhY3Qv" title=\"Contact\" target=\"_blank\">contacting me</a> or leaving a comment either here or on the CodePlex web site.</p>
 <img src="http://www.agile-code.com/blog/?feed-stats-post-id=2016" width="1" height="1" style="display: none;" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/agile-code?a=USxix171iXA:G7h4eKJf6TM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=USxix171iXA:G7h4eKJf6TM:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=USxix171iXA:G7h4eKJf6TM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/agile-code?i=USxix171iXA:G7h4eKJf6TM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=USxix171iXA:G7h4eKJf6TM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/agile-code?i=USxix171iXA:G7h4eKJf6TM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=USxix171iXA:G7h4eKJf6TM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/agile-code?i=USxix171iXA:G7h4eKJf6TM:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=USxix171iXA:G7h4eKJf6TM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/agile-code?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=USxix171iXA:G7h4eKJf6TM:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/agile-code?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/agile-code/~4/USxix171iXA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.agile-code.com/blog/whats-new-in-google-datatable-net-wrapper-v3-0-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.agile-code.com/blog/whats-new-in-google-datatable-net-wrapper-v3-0-0/</feedburner:origLink></item>
		<item>
		<title>Improving the Google DataTable .Net Wrapper</title>
		<link>http://feedproxy.google.com/~r/agile-code/~3/x2g_BfmPry0/</link>
		<comments>http://www.agile-code.com/blog/improving-the-google-datatable-net-wrapper/#comments</comments>
		<pubDate>Wed, 26 Dec 2012 23:03:53 +0000</pubDate>
		<dc:creator>Zoran Maksimovic</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[ASP.NET Web API]]></category>
		<category><![CDATA[Google DataTable .Net Wrapper]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://www.agile-code.com/blog/?p=1952</guid>
		<description><![CDATA[<br/>In the previous post I&#8217;ve described how to use the library and what are the main characteristics. For sure there is more to come and follow up, so stay tuned. In this post, I would like to describe the big performance&#160;improvements made in the meantime, as I was not fully happy with the serialization performance <a href='http://www.agile-code.com/blog/improving-the-google-datatable-net-wrapper/' class='excerpt-more'>[... read more]</a>]]></description>
				<content:encoded><![CDATA[<br/><p>In the <a title=\"Using the Google DataTable .Net Wrapper\" href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3VzaW5nLXRoZS1nb29nbGUtZGF0YXRhYmxlLW5ldC13cmFwcGVyLw==">previous post</a> I&#8217;ve described how to use the library and what are the main characteristics. For sure there is more to come and follow up, so stay tuned.</p>
<p>In this post, I would like to describe the <strong>big performance&nbsp;improvements</strong> made in the meantime, as I was not fully happy with the serialization performance in the first version.</p>
<p>As I have just submitted a new version of the source code as part of the&nbsp;change-set&nbsp;<a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2dvb2dsZWRhdGF0YWJsZWxpYi5jb2RlcGxleC5jb20vU291cmNlQ29udHJvbC9jaGFuZ2VzZXQvMTgyMTk=">18219</a> I would like to show you here some&nbsp;statistics&nbsp;regarding both object creation and serialization of those objects in JSON format expressed with concrete numbers.</p>
<h2>Let&#8217;s start with some statistics</h2>
<p>The following three charts show the <strong>creation and serialization of 1 million</strong> rows with the previous (v1) and current (v2) version of the <em>Google DataTable .Net Wrapper</em> library. I have run the same benchmark code <strong>5 times</strong> in order to obtain more or less some sort of a significant average time. So, in all charts you see the time expressed in milliseconds for each of the runs.</p>
<h3>Object Creation</h3>
<p>Values in the below chart (smaller values are better) show that the new version improves quite a lot the <strong>object creation speed</strong>. The average time spent for creating objects for 5 runs in Version 1 was <strong>3123</strong> milliseconds while in the Version 2 it has been reduced to <strong>2209</strong> milliseconds, which is about 44% of speed improvement.</p>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEyLzEyL0dvb2dsZV9EYXRhVGFibGVfT2JqZWN0X0NyZWF0aW9uX1RpbWUucG5n"><img class="aligncenter size-full wp-image-1954" alt="Google_DataTable_Object_Creation_Time" src="http://i2.wp.com/www.agile-code.com/blog/wp-content/uploads/2012/12/Google_DataTable_Object_Creation_Time.png?resize=598%2C359" data-recalc-dims="1" /></a></p>
<p>The code used for this benchmark:</p>
<pre>
DataTable dt = new DataTable();
var columnYear = new Column(ColumnType.Number, "Year");
var columnCount = new Column(ColumnType.String, "Count");

dt.AddColumn(columnYear);
dt.AddColumn(columnCount);

int ONE_MIO_ROWS = 1000000;

for (int i = 0; i &lt; ONE_MIO_ROWS ; i++)
{
    var row = dt.NewRow();
    row.AddCellRange(new Cell[]
        {
        new Cell() {Value = 2012, Formatted = "2012"},
        new Cell() {Value = 1, Formatted = "1"}
    });
        
    dt.AddRow(row);
}
</pre>
<p><br/></p>
<h3>Object Serialization</h3>
<p>In the first version of the library most of the time spent was to shape and obtain the correct object model. This is not yet perfect as by following the Google specification, the Property Map should be expressed as a NameValue pair, while in the library this is expressed as a simple string. This is definitively one additional thing to be changed in the future, but let&#8217;s speak about the present:)</p>
<p>I&#8217;m really proud to say that the <strong>average</strong> speed improvement is about <strong>183%</strong>. Serializing to JSON 1 million rows now takes in average 2291 milliseconds in comparison to the previous 6467 milliseconds.</p>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEyLzEyL0dvb2dsZV9EYXRhVGFibGVfT2JqZWN0X1NlcmlhbGl6YXRpb25fVGltZS5wbmc="><img class="aligncenter size-full wp-image-1955" alt="Google_DataTable_Object_Serialization_Time" src="http://i0.wp.com/www.agile-code.com/blog/wp-content/uploads/2012/12/Google_DataTable_Object_Serialization_Time.png?resize=591%2C352" data-recalc-dims="1" /></a></p>
<h3>Overall improvement</h3>
<p>If we sum up all together both the serialization and the object creating we will get the overall improvement of 114%. From the average of 9590 milliseconds in the first version we have doubled the speed to 4500 milliseconds, as you may see here below.</p>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEyLzEyL0dvb2dsZV9EYXRhVGFibGVfT3ZlcmFsbF9JbXByb3ZlbWVudC5wbmc="><img class="aligncenter size-full wp-image-1956" alt="Google_DataTable_Overall_Improvement" src="http://i2.wp.com/www.agile-code.com/blog/wp-content/uploads/2012/12/Google_DataTable_Overall_Improvement.png?resize=589%2C351" data-recalc-dims="1" /></a></p>
<h2>What has been changed?</h2>
<p>Now the most interesting part. What has been changed in order to get (for me) so impressive speed improvement?</p>
<p>Here is a list of code changes:</p>
<h4>StringBuilder vs StreamWriter (MemoryStream)</h4>
<p>In the first version, in order to concatenate strings, that then would become the serialized Json, I used <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL21zZG4ubWljcm9zb2Z0LmNvbS9lbi11cy9saWJyYXJ5L3N5c3RlbS50ZXh0LnN0cmluZ2J1aWxkZXIuYXNweA==" title=\"StringBuilder\" target=\"_blank\">StringBuilder</a> with few Extensions in order to &#8220;append&#8221; data in some specific cases, like if the property was null etc&#8230;<br />
I&#8217;ve seen that the performance could have been improved if MemoryStream and StreamWriter combination vs StingBuilder were used. I&#8217;ve conducted some extra tests, and I have to say that theoretically the performance improvements would have been minimal, but as the goal was to squeeze as much milliseconds as possible i have anyway chosen to go with this approach.</p>
<p>So the code now looks something like this:</p>
<pre>
public string GetJson()
{
    string rowsJson;
    using (var ms = new MemoryStream())
    {
        var sw = new StreamWriter(ms);

        //... concatenating strings here.. omitted for brevity
        sw.Flush();
        ms.Position = 0;
        
        using (var sr = new StreamReader(ms))
        {
            rowsJson = sr.ReadToEnd();
            sr.Close();
        };
    }

    return "{" + rowsJson + "}";
}
</pre>
<p>In addition to this, I tried not to call the <code>StreamWriter.Write()</code> as less as possible, so any time I had a predefined string I would put it into one Write() call.</p>
<p>example:</p>
<pre>
StringWriter sw = new StringWriter(stream);

//don't do this
sw.Write("rows");
sw.Write("[");
sw.Write("...");

//do this
sw.Write("rows [ ...");
</pre>
<p><br/></p>
<h4>Using <code>for(...)</code> rather than <code>foreach</code></h4>
<p><code>foreach</code> is a great syntactic sugar, and I have to admit that I always tend to use it in almost every application I write. It&#8217;s very easy to write and to understand and it makes the code prettier.<br />
In general, &#8220;T<a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5kb3RuZXRwZXJscy5jb20vZm9yLWZvcmVhY2g=" title=\"for vs foreach\" target=\"_blank\">he for-loop is faster than the foreach-loop if the array must only be accessed once per iteration.</a>&#8220;.<br />
I usually access the variable only once per iteration, so for loop was working better for me.</p>
<h4>Inline Code</h4>
<p>In general, I tend to follow the good object oriented design where every object has it&#8217;s own role and behavior. But, I&#8217;ve noticed that instead of accessing the code by calling a function of the object itself, for instance <code>Row.GetJson()</code>, when calling everything inline in one function, the speed <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5kb3RuZXRwZXJscy5jb20vaW5saW5lLW9wdGltaXphdGlvbg==" title=\"inline vs functions call in c#\" target=\"_blank\">would improve</a>. I didn&#8217;t have too much time to analyze how much indeed the difference was, but one thing is for sure, now the code is much more difficult to read <img src='http://i0.wp.com/www.agile-code.com/blog/wp-includes/images/smilies/icon_smile.gif?w=695' alt=':)' class='wp-smiley' data-recalc-dims="1" /> </p>
<h4>General small changes</h4>
<p>Here and there I&#8217;ve seen several bottlenecks, and code that could be improved, so that instead of always calculating certain values (that are known) to reuse the cached ones etc&#8230;</p>
<h2>Final thoughts</h2>
<p>It was really a joy working on the performance improvements. The amount of things that one can discover during the process is incredible. A lot of things that one would consider &#8220;fast&#8221; suddenly becomes slow once a deeper analysis has been made.<br />
One very important thing that I always follow is that the performance improvement is always left <strong>as a last thing to do</strong> because you really never know how long would it take, and usually this means that the original design is going to be a bit reconsidered. I personally consider a good design and maintainability of the code one of the most important things, the &#8220;really fast software&#8221; sometimes makes sense to spend time into, but sometimes don&#8217;t.<br />
Happy coding.</p>
 <img src="http://www.agile-code.com/blog/?feed-stats-post-id=1952" width="1" height="1" style="display: none;" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/agile-code?a=x2g_BfmPry0:L5wnsEY1aKw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=x2g_BfmPry0:L5wnsEY1aKw:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=x2g_BfmPry0:L5wnsEY1aKw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/agile-code?i=x2g_BfmPry0:L5wnsEY1aKw:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=x2g_BfmPry0:L5wnsEY1aKw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/agile-code?i=x2g_BfmPry0:L5wnsEY1aKw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=x2g_BfmPry0:L5wnsEY1aKw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/agile-code?i=x2g_BfmPry0:L5wnsEY1aKw:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=x2g_BfmPry0:L5wnsEY1aKw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/agile-code?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=x2g_BfmPry0:L5wnsEY1aKw:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/agile-code?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/agile-code/~4/x2g_BfmPry0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.agile-code.com/blog/improving-the-google-datatable-net-wrapper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.agile-code.com/blog/improving-the-google-datatable-net-wrapper/</feedburner:origLink></item>
		<item>
		<title>Using the Google DataTable .Net Wrapper</title>
		<link>http://feedproxy.google.com/~r/agile-code/~3/DuImmPTVp-M/</link>
		<comments>http://www.agile-code.com/blog/using-the-google-datatable-net-wrapper/#comments</comments>
		<pubDate>Sun, 23 Dec 2012 21:44:36 +0000</pubDate>
		<dc:creator>Zoran Maksimovic</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[ASP.NET Web API]]></category>
		<category><![CDATA[Google DataTable .Net Wrapper]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://www.agile-code.com/blog/?p=1940</guid>
		<description><![CDATA[<br/>As I have just published the Google DataTable .Net Wrapper project on CodePlex, the following post intends to be a quick introduction on the rationale on why this project has been created and its implementation. Quick Project Background While working on the implementation of the www.linktotweet.com web site, which is one of my side projects, <a href='http://www.agile-code.com/blog/using-the-google-datatable-net-wrapper/' class='excerpt-more'>[... read more]</a>]]></description>
				<content:encoded><![CDATA[<br/><p>As I have just published the <a title=\"Google DataTable .NET Wrapper\" href="googledatatablelib.codeplex.com" target=\"_blank\">Google DataTable .Net Wrapper</a> project on CodePlex, the following post intends to be a quick introduction on the rationale on why this project has been created and its implementation.</p>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEyLzEyL0NvZGVwbGV4LnBuZw=="><img class="aligncenter size-full wp-image-1945" alt="Codeplex" src="http://i0.wp.com/www.agile-code.com/blog/wp-content/uploads/2012/12/Codeplex.png?resize=509%2C184" data-recalc-dims="1" /></a></p>
<h2>Quick Project Background</h2>
<p>While working on the implementation of the <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5saW5rdG90d2VldC5jb20=">www.linktotweet.com</a> web site, which is one of my side projects, I had to choose a way of displaying charts in order to show the statistics. I mainly had two options, either to return an <em>image</em>, that would be fully generated server side, or to use a bit of a different way and use one of the existing&nbsp;<em>JavaScript&nbsp;libraries</em> and generate those charts directly in the client&#8217;s browser.</p>
<p>As I wanted to free up the server resources from generating images at runtime, and to be honest, haven&#8217;t had experience with javascript charting libraries,&nbsp;I&#8217;ve&nbsp;chosen&nbsp;to go with the&nbsp;JavaScript&nbsp;approach. Among a large number of JavaScript libraries I&#8217;ve&nbsp;chosen&nbsp;the &#8220;Google Chart Tools&#8221;. Google Chart Tools is one of the most extensive libraries of charts on the web. It supports both HTML5 or SVG rendered charts. One of the good points of the Google Chart Tools is that is as well compatible with the iOS and Android. In any case, all the information about the Google Charts can be directly consulted <a title=\"Google Charts\" href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cHM6Ly9kZXZlbG9wZXJzLmdvb2dsZS5jb20vY2hhcnQv" target=\"_blank\">on the official project page</a>.</p>
<h2>Why the Google DataTable .NET Wrapper?</h2>
<p>As in my case of a web site project, there are mainly two ways that <em>Google Chart Tools library</em> uses to handle the data that would be later displayed:</p>
<ol>
<li>Data, directly generated, <strong>client side</strong>, on the page, which means directly in the JavaScript.</li>
<li>Data prepared and then retrieved, i.e: by using a Ajax call, from the <strong>server</strong></li>
</ol>
<p>Let&#8217;s see both examples of how this can be done by looking at the client, JavaScript side:</p>
<h4>Generating a chart with data generated directly on the client</h4>
<p>In this example, the data has been generated directly in the JavaScript (the <code>data.addRows(...)</code> part. This is pretty much easy, but somehow cumbersome if you need to generate and return some complex dynamic data.</p>
<pre>
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});

// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);

// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {

// Create the DataTable directly in the javascript.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Topping');
data.addColumn('number', 'Slices');
data.addRows([
		['Mushrooms', 3],
		['Onions', 1],
		['Olives', 1],
		['Zucchini', 1],
		['Pepperoni', 2]
	]);

// Set chart options
var options = {'title':'How Much Pizza I Ate Last Night',
			   'width':400,
			   'height':300};

// Instantiate and draw our chart, passing in some options.
var chart = 
new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</pre>
<h4>Using Ajax in order to get the server side generated data</h4>
<p>In this, second, JavaScript example, the data has been generated on the server and Ajax has been used to retrieve data from a RESTful service. In order to achieve this, a reference to jQuery needs to be added to the page.</p>
<pre>
// Load the Visualization API and the piechart package.
google.load('visualization', '1', {'packages':['corechart']});
      
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);

function drawChart() {
	var jsonData = $.ajax({
		url: "/Statistics/GetStatisticsForChart?messageCode=SomeCodeHere",
		dataType: "json",
		async: false
	}).responseText;

	// Create our data table out of JSON data loaded from server.
	var data = new google.visualization.DataTable(jsonData);

	// Instantiate and draw our chart, passing in some options.
	var chart = 
new google.visualization.ColumnChart(document.getElementById('chart_div'));
	chart.draw(data, { width: 400, height: 240 });
}
</pre>
<p>for more info on this particular usage, please check the <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cHM6Ly9kZXZlbG9wZXJzLmdvb2dsZS5jb20vY2hhcnQvaW50ZXJhY3RpdmUvZG9jcy9waHBfZXhhbXBsZQ==" target=\"_blank\">google site</a>.</p>
<h2>Server Side generated content</h2>
<p>When retrieving data from the server, the data transfer format has to be expressed in JSON and in order to generate a Google Charts compatible <code>DataTable</code> format, a specific &#8220;schema&#8221; has to be used. Below is an example of a <code>DataTable</code> that <em>Google Chart Tools</em> understand, and expressed in JSON.</p>
<pre>
{
  "cols": 
	[
	  {"id":"", "label":"Topping", "pattern":"", "type":"string"},
	  {"id":"", "label":"Slices",  "pattern":"", "type":"number"}
	],
  "rows": 
	[
	  {"c":[{"v":"Mushrooms", "f":null}, {"v":3,"f":null}]},
	  {"c":[{"v":"Onions",    "f":null}, {"v":1,"f":null}]},
	  {"c":[{"v":"Olives",    "f":null}, {"v":1,"f":null}]},
	  {"c":[{"v":"Zucchini",  "f":null}, {"v":1,"f":null}]},
	  {"c":[{"v":"Pepperoni", "f":null}, {"v":2,"f":null}]}
	]
}
</pre>
<h2>Google DataTable .Net Wrapper to the rescue</h2>
<p>Are you willing to manually generate the above JSON code for every single case? I wasn&#8217;t and therefore I created, what I called, Google DataTable .NET Wrapper, that could simplify drastically the Json generation by following a full POCO lightweight object model.</p>
<h3>Let&#8217;s see it in action</h3>
<pre>
using Google.DataTable.Net.Wrapper;

private DataTable GetDataTableJson()
{
    DataTable dt = new DataTable();

    //Act -----------------
    dt.AddColumn(new Column(ColumnType.Number, "Year"));
    dt.AddColumn(new Column(ColumnType.String, "Count"));

    var row1 = dt.NewRow();
    var row2 = dt.NewRow();

    row1.AddCellRange(new[] {new Cell(2012, "2012"), new Cell(150, "150")});
    row2.AddCellRange(new[] {new Cell(2013, "2013"), new Cell(100, "100")});

    dt.AddRow(row1);
    dt.AddRow(row2);

    return dt.GetJson();
}
</pre>
<p>would result in the following generated JSON</p>
<pre>
{
  "cols": 
	[
	  {"type": "number", "id": "Year"}, 
	  {"type": "string", "id": "Count"}
	], 
  "rows": 
	[
	  {"c": [{"v": "2012", "f": "2012"}, {"v": "150", "f": "150"}]}, 
	  {"c": [{"v": "2013", "f": "2013"}, {"v": "100", "f": "100"}]}
	]
}
</pre>
<h2>Wrapping it all together</h2>
<p>As you may see in the above example, the <em>Google DataTable .Net Wrapper</em> is a simple library that contains several classes:</p>
<ol>
<li>DataTable</li>
<li>Column</li>
<li>Row</li>
<li>Cell</li>
</ol>
<p>and that gives a great way of expressing the data in a strongly typed way, by offering the possibility to export the Json data in exactly the format that the Google Chart Library needs. This will make you avoid writing any specific code in order to transform your object data into JSON format.<br />
Objects are lightweight and made very simple, so this should affect in any way the performance of your application.</p>
<h2>What comes next?</h2>
<p>There are still some unfinished things, as the &#8220;full&#8221; Google DataTable support. As the Google library supports a lot of different scenarios, especially when it comes to what Google calls &#8220;Property Map&#8221;, where additional data could be added to the <code>Cell</code> or the <code>DataTable</code> itself. For the time being this has been implemented as a single string, when in reality should be more a List of <code>NameValue</code> pair objects.</p>
<h2>Project page</h2>
<ol>
<li>Download the latest version of the <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2dvb2dsZWRhdGF0YWJsZWxpYi5jb2RlcGxleC5jb20vU291cmNlQ29udHJvbC9Ccm93c2VMYXRlc3Q=">source code</a></li>
<li>Download the <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2dvb2dsZWRhdGF0YWJsZWxpYi5jb2RlcGxleC5jb20vcmVsZWFzZXMvdmlldy85OTQ0NA==">library</a></li>
</ol>
<p>Get the library directly from NuGet:</p>
<div class="nuget-badge" >
<p>
         <code>PM> Install-Package Google.DataTable.Net.Wrapper</code>
   </p>
</div>
<p>or get more information by following the NuGet library page: <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cHM6Ly9udWdldC5vcmcvcGFja2FnZXMvR29vZ2xlLkRhdGFUYWJsZS5OZXQuV3JhcHBlcg==">https://nuget.org/packages/Google.DataTable.Net.Wrapper</a></p>
<h2>References:</h2>
<ul>
<li><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL215Lm9wZXJhLmNvbS90YWdhd2EvYmxvZy9saXN0LW9mLWphdmFzY3JpcHQtY2hhcnRpbmctbGlicmFyaWVz">http://my.opera.com/tagawa/blog/list-of-javascript-charting-libraries</a></li>
<li><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2phdmFzY3JpcHRlZC5tZS90b3AtNS1mcmVlLWphdmFzY3JpcHQtY2hhcnQtbGlicmFyaWVzLmh0bWw=">http://javascripted.me/top-5-free-javascript-chart-libraries.html</a></li>
<li><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cHM6Ly9kZXZlbG9wZXJzLmdvb2dsZS5jb20vY2hhcnQvaW50ZXJhY3RpdmUvZG9jcy9yZWZlcmVuY2UjRGF0YVRhYmxl" title=\"Google Charts DataTable Reference\" target=\"_blank\">Google Charts DataTable Reference</a></li>
</ul>
 <img src="http://www.agile-code.com/blog/?feed-stats-post-id=1940" width="1" height="1" style="display: none;" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/agile-code?a=DuImmPTVp-M:mxvyAbLcTuM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=DuImmPTVp-M:mxvyAbLcTuM:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=DuImmPTVp-M:mxvyAbLcTuM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/agile-code?i=DuImmPTVp-M:mxvyAbLcTuM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=DuImmPTVp-M:mxvyAbLcTuM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/agile-code?i=DuImmPTVp-M:mxvyAbLcTuM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=DuImmPTVp-M:mxvyAbLcTuM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/agile-code?i=DuImmPTVp-M:mxvyAbLcTuM:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=DuImmPTVp-M:mxvyAbLcTuM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/agile-code?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=DuImmPTVp-M:mxvyAbLcTuM:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/agile-code?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/agile-code/~4/DuImmPTVp-M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.agile-code.com/blog/using-the-google-datatable-net-wrapper/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.agile-code.com/blog/using-the-google-datatable-net-wrapper/</feedburner:origLink></item>
		<item>
		<title>MSBuild inline task explained</title>
		<link>http://feedproxy.google.com/~r/agile-code/~3/zr1XIXXqmvo/</link>
		<comments>http://www.agile-code.com/blog/msbuild-inline-task-explained/#comments</comments>
		<pubDate>Fri, 07 Dec 2012 23:38:14 +0000</pubDate>
		<dc:creator>Zoran Maksimovic</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[msbuild]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.agile-code.com/blog/?p=1895</guid>
		<description><![CDATA[<br/>In the last few days I was intensively working with MsBuild, as I had to automate the building and deployment of 3 projects to a large amount of environments. In order to achieve this, an obvious choice was to use the MsBuild, which in my opinion is a great framework that perfectly fits with the <a href='http://www.agile-code.com/blog/msbuild-inline-task-explained/' class='excerpt-more'>[... read more]</a>]]></description>
				<content:encoded><![CDATA[<br/><p>In the last few days I was intensively working with MsBuild, as I had to automate the building and deployment of 3 projects to a  large amount of environments. In order to achieve this, an obvious choice was to use the MsBuild, which in my opinion is a great framework that perfectly fits with the .NET world. Obviously there is a learning curve, but once mastered it&#8217;s really a joy to use.</p>
<p>MsBuild is primarily made of <code>Targets</code> and <code>Tasks</code>. Especially Tasks have a function to enable and enrich the MsBuild platform, and the great deal is that everyone can write a Task and extend the pre-existing functionalities.</p>
<div class="highlight">
If you are reading this page, my assumption is that you probably know what a MsBuild Task is all about. In case of doubt: a Task is simply a function/functionality exposed to MsBuild that accepts a number of parameters, and it could have or not a number of output parameters. As easy as it sounds.<br />
Some of the typical, already built in the platform, tasks are <code>Copy</code>, <code>Move</code>, <code>Delete</code> files, just to name some of the probably most useful and very simple ones.
</div>
<h2>Popular extensions</h2>
<p>MsBuild is very easy to extend, and there are two very important sources with tons of already written and ready to use Tasks. In case you are interested, feel free to download from the below links, as both are free to use and maintained by the community. There you will find Tasks such as Zip, SVN integration, SQL Server integration, and so on&#8230; </p>
<ol>
<li>Microsoft&#8217;s <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL21zYnVpbGRleHRlbnNpb25wYWNrLmNvZGVwbGV4LmNvbS8=" title=\"MsBuild.ExtensionPack\" target=\"_blank\">MSBuild ExtensionPack </a></li>
<li>MSBuild <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cHM6Ly9naXRodWIuY29tL2xvcmVzb2Z0L21zYnVpbGR0YXNrcw==" title=\"MS Build Community Tasks\" target=\"_blank\">Community Tasks</a></li>
</ol>
<p>Using and integrating the above libraries goes beyond this post. </p>
<h2>Creating own tasks</h2>
<p>There are mainly two ways of creating tasks by:</p>
<ol>
<li>Implementing and compiling an ITask interface: That&#8217;s it creating a class that would implement ITask interface. In order to integrate this into the MSBuild script file, one would need to specify a path to the compiled assembly that needs to be deployed together with the script.</li>
<li>Implementing an <strong>inline task</strong>.</li>
</ol>
<p>While there are many posts in internet related to the MSBuild task creating by implementing the ITask interface, in this post I would love to concentrate on Inline tasks.<br />
In the .NET Framework version 4, you can create tasks directly in the project file. You do not have to create a separate assembly to host the task. This makes it easier to keep track of source code and easier to deploy the task. The source code is integrated into the script itself.</p>
<p>I&#8217;ve created a very simple Tasks that is responsible for deleting files, given a list of files to be deleted.<br />
So, let&#8217;s start with explaining a skeleton of an inline task:</p>
<table>
<tr>
<td><code>UsingTask</code></td>
<td>UsingTask is a declaring element that needs to be used in order to create a Task. Attributes of the element would specify the Task Name, the so called TaskFactory, which will specify what would be the engine to be used in order to interpret the underlying code, and the Assembly that provides such a functionality. In our case the <code>CodeTaskFactory </code>and the <code>$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll</code> are default values.</td>
</tr>
<tr>
<td><code>ParameterGroup</code></td>
<td>ParameterGroupsection provides a possibility to declare the input and output parameters. Important thing is to specify a full signature of the DataType to be used , such as <code>System.String[]</code>, etc..<br />
In my case, I am creating a task that accepts</p>
<ul>
<li><code>FilesToDelete</code>, which is an array of strings with full paths of the files to be deleted</li>
<li>Two more input parameters, <code>IgnoreErrors</code> and <code>ShowErrors</code>: that would be used to control the workflow of the task.</li>
<li> and an <strong>output</strong> parameter <code>DeletedFiles</code> that will contain a list of files that have been successfully deleted. </li>
</ul>
</td>
</tr>
<tr>
<td><code>Task</code></td>
<td>And, finally the Task element that defines the task logic itself. There are several subelements that could be specified, but in my opinion the most useful and typical ones are the ones specified in the below example. The possibility to specify the &#8220;Import&#8221; of namespaces  by using the <code>Using</code> element and the actual <code>Code</code> itself. In my case the Task below is written in CSharp, and so it&#8217;s specified in the <code>Language</code> attribute.</td>
</tr>
</table>
<p><br/><br />
I think that is kind of useless to go through the implementation of the task as it is really trivial. Looping through the list of files received as the <code>FilesToDelete</code> parameter, and filling a list of deleted items.</p>
<p>Here is what an Inline Task looks like:</p>
<pre>
&lt;UsingTask TaskName=&quot;DeleteFiles&quot; 
           TaskFactory=&quot;CodeTaskFactory&quot;
           AssemblyFile=&quot;$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll&quot;&gt;

&lt;ParameterGroup&gt;
  &lt;FilesToDelete    ParameterType=&quot;System.String[]&quot; 
                    Required=&quot;true&quot; 
                    Output=&quot;false&quot;/&gt;
  &lt;IgnoreErrors     ParameterType=&quot;System.Boolean&quot;  
                    Required=&quot;true&quot; 
                    Output=&quot;false&quot;/&gt;
  &lt;ShowErrors       ParameterType=&quot;System.Boolean&quot; 
                    Required=&quot;true&quot; 
                    Output=&quot;false&quot;/&gt;
  &lt;DeletedFiles     ParameterType=&quot;System.String[]&quot; 
                    Output=&quot;true&quot; /&gt;
&lt;/ParameterGroup&gt;

&lt;Task&gt;
  &lt;Using Namespace=&quot;System.Collections.Generic&quot; /&gt;
  &lt;Using Namespace=&quot;System.IO&quot; /&gt;
  
  &lt;Code Type=&quot;Fragment&quot; Language=&quot;cs&quot;&gt;
	&lt;![CDATA[
	List&lt;string&gt; DeletedFilesList = new List&lt;string&gt;();
	
	if(this.FilesToDelete!=null &amp;&amp; this.FilesToDelete.Count()&gt;0)
	{
	  foreach(string file in this.FilesToDelete)
	  {
		try
		{
		  if(File.Exists(file))
		  {
			File.Delete(file);
			DeletedFilesList.Add(file);
		  }
		}
		catch(Exception exc)
		{
		  if(this.ShowErrors == true)
		  {
			Console.WriteLine(&quot;Deleting file &quot; + file 
                            + &quot; failed because of &quot; + exc.ToString());
		  }

		  if(this.IgnoreErrors == false)    
		  {
			break;
		  }
		}
	  }
	}
	this.DeletedFiles =  DeletedFilesList.ToArray();
	]]&gt;
  &lt;/Code&gt;  
&lt;/Task&gt;
&lt;/UsingTask&gt;
</pre>
<h2>Integration</h2>
<p>Using the above created inline task is pretty much straightforward. As shown here below, we simply need to create a tag with the task name, send parameters, and get back the output, if any.</p>
<pre>
&lt;Project xmlns=&quot;http://schemas.microsoft.com/developer/msbuild/2003&quot; 
         ToolsVersion=&quot;4.0&quot;&gt;

  &lt;UsingTask&gt; ... here goes the above implementation ... &lt;/UsingTask&gt;

  &lt;!-- Creating the target, as we would do usually --&gt;
  &lt;Target Name=&quot;DemoDeleteFiles&quot; &gt;
    &lt;Message Text=&quot;Starting execution of the DemoDeleteFiles...&quot;/&gt;
    &lt;ItemGroup&gt;
      &lt;FileToDelete Include=&quot;E:\svn\trunk\xxx.txt&quot;/&gt;
      &lt;FileToDelete Include=&quot;E:\svn\trunk\xxx1.txt&quot;/&gt;

    &lt;/ItemGroup&gt;

    &lt;!-- Simply create an element with the same name 
         of the inline task created in the previous example --&gt;
    &lt;DeleteFiles FilesToDelete=&quot;@(FileToDelete)&quot;
                 ShowErrors=&quot;true&quot;
                 IgnoreErrors=&quot;false&quot;&gt;
      
      &lt;!--Define the output...--&gt;
      &lt;Output TaskParameter=&quot;DeletedFiles&quot;
              ItemName=&quot;FilesSuccessfulyDeleted&quot;/&gt;
      
    &lt;/DeleteFiles&gt;

    &lt;!--Showing the output on the screen--&gt;
    &lt;Message Text=&quot;Files deleted: @(FilesSuccessfulyDeleted)&quot;/&gt;
  &lt;/Target&gt;
&lt;/Project&gt;
</pre>
<p>Save the full content in a file called <code>myfile.build</code> and execute it from the command line</p>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEyLzEyL01zQnVpbGQtRXhlY3V0ZS1UYXNrLnBuZw=="><img src="http://i1.wp.com/www.agile-code.com/blog/wp-content/uploads/2012/12/MsBuild-Execute-Task.png?resize=695%2C454" alt="" title="MsBuild Execute Task" class="aligncenter size-full wp-image-1931" data-recalc-dims="1" /></a></p>
<h2>Behind the scenes</h2>
<p>When executing the task, the MSBuild Code Factory will implement a task as follows and compile it before usage. Te below example is exactly the script generated for the above defined inline task.<br />
Things to note:</p>
<ol>
<li>Input and output parameters are exposed as public properties</li>
<li>Execute method contains the logic written in the inline task</li>
</ol>
<p>The full source code: </p>
<pre>
//-------------------------------------------------------------------------
// &lt;auto-generated&gt;
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.18010
//
//     Changes to this file may cause incorrect behavior and will be lost 
//     if the code is regenerated.
// &lt;/auto-generated&gt;
//-------------------------------------------------------------------------

namespace InlineCode
{
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Text;
    using System.Linq;
    using System.IO;
    using Microsoft.Build.Framework;
    using Microsoft.Build.Utilities;


    public class DeleteFiles : Microsoft.Build.Utilities.Task
    {

        private bool _Success = true;

        public virtual bool Success
        {
            get
            {
                return _Success;
            }
            set
            {
                _Success = value;
            }
        }

        private string[] _FilesToDelete;

        public virtual string[] FilesToDelete
        {
            get
            {
                return _FilesToDelete;
            }
            set
            {
                _FilesToDelete = value;
            }
        }

        private bool _IgnoreErrors;

        public virtual bool IgnoreErrors
        {
            get
            {
                return _IgnoreErrors;
            }
            set
            {
                _IgnoreErrors = value;
            }
        }

        private bool _ShowErrors;

        public virtual bool ShowErrors
        {
            get
            {
                return _ShowErrors;
            }
            set
            {
                _ShowErrors = value;
            }
        }

        private string[] _DeletedFiles;

        public virtual string[] DeletedFiles
        {
            get
            {
                return _DeletedFiles;
            }
            set
            {
                _DeletedFiles = value;
            }
        }

        public override bool Execute()
        {

            List&lt;string&gt; DeletedFilesList = new List&lt;string&gt;();

            if (this.FilesToDelete != null &amp;&amp; this.FilesToDelete.Count() &gt; 0)
            {
                foreach (string file in this.FilesToDelete)
                {
                    try
                    {
                        if (File.Exists(file))
                        {
                            File.Delete(file);
                            DeletedFilesList.Add(file);
                        }
                    }
                    catch (Exception exc)
                    {
                        if (this.ShowErrors == true)
                        {
                            Console.WriteLine(&quot;Deleting file &quot; + file
                            + &quot; failed because of &quot; + exc.ToString());
                        }

                        if (this.IgnoreErrors == false)
                        {
                            break;
                        }
                    }
                }
            }
            this.DeletedFiles = DeletedFilesList.ToArray();

            return _Success;
        }
    }
}
</pre>
<h2>Final Thoughts</h2>
<p>I&#8217;ve learned about inline tasks while working on the above mentioned project and it turned out to be a great functionality as I didn&#8217;t want to fragment my script. Indeed I find Inline tasks are really great if you want to keep the MSBuild project script file external-reference free.<br />
Per se, inline tasks are not more or less powerful than implementing c# Tasks, but I would say that inline tasks give us a bit less freedom i.e. in case we need to create some methods to be reused, or creating inline classes.</p>
 <img src="http://www.agile-code.com/blog/?feed-stats-post-id=1895" width="1" height="1" style="display: none;" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/agile-code?a=zr1XIXXqmvo:wDZYn6RLymk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=zr1XIXXqmvo:wDZYn6RLymk:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=zr1XIXXqmvo:wDZYn6RLymk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/agile-code?i=zr1XIXXqmvo:wDZYn6RLymk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=zr1XIXXqmvo:wDZYn6RLymk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/agile-code?i=zr1XIXXqmvo:wDZYn6RLymk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=zr1XIXXqmvo:wDZYn6RLymk:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/agile-code?i=zr1XIXXqmvo:wDZYn6RLymk:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=zr1XIXXqmvo:wDZYn6RLymk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/agile-code?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=zr1XIXXqmvo:wDZYn6RLymk:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/agile-code?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/agile-code/~4/zr1XIXXqmvo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.agile-code.com/blog/msbuild-inline-task-explained/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.agile-code.com/blog/msbuild-inline-task-explained/</feedburner:origLink></item>
		<item>
		<title>AJAX with jQuery – using the get() method</title>
		<link>http://feedproxy.google.com/~r/agile-code/~3/pZlyRHVU9nI/</link>
		<comments>http://www.agile-code.com/blog/ajax-with-jquery-using-the-get-method/#comments</comments>
		<pubDate>Wed, 21 Nov 2012 23:40:46 +0000</pubDate>
		<dc:creator>Zoran Maksimovic</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Web Service]]></category>

		<guid isPermaLink="false">http://www.agile-code.com/blog/?p=1880</guid>
		<description><![CDATA[<br/>This is the second post of the series about how to load dynamically external content to a html page by using jQuery AJAX capabilities. If you want to know how to use the load() method please check the previous post. There are mainly 4 ways of how jQuery library enables the AJAX requests, and this <a href='http://www.agile-code.com/blog/ajax-with-jquery-using-the-get-method/' class='excerpt-more'>[... read more]</a>]]></description>
				<content:encoded><![CDATA[<br/><p>This is the second post of the series about how to load dynamically external content to a html page by using jQuery AJAX capabilities. If you want to know how to use the <code>load()</code> method please check the previous <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL2FqYXgtd2l0aC1qcXVlcnktdXNpbmctdGhlLWxvYWQtbWV0aG9kLw==" title=\"AJAX with jQuery – using the load() method\">post</a>.</p>
<p>There are mainly 4 ways of how jQuery library enables the AJAX requests, and this article covers the second one in the list.</p>
<ol>
<li><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL2FqYXgtd2l0aC1qcXVlcnktdXNpbmctdGhlLWxvYWQtbWV0aG9kLw==" title=\"AJAX with jQuery – using the load() method\">using the load() function</a></li>
<li><strong>using the get() function</strong></li>
<li>using the post() function</li>
<li>using the ajax() function</li>
</ol>
<h2>Using the <code>get()</code> function</h2>
<p>The <code>get()</code> method is responsible of loading the data from the server using a HTTP GET request. In reality, this method is an alternative version of the <code>ajax()</code> method that we are going to explore more in one of the next posts. In other words, <code>get()</code> hides the &#8220;complexity&#8221; of the <code>ajax()</code> method.</p>
<p>The signature of the get() method is as follows:</p>
<div class="highlight">
<code>jQuery.get( url [, data] [, success(data, textStatus, jqXHR)] [, dataType] )</code>
</div>
<p>and it is a bit more complex that the previously seen <code>load()</code> method. The important thing to note here is that the url is the only mandatory argument.</p>
<ul>
<li><strong>data</strong>: string that is sent with the request. this could be a query string for instance.</li>
<li><strong>success</strong>: is a callback function if the request will be successful.</li>
<li><strong>dataType</strong>: is the dataType expected to be returned: xml, json, script, or html.</li>
</ul>
<p>a very interesting difference between the previously seen <code>load()</code> method and <code>get()</code>, is that the <code>get()</code> acts as a global function (indeed <code>$.get()</code> shows that), while the <code>load()</code> method on the other hand, is attached to a element.</p>
<h2>Example of get() by using xml format</h2>
<p>The example below shows how to dynamically retrieve xml data from another page, this could be a static page like in my case for this example, of a Web Service returning some xml dynamically. It doesn&#8217;t really make any difference.</p>
<p>In the example below, the javascript will load the data from <strong>xml_data.asp</strong> page, and if successful, execute the callback function. The whole logic is inside the callback itself. In the callback we parse the XML retrieved and displays an alert with the content of the <code>name</code> property.</p>
<pre>
$("#loadContent").click(function () {
    $.get('xml_data.asp', function(data) {
        var xml = $.parseXML(data),
        $xml = $(xml),
        $name = $xml.find("name");
        alert("Value retrieved from xml is: " + $name.text());
    });
});
</pre>
<p>Content of the mentioned <strong>xml_data.asp</strong> file is as follows</p>
<pre>
&lt;?xml version=&quot;1.0&quot; ?&gt;
&lt;customer&gt;
	&lt;name&gt;John&lt;/name&gt;
	&lt;surname&gt;Doe&lt;/surname&gt;
&lt;/customer&gt;
</pre>
<p>Try it live:<br />
<script src="http://code.jquery.com/jquery-latest.js"></script><br />
<input type="button" id="loadContent" value="Retrieve name from get() by using xml" /><br />
<script type="text/javascript">
$("#loadContent").click(function () {
    $.get('../xml_data.asp', function(data) {
        var xml = $.parseXML(data),
        $xml = $(xml),
        $name = $xml.find("name");
        alert("Value retrieved from xml is: " + $name.text());
    });
});
</script></p>
<h2>Example of get() by using json</h2>
<p>The same example by using the before mentioned <code>json</code> format. <code>get()</code> method automatically recognizes the <code>json</code> data and returns a serialized object.<br />
The content of the <strong>json_data.asp</strong> is as follows (this corresponds exactly to the previous <code>xml</code> example, but just in <code>json</code> notation).</p>
<pre>
{"customer":{
  "name": "John",
  "surname": "Doe"  
  }
}
</pre>
<p>The following is the javascript that would load the <code>json</code> data from <strong>json_data.asp</strong> file, and show the value of the customer&#8217;s &#8220;name&#8221; property.<br />
Please note that &#8220;json&#8221; has been specified as the <strong>dataType</strong> parameter. Values returned are automatically serialized to json, as you may see the data is directly accessible via <code>data.customer.name</code>. </p>
<pre>
$("#loadContent").click(function () {
    $.get('json_data.asp', function(data) {
         alert("Value retrieved from json is: " + data.customer.name);
    }, 'json');
});
</pre>
<p>Try it live:<br />
<input type="button" id="loadContent2" value="Retrieve name by using get() with json" /><br />
<script type="text/javascript">
$("#loadContent2").click(function () {
    $.get('../json_data.asp', function(data) {
         alert("Value retrieved from json is: " + data.customer.name);
    }, 'json');
});
</script></p>
<p>as you may see, the only difference between the <code>xml</code> and <code>json</code> versions is how we handle the data inside the callback function. </p>
<h3>jQuery.getJSON method</h3>
<p>jQuery contains another &#8220;shortcut&#8221; in order to simplify the execution of the <code>json</code> based data with the json specific method which signature is:</p>
<div class="highlight">
<code>jQuery.getJSON ( url [, data] [, success(data, textStatus, jqXHR)] )</code>
</div>
<p>in reality, there is no difference between the previous <code>get()</code>  a part the fact that we don&#8217;t need anymore to specify the <strong>dataType</strong> as we did previously.</p>
<pre>
$("#loadContent3").click(function () {
    $.getJSON('json_data.asp', function(data) {
         alert("Value retrieved from json is: " + data.customer.name);
    });
});
</pre>
<p>Try it live:<br />
<input type="button" id="loadContent3" value="Retrieve name from json by using getJSON()" /><br />
<script type="text/javascript">
$("#loadContent3").click(function () {
    $.getJSON('../json_data.asp', function(data) {
         alert("Value retrieved from json is: " + data.customer.name);
    });
});
</script></p>
<h2>Short Conclusion</h2>
<p><code>get()</code> method offers a fairly simple way of dynamically getting <code>xml</code> and <code>json</code> data. It represents a simplified version of the <code>ajax()</code> call, which makes it fairly easy to use and to understand.</p>
<p>Stay tuned as in the next post we will see how to use the <code>post()</code> method.</p>
 <img src="http://www.agile-code.com/blog/?feed-stats-post-id=1880" width="1" height="1" style="display: none;" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/agile-code?a=pZlyRHVU9nI:XhVeKbv6pUs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=pZlyRHVU9nI:XhVeKbv6pUs:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=pZlyRHVU9nI:XhVeKbv6pUs:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/agile-code?i=pZlyRHVU9nI:XhVeKbv6pUs:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=pZlyRHVU9nI:XhVeKbv6pUs:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/agile-code?i=pZlyRHVU9nI:XhVeKbv6pUs:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=pZlyRHVU9nI:XhVeKbv6pUs:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/agile-code?i=pZlyRHVU9nI:XhVeKbv6pUs:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=pZlyRHVU9nI:XhVeKbv6pUs:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/agile-code?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=pZlyRHVU9nI:XhVeKbv6pUs:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/agile-code?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/agile-code/~4/pZlyRHVU9nI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.agile-code.com/blog/ajax-with-jquery-using-the-get-method/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.agile-code.com/blog/ajax-with-jquery-using-the-get-method/</feedburner:origLink></item>
		<item>
		<title>AJAX with jQuery – using the load() method</title>
		<link>http://feedproxy.google.com/~r/agile-code/~3/aQEJ2Zi65zE/</link>
		<comments>http://www.agile-code.com/blog/ajax-with-jquery-using-the-load-method/#comments</comments>
		<pubDate>Tue, 20 Nov 2012 23:59:38 +0000</pubDate>
		<dc:creator>Zoran Maksimovic</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.agile-code.com/blog/?p=1792</guid>
		<description><![CDATA[<br/>This is the first post of the series about how to load dynamically external content to a html page by using jQuery AJAX capabilities. If you are new to AJAX, please check this short introduction Ajax (an acronym for Asynchronous JavaScript and XML) is a group of interrelated web development techniques used on the client-side <a href='http://www.agile-code.com/blog/ajax-with-jquery-using-the-load-method/' class='excerpt-more'>[... read more]</a>]]></description>
				<content:encoded><![CDATA[<br/><p>This is the first post of the series about how to load dynamically external content to a html page by using jQuery AJAX capabilities.</p>
<p>If you are new to AJAX, please check this short introduction</p>
<div class="highlight">Ajax (an acronym for Asynchronous JavaScript and XML) is a group of interrelated web development techniques used on the client-side to create asynchronous web applications. With Ajax, web applications can send data to, and retrieve data from, a server asynchronously (in the background) without interfering with the display and behavior of the existing page.<br />
&#8211; Source: <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9BamF4Xyhwcm9ncmFtbWluZyk=" title=\"Ajax_(programming)\" target=\"_blank\">Wikipedia</a></div>
<p>on the other side
<div class="highlight">jQuery is a multi-browser JavaScript library designed to simplify the client-side scripting of HTML.<br />
&#8211; Source: <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9KUXVlcnk=" title=\"jquery wikipedia\" target=\"_blank\">Wikipedia</a></div>
<p>jQuery supports JSON, XML, HTML data formats, and supports both GET and POST methods, has an excellent cross browser support and all this is done by using a fairly simply API. All this makes jQuery a very powerful tool for a client side web developer.<br />
As I won&#8217;t explain the basics of jQuery, in order to understand it better, please visit the jquery.com web site.</p>
<h2>4 ways of performing AJAX calls </h2>
<p>There are mainly 4 ways of how jQuery library enables the AJAX requests, and this covers only the first one.</p>
<ol>
<li>using the <code>load()</code> function</li>
<li><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL2FqYXgtd2l0aC1qcXVlcnktdXNpbmctdGhlLWdldC1tZXRob2Qv" title=\"AJAX with jQuery – using the get() method\">using the <code>get()</code> function</a></li>
<li>using the <code>post()</code> function</li>
<li>using the <code>ajax()</code> function</li>
</ol>
<div class="highlight">
We have to keep in mind that due to browser security restrictions, most &#8220;Ajax&#8221; requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain, or protocol.
</div>
<h2>Using the <code>load()</code> function</h2>
<p>As stated on the jQuery web site, this method is the simplest way to fetch data from the server. </p>
<p><code>load()</code> method signature is as follows:</p>
<div class="highlight">
    <code>$(selector).load(url, [data], [callback]);</code>
</div>
<p>where only the <code>url</code> parameter is the mandatory one, while the <code>data</code> and <code>callback</code> are optional. If the callback is specified, then this function will be executed <strong>after</strong> the call is completed, so there is a possibility to perform additional, post loading code.</p>
<p>In order to demonstrate how this works, below is provided an example, a static html page, that would load dynamically the content from another page into a <code>div</code>.</p>
<p>In the below example please note the following:</p>
<ol>
<li><code>jquery</code> script library is automatically downloaded from the jquery.com web site. This is a handy way of not hosting the library directly on your site as the jquery.com is highly optimized and the content download is really fast. you may opt for other sites offering the same functionality.</li>
<li>When the &#8220;loadContent&#8221; button is clicked, a function is attached to the event, and the load() function will be called.</li>
<li>The content of the external &#8220;Content.html&#8221; file will be loaded, if available, inside the <code>div id="success"</code></li>
<li>In case of an error, the callback function will make sure that the content of the <code>div id="error"</code> will contain the error message</li>
</ol>
<p>Content of the Index.html page:</p>
<pre>
&lt;html&gt;
&lt;head&gt;
    &lt;script src=&quot;http://code.jquery.com/jquery-latest.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

    &lt;input type=&quot;button&quot; id=&quot;loadContent&quot; value=&quot;Load&quot; /&gt;

    &lt;div id=&quot;success&quot;&gt;&lt;/div&gt;

    Error response:
    &lt;div id=&quot;error&quot;&gt;&lt;/div&gt;

    &lt;script&gt;
    $(&quot;#loadContent&quot;).click(function () {

        $(&quot;#success&quot;).load(&quot;Content.html&quot;, function (response, status, xhr) {
            if (status == &quot;error&quot;) {
                var msg = &quot;Sorry but there was an error: &quot;;
                $(&quot;#error&quot;).html(msg + xhr.status + &quot; &quot; + xhr.statusText);
            }
        });

    });       
    &lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>content of the &#8220;Content.html&#8221; page</p>
<pre>
&lt;html&gt;
&lt;body&gt;
    &lt;h2&gt;Title&lt;/h2&gt;
    &lt;p&gt;
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
        Praesent tristique mi in nulla lacinia imperdiet. 
        Nulla at tellus leo, porta viverra lectus. Mauris ac 
        purus vehicula lorem bibendum sodales id sodales 
        lorem. Donec tincidunt felis ac purus facilisis vulputate.
        Proin convallis interdum leo a ultrices. Cras neque ligula, 
        vestibulum nec venenatis vel, molestie non tortor. Ut tempor 
        risus ut diam dignissim nec adipiscing erat suscipit.
    &lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>the result, after pressing the load button will be:<br />
<a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEyLzExL2xvYWRfYWpheF9qcXVlcnkucG5n"><img src="http://i2.wp.com/www.agile-code.com/blog/wp-content/uploads/2012/11/load_ajax_jquery.png?resize=695%2C534" alt="" title="load_ajax_jquery" class="aligncenter size-full wp-image-1855" data-recalc-dims="1" /></a></p>
<h2>Conclusion</h2>
<p>In the next post I will describe the <code>get()</code> method, and provide a concrete example of usage.</p>
 <img src="http://www.agile-code.com/blog/?feed-stats-post-id=1792" width="1" height="1" style="display: none;" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/agile-code?a=aQEJ2Zi65zE:B6wXe4iF17c:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=aQEJ2Zi65zE:B6wXe4iF17c:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=aQEJ2Zi65zE:B6wXe4iF17c:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/agile-code?i=aQEJ2Zi65zE:B6wXe4iF17c:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=aQEJ2Zi65zE:B6wXe4iF17c:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/agile-code?i=aQEJ2Zi65zE:B6wXe4iF17c:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=aQEJ2Zi65zE:B6wXe4iF17c:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/agile-code?i=aQEJ2Zi65zE:B6wXe4iF17c:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=aQEJ2Zi65zE:B6wXe4iF17c:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/agile-code?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=aQEJ2Zi65zE:B6wXe4iF17c:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/agile-code?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/agile-code/~4/aQEJ2Zi65zE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.agile-code.com/blog/ajax-with-jquery-using-the-load-method/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.agile-code.com/blog/ajax-with-jquery-using-the-load-method/</feedburner:origLink></item>
		<item>
		<title>REST Web Services with Unity.WCF</title>
		<link>http://feedproxy.google.com/~r/agile-code/~3/IY99ojQ_rQE/</link>
		<comments>http://www.agile-code.com/blog/rest-web-services-with-unity-wcf/#comments</comments>
		<pubDate>Sat, 03 Nov 2012 17:44:58 +0000</pubDate>
		<dc:creator>Zoran Maksimovic</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ASP.NET Web API]]></category>
		<category><![CDATA[Microsoft.NET]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Web Service]]></category>

		<guid isPermaLink="false">http://www.agile-code.com/blog/?p=1739</guid>
		<description><![CDATA[<br/>Microsoft WCF framework is the Microsoft (de-facto) platform for developing SOAP Web Services. Even though in the latest .NET 4 version there are many improvements like: simplified configuration and better support for REST web services type, personally I have a love-hate relationship with it because I believe that is not the easiest platform to work <a href='http://www.agile-code.com/blog/rest-web-services-with-unity-wcf/' class='excerpt-more'>[... read more]</a>]]></description>
				<content:encoded><![CDATA[<br/><p>Microsoft WCF framework is the Microsoft (de-facto) platform for developing SOAP Web Services. Even though in the latest .NET 4 version there are many improvements like: simplified configuration and better support for REST web services type, personally I have a love-hate relationship with it because I believe that is not the easiest platform to work on, especially when it comes to the configuration. </p>
<h2>Dependency Injection</h2>
<p>One of the first things that I had to deal with when creating the service was the support for <code>IoC</code>. In our specific case, as my team and I are familiar with and we already have a number of libraries written for <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3VuaXR5LmNvZGVwbGV4LmNvbS8=" title=\"Microsoft Unity Framework\" target=\"_blank\">Microsoft Unity Framework</a>, that was our primary choice. </p>
<p>As there are many way of implementing the dependency injection in WCF, I found, what I believe one of the easiest ways of supporting IoC, without really writing any code. Our main choice was the Unity.WCF library that can be downloaded freely from the CodePlex site.</p>
<h3>Unity.WCF</h3>
<p>Taken from the <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3VuaXR5d2NmLmNvZGVwbGV4LmNvbS8=" title=\"Unity.WCF\" target=\"_blank\">Unity.WCF codeplex web site</a>: </p>
<blockquote><p>Unity.WCF is a library that allows the simple integration of Microsoft&#8217;s Unity IoC container with WCF. This project includes a bespoke <code>InstanceProvider</code> that creates a child container per client connection and disposes of all registered <code>IDisposable</code> instances once the connection is terminated.</p></blockquote>
<p>Unity.WCF implements out of the box the support for Microsoft Unity and after installing the package through Nuget, you will be immediately ready to use and inject objects to your service. For the complete reference of how to do so, please check <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5kZXZ0cmVuZHMuY28udWsvYmxvZy9pbnRyb2R1Y2luZy11bml0eS53Y2YtcHJvdmlkaW5nLWVhc3ktaW9jLWludGVncmF0aW9uLWZvci15b3VyLXdjZi1zZXJ2aWNlcw==" title=\"Indroducing Unity.WCF\" target=\"_blank\">here</a></p>
<h2>REST with Microsoft WCF</h2>
<p>Microsoft WCF is a good platform to work when building SOAP based web services, it <strong>doesn&#8217;t shine</strong> when it comes to the implementation of REST Web Services. Actually Microsoft has recently released the <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hc3AubmV0L3dlYi1hcGk=" title=\"ASP.NET Web Api\" target=\"_blank\">ASP.NET Web Api</a> framework that is build with only thing in mind, creating RESTful services. So, in general, it is strongly advised <strong>NOT</strong> to use WCF with REST as the full attention, and hence support and attention for future improvements, will be moved to the new ASP.NET Web Api framework.</p>
<p>I have recently described in one of the posts <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3doYXQtdGVjaG5vbG9neS1mb3ItYnVpbGRpbmctd2ViLXNlcnZpY2VzLWluLW1pY3Jvc29mdC1uZXQv" title=\"What technology for building Web Services in Microsoft.NET?\" target=\"_blank\">What technology to use when building Web Services in Microsoft.NET?</a>, so check it out.</p>
<p>So, even after the above explanation, if your choice is to use Microsoft WCF for building RESTful services, and if you want the same support for dependency injection, you may still use Unity.WCF but you need to do some changes, that I am going to show in the next chapter.</p>
<h2>Implementing a RESTful Web Service in Microsoft WCF</h2>
<p>One of the differences when building the RESTful service is that it should be (but not necessarily) hosted in the <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL21zZG4ubWljcm9zb2Z0LmNvbS9lbi11cy9saWJyYXJ5L3N5c3RlbS5zZXJ2aWNlbW9kZWwud2ViLndlYnNlcnZpY2Vob3N0JTI4dj12cy4xMDAlMjkuYXNweA==" title=\"WebServiceHost\" target=\"_blank\">WebServiceHost</a> class rather than on the <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL21zZG4ubWljcm9zb2Z0LmNvbS9lbi11cy9saWJyYXJ5L3N5c3RlbS5zZXJ2aWNlbW9kZWwuc2VydmljZWhvc3QlMjh2PXZzLjEwMCUyOS5hc3B4" title=\"ServiceHost\" target=\"_blank\">ServiceHost</a>. The <code>WebServiceHost</code> class is a derived class from <code>ServiceHost</code> and it is specifically tailored for the RESTful services.</p>
<p>Unfortunately Unity.WCF at the time of writing doesn&#8217;t support out of the box the support for the WebServiceHost, as internally uses the ServiceHost to host any type of service.</p>
<p>In order to get over this &#8220;limitation&#8221; we need to extend Unity.WCF, and it is pretty much straightforward. We will accomplish this by implementing two new classes that internally would use the infrastructure already offered by Unity.WCF, and that would be used to host the REST Web Service through WebServiceHost: </p>
<ol>
<li><code>UnityWebServiceHost</code> that mimics the existing Unity.WCF&#8217;s <code>UnityServiceHost</code> and</li>
<li><code>UnityWebServiceHostFactory</code> that mimics the existing <code>UnityServiceHostFactory</code></li>
</ol>
<h4>UnityWebServiceHostFactory</h4>
<p>Note: This class inherits from <code>WebServiceHostFactory</code>.</p>
<pre>
public abstract class UnityWebServiceHostFactory : WebServiceHostFactory
{
    protected abstract void ConfigureContainer(IUnityContainer container);

    protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
    {
        var container = new UnityContainer();

        ConfigureContainer(container);

        return new UnityWebServiceHost(container, serviceType, baseAddresses);
    }
}
</pre>
<h4>UnityWebServiceHost</h4>
<p>Note, this class inherits from <code>WebServiceHost</code></p>
<pre>
public class UnityWebServiceHost : WebServiceHost
{
    public UnityWebServiceHost(IUnityContainer container, Type serviceType, params Uri[] baseAddresses)
        : base(serviceType, baseAddresses)
    {
        if (container == null)
        {
            throw new ArgumentNullException(&quot;container&quot;);
        }

        ApplyServiceBehaviors(container);

        ApplyContractBehaviors(container);

        foreach (var contractDescription in ImplementedContracts.Values)
        {
            var contractBehavior =
                new UnityContractBehavior(new UnityInstanceProvider(container, contractDescription.ContractType));

            contractDescription.Behaviors.Add(contractBehavior);
        }
    }

    private void ApplyContractBehaviors(IUnityContainer container)
    {
        var registeredContractBehaviors = container.ResolveAll&lt;IContractBehavior&gt;();

        foreach (var contractBehavior in registeredContractBehaviors)
        {
            foreach (var contractDescription in ImplementedContracts.Values)
            {
                contractDescription.Behaviors.Add(contractBehavior);
            }
        }
    }

    private void ApplyServiceBehaviors(IUnityContainer container)
    {
        var registeredServiceBehaviors = container.ResolveAll&lt;IServiceBehavior&gt;();

        foreach (var serviceBehavior in registeredServiceBehaviors)
        {
            Description.Behaviors.Add(serviceBehavior);
        }
    }
}
</pre>
<h4>RestBootstrapper</h4>
<p><code>RestBootstrapper</code> is a class that will be used to configure our dependency injection code, and the facto, the Service1.svc should point to this file, as shown below:</p>
<pre>
public class RestBootstrapper: UnityWebServiceHostFactory
{
    protected override void ConfigureContainer(IUnityContainer container)
    { 
        //your configuration goes here...
        container.RegisterType&lt;IService1, Service1&gt;()
            .RegisterType&lt;IDataRepository, DataRepository&gt;();
    }
}
</pre>
<h4>Service1.svc</h4>
<pre>
&lt;%@ ServiceHost Language=&quot;C#&quot; Debug=&quot;true&quot; 
                Service=&quot;REST.Web.Service.Service1&quot; 
                CodeBehind=&quot;Service1.svc.cs&quot;
                Factory=&quot;REST.Web.Service.RestBootstrapper&quot; %&gt;
</pre>
<h4>web.config file</h4>
<p>Obviously from the web.config point of view, if we want to host the service in IIS, the web.config should be configured as follows:</p>
<pre>
&lt;system.serviceModel&gt;

  &lt;!--Configuration of the services exposed by this host.--&gt;
  &lt;services&gt;
    &lt;service name=&quot;REST.Web.Service.Service1&quot;&gt;
      &lt;endpoint address=&quot;&quot;
                binding=&quot;webHttpBinding&quot;
                bindingConfiguration=&quot;webBinding&quot;
                behaviorConfiguration=&quot;poxBehavior&quot;
                contract=&quot;REST.Web.Service.IService1&quot;/&gt;
    &lt;/service&gt;
  &lt;/services&gt;

  &lt;!-- BEHAVIORS --&gt;
  &lt;behaviors&gt;
    &lt;endpointBehaviors&gt;
      &lt;!-- plain old XML --&gt;
      &lt;behavior name=&quot;poxBehavior&quot;&gt;
        &lt;webHttp helpEnabled=&quot;true&quot; automaticFormatSelectionEnabled=&quot;true&quot;/&gt;
      &lt;/behavior&gt;      
    &lt;/endpointBehaviors&gt;
  &lt;/behaviors&gt;

  &lt;!--BINDINGS--&gt;
  &lt;bindings&gt;
    &lt;webHttpBinding&gt;
      &lt;binding name=&quot;webBinding&quot;/&gt;
    &lt;/webHttpBinding&gt;
  &lt;/bindings&gt;

  &lt;serviceHostingEnvironment multipleSiteBindingsEnabled=&quot;true&quot;
                              aspNetCompatibilityEnabled=&quot;false&quot;&gt;
  &lt;/serviceHostingEnvironment&gt;
&lt;/system.serviceModel&gt;
</pre>
<div class="highlight">
Download a fully working example that covers all the code mentioned in the post <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEyLzExL1JFU1QuV2ViXy5TZXJ2aWNlLnppcA==">REST.Web.Service</a>.<br />
If you liked the article, please pay me back by letting know to others via <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2NsaWNrdG90d2VldC5jb20vZGM1N2U=" title=\"Inform the others.\">twitter</a>.
</div>
<h2>Conclusion</h2>
<p>Unity.WCF is a really easy to use library and offers out of the box support for dependency injection on WCF. Actually, there are other libraries by the same author for MVC, etc, so you might check this out. Support for REST through <code>WebServiceHost</code> is not supported, but as shown above, it is very easy to achieve.</p>
<p>I hope that you enjoyed this article, if so, please consider writing a comment in case you think there are improvements to be done or in case there are alternative or easier ways of achieving this.</p>
 <img src="http://www.agile-code.com/blog/?feed-stats-post-id=1739" width="1" height="1" style="display: none;" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/agile-code?a=IY99ojQ_rQE:EwpQ5lYZ9_Q:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=IY99ojQ_rQE:EwpQ5lYZ9_Q:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=IY99ojQ_rQE:EwpQ5lYZ9_Q:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/agile-code?i=IY99ojQ_rQE:EwpQ5lYZ9_Q:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=IY99ojQ_rQE:EwpQ5lYZ9_Q:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/agile-code?i=IY99ojQ_rQE:EwpQ5lYZ9_Q:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=IY99ojQ_rQE:EwpQ5lYZ9_Q:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/agile-code?i=IY99ojQ_rQE:EwpQ5lYZ9_Q:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=IY99ojQ_rQE:EwpQ5lYZ9_Q:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/agile-code?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=IY99ojQ_rQE:EwpQ5lYZ9_Q:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/agile-code?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/agile-code/~4/IY99ojQ_rQE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.agile-code.com/blog/rest-web-services-with-unity-wcf/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.agile-code.com/blog/rest-web-services-with-unity-wcf/</feedburner:origLink></item>
		<item>
		<title>Unit testing with Microsoft Visual Studio 2012</title>
		<link>http://feedproxy.google.com/~r/agile-code/~3/g1ZHugcrgOw/</link>
		<comments>http://www.agile-code.com/blog/unit-testing-with-microsoft-visual-studio-2012/#comments</comments>
		<pubDate>Fri, 26 Oct 2012 22:46:33 +0000</pubDate>
		<dc:creator>Zoran Maksimovic</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Test Driven Development.]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.agile-code.com/blog/?p=1707</guid>
		<description><![CDATA[<br/>Microsoft Visual Studio 2012 comes with a large amount of new features and improvements in almost all areas. The changes introduced in the &#8220;unit testing&#8221; and generally &#8220;testing&#8221; area are very significative. I&#8217;ve read the following sentence in one of the Microsoft slides and I couldn&#8217;t agree more: The Visual Studio 11 Unit Testing experience <a href='http://www.agile-code.com/blog/unit-testing-with-microsoft-visual-studio-2012/' class='excerpt-more'>[... read more]</a>]]></description>
				<content:encoded><![CDATA[<br/><p>Microsoft Visual Studio 2012 comes with a large amount of new features and improvements in almost all areas. The changes introduced in the &#8220;unit testing&#8221; and generally &#8220;testing&#8221; area are very significative.<br />
I&#8217;ve read the following sentence in one of the Microsoft slides and I couldn&#8217;t agree more:</p>
<div class="highlight">The Visual Studio 11 Unit Testing experience is focused on <strong>developers</strong> writing and running <strong>unit tests</strong> while they write their code.</div>
<h2>Architecture</h2>
<p>Microsoft was working on making the testing framework extensible, indeed it allow us to use other testing frameworks such as xUnit.net and Nunit, something that in the past, in order to have something built into Visual Studio we had to use external plugins such as Resharper or others. All this can be seen in the below picture that depicts the current Microsoft <strong>Visual Studio Unit Test Platform</strong> that is in fact a <em>Unit Test Runners-Runner</em>. Yes, the responsibility of this layer is to run the third party unit test runners and it is supposed to be the &#8220;glue&#8221; between the user and the actual underlying unit testing framework.</p>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEyLzEwL1ZTMjAxMl9Vbml0VGVzdGluZ19BcmNoaXRlY3R1cmUucG5n"><img class="aligncenter size-full wp-image-1728" title="VS2012 Unit Testing Architecture" src="http://i0.wp.com/www.agile-code.com/blog/wp-content/uploads/2012/10/VS2012_UnitTesting_Architecture.png?resize=522%2C219" alt="VS2012 Unit Testing Architecture" data-recalc-dims="1" /></a></p>
<h2>Test Explorer</h2>
<p>Visually, the most important addition to the Visual Studio Unit testing is the so called <strong>Test Explorer</strong></p>
<p>Test explorer supports a number of features (as illustrated in the picture) such as:<br />
<img class="alignright size-full wp-image-1712" title="Test Explorer" src="http://i2.wp.com/www.agile-code.com/blog/wp-content/uploads/2012/10/TestExplorer.png?resize=248%2C305" alt="Test Explorer" data-recalc-dims="1" /></p>
<ul>
<li><strong>Search</strong>: it is possible to search within the test names and execute only those displayed in the search</li>
<li><strong>Red-Green bar</strong>: Bar at the top of the window will display if the tests have been failed (red) or if everything have run smoothly.</li>
<li><strong>Most important tests</strong> will be shown first (at the top)</li>
<li><strong>Timings</strong>: Each tests has the duration so we can see quickly how long it takes for a test to execute and fix it if it runs slowly.</li>
<li>Shows tests from <strong>any framework</strong>.</li>
<li><strong>Run details</strong>: there are details being shown in the bottom part that will tell why the test failed or other information.</li>
</ul>
<h2>Code Coverage</h2>
<p>Code coverage is a measure used in software testing. It describes the degree to which the source code of a program has been tested.</p>
<p>In the picture below you may see how the information are displayed directly in Visual Studio showing which part of the code haven&#8217;t been covered tested (in red) with a number of statistics around it.</p>
<p>Previously in order to see such number of statistics we had to use third party tools such as NCover, JetBrains dotCover or others.</p>
<p><a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL3dwLWNvbnRlbnQvdXBsb2Fkcy8yMDEyLzEwL1ZTMjAxMl9Vbml0VGVzdF9Db2RlQ292ZXJhZ2UucG5n"><img class="aligncenter size-full wp-image-1731" title="VS2012 Unit Test Code Coverage" src="http://i0.wp.com/www.agile-code.com/blog/wp-content/uploads/2012/10/VS2012_UnitTest_CodeCoverage.png?w=500" alt="VS2012 Unit Test Code Coverage"  data-recalc-dims="1" /></a></p>
<h2>Isolating code for better testing</h2>
<p>There is another improvement named <strong>VS11 Fakes framework</strong> that lets us isolate almost anything in .NET. There are two flavors of fakes:</p>
<ul>
<li><strong>Stubs</strong>: concrete implementations of interfaces or abstract classes. VS offers an easy way of creating stubs something that we previously had to do manually or using third part frameworks such as <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy5hZ2lsZS1jb2RlLmNvbS9ibG9nL21vY2tpbmctd2l0aC1tb3Ev" title=\"Mocking with Moq\">Moq</a>, or others. It is not fully a replacement but a good start.</li>
<li><strong>Shims</strong>: run-time interception lets you replace calls, even those from the .NET Base Class Library.</li>
</ul>
<p>Check <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL3d3dy55b3V0dWJlLmNvbS93YXRjaD9mZWF0dXJlPXBsYXllcl9lbWJlZGRlZCYjMDM4O3Y9Mk1hQmRuSnFVN3c=" title=\"http://www.youtube.com/watch?feature=player_embedded&#038;v=2MaBdnJqU7w\" target=\"_blank\">this</a> and <a href="http://www.agile-code.com/blog/?feed-stats-url=aHR0cDovL2NoYW5uZWw5Lm1zZG4uY29tL1Nlcmllcy9WaXN1YWwtU3R1ZGlvLTIwMTItUHJlbWl1bS1hbmQtVWx0aW1hdGUtT3ZlcnZpZXcvVmlzdWFsLVN0dWRpby1VbHRpbWF0ZS0yMDEyLUltcHJvdmluZy1xdWFsaXR5LXdpdGgtdW5pdC10ZXN0cy1hbmQtZmFrZXM=" title=\"Visual Studio Premium and Ultimate 2012: Improving quality with unit tests in Premium and with unit tests and fakes in Ultimate\" target=\"_blank\">this</a> videos if you like to see how to use the new Visual Studio 2012 fakes framework.</p>
<p>Fakes and shims visually represented:<br />
<div class="wp-caption alignnone" style="width: 689px"><img alt="" src="http://i1.wp.com/i.msdn.microsoft.com/dynimg/IC612237.png?resize=679%2C235" title="Shims" data-recalc-dims="1" /><p class="wp-caption-text">(c) Microsoft.com</p></div></p>
<h2>Continous Testing</h2>
<p>Continous testing in Visual Studio 2012 gives a possibility of continuously running the tests withing the solution. It helps you with the way you do TDD by taking care of all compiling and testing in the background to help you work more efficiently. </p>
<p>This framework could potentially replace the third party tools such as ContinousTest, NCrunch, or others.</p>
<h2>Conclusion</h2>
<p>Visual Studio 2012 has a list of improvements that will make the unit testing simpler and effective. The number of features is quite large so I encourage you further check and experience it by yourself. As I haven&#8217;t had the time to fully try all the above explained items, I am not yet sure if the above listed features would replace the other third party frameworks, but this is already a good step forward. Microsoft is showing us that it is moving into the right direction.</p>
 <img src="http://www.agile-code.com/blog/?feed-stats-post-id=1707" width="1" height="1" style="display: none;" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/agile-code?a=g1ZHugcrgOw:uIi-VUTlJKQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=g1ZHugcrgOw:uIi-VUTlJKQ:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/agile-code?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=g1ZHugcrgOw:uIi-VUTlJKQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/agile-code?i=g1ZHugcrgOw:uIi-VUTlJKQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=g1ZHugcrgOw:uIi-VUTlJKQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/agile-code?i=g1ZHugcrgOw:uIi-VUTlJKQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=g1ZHugcrgOw:uIi-VUTlJKQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/agile-code?i=g1ZHugcrgOw:uIi-VUTlJKQ:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=g1ZHugcrgOw:uIi-VUTlJKQ:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/agile-code?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/agile-code?a=g1ZHugcrgOw:uIi-VUTlJKQ:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/agile-code?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/agile-code/~4/g1ZHugcrgOw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.agile-code.com/blog/unit-testing-with-microsoft-visual-studio-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.agile-code.com/blog/unit-testing-with-microsoft-visual-studio-2012/</feedburner:origLink></item>
	</channel>
</rss>
