<?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, 09 Mar 2010 14:56:18 +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>AJAX call using an ASP.NET web page</title>
		<link>http://www.undisciplinedbytes.com/2010/03/ajax-call-using-an-asp-net-web-page/</link>
		<comments>http://www.undisciplinedbytes.com/2010/03/ajax-call-using-an-asp-net-web-page/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 14:56:18 +0000</pubDate>
		<dc:creator>Oliver Mezquita</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.undisciplinedbytes.com/?p=336</guid>
		<description><![CDATA[We already saw what an AJAX call is and the different types there are. Today we’re going to see how to perform an AJAX call using a regular web page at the server. The page will be the connection between the client’s web browser and the server. It will take care of performing the operations [...]]]></description>
			<content:encoded><![CDATA[<p>We already saw what an <a title="AJAX calls" href="http://www.undisciplinedbytes.com/2010/02/how-to-make-an-ajax-call-using-jquery-and-asp-net-i/" target="_blank">AJAX call is and the different types there are</a>. Today we’re going to see how to perform an AJAX call using a regular web page at the server. The page will be the connection between the client’s web browser and the server. It will take care of performing the operations at the server (let it be some kind of processes or calculations, or just a regular database access).</p>
<p>I’ll be using <a title="jQuery" href="http://jquery.com/" target="_blank">jQuery</a> in this example. <strong>jQuery is a superb </strong><a title="Javascript frameworks" href="http://www.undisciplinedbytes.com/2009/10/javascript-frameworks-overview/" target="_blank">Javascript framework</a>, and is the one I use the most. If you don’t know what it is yet, then the first thing you should do is getting acquainted with it. This JavaScript framework has <a title="jQuery functions to make an AJAX call" href="http://docs.jquery.com/Ajax" target="_blank">many convenient functions to make an AJAX</a> call. These functions hide much of the complexity of an AJAX call: you can forget about the <a title="XMLHttpRequest" href="http://en.wikipedia.org/wiki/XMLHttpRequest" target="_blank">XMLHttpRequest</a> object if you wish, and only worry about what to do with the data once you get it back from the server.</p>
<p><span id="more-336"></span></p>
<p>So, in order to perform an AJAX request, we’ll follow these steps:</p>
<ol>
<li>We’ll perform an AJAX call from the client, using Javascript. As I said before, we’ll be using jQuery. It makes the process much easier.</li>
<li>We’ll construct some way for the server to receive the request: in this example we’ll use a regular .aspx web page.</li>
<li>We’ll fetch the data to be returned to the client. This example is just a proof of concept, so we’ll leave this task to the reader. We’ll just return the server time.</li>
<li>We’ll convert that data into JSON notation.</li>
<li>Once the data gets back to the client, the jQuery library takes care of the conversion of the string received from the server to a Javascript object.</li>
<li>In this point we’ll have the data available to us. We’ll do something with it to show it on screen, for example.</li>
</ol>
<p>Ok, we already have the theory covered. Now, let’s get to work! Start a new Visual Studio project, and get to the newly created page. On the C# codebehind of the new page we won’t be changing anything. Leave everything by default. We’ll be doing our work in the .aspx part. First, we’ll need a little bit of HTML to draw our page:</p>
<pre class="brush:xml">&lt;body&gt;
   &lt;form id="form1" runat="server"&gt;
     &lt;h2&gt;jQuery AJAX call test page&lt;/h2&gt;
     &lt;button type="button" onclick='ExecuteAJAXCall()'&gt;Get server time&lt;/button&gt;
     &lt;br /&gt;&lt;br /&gt;
     &lt;div id="DataContainer" &gt;&lt;/div&gt;
   &lt;/form&gt;
&lt;/body&gt;</pre>
<p>This is a very simple page. We’ll just have a heading, a button to perform the AJAX call, and an empty DIV to hold the data retrieved from the server.</p>
<p>Now we need some actual code to make the AJAX call:</p>
<pre class="brush:javascript">&lt;script type="text/javascript"&gt;

    function ExecuteAJAXCall() {
        $.ajax({
            url: "AJAXCall.aspx",
            dataType: 'json',
            success: Callback_AJAXCall
        });
    };

    function Callback_AJAXCall(data) {
        document.getElementById("DataContainer").innerHTML = "The time at the server is: " + data;
    };

&lt;/script&gt;</pre>
<p>Note that the first function is invoked when the button is pressed. This function is in charge of performing the AJAX call by using the jQuery framework. We’re passing three parameters to the function: the URL of the page that will get called, they type of data we’re expecting back (JSON in this case) and the javascript function to execute once the data gets back to the client. The jQuery ajax function has <a href="http://api.jquery.com/jQuery.ajax/" target="_blank">many more parameters</a>, but we didn’t need them this time since the example is not very complicated.</p>
<p>The function called when the data is returned is very simple: its only purpose is to take the string returned from the server and write it in the container we previously created for this purpose. Note that the parameter it receives, data, is already a javascript object. The AJAX call returned a simple string from the server, but the jQuery function is smart enough to convert that string to a javascript object and pass it to the function we indicated.</p>
<p>Ok, so now that we have the test page in place, let’s deal with the AJAX call server-side. The <code>AJAXCall.aspx </code>page is the link between the client web browser and the server. Here we’ll process everything we need and we’ll return a string to the client with the data requested.</p>
<p>Here is the C# codebehind from the <code>AJAXCall.aspx</code> page:</p>
<pre class="brush:csharp">using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Script.Serialization;

namespace jQueryAJAXCall
{
    public partial class AJAXCall : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e) // Returns the server current date and time
        {
            JavaScriptSerializer JSSerializer = new JavaScriptSerializer();
            string CurrentDate = DateTime.Now.ToString();
            Response.CacheControl = "no-cache";
            Response.Write(JSSerializer.Serialize(CurrentDate));
        }
    }
}</pre>
<p>Note the <code>System.Web.Script.Serialization</code> class we’re importing. This class takes care of converting the object we want to return to JSON format.</p>
<p>This page is very simple: it just takes the current date and time from the server, converts it to JSON format and returns it. Nothing more is needed. Simple enough, right? Be aware that this page must not return anything else than the JSON string: if you’re using Visual Studio be careful when creating this new webpage, as VS adds a bunch of HTML code by default in the .aspx page. Erase all HTML code, otherwise your javascript won’t be able to understand the data sent back.</p>
<p>Note the line in which we deactivate the cache. If you don’t do this, the AJAX call will always seem to return the same data, as the web browser will have kept a copy of it the first time it was executed. Most AJAX calls need the cache disabled in order to work properly.</p>
<p>So this is it! Nothing else is required. Donwload the Visual Studio project and play with it as much as you want:</p>
<p><a href="http://www.undisciplinedbytes.com/wp-content/uploads/2010/02/jQueryAJAXCall.zip">jQueryAJAXCall.zip</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>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.undisciplinedbytes.com/2010/03/ajax-call-using-an-asp-net-web-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Different ways to use AJAX in ASP.NET</title>
		<link>http://www.undisciplinedbytes.com/2010/02/how-to-make-an-ajax-call-using-jquery-and-asp-net-i/</link>
		<comments>http://www.undisciplinedbytes.com/2010/02/how-to-make-an-ajax-call-using-jquery-and-asp-net-i/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 14:53:34 +0000</pubDate>
		<dc:creator>Oliver Mezquita</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.undisciplinedbytes.com/?p=314</guid>
		<description><![CDATA[Today’s web applications are unthinkable without AJAX techniques. These techniques provide an improved user experience, and tighten the gap between traditional desktop applications and web applications. This means that mastering AJAX technologies is a must for anyone who’s doing serious web application development. In this article I’ll explain the basics of AJAX, and I will [...]]]></description>
			<content:encoded><![CDATA[<p>Today’s web applications are unthinkable without <a title="AJAX" href="http://en.wikipedia.org/wiki/AJAX" target="_blank">AJAX</a> techniques. These techniques provide an improved user experience, and tighten the gap between traditional desktop applications and web applications. This means that mastering AJAX technologies is a must for anyone who’s doing serious web application development. In this article I’ll explain the basics of AJAX, and I will show how to program some AJAX calls using ASP.NET technology.</p>
<p><span id="more-314"></span></p>
<h4>First things first: the basics</h4>
<p><a href="http://en.wikipedia.org/wiki/AJAX" target="_blank">AJAX</a> is a set of web application development techniques used to create <a href="http://en.wikipedia.org/wiki/Rich_Internet_application" target="_blank">RIA</a> (<em>Rich Internet Applications</em>). These techniques are used in the web browser at the client’s computer, while an asynchronous communication with the web server is held in the background. Thus, it is possible to make changes in the pages without the need to reload them, increasing interactivity, speed and usability in these applications, compared to traditional click-and-wait web pages.</p>
<p>An AJAX call is nothing more than a request to the server for some data. It is the same thing as when you type in a web page address in your browser’s address box and hit Enter: your browser requests the server the HTML code representing that webpage. The only difference is that with an AJAX call, all this process takes place in the background, without the user’s knowledge. It is performed programmatically, using JavaScript.</p>
<p>AJAX stands for <strong><em>Asynchronous JavaScript and XML</em></strong>, which means that in its first conception XML was used to transmit data from the server to the client. But XML is not used much anymore, <a title="JSON" href="http://en.wikipedia.org/wiki/Json" target="_blank">JSON</a> is the preferred notation for this task. JSON is a lighter notation as it uses less characters, and follows the natural syntax of the JavaScript language. This means that, once you’ve received the data from the server in your JavaScript code, it is much simpler and faster to process it if it’s in JSON notation.</p>
<p>Let’s see a couple of examples to understand it better. This would be <strong>XML</strong>:</p>
<pre class="brush:xml">&lt;Person firstName="John" lastName="Smith"&gt;
    &lt;address&gt;
      &lt;streetAddress&gt;21 2nd Street&lt;/streetAddress&gt;
      &lt;city&gt;New York&lt;/city&gt;
      &lt;state&gt;NY&lt;/state&gt;
      &lt;postalCode&gt;10021&lt;/postalCode&gt;
    &lt;/address&gt;
    &lt;phoneNumber type="home"&gt;212 555-1234&lt;/phoneNumber&gt;
    &lt;phoneNumber type="fax"&gt;646 555-4567&lt;/phoneNumber&gt;
    &lt;newSubscription&gt;false&lt;/newSubscription&gt;
    &lt;companyName /&gt;
&lt;/Person&gt;</pre>
<p>And this would be the same data transmitted in <strong>JSON</strong> notation:</p>
<pre class="brush:javascript">{
       "firstName": "John",
       "lastName": "Smith",
       "address": {
           "streetAddress": "21 2nd Street",
           "city": "New York",
           "state": "NY",
           "postalCode": 10021
       },
       "phoneNumbers": [
           { "type": "home", "number": "212 555-1234" },
           { "type": "fax", "number": "646 555-4567" }
       ],
       "newSubscription": false,
       "companyName": null
}</pre>
<p>As you can see XML is lengthier to transmit. Besides, as it is not natural to JavaScript, the data must be interpreted and translated to a JavaScript object once it gets to the client, whereas JSON must not. Don’t worry though, you won’t have to deal with converting data to JSON and back, all this is done automatically.</p>
<h4>Different ways of requesting data from the web server</h4>
<p>There are several different techniques used to retrieve data from the server using ASP.NET technology. The most common ones are:</p>
<ul>
<li><strong>URL.</strong> This is the most used technique to provide data through AJAX. Most JavaScript plugins are designed to work this way, so it can be considered the most important technique as well. At the server, this type of request can be processed using two different approaches:
<ul>
<li>The request is processed as if it was a regular web page</li>
<li>The request is processed through an HTTP Handler</li>
</ul>
</li>
<li><strong>Page method.</strong> Server methods can be easily called just by using an attribute.</li>
<li><strong>Web service.</strong> Web services can be consumed from JavaScript, providing for an easy way to request data to the server.</li>
<li><strong>Web sockets.</strong> Not quite AJAX itself, web sockets are here to revolutionize the logic behind traditional client-server communication. Web sockets bring full-duplex and server-initiated communications, two techniques not possible in the web till now. They belong to the new HTML5 specification, and as such must be treated, meaning there’s not much support for it yet.</li>
</ul>
<p>We’ll be taking a look at each of these techniques. Stay tuned!</p>


<h4>Related posts:</h4><p><ol><li><a href='http://www.undisciplinedbytes.com/2010/03/ajax-call-using-an-asp-net-web-page/' rel='bookmark' title='Permanent Link: AJAX call using an ASP.NET web page'>AJAX call using an ASP.NET web page</a></li>
<li><a href='http://www.undisciplinedbytes.com/2009/11/jquery-grid-plugin-jqgrid/' rel='bookmark' title='Permanent Link: jQuery Grid plugin: jqGrid'>jQuery Grid plugin: jqGrid</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.undisciplinedbytes.com/2010/02/how-to-make-an-ajax-call-using-jquery-and-asp-net-i/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP or ASP.NET?</title>
		<link>http://www.undisciplinedbytes.com/2010/02/php-or-asp-net/</link>
		<comments>http://www.undisciplinedbytes.com/2010/02/php-or-asp-net/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 14:58:22 +0000</pubDate>
		<dc:creator>Oliver Mezquita</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.undisciplinedbytes.com/?p=234</guid>
		<description><![CDATA[The other day a friend of mine was telling me he was going to start a new project. He wanted to develop a new web app from scratch, and was telling me he was going to use PHP. He did have experience with ASP.NET from some other projects, so I told him to use this [...]]]></description>
			<content:encoded><![CDATA[<p>The other day a friend of mine was telling me he was going to start a new project. He wanted to develop a new web app from scratch, and was telling me he was going to use PHP. He did have experience with ASP.NET from some other projects, so I told him to use this technology. But he still preferred PHP. The reasons he gave me were:</p>
<ol>
<li>PHP is free. You do not have to pay to use it. With ASP.NET you need to pay a whole bunch of licenses.</li>
<li>PHP runs faster than ASP.NET.</li>
<li>PHP hosting is cheaper.</li>
<li>Out there on the internet, you can see more PHP than ASP.NET applications.</li>
<li>There’s more CMS on PHP than on ASP.NET.</li>
</ol>
<p>Ok, he had his reasons, but I didn’t fully agree with him. So I discussed some of those ideas with him:</p>
<p><span id="more-234"></span></p>
<ol>
<li>Yes, PHP is free, like ASP.NET. Well, at least for basic stuff. I mean, the core of ASP.NET is <a href="http://www.mono-project.com/ECMA" target="_blank">standardized</a>, which means that anyone can develop a compiler/server for these specifications. As a matter of fact, the <a href="http://mono-project.com/Main_Page" target="_blank">Mono Project</a> aims to develop alternative components to replace Microsoft’s products. So far, they have released an implementation of the .NET runtime, a .NET development environment, and much more stuff. You can read more about this on <a href="http://mono-project.com/FAQ:_Licensing" target="_blank">Mono FAQ</a>.<br />
Besides, if you don’t like <a href="http://monodevelop.com/" target="_blank">MonoDevelop</a>, you can still use the free version of Microsoft’s Visual Studio: Visual Web Developer. It’s pretty much the same thing, only designed to be used just by one person coding by himself.</li>
<li>PHP is an interpreted script, while ASP.NET applications are compiled. This means that ASP.NET is way faster than PHP. Yes, you could still use some techniques to accelerate PHP (like caching), but those same techniques can be applied to ASP.NET as well, making it even faster. If you want facts, you can take a look at <a href="http://misfitgeek.com/blog/aspnet/php-versus-asp-net-ndash-windows-versus-linux-ndash-who-rsquo-s-the-fastest/" target="_blank">this comparison</a>.</li>
<li>Well, it depends. If you’re talking about installing your application in your own server, then you might need to install some windows server and IIS, and both of them cost money. Actually, Windows does cost money, but IIS is already included in the most recent versions. But, as I said before, the Mono Project provides some free alternative to that.<br />
If you’re talking about deploying your web app in some external hosting and paying a monthly fee, then it is not more expensive at all. I’ve found similar offers in both technologies… it’s not even hard to find free external hosting for both platforms – although that might not be the best experience, depending on your needs.</li>
<li>So? Other people might have some other different reasons. Or maybe they want to adopt the cheapest platform and they just don’t know that ASP.NET is standardized and that there’s open source solutions for this technology as well.</li>
<li>He might be right, the number of CMS implemented with PHP might be greater than those that use ASP.NET. But that doesn’t mean they’re better. In order to choose a CMS for your project, you should compare some of them and decide which one better fits your needs. And you can find almost identical functionality on CMS from both platforms.</li>
</ol>
<p>But I still had some more points to add:</p>
<ul>
<li>Although many of them are not free, there&#8217;s a bunch of pre-programmed controls and components you can incorporate in your web app in ASP.NET (some of them are really impressive). And many of them don&#8217;t require much effort from your part&#8230; just drag&amp;drop the component on your web app and you&#8217;re done. You can even develop your own highly-complex, highly-reusable web app controls and share them among many different apps in just a matter of minutes. This is especially useful for GUI widgets.</li>
<li>By having full access to the .NET Framework, your ASP.NET application can have all the power of any Windows app.</li>
<li>PHP is a single threaded application, while .NET framework supports multi-threading. In a highly loaded app, this can make a huge difference.</li>
</ul>
<p>I know this discussion has been going on ever since ASP.NET was first released&#8230; but I’d say that asking whether PHP or ASP.NET is better just doesn&#8217;t make sense. There’s no such thing as <em>the best language</em>. The language you should use is the one that fits your needs best in the least amount of time. For some people it will be ASP.NET, and for others it will be PHP.</p>
<p>Still, I consider the ASP.NET platform an important skill every web application developer should have. But still, the whole point here is that you can find enough reasons to prefer or dislike any of these platforms&#8230; so it just comes down to personal preferences and project requirements.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.undisciplinedbytes.com/2010/02/php-or-asp-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sluggish database view? Materialize it!</title>
		<link>http://www.undisciplinedbytes.com/2010/01/sluggish-database-view-materialize-it/</link>
		<comments>http://www.undisciplinedbytes.com/2010/01/sluggish-database-view-materialize-it/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 14:59:29 +0000</pubDate>
		<dc:creator>Oliver Mezquita</dc:creator>
				<category><![CDATA[backend]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.undisciplinedbytes.com/2010/01/sluggish-database-view-materialize-it/</guid>
		<description><![CDATA[The other day we were having some slow database view at our project. It was the main view of the new module we were developing, and it was slowing down the whole application to an unacceptable point. It was a rather complex view and could not be optimized much more. So, what was the solution [...]]]></description>
			<content:encoded><![CDATA[<p>The other day we were having some slow database view at our project. It was the main view of the new module we were developing, and it was slowing down the whole application to an unacceptable point. It was a rather complex view and could not be optimized much more. So, what was the solution we adopted? We materialized the view.</p>
<p>Regular views store just the SQL script needed to retrieve the data, and every time they are consulted the stored SQL query is executed. However, materialized views not only store the script, but the retrieved records as well, making it much faster.</p>
<p><span id="more-254"></span></p>
<p>As with regular views, the SQL script defines which data is to be retrieved. However, with materialized views this script is executed when the view is first created, and the result is physically stored in a real table. From then on, when the materialized view is accessed, the <a href="http://en.wikipedia.org/wiki/Database_management_system" target="_blank">DBMS</a> transforms the SQL sentence targeting this table instead of the more expensive procedure of actually querying all elements involved in the SQL sentence.This table can be defined with the same storage parameters used for regular tables (tablespace, etc.). Indexes can be used for materialized views as well, improving the performance even more.</p>
<p>Obviously, the greater the number of tables used, the more benefits we’ll get by using a materialized view. In our project, we were accessing 15 tables: we cut the execution time from 4 seconds to 100 ms by implementing a materialized view… this means <strong>that execution was 40 times faster!!!</strong> Now, that’s what I call optimization!</p>
<p>However, when designing a materialized view you need to keep in mind that it’s actually going to become a table with static data… and you need to specify when and how that data is going to be updated. Not taking this into account might lead the application to display outdated or incorrect data. This means that <strong>we need to evaluate the benefits and drawbacks we’ll get by using a materialized view: it might as well turn out that it slows down the whole system. </strong>So I encourage you to do some design and testing before actually deploying the view into production environment.</p>
<h4>How to build a Materialized view in Oracle</h4>
<p>This is the command used to create materialized views:</p>
<pre class="brush:sql">CREATE MATERIALIZED VIEW materialized_view_name
 [TABLESPACE ts_name]
 [PARALELL (DEGREE n)]
 [BUILD {INMEDIATE|DEFERRED}]
 [REFRESH {FAST|COMPLETE|FORCE|NEVER|ON COMMIT}]
 [{ENABLE|DISABLE} QUERY REWRITE]
AS SELECT ... FROM ... WHERE ...</pre>
<p><strong>The <em>Build</em> parameter</strong></p>
<p>If you choose the <code>BUILD INMEDIATE</code> option, the table associated with the materialized view will be populated with data at creation time. On the contrary, if you’d rather have the table populated in the moment when the first access to the view is performed, then use the <code>BUILD DEFERRED</code> option.</p>
<p><strong></p>
<p></strong></p>
<p><strong>The <em>Refresh</em> parameter</strong></p>
<p>This option indicates the mechanism Oracle will use to update the table representing the materialized view. There quite a few options here, and I would say it’s one of the most important considerations when building a materialized view. I will write a new article explaining the different updating approaches we can use to implement these views.</p>
<p><strong></p>
<p></strong></p>
<p><strong>The <em>Query Rewrite</em> parameter</strong></p>
<p>The <code>ENABLE/DISABLE QUERY REWRITE</code> option indicates whether the Oracle optimizer is allowed to rewrite SQL sentences in a way in which the materialized view will be used in the execution phase instead of the base tables included in the original SQL sentence. This is a rather complex subject, and I will dedicate a post dealing with it.</p>
<p><strong></p>
<p></strong></p>
<h4>Other DBMS</h4>
<p>This article focused on Oracle’s Materialized Views. But most DBMS implement some kind of view optimization these days. In case you’re using some other DBMS, you might be interested in searching for:</p>
<ul>
<li>Microsoft SQL Server: Indexed views.</li>
<li>DB2: Materialized query table.</li>
<li>Some other DBMS (for example MySQL and PostgreSQL) don’t have such a feature, but you can implement your own manually using triggers.</li>
</ul>
<h4>Further reading</h4>
<ul>
<li><a href="http://download.oracle.com/docs/cd/B10500_01/server.920/a96567/repmview.htm" target="_blank">Oracle Materialized View Concepts and Architecture</a></li>
<li><a href="http://technet.microsoft.com/en-us/library/cc917715.aspx" target="_blank">Microsoft SQL Server 2005 Indexed views</a></li>
<li><a href="http://publib.boulder.ibm.com/infocenter/db2luw/v8//index.jsp?topic=/com.ibm.db2.udb.doc/core/c0009318.htm" target="_blank">DB2 Materialized query table</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.undisciplinedbytes.com/2010/01/sluggish-database-view-materialize-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Software design patterns (IV): behavioral patterns</title>
		<link>http://www.undisciplinedbytes.com/2010/01/software-design-patterns-iv-behavioral-patterns/</link>
		<comments>http://www.undisciplinedbytes.com/2010/01/software-design-patterns-iv-behavioral-patterns/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 15:01:57 +0000</pubDate>
		<dc:creator>Oliver Mezquita</dc:creator>
				<category><![CDATA[Documentation]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.undisciplinedbytes.com/?p=298</guid>
		<description><![CDATA[We’ve already been through a brief introduction to design patterns, and a description of the most important creational design patterns and structural design patterns. In this article we’ll take a look at the last category of design patterns: behavioral patterns.
Behavioral design patterns are concerned with the relationships among communications using different objects. They identify common [...]]]></description>
			<content:encoded><![CDATA[<p>We’ve already been through a brief <a href="http://www.undisciplinedbytes.com/2009/12/software-design-patterns-i/" target="_blank">introduction to design patterns</a>, and a description of the most important <a href="http://www.undisciplinedbytes.com/2009/12/software-design-patterns-ii-creational-patterns/" target="_blank">creational design patterns</a> and <a href="http://www.undisciplinedbytes.com/2010/01/software-design-patterns-iii-structural-patterns/" target="_blank">structural design patterns</a>. In this article we’ll take a look at the last category of design patterns: behavioral patterns.</p>
<p>Behavioral design patterns are concerned with the relationships among <strong>communications</strong> using different objects. <strong>They identify common communication patterns and provide a well-known solution to implement this communication</strong>, offering a higher degree of flexibility.</p>
<p>The most used behavioral patterns are:</p>
<p><span id="more-298"></span></p>
<h4>Chain of responsibility</h4>
<p>The <a href="http://en.wikipedia.org/wiki/Chain_of_responsibility_pattern" target="_blank">Chain of responsibility Pattern</a> can be used when there is a potentially high number of processing elements, and a stream of requests must be handled in different ways. Each request will be processed by different elements.</p>
<p>This pattern is implemented by encapsulating the processing elements inside a <em>pipeline </em>abstraction, and have objects launch and leave their requests at the entrance to the pipeline. The pattern chains the receiving objects together, and then passes any request messages from object to object until it reaches an object capable of handling the message.</p>
<p>Chain of Responsibility simplifies object interconnections. Instead of senders and receivers maintaining references to all candidate receivers, each sender keeps a single reference to the head of the chain, and each receiver keeps a single reference to its immediate successor in the chain</p>
<h4>Command</h4>
<p>The <a href="http://en.wikipedia.org/wiki/Command_pattern" target="_blank">Command Pattern</a> can be used when there is a need to issue requests to objects without knowing anything about the operation being requested or the receiver of the request.</p>
<p>Command decouples the object that invokes the operation from the one that knows how to perform it. To achieve this separation, the designer creates an abstract base class that maps a receiver (an object) with an action (a pointer to a member function). The base class contains an <code>execute()</code> method that simply calls the action on the receiver. All clients of Command objects treat each object as a “black box” by simply invoking the object’s virtual <code>execute()</code> method whenever the client requires the object’s “service”.</p>
<p>Command objects can be thought of as “tokens” that are created by one client that knows what needs to be done, and passed to another client that has the resources for doing it.</p>
<h4>Interpreter</h4>
<p>The <a href="http://en.wikipedia.org/wiki/Interpreter_pattern" target="_blank">Interpreter Pattern</a> can be used when we’re facing a class of problems that occurs repeatedly in a well-defined and well-understood domain. If the domain were characterized with a “language”, then problems could be easily solved with an interpretation “engine”.</p>
<p>The Interpreter pattern discusses: defining a domain language (i.e. problem characterization) as a simple language grammar, representing domain rules as language sentences, and interpreting these sentences to solve the problem. The pattern uses a class to represent each grammar rule. And since grammars are usually hierarchical in structure, an inheritance hierarchy of rule classes maps nicely.</p>
<p>An abstract base class specifies the method <code>interpret()</code>. Each concrete subclass implements <code>interpret()</code> by accepting (as an argument) the current state of the language stream, and adding its contribution to the problem solving process.</p>
<h4>Iterator</h4>
<p>The <a href="http://en.wikipedia.org/wiki/Iterator_pattern" target="_blank">Iterator Pattern</a> can be used when there’s a need to “abstract” the traversal of very different data structures so that algorithms can be defined that are capable of interfacing with each transparently.</p>
<p>An aggregate object such as a list should give you a way to access its elements without exposing its internal structure. Moreover, you might want to traverse the list in different ways, depending on what you need to accomplish. But you probably don’t want to bloat the List interface with operations for different traversals, even if you could anticipate the ones you’ll require. You might also need to have more than one traversal pending on the same list. And providing a uniform interface for traversing many types of aggregate objects (i.e. polymorphic iteration) might be valuable.</p>
<p>The Iterator pattern lets you do all this. The key idea is to take the responsibility for access and traversal out of the aggregate object and put it into an Iterator object that defines a standard traversal protocol.</p>
<h4>Mediator</h4>
<p>When you have a big number of objects interacting among them, a rather complex structure might be formed. It can become so complex that trying to reutilize some functionality might show the <em>spaghetti code phenomenon</em>: trying to scoop a single serving results in an all or nothing clump. To avoid this, the <a href="http://en.wikipedia.org/wiki/Mediator_pattern" target="_blank">Mediator Pattern</a> encapsulates the behavior of the whole group in a single object.</p>
<p>Partitioning a system into many objects generally enhances reusability, but proliferating interconnections between those objects tend to reduce it again. The mediator object encapsulates all interconnections, acts as the hub of communication, is responsible for controlling and coordinating the interactions of its clients, and promotes loose coupling by keeping objects from referring to each other explicitly.</p>
<p>In this pattern, peers are not coupled to one another. Each one talks to the Mediator, which in turn knows and conducts the orchestration of the others. The <em>many to many</em> mapping between colleagues that would otherwise exist, has been <em>promoted to full object status</em>. This new abstraction provides a locus of indirection where additional leverage can be hosted.</p>
<h4>Memento</h4>
<p>The <a href="http://en.wikipedia.org/wiki/Memento_pattern" target="_blank">Memento Pattern</a> can be used when you need to restore an object back to its previous state (<em>undo</em> or <em>rollback</em> operations).</p>
<p>The client requests a Memento from the source object when it needs to checkpoint the source object’s state. The source object initializes the Memento with a characterization of its state. The client is the “care-taker” of the Memento, but only the source object can store and retrieve information from the Memento (the Memento is “opaque” to the client and all other objects). If the client subsequently needs to “rollback” the source object’s state, it hands the Memento back to the source object for reinstatement.</p>
<p>An unlimited <em>undo</em> and <em>redo</em> capability can be readily implemented with a stack of Command objects and a stack of Memento objects.</p>
<h4>Observer</h4>
<p>The <a href="http://en.wikipedia.org/wiki/Observer_pattern" target="_blank">Observer Pattern</a> can be used when a large monolithic design does not scale well as new graphing or monitoring requirements are requested.</p>
<p>Define an object that is the “keeper” of the data model and/or business logic (the Subject). Delegate all “view” functionality to decoupled and distinct Observer objects. Observers register themselves with the Subject as they are created. Whenever the Subject changes, it broadcasts to all registered Observers that it has changed, and each Observer queries the Subject for that subset of the Subject’s state that it is responsible for monitoring.</p>
<p>This allows the number and “type” of “view” objects to be configured dynamically, instead of being statically specified at compile-time.</p>
<h4>Further reading</h4>
<ul>
<li><a href="http://www.oodesign.com/" target="_blank">Object Oriented Design</a></li>
<li><a href="http://en.wikipedia.org/wiki/Behavioral_pattern" target="_blank">Behavioral Pattern [Wikipedia]</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.undisciplinedbytes.com/2010/01/software-design-patterns-iv-behavioral-patterns/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Software design patterns (III): structural patterns</title>
		<link>http://www.undisciplinedbytes.com/2010/01/software-design-patterns-iii-structural-patterns/</link>
		<comments>http://www.undisciplinedbytes.com/2010/01/software-design-patterns-iii-structural-patterns/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 18:58:16 +0000</pubDate>
		<dc:creator>Oliver Mezquita</dc:creator>
				<category><![CDATA[Documentation]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.undisciplinedbytes.com/?p=261</guid>
		<description><![CDATA[We already saw what design patterns are and took a look at creational patterns in earlier articles. Today we’ll deal with the second category: structural patterns.
These design patterns are all about class and object composition. Class-creation patterns use inheritance to compose interfaces, whilst object patterns define ways to compose objects to obtain new functionality. All [...]]]></description>
			<content:encoded><![CDATA[<p>We already saw <a href="http://www.undisciplinedbytes.com/2009/12/software-design-patterns-i/" target="_blank">what design patterns are</a> and took a look at <a href="http://www.undisciplinedbytes.com/2009/12/software-design-patterns-ii-creational-patterns/" target="_blank">creational patterns</a> in earlier articles. Today we’ll deal with the second category: structural patterns.</p>
<p>These design patterns are all about<strong> class and object composition.</strong> Class-creation patterns use inheritance to compose interfaces, whilst object patterns define ways to compose objects to obtain new functionality. All of these patterns aim to <strong>ease the design by identifying a simple way to realize relationships between entities</strong>.</p>
<p>The most common structural patterns are:</p>
<p><span id="more-261"></span></p>
<h4>Adapter</h4>
<p>An <em>off the shelf </em>component may offer interesting functionality that you may want to reuse, but its <em>view of the world</em> is not compatible with the philosophy and architecture of the system currently being developed. This is where the <a href="http://en.wikipedia.org/wiki/Adapter_pattern" target="_blank">Adapter Pattern</a> steps in.</p>
<p>This pattern is about creating an intermediary abstraction that translates, or maps, the old component to the new system. Clients call methods on the Adapter object, which redirects them into calls to the legacy component.</p>
<h4>Bridge</h4>
<p>The <a href="http://en.wikipedia.org/wiki/Bridge_pattern" target="_blank">Bridge Pattern</a> decomposes the original component’s interface and implementation into different class hierarchies. The interface class contains a pointer to the abstract implementation class. This pointer is initialized with an instance of a particular implementation class, but all subsequent interaction from the interface class to the implementation class is limited to the abstraction maintained in the implementation base class. The client interacts with the interface class, and it in turn “delegates” all requests to the implementation class.</p>
<p>The interface object is the <em>handle</em> known and used by the client. The implementation object, or <em>body</em>, is encapsulated to ensure that it may continue to evolve, or be entirely replaced.</p>
<h4>Composite</h4>
<p>The <a href="http://en.wikipedia.org/wiki/Composite_pattern" target="_blank">Composite Pattern</a> might be used when an application needs to manipulate a hierarchical collection of objects of different types: different types of objects are handled in different ways, and querying the type of each object before processing it is not desirable.</p>
<p>This pattern is implemented by defining an abstract base class that specifies the behavior that needs to be performed upon all primitive and composite objects. Then, primitive and composite classes must be subclassed off of the Component class. Each composite object couples itself only to the abstract type component.</p>
<p>This pattern should be used when you have composites that contain components, each of which could be a composite.</p>
<h4>Decorator</h4>
<p>The <a href="http://en.wikipedia.org/wiki/Decorator_pattern" target="_blank">Decorator Pattern</a> can be used when a particular behavior or state must be applied to individual objects at run-time – in this case inheritance cannot be used because it is static.</p>
<p>The original object must be encapsulated inside an abstract wrapper interface, from which both the core and the decorator object inherit. The interface then uses recursive composition to allow an unlimited number of decorator <em>layers </em>to be added to each core object.</p>
<p>Note that this pattern allows functionality to be added to an object, not methods to an object’s interface. The interface presented to the client must remain constant as successive layers are specified.</p>
<h4>Facade</h4>
<p>When a segment of the client community needs a simplified interface to the overall functionality of a complex subsystem, you can use the <a href="http://en.wikipedia.org/wiki/Facade_pattern" target="_blank">Facade Pattern</a>: this kind of software design encapsulates a complex subsystem within a single interface object.</p>
<p>The Facade Pattern defines a unified, higher level interface to a subsystem that makes it easier to use. This way, the learning curve necessary to successfully leverage the subsystem is reduced. It also promotes decoupling the subsystem from its potentially many clients. On the other hand, if the Facade is the only access point for the subsystem, it will limit the features and flexibility that <em>power users </em>might need.</p>
<h4>Flyweight</h4>
<p>The <a href="http://en.wikipedia.org/wiki/Flyweight_pattern" target="_blank">Flyweight Pattern</a> is designed to solve problems related to granularity and performance: use it when designing objects down to the lowest levels of system granularity, with those objects being extremely expensive in terms of performance.</p>
<p>This pattern describes how to share objects to allow their use at fine granularities without prohibitive cost. Each Flyweight object is divided into two pieces: intrinsic (<em>stateless</em>) and extrinsic (<em>state-dependent</em>). Intrinsic state is stored in the Flyweight object. Extrinsic state is stored or computed by client objects, and passed to the Flyweight when its operations are invoked.</p>
<p>Flyweights are stored in a Factory’s repository. The client doesn’t create Flyweights directly, but requests them from the Factory. Each Flyweight cannot stand on its own. Any attributes that would make sharing impossible must be supplied by the client whenever a request is made of the Flyweight. The Flyweight uses sharing to support large numbers of objects efficiently.</p>
<h4>Proxy</h4>
<p>If you need to support resource-hungry objects, and you do not want to instantiate them unless and until they are absolutely necessary, you can use the <a href="http://en.wikipedia.org/wiki/Proxy_pattern" target="_blank">Proxy Pattern</a>.</p>
<p>The Proxy object instantiate some real object the first time the client makes a request of the proxy, remembers the identity of this real object, and forwards the request to it. Then, all subsequent requests are simply forwarded directly to the encapsulated real object. Implemented as an interface, the presence of the Proxy object standing in place of the real object is transparent to the client.</p>
<p><strong>Continue reading <a href="http://www.undisciplinedbytes.com/2010/01/software-design-patterns-iv-behavioral-patterns/" target="_self">Software design patterns (IV): behavioral patterns »</a></strong></p>
<h4>Further reading</h4>
<ul>
<li><a href="http://www.oodesign.com/" target="_blank">Object Oriented Design</a></li>
<li><a href="http://en.wikipedia.org/wiki/Structural_pattern" target="_blank">Structural Pattern [Wikipedia]</a></li>
</ul>


<h4>Related posts:</h4><p><ol><li><a href='http://www.undisciplinedbytes.com/2009/12/software-design-patterns-ii-creational-patterns/' rel='bookmark' title='Permanent Link: Software design patterns (II): creational patterns'>Software design patterns (II): creational patterns</a></li>
<li><a href='http://www.undisciplinedbytes.com/2010/01/software-design-patterns-iv-behavioral-patterns/' rel='bookmark' title='Permanent Link: Software design patterns (IV): behavioral patterns'>Software design patterns (IV): behavioral patterns</a></li>
<li><a href='http://www.undisciplinedbytes.com/2009/12/software-design-patterns-i/' rel='bookmark' title='Permanent Link: Software design patterns (I)'>Software design patterns (I)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.undisciplinedbytes.com/2010/01/software-design-patterns-iii-structural-patterns/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Software design patterns (II): creational patterns</title>
		<link>http://www.undisciplinedbytes.com/2009/12/software-design-patterns-ii-creational-patterns/</link>
		<comments>http://www.undisciplinedbytes.com/2009/12/software-design-patterns-ii-creational-patterns/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 15:01:42 +0000</pubDate>
		<dc:creator>Oliver Mezquita</dc:creator>
				<category><![CDATA[Documentation]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.undisciplinedbytes.com/?p=246</guid>
		<description><![CDATA[In an earlier article we saw what design patterns are and how they can help us. Today we’re going to take a look at the first category: creational patterns.
Creational design patterns deal with class creation and instantiation, and how to use those instances. Basic class creation could result in design problems or added complexity to [...]]]></description>
			<content:encoded><![CDATA[<p>In an <a href="http://www.undisciplinedbytes.com/2009/12/software-design-patterns-i/" target="_blank">earlier article</a> we saw what design patterns are and how they can help us. Today we’re going to take a look at the first category: creational patterns.</p>
<p>Creational design patterns deal with <strong>class creation and instantiation, and how to use those instances</strong>. Basic class creation could result in design problems or added complexity to the design. These patterns solve these problems by controlling this object creation.</p>
<p>Some examples of creational design patterns:</p>
<p><span id="more-246"></span></p>
<h4>Abstract factory</h4>
<p>The <a href="http://en.wikipedia.org/wiki/Abstract_factory_pattern" target="_blank">Abstract Factory Pattern</a> implements a new level of abstraction in charge of creating families of related or dependent objects without directly specifying their concrete classes. The <em>Factory </em>object provides creation services for the entire platform family. Clients never create platform objects directly, they ask the factory to do that for them.</p>
<p>This mechanism makes exchanging product families easy because the specific class of the factory object appears only once in the application – where it is instantiated. The application can replace the entire family of products simply by instantiating a different instance of the abstract factory.</p>
<h4>Builder</h4>
<p>The <a href="http://en.wikipedia.org/wiki/Builder_pattern" target="_blank">Builder Pattern</a> separates the algorithm for interpreting a stored persistence mechanism from the algorithm for building and representing one of many target products. The focus is on creating highly-complex objects.</p>
<p>This pattern affords finer control over the construction process. Unlike creational patterns that construct products in one shot, the builder pattern constructs the product step by step.</p>
<h4>Factory Method</h4>
<p>The <a href="http://en.wikipedia.org/wiki/Factory_method_pattern" target="_blank">Factory Method pattern</a> is the standard way to create objects. It is similar to the Abstract Factory, but without the emphasis on families. This pattern defines an interface for creating an object, but defers the actual creation to subclasses. A superclass specifies all standard and generic behavior, and delegates the creation details to subclasses that are supplied by the client.</p>
<p>Factory Methods are routinely specified by an architectural framework, and then implemented by the user of the framework.</p>
<h4>Object Pool</h4>
<p>The <a href="http://en.wikipedia.org/wiki/Object_pool" target="_blank">Object Pool pattern</a> lets others “check out” objects from its pool, and when those objects are no longer needed by their processes, they are returned to the pool in order to be reused.</p>
<p>We don’t want processes to be idle waiting for a particular object to be released, so the Object Pool also instantiates new objects as they are required. Furthermore, this pattern must also implement a facility to clean up unused objects periodically.</p>
<h4>Prototype</h4>
<p>The <a href="http://en.wikipedia.org/wiki/Prototype_pattern" target="_blank">Prototype pattern</a> creates new instances of an object by cloning others already in used, rather than by actually creating a new one. To do so, an abstract class must be declared specifying a pure virtual <code>clone()</code> method. Any class that needs a <em>polymorphic constructor</em> capability derives itself from the abstract base class, implementing the <code>clone()</code> operation.</p>
<p>The client then, instead of writing code that invokes the <code>new()</code> operator, calls a <code>clone()</code> operation on the abstract base class, indicating the particular concrete derived class desired.</p>
<h4>Singleton</h4>
<p>The <a href="http://en.wikipedia.org/wiki/Singleton_pattern" target="_blank">Singleton pattern</a> is used when the application needs one, and only one, instance of an object. By using this pattern, a global access point to the instance is provided, and the instance is created when the first access is made.</p>
<p>When choosing which ones to use, keep in mind that sometimes creational patterns are complementary, so you might be able to use more than one of these.</p>
<div><strong>Continue reading <a href="http://www.undisciplinedbytes.com/2010/01/software-design-patterns-iii-structural-patterns/">Software design patterns (III): structural patterns »</a></strong></div>
<h4>Further reading</h4>
<ul>
<li><a href="http://www.oodesign.com/" target="_blank">Object Oriented Design</a></li>
<li><a href="http://en.wikipedia.org/wiki/Creational_pattern" target="_blank">Creational Pattern [Wikipedia]</a></li>
</ul>


<h4>Related posts:</h4><p><ol><li><a href='http://www.undisciplinedbytes.com/2010/01/software-design-patterns-iii-structural-patterns/' rel='bookmark' title='Permanent Link: Software design patterns (III): structural patterns'>Software design patterns (III): structural patterns</a></li>
<li><a href='http://www.undisciplinedbytes.com/2009/12/software-design-patterns-i/' rel='bookmark' title='Permanent Link: Software design patterns (I)'>Software design patterns (I)</a></li>
<li><a href='http://www.undisciplinedbytes.com/2010/01/software-design-patterns-iv-behavioral-patterns/' rel='bookmark' title='Permanent Link: Software design patterns (IV): behavioral patterns'>Software design patterns (IV): behavioral patterns</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.undisciplinedbytes.com/2009/12/software-design-patterns-ii-creational-patterns/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Software design patterns (I)</title>
		<link>http://www.undisciplinedbytes.com/2009/12/software-design-patterns-i/</link>
		<comments>http://www.undisciplinedbytes.com/2009/12/software-design-patterns-i/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 15:01:03 +0000</pubDate>
		<dc:creator>Oliver Mezquita</dc:creator>
				<category><![CDATA[Documentation]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.undisciplinedbytes.com/?p=243</guid>
		<description><![CDATA[Design patterns are solutions to common software development problems, and aim to facilitate the development of a software project. A solution must have proven effectiveness and be highly reusable (can be applied to different design problems in different circumstances) to become a design pattern.
A pattern describes a problem that happens over and over again in [...]]]></description>
			<content:encoded><![CDATA[<p>Design patterns are solutions to common software development problems, and aim to facilitate the development of a software project. A solution must have proven effectiveness and be highly reusable (can be applied to different design problems in different circumstances) to become a design pattern.</p>
<p>A pattern describes a problem that happens over and over again in our environment, and then explains <strong>the core of the solution</strong> to that particular problem. Since it is <strong>just a scheme</strong> of the solution, the application of this pattern is not literal: <strong>it requires adaptation</strong>. You could use the same pattern a thousand times, and never repeat the way you applied it.</p>
<p><span id="more-243"></span></p>
<p>Software design patterns aim to:</p>
<ul>
<li>Provide reusable elements in the design of software projects</li>
<li>Avoid spending time in the search of a solution to well-known and previously solved problems</li>
<li>Standardize the process of designing software applications</li>
<li>Facilitate the learning process of new generations of software developers and designers</li>
</ul>
<p>Software design patterns are not used for:</p>
<ul>
<li>Imposing some alternatives against others: there are plenty of design patterns out there, and the software engineer must compare all of them and choose the one that best suits the needs of the project, if any at all.</li>
<li>Erase the creativity inherent to software design: these patterns are a just a guide to an easier design process, a set of advices to follow. Developers can choose to either follow these rules or adapt them to better fit requirements.</li>
</ul>
<p>These patterns are only recommended in case we’re facing a similar problem that the pattern addresses, having always in mind that it could just not be applied to our particular case. <strong>Abusing or forcing the use of design patterns can be a mistake.</strong></p>
<p>In brief, a pattern is a common structure that similar applications have. This happens in all levels of life. For example, in our ordinary life we apply the pattern<em> “greeting – introduction– message – farewell”</em> in many different occasions. If you don’t think patterns are useful, then try to use the scheme <em>“farewell – message – introduction – greeting”</em> and see what happens.</p>
<p>The most widespread catalogue of design patterns can be found in the book <strong><em>Design Patterns: Elements of Reusable Object-Oriented Software</em></strong>, from Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides (1995, Addison-Wesley), AKA GOF (Gang-Of-Four). According to this book, design patterns can be categorized regarding the purpose they have been defined for:</p>
<ul>
<li><strong>Creational patterns</strong>: solve instance creation problems. They help in encapsulating and abstracting these creations.</li>
<li><strong>Structural patterns</strong>: solve class and object composition problems.</li>
<li><strong>Behavioral patterns</strong>: solve problems about interaction and responsibilities among classes and objects.</li>
</ul>
<p>Software design patterns are usually easy to understand. What might get you more headaches might be using them. They really help and make software development less problematic, so it is very important to get to know some of them. I’ll mention some of them in the next few posts.</p>
<div><strong>Continue reading <a href="http://www.undisciplinedbytes.com/2009/12/software-design-patterns-ii-creational-patterns/">Software design patterns (II): creational patterns »</a></strong></div>
<h4>Further reading</h4>
<ul>
<li><a href="http://www.serc.nl/people/florijn/interests/patts.html" target="_blank">Software (design) patterns resources</a></li>
<li><a href="http://www.cmcrossroads.com/bradapp/docs/patterns-intro.html" target="_blank">Patterns and Software: Essential Concepts and Terminology</a></li>
<li><a href="http://en.wikipedia.org/wiki/Design_Patterns_(book)" target="_blank">Design Patterns: Elements of Reusable Object-Oriented Software (ISBN 0-201-63361-2)</a></li>
</ul>


<h4>Related posts:</h4><p><ol><li><a href='http://www.undisciplinedbytes.com/2009/12/software-design-patterns-ii-creational-patterns/' rel='bookmark' title='Permanent Link: Software design patterns (II): creational patterns'>Software design patterns (II): creational patterns</a></li>
<li><a href='http://www.undisciplinedbytes.com/2010/01/software-design-patterns-iii-structural-patterns/' rel='bookmark' title='Permanent Link: Software design patterns (III): structural patterns'>Software design patterns (III): structural patterns</a></li>
<li><a href='http://www.undisciplinedbytes.com/2010/01/software-design-patterns-iv-behavioral-patterns/' rel='bookmark' title='Permanent Link: Software design patterns (IV): behavioral patterns'>Software design patterns (IV): behavioral patterns</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.undisciplinedbytes.com/2009/12/software-design-patterns-i/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>CSS 3: one more step in the evolution of the web</title>
		<link>http://www.undisciplinedbytes.com/2009/12/css-3-one-more-step-in-the-evolution-of-the-web/</link>
		<comments>http://www.undisciplinedbytes.com/2009/12/css-3-one-more-step-in-the-evolution-of-the-web/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 15:01:41 +0000</pubDate>
		<dc:creator>Oliver Mezquita</dc:creator>
				<category><![CDATA[Documentation]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[Semantic web]]></category>

		<guid isPermaLink="false">http://www.undisciplinedbytes.com/2009/12/css-3-one-more-step-in-the-evolution-of-the-web/</guid>
		<description><![CDATA[CSS 2 was released in 1997, and after more than 10 years it needs to be updated to reflect the new uses and trends we’ve been seeing in the web. This new version of Cascading Style Sheets brings new features long awaited that will make web development easier. Alongside with HTML 5, this new version [...]]]></description>
			<content:encoded><![CDATA[<p>CSS 2 was released in 1997, and after more than 10 years it needs to be updated to reflect the new uses and trends we’ve been seeing in the web. This new version of <a href="http://en.wikipedia.org/wiki/Cascading_Style_Sheets" target="_blank">Cascading Style Sheets</a> brings new features long awaited that will make web development easier. Alongside with <a href="http://www.undisciplinedbytes.com/2009/11/html-5-dramatic-improvements-in-the-web-language/" target="_blank">HTML 5</a>, this new version represents the evolution of the web, and aims to take the concept of <a href="http://www.undisciplinedbytes.com/2009/11/the-semantic-web/" target="_blank">semantics</a> into the core of the web.</p>
<p>CSS 3 has quite a few new concepts. Let’s take a look:</p>
<p><span id="more-239"></span></p>
<h4>New properties</h4>
<ul>
<li><strong>Borders</strong>: border-color, border-image, border-radius, box-shadow.</li>
<li><strong>Backgrounds</strong>: background-origin, background-clip, background-size, layering multiple background images.</li>
<li><strong>Color</strong>: HSL colors, HSLA colors, RGBA colors opacity.</li>
<li><strong>Text</strong>: text-shadow, text-overflow.</li>
<li><strong>Interface</strong>: box-sizing, resize.</li>
<li><strong>Selectors</strong>: attribute selectors.</li>
<li><strong>Formats</strong>: media queries, multiple column layout, speech.</li>
</ul>
<h4>New features</h4>
<p>Using these new properties we’ll be able to achieve things such as:</p>
<ul>
<li><strong>Borders, background</strong><br />
CSS 3 will allow images for borders, round corners and shadows. Objects can not only be positioned, but its direction can also be changed (horizontal or vertical).</li>
<li><strong>Multi-column layout</strong><br />
Designing pages with multiple columns now will be easier than ever. Until now we needed to enclose the content in two separate DIVs to simulate a two-column layout; now we’ll just use <code>column-count: 2</code>. Not all that hard, right?</li>
<li><strong>Advanced Layout</strong><br />
This new feature will allow objects to be distributed along the screen in a better an easier way, and combine them in different manners without additional tags. Besides, the page model will be included: this means that we will be able to indicate page footers, crossed references, and section headers.</li>
<li><strong>Selectors </strong><br />
There are new selectors to make it easier locating exactly the element you want:<br />
<code>E:only-of-type</code>: an element which is unique in its type.<br />
<code>E:not(s)</code>: an element which doesn’t match simple selector.<br />
<code>E ~ F</code>: an element F with an element E right before.<br />
<code>E:nth-child</code>: the n-th child element of a parent node. With this selector we’ll be able to implement things such as <strong>zebra tables.</strong><br />
<code>E:nth-last-child</code>: the last child element from a parent node.<br />
<code>E:nth-of-type</code>: the n-th element which is of a certain type.<br />
<code>E:first-of-type</code>: the first element which is of a certain type.</li>
<li><strong>Resizing </strong><br />
Up till now, if we wanted our elements to be resizable we needed to use Javascript to alter its attributes. With CSS 3 it will now be a task of the browser, just by using the <code>resize</code> property.</li>
<li><strong>And many more things …</strong></li>
</ul>
<p>Some properties of CSS 3 <a href="http://westciv.com/wiki/Experimental_CSS_compatibility_table" target="_blank">are already being implemented in most major browsers</a>. There’s not a 100% fully compliant web browser yet (specially because CSS 3 is not finished yet), but it won’t take much time to have one. This means that maybe we won’t be able to use all of these new features right now, but we can certainly start using some of them. So, what are you waiting for? The sooner the better!</p>
<h4>Further reading</h4>
<ul>
<li><a href="http://www.w3.org/TR/css3-roadmap/" target="_blank">W3C CSS3</a></li>
<li><a href="http://www.css3.info">www.css3.info</a></li>
<li><a href="http://www.webappers.com/2009/08/10/70-must-have-css3-and-html5-tutorials-and-resources/" target="_blank">70 Must-Have CSS3 and HTML5 Tutorials and Resources</a></li>
</ul>


<h4>Related posts:</h4><p><ol><li><a href='http://www.undisciplinedbytes.com/2009/11/html-5-dramatic-improvements-in-the-web-language/' rel='bookmark' title='Permanent Link: HTML 5: dramatic improvements in the web language'>HTML 5: dramatic improvements in the web language</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.undisciplinedbytes.com/2009/12/css-3-one-more-step-in-the-evolution-of-the-web/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML 5: dramatic improvements in the web language</title>
		<link>http://www.undisciplinedbytes.com/2009/11/html-5-dramatic-improvements-in-the-web-language/</link>
		<comments>http://www.undisciplinedbytes.com/2009/11/html-5-dramatic-improvements-in-the-web-language/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 15:00:23 +0000</pubDate>
		<dc:creator>Oliver Mezquita</dc:creator>
				<category><![CDATA[Documentation]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[Semantic web]]></category>

		<guid isPermaLink="false">http://www.undisciplinedbytes.com/?p=200</guid>
		<description><![CDATA[HTML 5 is a new revision of the standard language that moves the web. The increase in needs has brought new uses in HTML and new tags to support them, paying special attention to the semantic web. There are quite a few elements added to the new HTML standard to encapsulate different types of information:

New [...]]]></description>
			<content:encoded><![CDATA[<p>HTML 5 is a new revision of the standard language that moves the web. The increase in needs has brought new uses in HTML and new tags to support them, paying special attention to the semantic web. There are quite a few elements added to the new HTML standard to encapsulate different types of information:</p>
<p><span id="more-200"></span></p>
<h4>New tags</h4>
<ul>
<li><code>&lt;article /&gt;</code> This new element defines a portion of the content as an article. Perfect for newspapers or blogs.</li>
<li><code>&lt;aside /&gt;</code> Represents a fragment of information that slightly relates with the rest of the content.</li>
<li><code>&lt;dialog /&gt;</code> Depicts conversations.</li>
<li><code>&lt;figure /&gt;</code> Used to associate a caption with an embedded content, such as graphics or video.</li>
<li><code>&lt;footer /&gt;</code> Page section to hold author information, copyright statement, etc&#8230;</li>
<li><code>&lt;header /&gt;</code> Page section to hold some introductory information.</li>
<li><code>&lt;nav /&gt;</code> Section oriented to navigation.</li>
<li><code>&lt;section /&gt;</code> Element that defines a generic section.</li>
<li><code>&lt;audio /&gt;</code> and &lt;video /&gt; Provides multimedia content.</li>
<li><code>&lt;embed /&gt;</code> Supports plugin contents.</li>
<li><code>&lt;m /&gt;</code> Marked text.</li>
<li><code>&lt;meter /&gt;</code> Used to display measures.</li>
<li><code>&lt;time /&gt;</code> Used to display dates and/or time.</li>
<li><code>&lt;canvas /&gt;</code> Used to show real-time renderized graphics, such as games. For example, <a href="http://www.undisciplinedbytes.com/2009/10/html-5-canvas-tag-demonstration-sierra-adventure-games/" target="_blank">Sierra adventure games.</a></li>
<li><code>&lt;command /&gt;</code> Related with commands a user can invoke.</li>
<li><code>&lt;datagrid /&gt;</code> Shows additional information if it is requested by the user.</li>
<li><code>&lt;datalist /&gt;</code> Used together with the new attribute for &lt;input /&gt; can be used to create comboboxes.</li>
<li><code>&lt;output /&gt;</code> Denotes what kind of output the page produces.</li>
<li><code>&lt;progress /&gt;</code> Represents a progress bar in a time consuming task, such as donwloading a file.</li>
</ul>
<h4>New local attributes</h4>
<p>There&#8217;s a few new attributes for some of the elements that were already present in HTML4.</p>
<ul>
<li><code>media</code>: for greater consistency with the <code>link</code> element.</li>
<li><code>ping</code>: whitespace-delimited URLs list to which a ping will be produced when the link is followed. For the elements <code>&lt;area /&gt;</code> and <code>&lt;a /&gt;</code>.</li>
<li><code>target</code>: for greater consistency the <code>&lt;a /&gt;</code> element.</li>
<li><code>autofocus</code>: indicates that the <code>&lt;input /&gt;, &lt;select /&gt;, &lt;textarea /&gt;</code> or <code>&lt;button /&gt;</code> element should get the focus at page load.</li>
<li><code>form</code>: attribute for <code>&lt;input /&gt;, &lt;ouput /&gt;, &lt;select /&gt; &lt;textarea /&gt;, &lt;button /&gt;</code> and <code>&lt;fieldset /&gt;</code> which allows them to be associated to a form. This way, they can now be placed anywhere on a page, not as children of the <code>form</code> element.</li>
<li><code>replace</code>: will affect the element once changes are performed to it. For elements <code>&lt;input /&gt;, &lt;button /&gt;</code> and <code>&lt;form /&gt;</code>.</li>
<li><code>data</code>: specifies data for the elements <code>&lt;form /&gt;, &lt;select /&gt;</code> and <code>&lt;datalist /&gt;</code>.</li>
<li><code>required</code>: denotes a required element, for <code>&lt;input /&gt;</code> and <code>&lt;textarea /&gt;</code>.</li>
<li><code>disabled</code>: for the <code>&lt;fieldset /&gt;</code> element.</li>
<li><code>autocomplete, min, max, pattern, step</code>: these attributes delimitate the possibilities of the <code>&lt;input /&gt;</code> element.</li>
<li><code>list</code>: for <code>&lt;datalist /&gt;</code> and <code>&lt;select /&gt; </code> elements.</li>
<li><code>template</code>: for <code>&lt;input /&gt;</code> and <code>&lt;button /&gt;</code> elements, it will be used to repeat templates.</li>
<li><code>scoped</code>: for the <code>&lt;style /&gt;</code> element, enables the use of scoped style sheets.</li>
<li><code>async</code>: for the <code>&lt;script /&gt;</code> element. AJAX turned into an attribute.</li>
</ul>
<h4>New global attributes</h4>
<p>Some attributes that apply to the whole web page document:</p>
<ul>
<li><code>contenteditable</code>: denotes an editable area.</li>
<li><code>contextmenu</code>: contextual menu supplied by the user.</li>
<li><code>draggable</code>: &#8230; needs explanation?</li>
<li><code>tabindex</code>: a numeric value representing the order of elements we will tour around when pressing the TAB key.</li>
<li><code>irrelevant</code>: &#8230; need I say more?</li>
<li><code>repeat, repeat-start, repeat-min, repeat-max</code>: these attributes refer to iterations.</li>
</ul>
<h4>HTMLDocument extensions</h4>
<p>There are some improvements, and some other elements that finally get standarized:</p>
<ul>
<li><code>getElementsByClassName()</code>: selects elements given a class. Time responses seem to be dramatically improved by using this function.</li>
<li><code>innerHTML</code>: present in all ECMAScript implementations, it was not a standard till now.</li>
<li><code>activeElement, hasFocus()</code>: will allow us to know which is element is active and which one has the focus.</li>
<li><code>getSelection()</code>: returns an object with the current selection.</li>
<li><code>designMode, execCommand()</code>: used to edit documents.</li>
</ul>
<h4>HTMLElement extensions:</h4>
<p>The DOM element has also had some changes:</p>
<ul>
<li><code>getElementsByClassName()</code>: returns the children of an element that has a given class.</li>
<li><code>innerHTML</code>: reads/changes the content of a node.</li>
<li><code>classList</code>: a very interesting implementation that, along with <code>className</code>, lets us interact with element classes, providing methods such as <code>has(), toggle(), add()</code> and <code>remove()</code>.</li>
<li><code>relList</code>: works as <code>classList</code> on the rel attributes of the elements <code>&lt;a /&gt;, &lt;area /&gt; and &lt;link /&gt;</code>.</li>
</ul>
<p>This is just a quick overview of the most important changes that HTML will bring. But there&#8217;s many more not mentioned here. For a complete reference guide, consult the <a href="http://dev.w3.org/html5/html4-differences/Overview.html" target="_blank">W3C official draft</a>.</p>
<p>HTML 5 is still a draft. Its definition is not finished yet. But all major browsers are already starting to implement some of its features. There&#8217;s still many years to wait for HTML 5 to be as widespread as HTML 4.01 is today, but the improvements this new version bring are so impressive that may affect its adoption speed. The originally proposed name for HTML 5 was <strong>Web Applications 1.0</strong>, which provides a very good idea about the goal of this new standard.</p>
<h4>Further reading</h4>
<ul>
<li> <a href="http://www.sitepoint.com/article/html-5-snapshot-2009/" target="_blank">Yes, you can use HTML 5 today!</a></li>
<li><a href="http://www.smashingmagazine.com/2009/07/06/html-5-cheat-sheet-pdf/" target="_blank">HTML 5 cheat sheet</a></li>
<li><a href="http://www.smashingmagazine.com/2009/08/04/designing-a-html-5-layout-from-scratch/" target="_blank">Coding an HTML 5 layout from scratch</a></li>
<li><a href="http://molly.com/html5/html5-0709.html" target="_blank">A selection of supported features in HTML 5</a></li>
<li><a href="http://jontangerine.com/log/2008/03/preparing-for-html5-with-semantic-class-names" target="_blank">Preparing for HTML 5 with semantic class names</a></li>
</ul>


<h4>Related posts:</h4><p><ol><li><a href='http://www.undisciplinedbytes.com/2009/12/css-3-one-more-step-in-the-evolution-of-the-web/' rel='bookmark' title='Permanent Link: CSS 3: one more step in the evolution of the web'>CSS 3: one more step in the evolution of the web</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.undisciplinedbytes.com/2009/11/html-5-dramatic-improvements-in-the-web-language/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
