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

<channel>
	<title>Undisciplined Bytes</title>
	<atom:link href="http://www.undisciplinedbytes.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.undisciplinedbytes.com</link>
	<description>Web Application Development Tips, Tricks and Techniques</description>
	<lastBuildDate>Tue, 13 Mar 2012 09:01:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Creating a Timestamp column with Entity Framework</title>
		<link>http://www.undisciplinedbytes.com/2012/03/creating-a-timestamp-column-with-entity-framework/</link>
		<comments>http://www.undisciplinedbytes.com/2012/03/creating-a-timestamp-column-with-entity-framework/#comments</comments>
		<pubDate>Tue, 13 Mar 2012 09:01:01 +0000</pubDate>
		<dc:creator>Oliver Mezquita</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.undisciplinedbytes.com/?p=657</guid>
		<description><![CDATA[Entity Framework by default doesn’t handle concurrency issues. If you want it to perform concurrency checks, you need to have some column in each of your tables to be able to check whether the row you’re about to overwrite has changed since the last time you read it. The best solution for that is to [...]]]></description>
			<content:encoded><![CDATA[<p>Entity Framework by default doesn’t handle concurrency issues. If you want it to perform concurrency checks, you need to have some column in each of your tables to be able to check whether the row you’re about to overwrite has changed since the last time you read it. The best solution for that is to have a column in which to write a new value (ie. a version number) each time you write a row, and then compare it just before updating it.</p>
<p>Fortunately, Entity Framework does support this technique:</p>
<p><span id="more-657"></span></p>
<h4>Timestamp column with code-first approach</h4>
<p>For the code-first approach, you need to declare a column of type Byte[], and then decorate it with the Timestamp attribute. This way, Entity Framework will know this column must be included in the Where clause of SQL sentences for Updates and Deletes actions.</p>
<pre class="brush:c#">using System;
using System.ComponentModel.DataAnnotations;

namespace MyProject.Entities
{
   public class Person
   {
      public Int64 Id { get; set; }
      public string Name { get; set; }
      public DateTime BirthDate { get; set; }
      public string EMail { get; set; } 

      [Timestamp]
      public Byte[] Timestamp { get; set; }
   }
}</pre>
<p>Now you need to update your EF model and re-create the database structure, so the new column will be created in the table.</p>
<p>And voila! Now you have automatic concurrency checking every time you try to update/delete a row in this table. You can check this column is being included in all row-modifying SQL sentences EF generates. You could use SQL server profiler, for example, to inspect these sentences.</p>
<h4>Timestamp column with model-first approach</h4>
<p>Now, setting this column with the model-first approach is a little bit trickier. There’s no built-in support for this in EF’s model itself (yet), so we’ll have to hack the code generation template to fulfill our needs.</p>
<p>What we need to do to set up a  timestamp column using model first approach is the following:</p>
<ol>
<li>Add a property named “Timestamp” to the entity in EF’s model</li>
<li>Set the type to binary</li>
<li>Set nullable to false</li>
<li>Set StoreGeneratedPattern to Computed</li>
<li>Set ConcurrencyMode to Fixed</li>
<li>Create a copy of SSDLToSQL10.tt (typically found in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\DBGen)</li>
<li>Edit the line that says:<br />
<code>[&lt;#=Id(prop.Name)#&gt;] &lt;#=prop.ToStoreType()#&gt; &lt;#=WriteIdentity(prop, targetVersion)#&gt; &lt;#=WriteNullable(prop.Nullable)#&gt;&lt;#=(p &lt; entitySet.ElementType.Properties.Count - 1) ? "," : ""#&gt;</code></li>
<li>Change it to:<br />
<code>[&lt;#=Id(prop.Name)#&gt;] &lt;#if (string.Compare(prop.Name,"TimeStamp",true) == 0) { #&gt;TIMESTAMP&lt;# } else { #&gt;&lt;#=prop.ToStoreType()#&gt;&lt;# } #&gt; &lt;#=WriteIdentity(prop, targetVersion)#&gt; &lt;#=WriteNullable(prop.Nullable)#&gt;&lt;#=(p &lt; entitySet.ElementType.Properties.Count - 1) ? "," : ""#&gt;</code><br />
This will change any column that is called “Timestamp” (case insensitive) to be a Timestamp column.</li>
<li>Click on the entity canvas and set the DDL Generation Template to this new copy of the file</li>
<li>Click on Generate Database From Model</li>
<li>Enjoy your new concurrency-aware data access!</li>
</ol>


<h4>Related posts:</h4><p><ol><li><a href='http://www.undisciplinedbytes.com/2012/01/entity-framework/' rel='bookmark' title='Permanent Link: Entity Framework'>Entity Framework</a></li>
<li><a href='http://www.undisciplinedbytes.com/2012/02/things-to-consider-when-using-entity-framework/' rel='bookmark' title='Permanent Link: Things to consider when using Entity Framework'>Things to consider when using Entity Framework</a></li>
<li><a href='http://www.undisciplinedbytes.com/2011/12/persistence-layer-object-relational-mapping-tools/' rel='bookmark' title='Permanent Link: Persistance layer: object-relational mapping tools'>Persistance layer: object-relational mapping tools</a></li>
<li><a href='http://www.undisciplinedbytes.com/2010/01/sluggish-database-view-materialize-it/' rel='bookmark' title='Permanent Link: Sluggish database view? Materialize it!'>Sluggish database view? Materialize it!</a></li>
<li><a href='http://www.undisciplinedbytes.com/2011/03/which-database-to-use-for-a-personal-project/' rel='bookmark' title='Permanent Link: Which database to use for a personal project?'>Which database to use for a personal project?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.undisciplinedbytes.com/2012/03/creating-a-timestamp-column-with-entity-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Things to consider when using Entity Framework</title>
		<link>http://www.undisciplinedbytes.com/2012/02/things-to-consider-when-using-entity-framework/</link>
		<comments>http://www.undisciplinedbytes.com/2012/02/things-to-consider-when-using-entity-framework/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 09:16:54 +0000</pubDate>
		<dc:creator>Oliver Mezquita</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.undisciplinedbytes.com/?p=650</guid>
		<description><![CDATA[Entity Framework is a great ORM tool. It greatly simplifies database access and gets you going really fast. It’s got a great set of features, and it’s becoming one of the most used ORM tools in the .Net world. However, in some situations, not everything in EF is so great. There are certain things that [...]]]></description>
			<content:encoded><![CDATA[<p>Entity Framework is a great ORM tool. It greatly simplifies database access and gets you going really fast. It’s got a great set of features, and it’s becoming one of the most used ORM tools in the .Net world. However, in some situations, not everything in EF is so great. There are certain things that you have to be careful with when working with EF. For the most simple scenarios, its usage right out the box without any other consideration will work. But, if you’re working in some medium or large-sized project, then there’s some things to consider:</p>
<p><span id="more-650"></span></p>
<h4>Entity Framework has been designed following the Unit of Work pattern</h4>
<p>The Unit of Work pattern is a very well thought data-access pattern. When using this pattern, there’s an object that keeps track of changes made to data, and that coordinates the writing out of changes to the database.</p>
<p>When you use EF, you’ll realize that it creates a context class that inherits from System.Data.Entity.DbContext. This DbContext class is the UnitOfWork object. It keeps track of the changes made to objects, and is responsible for persisting data to the database.</p>
<p>This means that this context keeps a local copy of the data stored in the database along with the changes made. This brings us to the next point:</p>
<h4>Entity Framework’s context must be short-lived</h4>
<p>The Unit of Work pattern recommends having a UnitOfWork object per transaction. As this object keeps a local copy of the data and the changes made to it, it must be quickly stored to the database in case there’s another request for this data.</p>
<p>You can never totally rule out concurrency problems. But, by keeping EF’s context as short-lived as possible, you’ll be minimizing these problems.</p>
<p>There seems to be a recommendation about EF’s context life to be that of a web request in a web application. I agree, as long as that web request is a regular one, just taking a very small amount of database requests to build the page. But, if you’re doing something heavier, like batch-processing some files or calculating some statistics, then you should discard the context as quickly as possible. In these situations I wouldn’t recommend using a web-request-lived context, but one you create and dispose per each database transaction you need.</p>
<p>What about the costs of context instantiation? Wouldn’t that make the application much slower? Well, instantiating an object always consumes resources, but creating a new context instance is not as expensive as you may think. There’s a local cache kept by Entity Framework that makes this process much faster. Besides, disposing of objects that you’re done with as quickly as possible is one of the best practices you could follow as a programmer. That’s something you should be always doing, not only with EF.</p>
<h4>By default Entity Framework does not handle concurrency issues</h4>
<p>Or put it in some other way: Entity Framework’s default concurrency policy is “Last-Write-Wins”. This policy isn’t the best one available, and if we’re doing something serious we <strong>must not use this policy</strong>. Entity Framework does support an optimistic concurrency model. When using this policy, an exception will be thrown when trying to save an entity which has been modified since it was retrieved by that instance of the context. We can then capture this exception and handle the error.</p>
<p>An example and explanation of this will not be very short, so I’ll be posting an article explaining how to do this.</p>
<p>Entity Framework might give you some headaches if you’re not aware of these issues. Make sure that you understand them and that you have taken steps to minimize possible problems.</p>


<h4>Related posts:</h4><p><ol><li><a href='http://www.undisciplinedbytes.com/2012/03/creating-a-timestamp-column-with-entity-framework/' rel='bookmark' title='Permanent Link: Creating a Timestamp column with Entity Framework'>Creating a Timestamp column with Entity Framework</a></li>
<li><a href='http://www.undisciplinedbytes.com/2012/01/entity-framework/' rel='bookmark' title='Permanent Link: Entity Framework'>Entity Framework</a></li>
<li><a href='http://www.undisciplinedbytes.com/2011/12/persistence-layer-object-relational-mapping-tools/' rel='bookmark' title='Permanent Link: Persistance layer: object-relational mapping tools'>Persistance layer: object-relational mapping tools</a></li>
<li><a href='http://www.undisciplinedbytes.com/2010/08/unit-testing/' rel='bookmark' title='Permanent Link: Unit testing'>Unit testing</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.undisciplinedbytes.com/2012/02/things-to-consider-when-using-entity-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Entity Framework</title>
		<link>http://www.undisciplinedbytes.com/2012/01/entity-framework/</link>
		<comments>http://www.undisciplinedbytes.com/2012/01/entity-framework/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 09:07:24 +0000</pubDate>
		<dc:creator>Oliver Mezquita</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.undisciplinedbytes.com/?p=640</guid>
		<description><![CDATA[Entity framework is the new kid on the block on the ORM realm. It’s Microsoft new technology for data access, and although it didn’t receive very good comments on its first version, things have been greatly improved in its latest release. It now looks really interesting, with some features which surpass the most seasoned ORM [...]]]></description>
			<content:encoded><![CDATA[<p>Entity framework is the new kid on the block on the ORM realm. It’s Microsoft new technology for data access, and although it didn’t receive very good comments on its first version, things have been greatly improved in its latest release. It now looks really interesting, with some features which surpass the most seasoned ORM frameworks that have been in the game for years.</p>
<p>Here’s what Entity Framework (EF) has to offer:</p>
<p><span id="more-640"></span></p>
<ul>
<li>Using EF with the <strong>Model First approach</strong>, you design a schema of the model you want to implement, and EF generates a database and the code to implement it. Now, that’s what I call saving time! Using this approach, you can get going really really quick.</li>
<li>If you already have the code for your model, then EF can generate the database to store this model as well as the rest of the code handling persistance to this database, using the<strong> Code First approach</strong>.</li>
<li>In case you already have the database, EF can generate the code using the <strong>Database First approach</strong>.</li>
<li><strong>EF uses </strong><strong>Plain .Net objects (POCOs)</strong> with navigational properties to implement your model. Very easy stuff. The way EF lets you interact with the data once it’s retrieved from the DB is piece of cake (not the fact of data retrieval itself, that can get tricky).</li>
<li><strong>Automatic code generation</strong> with T4 templates. Once you have EF set up in your project, there’s a bunch of templates to generate a lot of code for you. That doesn’t mean you must use it, but it’s there for your convenience, in case you think some templates can help you. Me myself I use some of the T4 templates, but not all of them. There’s some things I actually prefer doing manually.</li>
<li><strong>Self-tracking entities</strong> will greatly simplify the process of implementing an over-the-wire scenario, in which you have different layers spanning across different systems and you have to serialize and de-serialize your entities. EF makes this really easy.</li>
<li><strong>Local caching</strong>, to speed up your data access.</li>
<li><strong>Lazy loading</strong>, which can improve overall application performance.</li>
<li>Support for <strong>LINQ</strong> (both coming from Microsoft, you would expect this, right?).</li>
<li><strong>Convention over configuration.</strong> The hottest trend in software development. You wouldn’t think EF would miss it, would you? When starting up a new project with EF, the only thing you need to configure are the database server and its name. Nothing else. All other things are taken care of for you. Of course, if you want more control over what EF is doing, you can tweak it to meet your criteria. But that isn’t something you have do right at the beginning. This way, you can be productive much faster.</li>
<li><strong>Support for the major databases</strong>: MS SQL Server (of course), Oracle, MySQL, PostgreSQL, etc…</li>
</ul>
<p>And last but not least:</p>
<ul>
<li>Coming from a big player in the industry like Microsoft, Entity Framework has great resources and a great community behind it. If you ever have a problem with EF, or want to tweak its behavior, chances are you’ll be finding what you need really fast. If you’re a seasoned developer, you’ll find this is one of the most important features of EF.</li>
</ul>
<p>If you haven’t tried it out yet, don’t wait any longer and <a href="http://msdn.microsoft.com/en-us/library/bb399572.aspx">see for yourself what I’m talking about!</a></p>


<h4>Related posts:</h4><p><ol><li><a href='http://www.undisciplinedbytes.com/2012/03/creating-a-timestamp-column-with-entity-framework/' rel='bookmark' title='Permanent Link: Creating a Timestamp column with Entity Framework'>Creating a Timestamp column with Entity Framework</a></li>
<li><a href='http://www.undisciplinedbytes.com/2012/02/things-to-consider-when-using-entity-framework/' rel='bookmark' title='Permanent Link: Things to consider when using Entity Framework'>Things to consider when using Entity Framework</a></li>
<li><a href='http://www.undisciplinedbytes.com/2011/12/persistence-layer-object-relational-mapping-tools/' rel='bookmark' title='Permanent Link: Persistance layer: object-relational mapping tools'>Persistance layer: object-relational mapping tools</a></li>
<li><a href='http://www.undisciplinedbytes.com/2011/03/which-database-to-use-for-a-personal-project/' rel='bookmark' title='Permanent Link: Which database to use for a personal project?'>Which database to use for a personal project?</a></li>
<li><a href='http://www.undisciplinedbytes.com/2010/01/sluggish-database-view-materialize-it/' rel='bookmark' title='Permanent Link: Sluggish database view? Materialize it!'>Sluggish database view? Materialize it!</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.undisciplinedbytes.com/2012/01/entity-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.NET 4.5 and Visual Studio 11</title>
		<link>http://www.undisciplinedbytes.com/2012/01/asp-net-4-5-and-visual-studio-11/</link>
		<comments>http://www.undisciplinedbytes.com/2012/01/asp-net-4-5-and-visual-studio-11/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 08:45:27 +0000</pubDate>
		<dc:creator>Oliver Mezquita</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.undisciplinedbytes.com/?p=674</guid>
		<description><![CDATA[Back in September 2011 the next versions of ASP.NET and Visual Studio were announced. Microsoft has set up a page informing about all of the new features we can find in them. Check them out:


ASP.NET Core Runtime and Framework

Asynchronously Reading and Writing HTTP Requests and Responses.
Improvements to HttpRequest handling
Asynchronously flushing a response
Support for await and [...]]]></description>
			<content:encoded><![CDATA[<p>Back in September 2011 the next versions of ASP.NET and Visual Studio were announced. Microsoft has set up <a href="http://www.asp.net/vnext/overview/whitepapers/whats-new#_Toc303354469" target="_blank">a page informing about all of the new features</a> we can find in them. Check them out:</p>
<p><span id="more-674"></span></p>
<ul>
<li><strong>ASP.NET Core Runtime and Framework</strong>
<ul>
<li>Asynchronously Reading and Writing HTTP Requests and Responses.</li>
<li>Improvements to HttpRequest handling</li>
<li>Asynchronously flushing a response</li>
<li>Support for <em>await</em> and <em>Task</em>-Based Asynchronous Modules and Handlers</li>
<li>Asynchronous HTTP modules</li>
<li>Asynchronous HTTP handlers</li>
<li>New ASP.NET Request Validation Features</li>
<li>Deferred (&#8221;lazy&#8221;) request validation</li>
<li>Support for unvalidated requests</li>
<li>Anti-XSS Library</li>
<li>Support for WebSockets Protocol</li>
<li>Bundling and Minification</li>
<li>Performance Improvements for Web Hosting
<ul>
<li>Key Performance Factors</li>
<li>Requirements for New Performance Features</li>
<li>Sharing Common Assemblies</li>
<li>Using multi-Core JIT compilation for faster startup</li>
<li>Tuning garbage collection to optimize for memory</li>
<li>Prefetching for web applications</li>
</ul>
</li>
</ul>
</li>
<li><strong>ASP.NET Web Forms</strong>
<ul>
<li>Strongly Typed Data Controls</li>
<li>Model Binding
<ul>
<li>Selecting data</li>
<li>Value providers</li>
<li>Filtering by values from a control</li>
</ul>
</li>
<li>HTML Encoded Data-Binding Expressions</li>
<li>Unobtrusive Validation</li>
<li>HTML5 Updates</li>
</ul>
</li>
<li><strong>ASP.NET MVC 4 </strong></li>
<li><strong>ASP.NET Web Pages 2</strong>
<ul>
<li>New and Updated Site Templates</li>
<li>Improved Input Validation</li>
<li>Resource Management</li>
<li>Enhanced Membership and Authentication</li>
<li>Side-by-side Execution</li>
<li>Mobile Device Rendering</li>
<li>The Maps Helper</li>
</ul>
</li>
<li><strong>Visual Web Developer 11 Developer Preview.</strong>
<ul>
<li>HTML Editor
<ul>
<li>Smart Tasks</li>
<li>WAI-ARIA support</li>
<li>New HTML5 snippets</li>
<li>Extract to user control</li>
<li>IntelliSense for code nuggets in attributes</li>
<li>Automatic renaming of matching tag when you rename an opening or closing tag</li>
<li>Event handler generation</li>
<li>Smart indent</li>
<li>Auto-reduce statement completion</li>
</ul>
</li>
<li>JavaScript Editor
<ul>
<li>Code outlining</li>
<li>Brace matching</li>
<li>Go to Definition</li>
<li>ECMAScript5 support</li>
<li>DOM IntelliSense</li>
<li>VSDOC signature overloads</li>
<li>Implicit references</li>
</ul>
</li>
<li>CSS Editor
<ul>
<li>Auto-reduce statement completion</li>
<li>Hierarchical indentation</li>
<li>CSS hacks support</li>
<li>Vendor specific schemas (-moz-, -webkit)</li>
<li>Commenting and uncommenting support</li>
<li>Color picker</li>
<li>Snippets</li>
<li>Custom regions</li>
</ul>
</li>
<li>Page Inspector</li>
<li>Publishing
<ul>
<li>Publish profiles</li>
<li>ASP.NET precompilation and merge</li>
</ul>
</li>
<li>IIS Express</li>
</ul>
</li>
</ul>
<p>These are developer previews, which mean that they should be used for <strong>testing purposes only, and never in production environments</strong> – not yet, at least.</p>
<p>In case you’re interested, Microsoft’s central hub for ASP.NET’s next version articles is <a href="http://www.asp.net/vnext" target="_blank">ASP.NET vNext section</a>.</p>
<p>Via <a title="ASP.NET" href="http://www.asp.net/" target="_blank">Microsoft&#8217;s ASP.NET web site</a>.</p>


<h4>Related posts:</h4><p><ol><li><a href='http://www.undisciplinedbytes.com/2010/02/how-to-make-an-ajax-call-using-jquery-and-asp-net-i/' rel='bookmark' title='Permanent Link: Different ways to use AJAX in ASP.NET'>Different ways to use AJAX in ASP.NET</a></li>
<li><a href='http://www.undisciplinedbytes.com/2010/02/php-or-asp-net/' rel='bookmark' title='Permanent Link: PHP or ASP.NET?'>PHP or ASP.NET?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.undisciplinedbytes.com/2012/01/asp-net-4-5-and-visual-studio-11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Persistance layer: object-relational mapping tools</title>
		<link>http://www.undisciplinedbytes.com/2011/12/persistence-layer-object-relational-mapping-tools/</link>
		<comments>http://www.undisciplinedbytes.com/2011/12/persistence-layer-object-relational-mapping-tools/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 10:36:16 +0000</pubDate>
		<dc:creator>Oliver Mezquita</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.undisciplinedbytes.com/?p=242</guid>
		<description><![CDATA[Nowadays it&#8217;s very usual to work with object-oriented programming and relational data bases. Relational data bases are all about tables, relations and groups. However, the object-oriented programming paradigm consists of objects, attributes and inter-object relationships. When these objects need to be stored using a relational data base, it&#8217;s very obvious that these two models of [...]]]></description>
			<content:encoded><![CDATA[<p>Nowadays it&#8217;s very usual to work with object-oriented programming and relational data bases. Relational data bases are all about tables, relations and groups. However, the object-oriented programming paradigm consists of objects, attributes and inter-object relationships. When these objects need to be stored using a relational data base, it&#8217;s very obvious that these two models of representing information are very different from each other. We need some kind of translation to transfer data from one to the other.</p>
<p>If we&#8217;re using objects in our application and we want to save them, we&#8217;ll probably use some data base system. We&#8217;ll most likely establish a connection to the data base, create a SQL sentence with the values of the object (or call some kind of stored procedure), and save them to some table. Easy enough, right? Well, this may seem trivial for a small object with 4 or 5 properties. Just consider an object not so small, with 40 or 50 properties. But&#8230; what happens with associations? And&#8230; what if the object itself contains some other objects? We&#8217;ll store them in the data base as well? All of them or just some? What will we do with foreign keys? We can see that, as the application gets more complex, this translation is not so trivial anymore&#8230; As a matter of fact, storing objects in the database can become a very usual source of headaches. There are some studies which state that <strong>up to 35% of code is dedicated to the role of translating data between the application and the data warehouse.</strong></p>
<p><span id="more-242"></span></p>
<p><strong> </strong></p>
<p>And this is where <strong><em>Object-Relational Mapping tools</em></strong> come into play. ORM tools applied to databases transform a DB register to a code object and vice-versa, allowing us to abstract away from writing code to directly access the database. This will speed up development and will allow us to follow the mantra of<strong> focusing on business functionalities, not on application plumbing</strong>.</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">But, what exactly can an ORM tool help me with? Well, they usually do some things like:</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">- Handle object persistance (to a database, for example). You won&#8217;t have to write code for this. And remember, less code means less bugs and less headaches.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">- Access different databases. Most of these tools support communicating with different database providers (Oracle, MS SQL Server, MySql, Postgre, etc.).</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">- Cache. Many of these tools offer some way of caching objects in memory, resulting in much faster data access.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">- Help with design. Some of these tools also provide some kind of wizar or graphical interface to aid in the design of the schema and/or database, which leads us to the following point:</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">- Create your database for you. If you have your data schema already modeled, some of these tools will not only handle how to get the data or how to write it. They can also create the database.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">So now that you&#8217;ve decided to use an ORM, take a look at the most popular ORM tools available for .NET:</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">- Linq to SQL: not really a full-blown ORM, but it does help with data access.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">- NHibernate: I would say NHibernate is one of the most mature ORM projects in .NET, and one of the most used as well.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">- Entity Framework: Microsoft&#8217;s new kid on the block. Its first version didn&#8217;t receive very positive comments, but its latest release looks very good indeed.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">In the next post I&#8217;ll be covering Entity Framework a bit. Stay tuned!</div>
<p>But, what exactly can an ORM tool helps us with? Well, they usually do some things like:</p>
<ul>
<li><strong>Handle object persistance </strong>(to a database, for example). You won&#8217;t have to write code for this. And remember, less code means less bugs and less headaches.</li>
<li><strong>Access different databases</strong>. Most of these tools support communicating with different database providers (Oracle, MS SQL Server, MySql, Postgre, etc.).</li>
<li><strong>Cache</strong>. Many of these tools offer some way of caching objects in memory, resulting in much faster data access.</li>
<li><strong>Help with design</strong>. Some of these tools also provide some kind of wizard or graphical interface to aid in the design of the schema and/or database, which leads us to the following point:</li>
<li><strong>Create your database for you</strong>. If you have your data schema already modeled, some of these tools will not only handle how to get the data or how to write it. They can also create the database.</li>
</ul>
<p>You&#8217;re already convinced to use an ORM for your project, right? Good. Now take a look at the most popular ORM tools available for .NET:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/bb425822.aspx" target="_blank">Linq to SQL</a>: not really a full-blown ORM, but it does help with data access.</li>
<li><a href="http://nhforge.org/" target="_blank">NHibernate</a>: I would say NHibernate is one of the most mature ORM projects in .NET, and one of the most used as well.</li>
<li><a href="http://msdn.microsoft.com/en-us/data/aa937723.aspx" target="_blank">Entity Framework</a>: Microsoft&#8217;s new kid on the block. Its first version didn&#8217;t receive very positive comments, but its latest release looks very good indeed.</li>
<li><a href="http://www.llblgen.com/defaultgeneric.aspx" target="_blank">LLBLGen Pro</a>: very mature project, although it&#8217;s not the simplest of all.</li>
<li><a href="http://dataobjects.net/" target="_blank">DataObjects.Net</a>: quite new, but very promising. It already has a lot of interesting features. Definetely worth taking a look at.</li>
</ul>
<p>In the next post I&#8217;ll be covering Entity Framework a bit. Stay tuned!</p>


<h4>Related posts:</h4><p><ol><li><a href='http://www.undisciplinedbytes.com/2012/02/things-to-consider-when-using-entity-framework/' rel='bookmark' title='Permanent Link: Things to consider when using Entity Framework'>Things to consider when using Entity Framework</a></li>
<li><a href='http://www.undisciplinedbytes.com/2012/01/entity-framework/' rel='bookmark' title='Permanent Link: Entity Framework'>Entity Framework</a></li>
<li><a href='http://www.undisciplinedbytes.com/2012/03/creating-a-timestamp-column-with-entity-framework/' rel='bookmark' title='Permanent Link: Creating a Timestamp column with Entity Framework'>Creating a Timestamp column with Entity Framework</a></li>
<li><a href='http://www.undisciplinedbytes.com/2011/04/some-open-source-projects-for-net-you-should-take-a-look-at/' rel='bookmark' title='Permanent Link: Some open source projects for .NET you should take a look at'>Some open source projects for .NET you should take a look at</a></li>
<li><a href='http://www.undisciplinedbytes.com/2011/03/which-database-to-use-for-a-personal-project/' rel='bookmark' title='Permanent Link: Which database to use for a personal project?'>Which database to use for a personal project?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.undisciplinedbytes.com/2011/12/persistence-layer-object-relational-mapping-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parallel programming with .NET</title>
		<link>http://www.undisciplinedbytes.com/2011/09/parallel-programming-with-net/</link>
		<comments>http://www.undisciplinedbytes.com/2011/09/parallel-programming-with-net/#comments</comments>
		<pubDate>Mon, 26 Sep 2011 10:35:25 +0000</pubDate>
		<dc:creator>Oliver Mezquita</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.undisciplinedbytes.com/2011/02/parallel-programming-with-net/</guid>
		<description><![CDATA[When I’m talking to people about the new things that Visual Studio 2010 and ASP.NET 4.0 bring, and the easy it is to write code to be executed in parallel, many people just don’t care. They see it as if it wasn’t related to them. It’s true that some kind of applications don’t really need [...]]]></description>
			<content:encoded><![CDATA[<p>When I’m talking to people about the new things that Visual Studio 2010 and ASP.NET 4.0 bring, and the easy it is to write code to be executed in parallel, many people just don’t care. They see it as if it wasn’t related to them. It’s true that some kind of applications don’t really need this type of optimization… but that’s not an excuse to try to take advantage of our hardware as much as possible.  From several years ago the most common thing in any computer is to have at least two processor cores. As a matter of fact, we’re starting to see now desktop computers with 8-core processors. The trend is to have an ever-increasing number of cores in our computers. This means that any application will have the chance to work in an environment where more than one thread can be executed simultaneously.  Besides, nowadays if you want your software to perform faster, you can no longer just move it to a machine with a faster processor and forget about it. We’re approaching the maximum speed a processor can get, so improvements in next CPUs will come from the side of more threads, not a higher clock-rate.  I think parallel programming  is a key concept all programmers should care about.  ASP.NET 4.0 and Visual Studio 2010 bring new libraries, types and tools to ease multi-core development. ASP.NET 4.0 includes the new “Parallel Extensions”, which are formed by:</p>
<p><span id="more-565"></span></p>
<ul>
<li>Task Parallel Library: this new library, included in the namespace System.Threading.Tasks.Parallel, has new elements to execute tasks in parallel automatically. It’s got, for example, a parallel <em>For</em> loop, and a parallel <em>ForEach</em> loop.</li>
<li>Parallel LINQ Execution Engine: as you can guess, it’s a parallelized version of Linq to Objects. It’s the same thing, except that it will run in parallel whenever possible.</li>
<li>Coordination Data Structures: it’s a set of primitives for sincronization and thread-safe collections. For example, we have thread-safe dictionaries, stacks and buffers, and special objects for thread sincronization, such as <em>SpinWait</em> or <em>SpinLock</em>.</li>
</ul>
<p>Now, the good part about these parallel extensions is that it gets extremely easy to do parallel programming. Just by using these new features, your code will escalate to use as many parallel threads as possible. For example, in a machine with just one processor all your code will execute sequentially, just as always. But, in an 8-core-processor computer, your code will be broken down into 8 different threads, and they all will execute your code in parallel –assuming all 8 cores are available, of course.  You can learn more <a href="http://msdn.microsoft.com/en-us/library/dd460693.aspx" target="_blank">this article</a> from MSDN.</p>


<h4>Related posts:</h4><p><ol><li><a href='http://www.undisciplinedbytes.com/2011/12/persistence-layer-object-relational-mapping-tools/' rel='bookmark' title='Permanent Link: Persistance layer: object-relational mapping tools'>Persistance layer: object-relational mapping tools</a></li>
<li><a href='http://www.undisciplinedbytes.com/2012/01/asp-net-4-5-and-visual-studio-11/' rel='bookmark' title='Permanent Link: ASP.NET 4.5 and Visual Studio 11'>ASP.NET 4.5 and Visual Studio 11</a></li>
<li><a href='http://www.undisciplinedbytes.com/2012/01/entity-framework/' rel='bookmark' title='Permanent Link: Entity Framework'>Entity Framework</a></li>
<li><a href='http://www.undisciplinedbytes.com/2012/02/things-to-consider-when-using-entity-framework/' rel='bookmark' title='Permanent Link: Things to consider when using Entity Framework'>Things to consider when using Entity Framework</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.undisciplinedbytes.com/2011/09/parallel-programming-with-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Test-driven development</title>
		<link>http://www.undisciplinedbytes.com/2011/07/test-driven-development/</link>
		<comments>http://www.undisciplinedbytes.com/2011/07/test-driven-development/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 09:09:20 +0000</pubDate>
		<dc:creator>Oliver Mezquita</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.undisciplinedbytes.com/?p=575</guid>
		<description><![CDATA[Surprisingly, there’s many programmers who still don’t know what Test-driven development (TDD) is. I think it’s a very important practice that all of us should follow, since it produces software with many less bugs.
TDD is a programming methodology that involves two other practices: test first development, and refactoring. First a set of unit tests is [...]]]></description>
			<content:encoded><![CDATA[<p>Surprisingly, there’s many programmers who still don’t know what Test-driven development (TDD) is. I think it’s a very important practice that all of us should follow, since it produces software with many less bugs.</p>
<p>TDD is a programming methodology that involves two other practices: test first development, and refactoring. First a set of unit tests is written and verified to fail. Then, code to make them pass must be written, and lastly this code is refactored. The aim of TDD is to achieve clean code that works. The main idea around this methodology is that requirements must be translated into automated tests: thus, when these tests pass, all requirements are guaranteed to have been accomplished. The application to be developed must be flexible enough to allow automated tests to be run. Each test should be small enough to exactly determine which piece of code is failing.</p>
<p><span id="more-575"></span></p>
<p><strong>Test-driven development cycle</strong></p>
<p>Once a set of requirements has been defined, a new cycle starts:</p>
<ol>
<li>Choose a requirement: select a requirement you understand and about which you can write code both to test it and to implement it.</li>
<li>Write a test: the first code you must write is a test to determine whether the requirement is met, accessing the code through its interfaces. This step makes the programmer consider the problem from the client perspective.</li>
<li>Verify the test fails: if the test doesn’t fail it’s because this requirement is already implemented, or because the test is incorrect.</li>
<li>Write the implementation: Write the simplest code that will make the test pass. Follow the KISS philosophy (<em>Keep It Simple, Stupid!</em>).</li>
<li>Run the automated test: Verify whether the whole set of tests are passed.</li>
<li>Refactor: usually used to take out duplicate code. Each change should be made in small increments, and with each increment the tests should be re-run.</li>
<li>Update the requirements list: once the requirement is met mark it as done. Besides, add more requirements that may have been detected in this cycle or design requirements, like, for example, some functionality that has been decoupled from another one.</li>
</ol>
<p>Having a repository of tests makes another good practice easier: frequent integration. Integrating our work frequently with the rest of the team allows us to check whether our code is compatible with the rest of the application, and makes it easier to detect bugs in an early phase. It is much easier and cheaper to fix bugs every few hours than facing enormous problems close to a release date.</p>
<p>Generation of tests for each functionality means that programmers can trust the code. This means that we can make big modifications deep in the core of the system that we would otherwise avoid, since we can be certain that, as long as all the tests pass, the code works as intended and the requirements are still met.</p>
<p>Another thing to keep in mind is that programmers must make the unit tests fail. Unit tests must be tested. The idea is to be sure that unit tests really work, and that they’re able to pick up an error whenever it happens.</p>
<h4>Advantages</h4>
<p>Programmers that use test-driven development from the beginning of a project find that they seldom have the necessity to use a debugger. In the few occasions that a bug is discovered, it is very easy to fix.</p>
<p>Despite of the high initial requirements of this methodology, TDD may provide a great added value to the software development process, producing higher-quality applications in less time. TDD not only offers a simple requirements validation: it can also lead the design of a program. By writing unit tests, a programmer must imagine how customers will be using the functionality, which may avoid some misinterpretations or bad implementations of a functionality.</p>
<h4>Limitations</h4>
<p>In order to follow the test-driven development methodology, tests must be automated. This may turn out to be rather complex in the following situations:</p>
<ul>
<li>Graphical User Interfaces, although there are some partial solutions proposed.</li>
<li>Distributed Objects, even though Mock Objects may help.</li>
<li>Data bases: writing tests that work with data bases is quite complex, since you need to put some known data before, and you have to verify that the contents of the database is the expected once the test is done. This makes these kinds of tests costly to develop.</li>
</ul>
<p>Test-driven development is a programming methodology that should be in place in all organizations that develop software and consider themselves serious. Unfortunately, this is not the case. I hope things start to change in the near future!</p>


<h4>Related posts:</h4><p><ol><li><a href='http://www.undisciplinedbytes.com/2010/07/improving-software-quality-automatic-testing/' rel='bookmark' title='Permanent Link: Improving software quality: automatic testing'>Improving software quality: automatic testing</a></li>
<li><a href='http://www.undisciplinedbytes.com/2010/10/gui-testing/' rel='bookmark' title='Permanent Link: GUI Testing'>GUI Testing</a></li>
<li><a href='http://www.undisciplinedbytes.com/2010/08/unit-testing/' rel='bookmark' title='Permanent Link: Unit testing'>Unit testing</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.undisciplinedbytes.com/2011/07/test-driven-development/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Some open source projects for .NET you should take a look at</title>
		<link>http://www.undisciplinedbytes.com/2011/04/some-open-source-projects-for-net-you-should-take-a-look-at/</link>
		<comments>http://www.undisciplinedbytes.com/2011/04/some-open-source-projects-for-net-you-should-take-a-look-at/#comments</comments>
		<pubDate>Tue, 12 Apr 2011 12:49:52 +0000</pubDate>
		<dc:creator>Oliver Mezquita</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.undisciplinedbytes.com/?p=569</guid>
		<description><![CDATA[We all agree that ASP.NET and Visual Studio are amazing technologies with state-of-the-art tools. One requires almost nothing more to write any kind of software – except for a database. However, there are some tools that greatly simplify that task. It depends on what you’re trying to achieve, but I’m sure some of these projects [...]]]></description>
			<content:encoded><![CDATA[<p>We all agree that ASP.NET and Visual Studio are amazing technologies with state-of-the-art tools. One requires almost nothing more to write any kind of software – except for a database. However, there are some tools that greatly simplify that task. It depends on what you’re trying to achieve, but I’m sure some of these projects will help you get your tasks accomplished faster and easier:</p>
<ul>
<li><a href="http://nhforge.org/Default.aspx" target="_blank">NHibernate</a>: NHibernate is a mature, open source object-relational mapper for the .NET framework. It&#8217;s actively developed, fully featured and used in thousands of successful projects.</li>
<li><a href="http://www.nunit.org/index.php" target="_blank">NUnit</a>: NUnit is a unit-testing framework for all .Net languages, initially ported from  JUnit. It is written entirely in C# and has been completely redesigned to take advantage of many .NET language features, for example custom attributes and other reflection related capabilities. NUnit brings xUnit to all .NET languages</li>
<li><a href="http://jquery.com/" target="_blank">jQuery</a>: jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript.</li>
<li><a href="http://ayende.com/projects/rhino-mocks.aspx" target="_blank">Rhino.Mocks</a>: A dynamic mock object framework for the .Net platform. It&#8217;s purpose is to ease testing by allowing the developer to create mock implementations of custom objects and verify the interactions using unit testing.</li>
<li><a href="http://www.codeplex.com/MVCContrib" target="_blank">MVC Contrib</a>: This is the contrib project for the ASP.NET MVC framework. This project adds additional functionality on top of the MVC Framework. These enhancements can increase your productivity using the MVC Framework. It is written in C#. Founded by Eric Hexter and Jeffrey Palermo.</li>
<li><a href="http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET" target="_blank">CruiseControl.NET</a>: CruiseControl.NET is an Automated Continuous Integration server, implemented using the Microsoft .NET Framework.</li>
<li><a href="http://code.google.com/p/sharp-architecture/" target="_blank">S#arp Architecture</a>: Pronounced &#8220;Sharp Architecture,&#8221; this is a solid architectural foundation for rapidly building maintainable web applications leveraging the ASP.NET MVC framework with NHibernate. The primary advantage to be sought in using any architectural framework is to decrease the code one has to write while increasing the quality of the end product. A framework should enable developers to spend little time on infrastructure details while allowing them to focus their attentions on the domain and user experience.</li>
<li><a href="http://sparkviewengine.com/" target="_blank">Spark View Engine</a>: <strong></strong>Spark is a view engine for Asp.Net Mvc and Castle Project MonoRail frameworks. The idea is to allow the html to dominate the flow and the code to fit seamlessly.</li>
<li><a href="http://tortoisesvn.tigris.org/" target="_blank">TortoiseSVN</a>: <strong></strong>A Subversion client, implemented as a windows shell extension. TortoiseSVN is a really easy to use Revision control / version control / source control software for Windows. Since it&#8217;s not an integration for a specific IDE you can use it with whatever development tools you like.</li>
<li><a href="http://www.castleproject.org/container/index.html" target="_blank">Castle Windsor</a>: Castle Project offers two Inversion of Control Containers. The MicroKernel and the Windsor Container. Castle Windsor aggregates the MicroKernel  and exposes a powerful configuration support. It is suitable for common enterprise application needs. It is able to register facilities and components based on the configuration and adds support for interceptors.</li>
</ul>
<p>Take a look at these projects. I&#8217;m sure you’ll be able to find some good use for them in your projects!</p>
<p>Via <a href="http://dotnet.dzone.com/articles/t0p-10-open-source-projects" target="_blank">.NET Zone</a>.</p>


<h4>Related posts:</h4><p><ol><li><a href='http://www.undisciplinedbytes.com/2009/10/open-source-software/' rel='bookmark' title='Permanent Link: Open Source Software'>Open Source Software</a></li>
<li><a href='http://www.undisciplinedbytes.com/2010/08/unit-testing/' rel='bookmark' title='Permanent Link: Unit testing'>Unit testing</a></li>
<li><a href='http://www.undisciplinedbytes.com/2011/12/persistence-layer-object-relational-mapping-tools/' rel='bookmark' title='Permanent Link: Persistance layer: object-relational mapping tools'>Persistance layer: object-relational mapping tools</a></li>
<li><a href='http://www.undisciplinedbytes.com/2010/07/improving-software-quality-automatic-testing/' rel='bookmark' title='Permanent Link: Improving software quality: automatic testing'>Improving software quality: automatic testing</a></li>
<li><a href='http://www.undisciplinedbytes.com/2011/09/parallel-programming-with-net/' rel='bookmark' title='Permanent Link: Parallel programming with .NET'>Parallel programming with .NET</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.undisciplinedbytes.com/2011/04/some-open-source-projects-for-net-you-should-take-a-look-at/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Which database to use for a personal project?</title>
		<link>http://www.undisciplinedbytes.com/2011/03/which-database-to-use-for-a-personal-project/</link>
		<comments>http://www.undisciplinedbytes.com/2011/03/which-database-to-use-for-a-personal-project/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 14:03:16 +0000</pubDate>
		<dc:creator>Oliver Mezquita</dc:creator>
				<category><![CDATA[backend]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.undisciplinedbytes.com/?p=458</guid>
		<description><![CDATA[When starting a new project, the choice of which database to use usually boils down to the one the company usually uses. The systems that are usually considered are just Oracle and Microsoft’s SQL server (MS-SQL). There’s no doubt that big bucks companies have the resources to make the best-of-its-breed products, and almost no other [...]]]></description>
			<content:encoded><![CDATA[<p>When starting a new project, the choice of which database to use usually boils down to the one the company usually uses. The systems that are usually considered are just Oracle and Microsoft’s SQL server (MS-SQL). There’s no doubt that big bucks companies have the resources to make the best-of-its-breed products, and almost no other database system comes close to what Oracle and MS-SQL can offer in terms of quality, features, and highly skilled professionals around their products. Yes, all this is true, but there’s a price. And usually this price tag can only be afforded by a company, not by a sole individual.</p>
<p>So, what if I want to develop my own personal project and I require a RDBMS (<em>Relational DataBase Management System</em>)? Oracle and MS-SQL are out of the question because of their high cost. MS-SQL Express has great limitations, so, although it is free, we won’t be considering it for our purpose. Which is the best open source RDBMS?</p>
<p><span id="more-458"></span></p>
<p>Today’s most known open source RDBMS are MySQL and PostgreSQL. PostgreSQL is considered to beat MySQL in the features war. This used to be true some time ago, but it’s no longer the case anymore. 99% of the needs you will have with your RDBMS will be covered by both MySQL and PostgreSQL. Still, there’s many people who think that MySQL has improved a lot, but it’s just not PostgreSQL.</p>
<p>If you want to compare performance, fans of both systems will tell you their RDBMS is faster than the other one. On one hand, PostgreSQL has been recently paying attention to speed, and has been making its product faster and faster with every release. On the other hand, MySQL proponents say that, if configured properly, MySQL’s MyISAM tables are indeed lightweight and make for a faster database.</p>
<p>But probably, the most important thing to consider when choosing which RDBMS you should use, is which one is easier to use. I can tell you that previous Oracle experience will make you feel at home and comfortable with PostgreSQL. Still, the MySQL community seems to be much bigger than PostgreSQL’s, so, should you require some assistance when developing your project, if you’re using MySQL chances are that you will get quick help from them.</p>
<p>MySQL is licensed under the GNU GPL, but offers an alternative commercial license for those who don’t want to be restricted by that license. PostgreSQL uses the BSD license, which stipulates that the credits have to be maintained, but beyond that you can do whatever you want with it.</p>
<p>But, after all, it just all comes down to personal tastes. Just choose whatever you like and whichever you think might fit your needs better. What might be the best for one person, might be a bad choice for another.</p>
<p>Check these links for more info:</p>
<ul>
<li><a href="http://www.devx.com/dbzone/Article/29480" target="_blank">Open Source Database Feature Comparison Matrix</a></li>
<li><a href="http://en.wikipedia.org/wiki/Comparison_of_relational_database_management_systems" target="_blank">Comparison of RDBMS</a></li>
</ul>


<h4>Related posts:</h4><p><ol><li><a href='http://www.undisciplinedbytes.com/2010/01/sluggish-database-view-materialize-it/' rel='bookmark' title='Permanent Link: Sluggish database view? Materialize it!'>Sluggish database view? Materialize it!</a></li>
<li><a href='http://www.undisciplinedbytes.com/2012/01/entity-framework/' rel='bookmark' title='Permanent Link: Entity Framework'>Entity Framework</a></li>
<li><a href='http://www.undisciplinedbytes.com/2011/12/persistence-layer-object-relational-mapping-tools/' rel='bookmark' title='Permanent Link: Persistance layer: object-relational mapping tools'>Persistance layer: object-relational mapping tools</a></li>
<li><a href='http://www.undisciplinedbytes.com/2012/03/creating-a-timestamp-column-with-entity-framework/' rel='bookmark' title='Permanent Link: Creating a Timestamp column with Entity Framework'>Creating a Timestamp column with Entity Framework</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.undisciplinedbytes.com/2011/03/which-database-to-use-for-a-personal-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript best practices II</title>
		<link>http://www.undisciplinedbytes.com/2011/02/javascript-best-practices-ii/</link>
		<comments>http://www.undisciplinedbytes.com/2011/02/javascript-best-practices-ii/#comments</comments>
		<pubDate>Tue, 22 Feb 2011 10:35:08 +0000</pubDate>
		<dc:creator>Oliver Mezquita</dc:creator>
				<category><![CDATA[browser]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.undisciplinedbytes.com/?p=552</guid>
		<description><![CDATA[We’ve seen some basic recommendations we should all follow when writing  JavaScript. Now let’s go through some more:


Comment as much as needed, but no more: comment what you consider needed,  but don’t tell others your life story. Too many comments may make some other  developer get distracted from the actual code.
Javascript is [...]]]></description>
			<content:encoded><![CDATA[<p>We’ve seen some basic recommendations we should all follow when writing  JavaScript. Now let’s go through some more:</p>
<p><span id="more-552"></span></p>
<ul>
<li>Comment as much as needed, but no more: comment what you consider needed,  but don’t tell others your life story. Too many comments may make some other  developer get distracted from the actual code.</li>
<li>Javascript is used to define the behaviour, not the look &amp; feel: even  though there’s the possibility to set the appearance of your application through  JavaScript, you should leave that for CSS. Always follow the “separation of  concerns” mantra. A change in the icons or the color of borders shouldn’t  require dealing with JavaScript code.</li>
<li>Modularize: keep your code modularized and specialized. Make sure to write  smaller, generic helper functions that fulfill one specific task, rather than  catch-all methods.</li>
<li>Allow for configuration and translation: everything that is likely to change  in your code should not be scattered throughout the code, for example, labels,  CSS classes and IDs. By putting these into a configuration object and making it  public, we make maintenance very easy and allow for customization.</li>
<li>Access the DOM as little as possible: accessing the DOM in browsers is an  expensive thing to do. The DOM is a very complex API and rendering in browsers  can take up a lot of time. To make sure that your code is fast and doesn’t slow  down the browser to a halt try to keep DOM access to a bare minimum.</li>
<li>Build on the shoulders of giants: JavaScript libraries are specifically  built to make browsers behave as you would expect by plugging browser holes.  Therefore, if you want to write code that works without keeping the maintenance  overhead of supporting current browsers and those to come, start with a good  library.</li>
<li>Development code is not live code: live code is done for machines,  development code is done for humans. Make your code as readable and  understandable as possible. Then, before deploying your web application,  collate, minify and optimize your code in a build process.</li>
</ul>
<p>If you follow all these recommendations, you can be sure you’ll have produced  a high quality code that will be easy to maintain.</p>


<h4>Related posts:</h4><p><ol><li><a href='http://www.undisciplinedbytes.com/2011/01/javascript-best-practices-i/' rel='bookmark' title='Permanent Link: JavaScript best practices I'>JavaScript best practices I</a></li>
<li><a href='http://www.undisciplinedbytes.com/2009/10/javascript-frameworks-overview/' rel='bookmark' title='Permanent Link: Javascript frameworks overview'>Javascript frameworks overview</a></li>
<li><a href='http://www.undisciplinedbytes.com/2010/12/object-oriented-javascript-i-the-basics/' rel='bookmark' title='Permanent Link: Object Oriented JavaScript I: the basics'>Object Oriented JavaScript I: the basics</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.undisciplinedbytes.com/2011/02/javascript-best-practices-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

