<?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>Code lab for HTML, CSS, PHP, Javascript and more.</title>
	<atom:link href="http://www.sandeshshrestha.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sandeshshrestha.com/blog</link>
	<description></description>
	<lastBuildDate>Mon, 14 May 2012 10:49:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Extreme Programming (XP)</title>
		<link>http://www.sandeshshrestha.com/blog/extreme-programming-xp/</link>
		<comments>http://www.sandeshshrestha.com/blog/extreme-programming-xp/#comments</comments>
		<pubDate>Mon, 14 May 2012 10:45:51 +0000</pubDate>
		<dc:creator>Sandesh</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Extreme Programming]]></category>
		<category><![CDATA[Quality]]></category>
		<category><![CDATA[XP]]></category>

		<guid isPermaLink="false">http://www.sandeshshrestha.com/blog/?p=70</guid>
		<description><![CDATA[XP was developed by Beck, Cunningham, and Jeffries and is a “lightweight discipline of software development based on principles of simplicity, communication, feedback, and courage”[5]. It is a type of agile software development method, which is focused on software quality, accept changing requirement and frequent release. It is done in small to medium size teams[4]. [...]]]></description>
			<content:encoded><![CDATA[<p dir="ltr">XP was developed by Beck, Cunningham, and Jeffries and is a “lightweight discipline of software development based on principles of simplicity, communication, feedback, and courage”[5]. It is a type of agile software development method, which is focused on software quality, accept changing requirement and frequent release. It is done in small to medium size teams[4]. XP is a collection of ideas and practices drawn from already existing methodologies [4]. On traditional methodology, scope, time and cost are fixed but quality is variable, where is in XP project Scope is variable but time, cost and quality is fixed[3]. This approach allows any changes of requirement keeping the time cost and quality fixed.</p>
<p><strong>XP consists of these phases: Exploration, Planning, Iterations to Release, Productionizing, Maintenance and Death[1].</strong></p>
<p><strong><strong><img src="https://lh6.googleusercontent.com/PrGich0UbRSDiwvqrqACV5VA-nlI7hAfe1K8zF9DMFVX-nTtr_URsek0_B7HX4-AQ_etBbUSgekKuH3siNwUG_8R2jcLf4M7MfBgudlJsWEQs97Re7Q" alt="" width="574px;" height="247px;" /><br />
</strong></strong></p>
<p dir="ltr">[Image source: http://www.extremeprogramming.org/map/images/project.gif]<span id="more-70"></span></p>
<p><strong>Exploration phase:</strong> Exploration phase is about customer communication. Customers write some story cards where they include their wish to be included in first release. Each story card is a feature to be added in the program. And this phase is also about developers familiarize themselves with the tools and technology. Testing of technology. This phase will last from few weeks to few months, depending upon how familiar the technology is.</p>
<p dir="ltr"><strong>Planning phase:</strong> Planning phase is normally not more than 2 months, where developers the time estimate each story requires and agree on the contents for the first small release. Overall release plan is also made in this phase.</p>
<p><strong>Iteration to release phase:</strong> On Iterations to release phase each story are divided into several iterations which will take around one to four weeks. The first iteration is about coming up with whole system architecture, which is done by selecting the stories that will give the structure of whole system.</p>
<p dir="ltr">Programmer work on each story at a time using pair programming, where the analysis, design, planning for test and test. The first iteration is the story with the highest business value and the last iteration the system is ready for production.</p>
<p><strong>Production phase:</strong> Production phase the software is tested again and checked for the performance of the system before release. New changes may be introduced in this phase, which will need quick decision if they are included in this release or not.</p>
<p><strong>Maintenance phase:</strong> Maintenance phase require incorporating new people in team and require an effort also for customer support. This phase is after the first release. Production phase is also running during this phase.</p>
<p><strong>Death phase:</strong> The last phase is the Death phase, when customer have no any stories to implement, which satisfies customer needs.  All necessary documentation is written in this phase. This phase may also occur if the development is stopped because of not delivering the desired product or is too expensive for further development.</p>
<p>&nbsp;</p>
<p><strong>Different software quality control on XP.</strong></p>
<p dir="ltr">There are 12 different aspects in XP which are focused for maintaining the software quality[2]. Each of the points are distributed among all the different phases of XP.</p>
<p><strong>1. Simple design:</strong> On each iteration, when developers choose some task to perform then they are focused on the need of current iteration only, which make it simple to view and have control over. They don’t have to think about the whole project or next iteration.</p>
<p><strong>2. Testing:</strong>  On XP tests are done at least once for each story[3]. Which reduce the chances of finding a big bugs at the end of project. And because it is done quite frequently it&#8217;s easy for developers to test and correct small piece of code then the whole project.</p>
<p style="padding-left: 30px;" dir="ltr"><strong>2.1 Unit testing:</strong> Unit testing is a test of methods, classes, properties and assemblies performed by developers who write the code. On XP, developers write unit test before writing the actual code (classes, methods or properties). So that when they start writing code, it is automatically tested by unit testing software.</p>
<p style="padding-left: 30px;" dir="ltr"><strong>2.2 Functional testing:</strong> This is the testing of the software, if it meets the customer story. This test is done at the end of the development in traditional way, which result in finding more bugs and hard to fix. But on XP it is done after each iteration, satisfying the need stated on the customer story card.</p>
<p><strong>3. Refactoring:</strong> Refactoring the process where developers continues to edit the code throughout the project life. It is done to remove redundancy and unused functions..</p>
<p><strong>4. Continuous integration:</strong> Each small part of code that are adding in the system are tested automatically. This adding of code is done frequently with the test done on each time.</p>
<p><strong>5. Small releases:</strong> The development process in XP is simple where developers release a small working product in a first release and go on adding small functionality more on each iteration. This way of working a small bit at a time, makes developers easy to work, which result in less chances of making error.</p>
<p><strong>6. Coding standards:</strong> Each XP team follow their standard manner of writing codes. This standardization of code makes developers easy to understand the code written by other.</p>
<p><strong>7. Planning game:</strong></p>
<p style="padding-left: 30px;" dir="ltr"><strong>7.1 Release Planning:</strong> During this planning phase customer provides requirement for the system in customer story cards, which is later determined by developers for when to release.</p>
<p style="padding-left: 30px;" dir="ltr"><strong>7.2 Iteration Planning:</strong> This planning is done only by developers. They spit requirements into different tasks. Time required to complete each task is assigned and matched with the original customer story when finished.</p>
<p><strong>8. Customer on-site:</strong> Customer representative is always co-located with developers which help in fast response to developers if something is going wrong. And if developers are ahead of schedule then the customer can add more requirement in the iteration.</p>
<p><strong>9. Pair programming:</strong> Pair programming is a practice where two programming works together, where one write codes and other checks if it is written correctly. The person writing the code is thinking “tactically” whereas the other person is thinking “strategically”, ensuring the coding standards are followed[3].</p>
<p><strong>10. Collective ownership:</strong> On XP development method everyone have access to any code and can be edited by anyone in the team. This will facilitate with the fast editing of code when there is any error.</p>
<p><strong>11. Metaphor:</strong> Use of simple and meaningful words and descriptions for developer can easily guess and work with.</p>
<p><strong>12. 40-hour week:</strong> XP tries not to make its developers tired because tired developers tends to make more mistakes. So without more time on work, XP have fix time in a week to work, keeping developers fresh and active every time they work.</p>
<p><strong>Reference</strong></p>
<p dir="ltr">[1] Ioannis G. Stamelos, Panagiotis Sfetsos, Agile software development methods</p>
<p dir="ltr">[2] Yael Dubinsky, Orit Hazzan, Improvement of software quality: introducing extreme programming into a project-based course</p>
<p dir="ltr">[3] Dave Rooney, Enabling software quality using Extreme programming</p>
<p dir="ltr">[4] Beck, Embracing Change With Extreme Programming</p>
<p dir="ltr">[5] Nicholas R. Zuiderveld, eXtreme Programming and SCRUM, A Comparative Analysis of Agile Methods</p>
<p dir="ltr">
]]></content:encoded>
			<wfw:commentRss>http://www.sandeshshrestha.com/blog/extreme-programming-xp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Selection sorting</title>
		<link>http://www.sandeshshrestha.com/blog/selection_sorting/</link>
		<comments>http://www.sandeshshrestha.com/blog/selection_sorting/#comments</comments>
		<pubDate>Sun, 18 Dec 2011 14:24:47 +0000</pubDate>
		<dc:creator>Sandesh</dc:creator>
				<category><![CDATA[Algorithm]]></category>
		<category><![CDATA[Data types]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.sandeshshrestha.com/blog/?p=52</guid>
		<description><![CDATA[Selection sort works by finding the smallest item in the array and exchange in with the first entry. Then, find the next smallest item and exchange in with the second entry, which continue till all array is sorted. Selection sorting takes (N*N)/2 running time to sort N items. Tuterial video &#160; Java Code public class [...]]]></description>
			<content:encoded><![CDATA[<p>Selection sort works by finding the smallest item in the array and exchange in with the first entry. Then, find the next smallest item and exchange in with the second entry, which continue till all array is sorted.</p>
<p>Selection sorting takes (N*N)/2 running time to sort N items.</p>
<p><strong>Tuterial video<span id="more-52"></span></strong><br />
<iframe src="http://www.youtube.com/embed/6nDMgr0-Yyo" frameborder="0" width="480" height="360"></iframe></p>
<p>&nbsp;</p>
<p><strong>Java Code</strong></p>
<pre class="brush:java">public class Example
{
	public static void sort(Comparable[] a)
	{
		int N = a.length;
		for (int i = 0; i &lt; N; i++)
		{
			int min = i;
			for (int j = i+1; j &lt; N; j++)
				if (less(a[j], a[min]))
					min = j;
        	  	exch(a, i, min);
		}
	}
	private static boolean less(Comparable v, Comparable w)
	{
		return v.compareTo(w) &lt; 0;
	}
	private static void exch(Comparable[] a, int i, int j)
	{
		Comparable t = a[i];
		a[i] = a[j];
		a[j] = t;
	}
	private static void show(Comparable[] a)
	{
		for (int i = 0; i &lt; a.length; i++)
			StdOut.print(a[i] + " ");
		StdOut.println();
	}
	public static boolean isSorted(Comparable[] a)
	{
		for (int i = 1; i &lt; a.length; i++)
			if (less(a[i], a[i-1]))
				return false;
		return true;
	}
	public static void main(String[] args)
	{
		String[] a = In.readStrings();
		sort(a); // sort
		assert isSorted(a); // check if it sorted properly
		show(a); // displaying the sorted array
	}
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.sandeshshrestha.com/blog/selection_sorting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Memory used by Java data types.</title>
		<link>http://www.sandeshshrestha.com/blog/memory-used-by-java-data-types/</link>
		<comments>http://www.sandeshshrestha.com/blog/memory-used-by-java-data-types/#comments</comments>
		<pubDate>Sat, 17 Dec 2011 01:26:44 +0000</pubDate>
		<dc:creator>Sandesh</dc:creator>
				<category><![CDATA[Data types]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Memory]]></category>

		<guid isPermaLink="false">http://www.sandeshshrestha.com/blog/?p=44</guid>
		<description><![CDATA[This article will try to explain the basic idea about memory used by Primitive data type and some data structure in Java implementation. Primitive data types boolean 1 byte byte 1 byte char 2 bytes int 4 bytes float 4 bytes long 8 bytes double 8 bytes overhead 16 bytes // overhead includes a reference [...]]]></description>
			<content:encoded><![CDATA[<p>This article will try to explain the basic idea about memory used by Primitive data type and some data structure in Java implementation.</p>
<p><strong>Primitive data types</strong></p>
<ul>
<li>boolean 1 byte</li>
<li>byte 1 byte</li>
<li>char 2 bytes</li>
<li>int 4 bytes</li>
<li>float 4 bytes</li>
<li>long 8 bytes</li>
<li>double 8 bytes</li>
</ul>
<ul>
<li>overhead 16 bytes // overhead includes a reference to the object&#8217;s class, garbage collection information and synchronization information</li>
<li>padding 4 bytes // memory uses padded on a 64-bit machine</li>
<li>reference 8 bytes // reference to different object or data type</li>
</ul>
<p><strong>Object</strong> : Memory used by an object is equal to the memory used by each instance + overhead (16 bytes) + padding (4 bytes). For example</p>
<pre class="brush:java">private class ageGender
{
int age=0;
char gender = ''; //"m" for male and "f" for female
}</pre>
<p><span id="more-44"></span>The abover object &#8220;ageGender&#8221; will use 26 bytes<br />
_____________<br />
| overhead           | 16 bytes<br />
| int (age)             | 4 bytes<br />
| char (gender)  | 2 bytes<br />
| padding              | 4 bytes<br />
|____________|</p>
<p><strong>Linked list</strong> : To understand the memory used by Linked list, we have to first understand the Linked list first.</p>
<p>Each linked list is a class, which have 1 reference to the first node, 1 int storing the size of linked list and list of a lot of nodes.</p>
<p>Each node is again a class with 2 references, first one is the reference of the class storing the value of that node and second is the reference to the next node. And its a inner class of a Linked list class.<br />
Now if this linked list is storing int values, then it will create Integer class for int value stored in each node.</p>
<p>Linked list (storing int values)<br />
____________<br />
| First node      |<br />
| int                     |<br />
| _________  |<br />
||Node 1         | |<br />
||________  | |<br />
| _________  |<br />
||Node 2         | |<br />
||________  | |<br />
|          .                |<br />
|          .                |<br />
|          .                |<br />
|__________ |</p>
<p>If we examile the above class it will use overhead (16 bytes) + padding (4 bytes) + reference to first node (8 bytes) + size of link list (4 bytes) + reference to each node (8N bytes) memory. In total 32+8N</p>
<p>Node<br />
_______________________<br />
| reference to Integer class     |<br />
| reference to next node           |<br />
|______________________|</p>
<p>Now the memory used by this node is overhead (16 bytes) + 2 reference (2*8 bytes), in total 32 bytes.</p>
<p>Integer class will also have overhead (16 bytes) + padding (4 bytes) + int value (4 bytes), in total 24 bytes of size.<br />
Now the total memory used by Linked list after adding all this will be 32 + (8+32+24)N = <strong>32 + 64N.</strong></p>
<p><strong>Array</strong> : In Java array is an object with extra overhead for the length of the array. So an array of integer int[] will require overhead (16 bytes) + length of array (4 bytes) + padding (4 bytes) + list of int values (4N bytes). In total, int[] will require 24+4N memory whereas char[] will require 24+2N memory.</p>
<p><strong>String object</strong> : String object is a class containing reference of an array of char[] containing each character of reference, with three extra overheads (offset, count and hash). This means that string object will require overhead (16 bytes) + padding (4 bytes) + offset, count and hash (3*4 bytes), 1 reference to the char array (8 bytes) and a char array (24+2N) memory, in total 64 + 2N memory.<br />
But creating substring from a string will only create a new class but uses the old char array, this means it only require 40 extra bytes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sandeshshrestha.com/blog/memory-used-by-java-data-types/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AJAX XmlHttpRequest</title>
		<link>http://www.sandeshshrestha.com/blog/ajax-xmlhttprequest/</link>
		<comments>http://www.sandeshshrestha.com/blog/ajax-xmlhttprequest/#comments</comments>
		<pubDate>Fri, 16 Dec 2011 00:08:47 +0000</pubDate>
		<dc:creator>Sandesh</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.sandeshshrestha.com/blog/?p=31</guid>
		<description><![CDATA[Javascript code using AJAX XmlHttpRequest. &#8220;send()&#8221; function can be executed using normal javascript function call, passing one argument to be sent to send.php through POST. //Function creating XmlHttpObject function GetXmlHttpObject(){ var xmlHttp=null; try{ // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e){ // Internet Explorer try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e){ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } [...]]]></description>
			<content:encoded><![CDATA[<p>Javascript code using AJAX XmlHttpRequest. &#8220;send()&#8221; function can be executed using normal javascript function call, passing one argument to be sent to send.php through POST.</p>
<pre class="brush:javascript">//Function creating XmlHttpObject
function GetXmlHttpObject(){
var xmlHttp=null;
try{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e){
// Internet Explorer
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}</pre>
<p><span id="more-31"></span></p>
<pre class="brush:javascript">//function to send the post data to send.php file and activate receive().
function send(a){
var parameters = "code=" + encodeURIComponent(a);
http_request=GetXmlHttpObject();
if (http_request==null){
alert ("Your browser does not support AJAX!");
return;
}
http_request.onreadystatechange = receive;
http_request.open("POST", "send.php", true);
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http_request.send(parameters);
}</pre>
<pre class="brush:javascript">//function to alert() data from send.php
function receive(){
if (http_request.readyState == 4) {
if (http_request.status == 200) {
var result = http_request.responseText;
alert(result);
}
}</pre>
<p>send.php</p>
<pre class="brush:php">&lt;?php
$a=$_POST["code"];
echo $a;
?&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.sandeshshrestha.com/blog/ajax-xmlhttprequest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easy form validation using HTML5</title>
		<link>http://www.sandeshshrestha.com/blog/hello-world/</link>
		<comments>http://www.sandeshshrestha.com/blog/hello-world/#comments</comments>
		<pubDate>Thu, 15 Dec 2011 06:20:12 +0000</pubDate>
		<dc:creator>Sandesh</dc:creator>
				<category><![CDATA[HTML5]]></category>

		<guid isPermaLink="false">http://www.sandeshshrestha.com/blog/?p=1</guid>
		<description><![CDATA[It is possible to pre-define the form input type according to its validation rule using HTML5. This use will will validate the input data with out the use of custom code. There are 7 different types of input type email, url, number, range, date pickers, search and color. As in the example below &#60;input&#62; type [...]]]></description>
			<content:encoded><![CDATA[<p>It is possible to pre-define the form input type according to its validation rule using HTML5. This use will will validate the input data with out the use of custom code.<br />
There are 7 different types of input type <strong>email, url, number, range, date pickers, search and color</strong>.</p>
<p>As in the example below <strong>&lt;input&gt;</strong> type is set to &#8220;<strong>email</strong>&#8221; and <strong>required</strong> attribute is set to &#8220;<strong>required</strong>&#8220;.<span id="more-1"></span></p>
<pre class="brush:html">
<form action="" method="post">
<input id="name" type="text" name="name" size="45" />
<input id="email" type="email" name="email" size="45" />
<input type="submit" value="Submit" /></form>
</pre>
<p><a href="http://www.sandeshshrestha.com/blog/wp-content/uploads/2011/12/HTML5-form-validation.jpg"><img class="alignnone size-full wp-image-15" style="border-image: initial; border-width: 1px; border-color: black; border-style: solid;" title="HTML5 form validation" src="http://www.sandeshshrestha.com/blog/wp-content/uploads/2011/12/HTML5-form-validation.jpg" alt="" width="329" height="109" /> </a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sandeshshrestha.com/blog/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

