<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Programming Tips For Versatile Coders</title>
	
	<link>http://www.codercaste.com</link>
	<description />
	<lastBuildDate>Sat, 24 Mar 2012 21:34:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Codercastecom" /><feedburner:info uri="codercastecom" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>Codercastecom</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>How Newer Upgrades in Ice Cream Sandwich Android Platform Are Going to Benefit Technology Device Manufacturers</title>
		<link>http://feedproxy.google.com/~r/Codercastecom/~3/XLK3fCxxiDA/</link>
		<comments>http://www.codercaste.com/2012/03/24/how-newer-upgrades-in-ice-cream-sandwich-android-platform-are-going-to-benefit-technology-device-manufacturers/#comments</comments>
		<pubDate>Sat, 24 Mar 2012 21:33:12 +0000</pubDate>
		<dc:creator>Spyros</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[android framework]]></category>
		<category><![CDATA[android platform]]></category>
		<category><![CDATA[droid]]></category>
		<category><![CDATA[ice cream sandwich android]]></category>

		<guid isPermaLink="false">http://www.codercaste.com/?p=1154</guid>
		<description><![CDATA[As technology changes, it seems that technology device manufacturers also add improvements to their devices. Ice Cream Sandwich is one such, recently released, technology that looks to be extremely beneficial for device manufacturers. New Framework One of the biggest changes to the new operating system is the enhanced and unified framework used in the user [...]]]></description>
			<content:encoded><![CDATA[<p><em><a href="http://www.codercaste.com/wp-content/uploads/2012/03/Android-overtakes-Apple-iOS1.jpg"><img class="alignleft size-thumbnail wp-image-1156" title="Android-overtakes-Apple-iOS1" src="http://www.codercaste.com/wp-content/uploads/2012/03/Android-overtakes-Apple-iOS1-150x150.jpg" alt="" width="150" height="150" /></a></em></p>
<p>As technology changes, it seems that technology device manufacturers also add improvements to their devices. Ice Cream Sandwich is one such, recently released, technology that looks to be extremely beneficial for device manufacturers.</p>
<p><span id="more-1154"></span></p>
<p><strong>New Framework</strong></p>
<p>One of the biggest changes to the new operating system is the enhanced and unified framework used in the user interface. The new interface includes all the things that you loved about the previous 3.x interface and ads more elements to it; including the new APIs.<br />
Examples of interfaces include the Samsung TouchWiz and Sony Ericsson’s Timescape user interface. The new framework allows device manufacturers to create better and enhanced interfaces. This will make navigation easier and faster than ever before. It will also allow manufacturers to finally make full use of the hardware they put into their devices.</p>
<p>One of the biggest changes to Ice Cream Sandwich is the new unification of contacts and files. This allows device manufacturers to create better storage and access methods for contact and files (photos, music, office documents and videos). This is especially important when it comes to widgets as they have to pull out information from the phone. By unifying a storage method, manufacturer-specific widgets and applications become more efficient than ever before. The new visual voicemail API also lets you get to your voicemail services faster than ever before. These services can be streamlined by device manufacturers to make their device better than the competition.</p>
<p><strong>New Connections</strong></p>
<p>The Android Beam is a new feature that was released with Ice Cream Sandwich. It allows two Android devices to send information directly to each other via Wi-Fi. You can practically share anything so long as you are within range. For device manufacturers and especially developers, this is one amazing innovation. Manufacturers can use this feature to allow almost anything to be shared including themes, widgets and even customizations. With the new Bluetooth Health Device Profile, doctors can easily connect to wireless hospital sensors and other such devices to keep a better track on their patients. If device manufacturers are able to make full use of this profile, it may just revolutionize the health industry.</p>
<p><strong>Enhanced Application Development</strong></p>
<p>Manufacturers can even set up new security, sharing and notification features that are specific to their devices. Manufacturers can also create custom widgets that enable their mobiles to work more efficiently. The new user interface allows device manufacturers to create widgets faster than ever before. All they have to do is program their customizations and the system will add everything else.</p>
<p><strong>Better Camera Function</strong></p>
<p>One of the biggest changes that come with Ice Cream Sandwich is that of enhanced camera capabilities. Better zoom, exposures, focusing and editing function all work efficiently to maximize the capabilities of the built-in cameras. For device manufacturers, this is a great way to maximize the capabilities of their hardware. Not every camera is able to perform well because of the above features. When an operating system is streamlined, its camera function improves as well. In short, the new Ice Cream Sandwich allows device manufacturers to get the most out of their cameras. It also allows them to build on current capabilities. Furthermore, with enhanced image processing and editing abilities, device manufacturers are finally able to make full use of their CPUs and GPUs. It also lets device manufacturers introduce new technology into their mobiles because of the (now) compatible operating system.</p>
<p>This is actually great news for GPU manufacturers who will now be able to create and integrate more powerful GPUs into mobile phones. Not only will the software be able to make full use of the hardware but manufacturers will also be able to create a more power saving solution. The new face detection technology also enables device manufacturers to come up with new ways of improving facial recognition; ways only available on their device. All the changes made in the input services are huge steps and benefits for device manufacturers. They can now finally create pressure and axis based input methods that will allow devices to perform better and more than they ever could. It seems that the new operating system from Android, Ice Cream Sandwich, is proving to be highly beneficial for device manufacturers. The biggest benefit to manufacturers is that they are finally able to make full use of their current and future hardware.</p>
<p><em>This article is composed and edited by Shannen Doherty. She is a technical content writer. She is associated with many technology and designing communities including Broadband Expert as their freelance writer and adviser. In her free time she writes articles related to: internet, <a href="http://www.broadbandexpert.com/">high speed internet providers</a>, technology mobile broadband, etc.</em></p>
<img src="http://feeds.feedburner.com/~r/Codercastecom/~4/XLK3fCxxiDA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codercaste.com/2012/03/24/how-newer-upgrades-in-ice-cream-sandwich-android-platform-are-going-to-benefit-technology-device-manufacturers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codercaste.com/2012/03/24/how-newer-upgrades-in-ice-cream-sandwich-android-platform-are-going-to-benefit-technology-device-manufacturers/</feedburner:origLink></item>
		<item>
		<title>The Expectations of Uptime in the Real World</title>
		<link>http://feedproxy.google.com/~r/Codercastecom/~3/KzL8oG0JNmI/</link>
		<comments>http://www.codercaste.com/2012/01/03/the-expectations-of-uptime-in-the-real-world/#comments</comments>
		<pubDate>Tue, 03 Jan 2012 20:50:58 +0000</pubDate>
		<dc:creator>Spyros</dc:creator>
				<category><![CDATA[General Tips & Tricks]]></category>
		<category><![CDATA[server availability]]></category>
		<category><![CDATA[server hosting]]></category>
		<category><![CDATA[server uptime]]></category>
		<category><![CDATA[uptime]]></category>

		<guid isPermaLink="false">http://www.codercaste.com/?p=1140</guid>
		<description><![CDATA[&#160; This is a guest post. Mila Johnson is an internet entrepreneur who uses GoDaddy discount codes to save money on her domains.  Server uptime is one of those &#8220;real-world&#8221; expectations that is often misunderstood by webmasters and web designers when selecting the right host for their professional web creations. The term uptime is interchangeable with reliability, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.codercaste.com/wp-content/uploads/2012/01/server_uptime.jpg"><img class="alignleft size-thumbnail wp-image-1143" title="server_uptime" src="http://www.codercaste.com/wp-content/uploads/2012/01/server_uptime-150x150.jpg" alt="" width="150" height="150" /></a></p>
<p>&nbsp;</p>
<p><em>This is a guest post. Mila Johnson is an internet entrepreneur who uses <a href="http://www.fatwallet.com/GoDaddy-coupons/">GoDaddy discount codes</a> to save money on her domains. </em></p>
<p><span id="more-1140"></span></p>
<p>Server uptime is one of those &#8220;real-world&#8221; expectations that is often misunderstood by webmasters and web designers when selecting the right host for their professional web creations. The term uptime is interchangeable with reliability, and it is an important statistic that web hosting providers carefully monitor. Hosting providers that have servers with record uptimes often instruct their marketing and sales personnel to tout those long-running statistics to prospective clients. For techies involved in managing server farms, a lengthy server uptime record is like a badge of honor.</p>
<p><strong>What Uptime Really Means</strong></p>
<p>Uptime can be defined as the uninterrupted time elapsed since any machine or device began operating. Any interruptions in a machine&#8217;s operation, including reboots, qualify as downtime. Information technology (IT) professionals may obsess over uptime, but several devices outside of IT have posted impressive uptime records. The ATS-3 satellite, launched by NASA in 1967, was continuously operational until 2001. That&#8217;s 34 uptime years. Home refrigerators are known to run for years without being turned off, save for power outages, and nuclear plants have similarly amazing uptimes.</p>
<p>Server computers are regularly subject to downtime caused by issues such as operating system (OS) upgrades, patches, power outages, disaster prevention measures, etc. For these and other reasons, servers that post long-running uptime statistics never fail to impress IT professionals.</p>
<p><strong>Record Uptime Statistics</strong></p>
<p>In 2006, IT industry giant asked its clients to send the company proof of their Netware server uptimes. One client submitted a screen capture of a server running on a 486 that was last rebooted in 2000. The client apologized for not having implemented a patch that fixed a memory leak which required an annual reboot, otherwise the server uptime would have been closer to 9 years.</p>
<p>Uptime statistics are reported by the OS, but this measurement has proven unreliable at least once. In 2009, a Linux server user detected a bug which returned uptime results of nearly 40 years for some Linux OS versions. Still, many Linux servers running on different hardware platforms have reported uptimes of 2000 days.</p>
<p>Apple&#8217;s Mac OS X may not be an industry favorite when it comes to server machines, but a website that compiles Mac OS X uptime stats has been tracking a server in Sweden with an uptime longer than 8 years.</p>
<p><strong>Uptime versus Availability</strong></p>
<p>Sever uptime statistics can give webmasters looking for a new place to park their websites a pretty good idea about the host&#8217;s level of commitment to its clients. Uptime records can also reveal patterns of administration employed by hosting providers to maintain their servers.</p>
<p>When evaluating different hosting providers, webmasters will invariably hear about 99 percent or higher uptimes. This figure sounds reasonable until actual time is taken into account. A downtime measurement of 9 percent means that a server was not operational for about 87 hours in a year. Assuming that a webmaster needs to see his or her sites up and running around the clock, 365 days a year, those 87 hours could means a lot of lost business.</p>
<p>Availability, the capacity of a server to handle all requests, is a more accurate representation of the dependability webmasters should look for. Besides availability and uptime. what other factors are vital when looking for the ideal web hosting provider?</p>
<img src="http://feeds.feedburner.com/~r/Codercastecom/~4/KzL8oG0JNmI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codercaste.com/2012/01/03/the-expectations-of-uptime-in-the-real-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codercaste.com/2012/01/03/the-expectations-of-uptime-in-the-real-world/</feedburner:origLink></item>
		<item>
		<title>Which Programming Languages Will Be Useful for Windows 8?</title>
		<link>http://feedproxy.google.com/~r/Codercastecom/~3/Hkz9s95B48s/</link>
		<comments>http://www.codercaste.com/2011/10/05/which-programming-languages-will-be-useful-for-windows-8/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 16:21:29 +0000</pubDate>
		<dc:creator>Spyros</dc:creator>
				<category><![CDATA[Windows Programming]]></category>
		<category><![CDATA[.net development]]></category>
		<category><![CDATA[.net framework]]></category>
		<category><![CDATA[metro apps]]></category>
		<category><![CDATA[windows 8]]></category>
		<category><![CDATA[windows metro]]></category>
		<category><![CDATA[windows phone]]></category>

		<guid isPermaLink="false">http://www.codercaste.com/?p=1132</guid>
		<description><![CDATA[This is a guest post, thank you Mariana ! Mariana Ashley is a freelance writer who particularly enjoys writing about online colleges. She loves receiving reader feedback, which can be directed to mariana.ashley031 @gmail.com. No less than a month ago, Microsoft unveiled Windows 8 at the BUILD conference for developers. Described as a “reimagined” operating system (OS) [...]]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: underline;"><em><a href="http://www.codercaste.com/wp-content/uploads/2011/10/microsoft-.net-framework-4.png"><img class="alignleft size-thumbnail wp-image-1133" title="microsoft-.net-framework-4" src="http://www.codercaste.com/wp-content/uploads/2011/10/microsoft-.net-framework-4-150x150.png" alt="" width="150" height="150" /></a>This is a guest post, thank you Mariana !</em></span></p>
<p><strong>Mariana Ashley</strong> is a freelance writer who particularly enjoys writing about <a href="http://www.onlinecolleges.net/">online colleges</a>. She loves receiving reader feedback, which can be directed to mariana.ashley031 @gmail.com.</p>
<p><span id="more-1132"></span></p>
<p>No less than a month ago, Microsoft unveiled Windows 8 at the BUILD conference for developers. Described as a “reimagined” operating system (OS) which combines touch interface with traditional mouse and keyboard input, Windows 8 is designed to work across a broad range of devices, most notably the tablet slate (but also any combination of yet-to-be touch-screen laptops, desktop monitors, and <a href="http://www.knowyourmobile.com/blog/1061833/windows_8_supports_phone_features.html">possibly phones?</a>).</p>
<p><strong>Metro Development</strong></p>
<p>One of the most notable changes to Windows 8 is the new Metro interface, which looks like a graduated, beefier version of Windows Phone 7. There has been much <a href="http://blog.seattlepi.com/techchron/2011/09/13/real-test-for-windows-8-will-be-the-execution/">approval</a> and even <a href="http://tech.fortune.cnn.com/2011/09/20/investors-may-regret-not-warming-up-to-microsoft/">some praise</a> over the Metro interface, which runs “Metro style” apps that are developed from a variety of languages:</p>
<ul>
<li>C#, C++, or Visual Basic
<ul>
<li>XAML (user interface design)</li>
</ul>
</li>
<li>Javascript
<ul>
<li>HTML5 and CSS3 (user interface design)</li>
</ul>
</li>
</ul>
<p><strong>.Net Development</strong></p>
<p><strong> </strong>As for developers trying to figure out how (and whether or not) to code for Windows 8, you are left with a few options. For those with loads of Silverlight experience and .NET Framework know-how, do not worry too much as versions of Windows 8 on x86 processors will run .NET Framework in the “desktop app” which you can access from Metro; so essentially, keep developing for Windows 7, and your programs will be fine on x86 versions of Windows 8. And of course developers who took the patience to understand Windows Presentation Foundation (WPF) will have an easy time creating native Metro apps in XAML.</p>
<p><strong>Where to Start?</strong></p>
<p>With the large variety of programming language options at your disposal, I would begin wherever your strengths direct you. First of course, you will want to download the <a href="http://msdn.microsoft.com/en-us/windows/apps/br229516/">Windows Developer Preview of Windows 8</a>. As for which device you want to develop Windows 8 “Metro style” apps on, obviously a touch-screen device would be ideal to take advantage of the touch interface. A keyboard dock would also be nice to have, considering you will have a good deal of typing to do. However, there are also many reports of Windows 8 <a href="http://thisismynext.com/2011/09/14/windows-8-install-laptop-pictures-how-to-hands-on/">running surprisingly smooth</a> and intuitively on a standard laptop.</p>
<p>From here, I would just stick to <a href="http://msdn.microsoft.com/en-us/windows/apps/">Microsoft’s own guide</a> to app-building for Windows 8. It covers every detail, from the basic questions of “<a href="http://msdn.microsoft.com/library/windows/apps/br211386">what language do I want to build Metro apps in</a>” to <a href="http://msdn.microsoft.com/library/windows/apps/hh465421">planning apps</a>, <a href="http://msdn.microsoft.com/library/windows/apps/br211363">developing apps</a>, and even <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh465433">outlining different ways to monetize apps</a>. And of course, Microsoft provides some sample apps when you install Windows 8, so you can always base your preliminary coding and interface around the samples, and then later tweak interface and design to fit your apps’ needs.</p>
<img src="http://feeds.feedburner.com/~r/Codercastecom/~4/Hkz9s95B48s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codercaste.com/2011/10/05/which-programming-languages-will-be-useful-for-windows-8/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.codercaste.com/2011/10/05/which-programming-languages-will-be-useful-for-windows-8/</feedburner:origLink></item>
		<item>
		<title>The Strategy Design Pattern in Ruby</title>
		<link>http://feedproxy.google.com/~r/Codercastecom/~3/HWEicJ8H-6Q/</link>
		<comments>http://www.codercaste.com/2011/09/27/the-strategy-design-pattern-in-ruby/#comments</comments>
		<pubDate>Wed, 28 Sep 2011 03:48:49 +0000</pubDate>
		<dc:creator>Spyros</dc:creator>
				<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Ruby Programming]]></category>
		<category><![CDATA[ruby design patterns]]></category>
		<category><![CDATA[strategy pattern in ruby]]></category>

		<guid isPermaLink="false">http://www.codercaste.com/?p=1121</guid>
		<description><![CDATA[Programming large projects can be a quite tedious projects that needs lots of code refactoring again and again, if the code is not well written from the beginning. A very efficient way to make sure that your code is of the highest standards, is by utilizing design patterns if applicable. A design pattern is actually [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.codercaste.com/wp-content/uploads/2011/09/najdorf-move-6.jpg"><img class="alignleft size-thumbnail wp-image-1128" title="najdorf move 6" src="http://www.codercaste.com/wp-content/uploads/2011/09/najdorf-move-6-150x150.jpg" alt="" width="150" height="150" /></a>Programming large projects can be a quite tedious projects that needs lots of code refactoring again and again, if the code is not well written from the beginning. A very efficient way to make sure that your code is of the highest standards, is by utilizing design patterns if applicable. A design pattern is actually a way of organizing your code so that it is well written, maintainable and extensible. There are various design patterns fitting lots of different situations. One of my favorites is the Strategy design pattern.</p>
<p><span id="more-1121"></span></p>
<p><strong>What is the Strategy design pattern ?</strong></p>
<p>In the formal sense, the Strategy pattern is one that defines a family of algorithms, encapsulated each one of them and makes it so that they can be interchanged. In a more informal and more understandable definition, it&#8217;s a neat way to dynamically assign behaviour to a particular client object (class object). Let&#8217;s think of an example. Illustrate that we are creating a new game where there is a user that has a first class attribute, which can either be a Ranger, a Fighter, or a Magician. Each class has different skills and, say, different cost to research.</p>
<p>Now, this already creates some questions for us to solve. How will we handle the situation ? Let&#8217;s see how one could do it :</p>
<p>1. We could start by having a User class. This class has an attribute named first_class that can be either set as one of the three types (Ranger, Fighter, Magician). Thus, we would see this :</p>
<pre class="brush: ruby; title: ; notranslate">

user = User.new
user.first_class = 'Ranger'
puts user.cost
</pre>
<p>Now, you may already see the problem in this. The cost function implemented by the User class has serious design flaws. Let&#8217;s see its possible implementation :</p>
<pre class="brush: ruby; title: ; notranslate">

def cost
  if self.first_class == 'Ranger'
    100
  elsif self.first_class == 'Fighter'
    200
  elsif self.first_class == 'Magician'
    130
  end
end
</pre>
<p>An important design principle of good code is the OPEN/CLOSED principle. That code must be open for extension, but closed for modification. Think what will happen if we ever need to add a new first_class, say &#8216;Knight&#8217;. We would need to change the cost function and every other function that operates in the same IF-ELSE way. That would be a big nightmare and a big design problem. Moreover, user.cost does not actually mean anything. Even if we create the method so that it&#8217;s something like user.first_class_cost, we are actually passing first class behavior to the User class. Not a good thing, this class is probably doing too much in terms of responsibilities. We should really make sure that every class only does as much as needed and nothing more. So, how can we make this code better and more extensible ?</p>
<p><strong>Enter The Strategy Design Pattern </strong></p>
<p>Let&#8217;s start by seeing how this code changes when transformed to utilize the Strategy Pattern :</p>
<pre class="brush: ruby; title: ; notranslate">

class User
  attr_accessor :name, :first_class

  def first_class= klass
    @first_class = klass.new
  end

  def first_class_description
    @first_class_description = @first_class.description
  end

end

class FirstClass

  def vehicle
    'car'
  end

end

class Ranger &lt; FirstClass

  def cost
    30
  end

end

class Fighter &lt; FirstClass

  def cost
    20
  end

end
</pre>
<p>See the difference now ? The idea is that we still have a User model, but now we act smarter on defining its first_class. Instead of making it a nightmare String based value, we are actually making it a new model. A new User object now expects a new first_class object in order to operate correctly (we can add it to the constructor as well, if needed). Now, in this example, every first_class gets a new vehicle automatically, so that each new first class character gets a &#8216;car&#8217;. Of course, this can be extended as well, using the same pattern, but it just serves as an example in showing how static things can just stay in the main class. Now, a Ranger, Fighter or anything else, inherits FirstClass and defines a new set of algorithms that operate on the base class. Pretty straight forward i guess.</p>
<p>The best thing about this pattern now is that our object does not need to know what it is, in order to present the description or the cost of its class. The behavior is dynamically set. Let&#8217;s see the example execution :</p>
<pre class="brush: ruby; title: ; notranslate">

user = User.new

user.first_class = Ranger
puts user.first_class.description
puts user.first_class.cost

user.first_class = Fighter
puts user.first_class_description
puts user.first_class.cost
</pre>
<p>And when we execute the program we get :</p>
<pre class="brush: bash; title: ; notranslate">
A Ranger here
30
A Fighter here
20
</pre>
<p>As a side note, see that i also define a first_class_description method, which delegates responsibility directly to the first_class model. This is actually what Rails does with the delegate_to method. It&#8217;s a good practice and a fully encapsulated way to do things. That&#8217;s it with the Strategy Pattern in Ruby, hope that it will help you in designing your implementation.</p>
<img src="http://feeds.feedburner.com/~r/Codercastecom/~4/HWEicJ8H-6Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codercaste.com/2011/09/27/the-strategy-design-pattern-in-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codercaste.com/2011/09/27/the-strategy-design-pattern-in-ruby/</feedburner:origLink></item>
		<item>
		<title>Create a Git Repository on Remote Server and Checkout From Your Local Machine</title>
		<link>http://feedproxy.google.com/~r/Codercastecom/~3/3UoTs8zI7rk/</link>
		<comments>http://www.codercaste.com/2011/08/01/create-a-git-repository-on-remote-server-and-checkout-from-your-local-machine/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 01:43:57 +0000</pubDate>
		<dc:creator>Spyros</dc:creator>
				<category><![CDATA[General Tips & Tricks]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[first git]]></category>
		<category><![CDATA[git bare]]></category>
		<category><![CDATA[git locally]]></category>
		<category><![CDATA[git non bare]]></category>
		<category><![CDATA[git remote repository]]></category>

		<guid isPermaLink="false">http://www.codercaste.com/?p=1111</guid>
		<description><![CDATA[Some time ago, i&#8217;ve written a post about the basics of git, how to create a local repository on git and more. However, git is a bit complicated, especially if you are switching from subversion. It&#8217;s highly likely that you have been using subversion in a remote repository, that is in another machine, and you have [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.codercaste.com/wp-content/uploads/2011/08/git-r-done.gif"><img class="alignleft size-thumbnail wp-image-1113" title="git-r-done" src="http://www.codercaste.com/wp-content/uploads/2011/08/git-r-done-150x150.gif" alt="" width="150" height="150" /></a></p>
<p>Some time ago, i&#8217;ve written a post about <a href="http://www.codercaste.com/2011/02/23/how-to-create-a-repository-for-your-rails-and-not-only-projects-using-git/">the basics of git, how to create a local repository on git</a> and more. However, git is a bit complicated, especially if you are switching from subversion. It&#8217;s highly likely that you have been using subversion in a remote repository, that is in another machine, and you have been committing your changes there. This is definitely the most standard model that programmers tend to work with.</p>
<p><span id="more-1111"></span></p>
<p>Although this can happen with git, doing it can be a bit weird. For starters, you need to know that git has 2 different types of repositories. The first one is the non bare repository and the other one is the bare repository. But, what are the differences ?</p>
<p><strong>Git Bare Repository vs Git Non Bare Repository</strong></p>
<p>The bare repository is the one that you are used to with subversion. That is, a repository that has an internal way of representing data, using indexes and more.  On the other hand, a non bare repository actually refers to a working copy of the repository. A copy that just has the files of your project and not any configuration, indexes or other that the non-bare repository has.</p>
<p><strong>5 Easy Steps For Creating Your Remote Repository</strong></p>
<p>1) First, we will create an empty bare repository. The placeholder for our new project. SSH to your server, and give the commands :</p>
<pre class="brush: bash; title: ; notranslate">

mkdir /home/you/git/repository.git

cd /home/you/git/repository.git

git init --bare
</pre>
<p>This creates your empty bare repository and initializes it as empty.</p>
<p>2) Go the source directory, the one that has your project files. If it&#8217;s not in your remote server, just scp it there, upload it via ftp, whatever is more comfortable for you. Let&#8217;s say that your root project folder lies on /home/you/project. Now, we need to go to this folder and make it a non-bare repository. We do this with the commands :</p>
<pre class="brush: bash; title: ; notranslate">

cd /home/you/project

git init
</pre>
<p>3) Now that you have your non-bare repository, you need to add the files to that repository and commit the changes :</p>
<pre class="brush: bash; title: ; notranslate">

git add .

git commit -m 'initial commit'
</pre>
<p>4. You are now ready to add the bare repository as the remote origin :</p>
<pre class="brush: bash; title: ; notranslate">

git remote add origin /home/you/git/repository.git
</pre>
<p>5. You are now ready to push the changes to your bare repository, which is now the origin. One command to go :</p>
<pre class="brush: bash; title: ; notranslate">

git push --all
</pre>
<p><strong>Check out (or clone for git) from your local machine</strong></p>
<p>Your remote repository is ready now. What is left is testing it. Open up a shell in your local computer and execute :</p>
<pre class="brush: bash; title: ; notranslate">

git clone ssh://remote_ip/path_to_project.git new_project
</pre>
<p>new_project is the name of the folder that will be created with your files inside.</p>
<img src="http://feeds.feedburner.com/~r/Codercastecom/~4/3UoTs8zI7rk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codercaste.com/2011/08/01/create-a-git-repository-on-remote-server-and-checkout-from-your-local-machine/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.codercaste.com/2011/08/01/create-a-git-repository-on-remote-server-and-checkout-from-your-local-machine/</feedburner:origLink></item>
		<item>
		<title>Programming Logic For CSS</title>
		<link>http://feedproxy.google.com/~r/Codercastecom/~3/TjvqR7ugM2g/</link>
		<comments>http://www.codercaste.com/2011/06/13/programming-logic-for-css-2/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 15:54:28 +0000</pubDate>
		<dc:creator>Spyros</dc:creator>
				<category><![CDATA[Cascading Style Sheets (CSS)]]></category>
		<category><![CDATA[css classes]]></category>
		<category><![CDATA[css divs]]></category>
		<category><![CDATA[css ids]]></category>
		<category><![CDATA[css paragraph]]></category>
		<category><![CDATA[programming logic in css]]></category>

		<guid isPermaLink="false">http://www.codercaste.com/?p=1092</guid>
		<description><![CDATA[﻿This is a guest post by Nadia Jones who blogs at best online college about education, college, student, teacher, money saving, movie related topics. You can reach her at nadia.jones5(at)gmail.com. Thank you Nadia ! Knowing and executing good HTML is child&#8217;s play; knowing and executing good CSS is an art form. I remember the first [...]]]></description>
			<content:encoded><![CDATA[<p>﻿<a href="http://www.codercaste.com/wp-content/uploads/2011/06/css_is_awesome_mug-p16871643507198192821yff_400.jpg"><img class="alignleft size-thumbnail wp-image-1103" title="css_is_awesome_mug-p16871643507198192821yff_400" src="http://www.codercaste.com/wp-content/uploads/2011/06/css_is_awesome_mug-p16871643507198192821yff_400-150x150.jpg" alt="" width="150" height="150" /></a>This is a guest post by <strong>Nadia Jones</strong> who blogs at <a href="http://www.onlinecollege.org/">best online college</a> about education, college, student, teacher, money saving, movie related topics. You can reach her at nadia.jones5(at)gmail.com. Thank you Nadia ! <img src='http://www.codercaste.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span id="more-1092"></span></p>
<p>Knowing and executing good HTML is child&#8217;s play; knowing and executing good CSS is an art form. I remember the first website I ever built, just a silly teenage &#8220;look at me&#8221; type of site. It was hosted on Angelfire.com. I used their template at first; then I started making slight customizations until I gradually learned the basic HTML language. By the end of that site&#8217;s life, it was filled to the brim with chaotic html code and strange tags to try to achieve awkward sidebar menus and the like.</p>
<p>Later, once I learned CSS, I became extremely drawn to the beauty and simplicity of the code. No longer were my webpages cluttered and clunky with hundreds of lines of code. The beauty of CSS lies in the separation of HTML from web formatting and styling. See, HTML was not initially indented to contain tags for formatting a web page. The tags, such as &lt; h1 &gt; or &lt; p &gt; were initially intended to simply define content. Once HTML 3.2 hit, font tags and color attributes were added. Suddenly, formatting a site with a large amount of pages became a huge, laborious task as web design standards increased.</p>
<p>CSS saves the pain of inputting the same style tags across every page in a site just to make it look uniform because CSS defines how HTML elements are to be displayed <strong>and</strong> one CSS stylesheet can apply to <strong>multiple pages</strong>. Meaning, you can define a &lt; h2 &gt; to look larger or smaller (or a different font or color) than the standard tag style. With CSS you can style pretty much any HTML element to your liking. This is how whole navigation menus (even dropdown menus) can be made purely through CSS styling unordered lists &lt; ul &gt; and list items &lt; li &gt;.</p>
<p><strong>CSS Basics</strong></p>
<p>There are two important selectors in CSS, &#8220;id&#8221; and &#8220;class.&#8221; The id selector can specify a style for a single and unique element. This means that each element can only have one id and each page can only have one element with that id. So say I only want one &lt; p &gt; to be the color blue. In the CSS stylesheet, I would input:</p>
<pre class="brush: css; title: ; notranslate">

#bluegraph {
    color: blue;
}
</pre>
<p>And in the HTML body, I would input:</p>
<pre class="brush: css; title: ; notranslate">

&lt;p id='bluegraph'&gt;This paragraph is styled blue by its id&lt;/p&gt;
</pre>
<p>And only that paragraph on the page could use that id.</p>
<p>Classes are different from ids in that they are <strong>not </strong>unique. You can use the same class on multiple elements, and you can also apply multiple classes on the same element. So if I want multiple elements, say a &lt; p &gt; and a &lt; h1 &gt; to share the same blue color style, I would create the class using a similar declaration to id (although classes are declared through &#8220;.&#8221; and not &#8220;#&#8221;):</p>
<pre class="brush: css; title: ; notranslate">

.blue {
  color: blue;
}
</pre>
<p>And in the HTML body, I would input:</p>
<pre class="brush: css; title: ; notranslate">
&lt;h1 class=&quot;blue&quot;&gt;This is a blue heading&lt;/h1&gt;
&lt;p class=&quot;blue&quot;&gt;This is a blue paragraph&lt;/p&gt;
</pre>
<p>And both elements would be blue.</p>
<p><strong>Using Div</strong></p>
<p>Now that we know how to style class and id selectors, we can start to style separate elements of our page differentiated by &lt; div &gt; tags. Most people refer to div tags as containers. So, for a page, you would have a div for your header, your navigation menu, your footer, your main content area, and perhaps a sidebar or two if you&#8217;re really fancy. If you have two div elements that are nearly identical, you can use the same class selector to style them. However, I find that most of my div tags are styled with unique id selectors.</p>
<img src="http://feeds.feedburner.com/~r/Codercastecom/~4/TjvqR7ugM2g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codercaste.com/2011/06/13/programming-logic-for-css-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codercaste.com/2011/06/13/programming-logic-for-css-2/</feedburner:origLink></item>
		<item>
		<title>How to Create an XML Writer Class in Python</title>
		<link>http://feedproxy.google.com/~r/Codercastecom/~3/0Bcz5-bCiXI/</link>
		<comments>http://www.codercaste.com/2011/04/02/how-to-create-an-xml-writer-class-in-python/#comments</comments>
		<pubDate>Sat, 02 Apr 2011 06:22:41 +0000</pubDate>
		<dc:creator>Spyros</dc:creator>
				<category><![CDATA[Python Programming]]></category>
		<category><![CDATA[code xml in python]]></category>
		<category><![CDATA[handle xml in python]]></category>
		<category><![CDATA[python xml]]></category>
		<category><![CDATA[python xml programming]]></category>
		<category><![CDATA[xml class in python]]></category>
		<category><![CDATA[xml parser python]]></category>
		<category><![CDATA[xml writer in python]]></category>

		<guid isPermaLink="false">http://www.codercaste.com/?p=1063</guid>
		<description><![CDATA[Even if you haven&#8217;t had a chance to handle XML through one of your programs yet, chances are that there will be a time that you will need to. Well, maybe that time is now, since you&#8217;re reading this post. I have good news for you. Handling XML in Python is very easy. In this [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.codercaste.com/wp-content/uploads/2011/04/xml_doc2.gif"><img class="alignleft size-thumbnail wp-image-1065" title="xml_doc2" src="http://www.codercaste.com/wp-content/uploads/2011/04/xml_doc2-150x150.gif" alt="" width="150" height="150" /></a>Even if you haven&#8217;t had a chance to handle XML through one of your programs yet, chances are that there will be a time that you will need to. Well, maybe that time is now, since you&#8217;re reading this post. I have good news for you. Handling XML in Python is very easy. In this post, i will describe how you can create a very handy minimal xml writer class, that will help you create your xml files with ease.</p>
<p><span id="more-1063"></span></p>
<p>The code is actually pretty short, so i think that i will first paste it here and then discuss how it works :</p>
<pre class="brush: python; title: ; notranslate">

from xml.dom.minidom import Document
from xml.sax.saxutils import unescape

class XmlWriter:

  def __init__(self):
    self.doc = Document()

  def createNode(self, nodeName, parentNode = '', withAttribs = {}):
    node = self.doc.createElement(nodeName)
    if parentNode == '':   # create a parent node
      createdNode = self.doc.appendChild(node)
    else:                  # create a child node
      createdNode = parentNode.appendChild(node)

    if withAttribs != {}:
      for key, value in withAttribs.items():
        self.setAttribute(createdNode, key, value)

    return createdNode

  def setAttribute(self, node, key, value):
    node.setAttribute(key, value)

  def printXML(self):
    print self.doc.toprettyxml(indent=&quot;  &quot;)
</pre>
<p>As you can see, i&#8217;m creating an XMLWriter class, that is responsible for creating xml files. I will be using the nice xml minidom package, which is a very nice and simple way to parse and write xml files. With this xml writer, the process of creating an xml file will be even more elegant and the used code will better illustrate what is happening.</p>
<p>In the class contructor (__init__), we create an instance variable named doc. In this one, we execute Document(), to create a Document object and start populating it with nodes and attributes. Our first interesting function is createNode. This one retrieves a node name and has 2 more optional arguments. The first is parentNode and the second one is withAttribs, that actually expects a python dictionary.</p>
<p>A node in XML can either have a parent and be a child, or be a parent node on its own. If we specify a parentNode, then our newly created node will have to be a child of that node. You can see in the actual code of the function that if parentNode is not specified, we create a new node on the document object. Thus, it&#8217;s a parent node. If parentNode is specified, though, we create a node that is a child of that one.</p>
<p>A node can also have certain attributes, like <strong>&lt;node attrib1 = &#8221;/&gt;</strong>. The withAttribs parameters is a way to specify if you want to add attributes to a node or not. If you do not specify a new dict, the newly created node will not have any attributes. If you do, then you just have to pass a dictionary with keys, values that represent the node attributes. The createNode method utilizes setAttribute, which is the actual function responsible for creating attributes for an XML node. You can make this one private if you like, but i prefer to have the ability to execute it as a standalone method as well.</p>
<p>Finally, there is the printXML method that just outputs the resulting XML. Let&#8217;s now take a look at an execution example of the class :</p>
<pre class="brush: python; title: ; notranslate">

doc = XmlWriter()
node = doc.createNode('node1', withAttribs = {'1': 'first', '2': 'second'})
node2 = doc.createNode('node2', node, withAttribs = {'3': 'third'})
node3 = doc.createNode('node3', node, withAttribs = {'4': 'fourth'})
doc.printXML()
</pre>
<p>You see that we create a parent node with attribs 1= &#8216;first&#8217; and 2=&#8217;second&#8217;. Then, we create a child node of the parent node and we name it node2. This one has attrib 3 = &#8216;third&#8217;. Finally, we create another child to the parent node, with attribs 4 = &#8216;fourth&#8217;. Upon execution of the above, we get this output :</p>
<pre class="brush: python; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; ?&gt;
&lt;node1 1=&quot;first&quot; 2=&quot;second&quot;&gt;
  &lt;node2 3=&quot;third&quot;/&gt;
  &lt;node3 4=&quot;fourth&quot;/&gt;
&lt;/node1&gt;
</pre>
<p>Of course, you can redirect that to a file like &#8220;python XmlWriter.py &gt; example.xml&#8221; or just write a class method that will create the file for you. Hope this makes your xml python creation a bit easier now. In a future post i will also create an xml reader class in Python.</p>
<img src="http://feeds.feedburner.com/~r/Codercastecom/~4/0Bcz5-bCiXI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codercaste.com/2011/04/02/how-to-create-an-xml-writer-class-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codercaste.com/2011/04/02/how-to-create-an-xml-writer-class-in-python/</feedburner:origLink></item>
		<item>
		<title>Explaining How Stacks Work in C++</title>
		<link>http://feedproxy.google.com/~r/Codercastecom/~3/1soATgubSQc/</link>
		<comments>http://www.codercaste.com/2011/03/05/explaining-how-stacks-work-in-c/#comments</comments>
		<pubDate>Sat, 05 Mar 2011 22:24:19 +0000</pubDate>
		<dc:creator>Spyros</dc:creator>
				<category><![CDATA[C/C++ Programming]]></category>
		<category><![CDATA[c++ stacks]]></category>
		<category><![CDATA[define c++ stack]]></category>
		<category><![CDATA[how to create a stack in c++]]></category>
		<category><![CDATA[initialize stack c++]]></category>
		<category><![CDATA[stack class]]></category>
		<category><![CDATA[stack create]]></category>
		<category><![CDATA[stack data structure]]></category>
		<category><![CDATA[stack detroy]]></category>
		<category><![CDATA[stack elements c++]]></category>
		<category><![CDATA[stack methods c++]]></category>
		<category><![CDATA[stack pop]]></category>
		<category><![CDATA[stack push]]></category>
		<category><![CDATA[stack reverse c++]]></category>
		<category><![CDATA[stack template c++]]></category>

		<guid isPermaLink="false">http://www.codercaste.com/?p=1027</guid>
		<description><![CDATA[This is a guest post Today i will talk more deeply about Stacks in C++. In the previous tutorial we just declared some methods of this class, so now let&#8217;s see their content and in future tutorials we will use Stacks in an application in C++. Let&#8217;s start with a look at the template of [...]]]></description>
			<content:encoded><![CDATA[<p><em><a href="http://www.codercaste.com/wp-content/uploads/2011/03/stack.gif"><img class="alignleft size-thumbnail wp-image-1039" title="stack" src="http://www.codercaste.com/wp-content/uploads/2011/03/stack-150x150.gif" alt="" width="150" height="150" /></a>This is a guest post</em></p>
<p>Today i will talk more deeply about Stacks in C++. In the previous tutorial we just declared some methods of this class, so now let&#8217;s see their content and in future tutorials we will use Stacks in an application in C++. Let&#8217;s start with a look at the template of the class Stack one more time.</p>
<p><span id="more-1027"></span></p>
<pre class="brush: cpp; title: ; notranslate">template&lt; class T &gt;
class Stack
{
    private:
        Node&lt; T&gt; *top;
        void destroyStack();
        const Stack&lt; T&gt;&amp; reverse();
    public:
        Stack();
        Stack(const Stack&lt; T&gt;&amp; s);
        virtual ~Stack();
        void push(const T &amp;elem);
        void pop(T &amp;x);
        const T&amp; top() const;
        bool empty() const;
        int lenght() const;
        const Stack&lt; T&gt;&amp; operator = (const Stack&lt; T&gt; &amp;s);
        void write(ostream &amp; ostr) const;
};</pre>
<p>Now let&#8217;s see the content. First the constructors and the default constructor:</p>
<pre class="brush: cpp; title: ; notranslate">template &lt; class T&gt; Stack&lt; T&gt;::Stack() { top = NULL; }</pre>
<p>Let&#8217;s now check the copy constructor. As we can see, it&#8217;s far more complex than the default constructor, but if you pay attention closely, its not much difficult to understand. What we see is just the copy from the content of the stack passed by reference in the &#8220;argument bar&#8221;, to another stack.</p>
<pre class="brush: cpp; title: ; notranslate">template &lt; class T&gt; Stack&lt; T&gt;::Stack(const Stack&lt; T&gt; &amp;s)
{
    Node&lt; T&gt; * apnode = new Node&lt; T&gt;;
    if(s.top)
        top=apnode;
    else
        top=NULL;
    Node&lt; T&gt; *ap = s.top;
    while (ap != NULL) {
        apnode-&gt;info=ap-&gt;info;
        if(ap-&gt;next == NULL)
            apnode-&gt;next=NULL;
        else {
            apnode-&gt;next=new Node&lt; T&gt;;
            apnode=apnode-&gt;next;
        }
        ap=ap-&gt;next;
     }
}</pre>
<p>Now, for the destructors. This one is not the typical destructor we normally see and you now why? Because this is not the &#8220;true&#8221; destructor&#8221;. This method is called by the real destructor (below). This one is just a safety method to ensure the clearance of the Stack, element by element in the top of the Stack.</p>
<pre class="brush: cpp; title: ; notranslate">template &lt; class T&gt;
void Stack&lt; T&gt;::destroyStack() {
    Node&lt; T&gt; * temp; while (top)
    {
        temp=top-&gt;next;
        delete top;
        top=temp;
    }
}</pre>
<p>The real destructor (the one who calls the method above):</p>
<pre class="brush: cpp; title: ; notranslate">template &lt; class T&gt; Stack&lt; T&gt;::~Stack() { destroyStack(); }</pre>
<p>The empty method returns a bool(True or False), which means that it tells us if a selected stack is empty or not.</p>
<pre class="brush: cpp; title: ; notranslate"> template&lt; class T&gt; bool Stack::empty() const { return (top==NULL); }</pre>
<p>This one is easy to judge by its name; it returns the length of a stack. It&#8217;s very useful when we use a for structure or other data structures.</p>
<pre class="brush: cpp; title: ; notranslate">template&lt; class T&gt;
    int Stack&lt; T&gt;::lenght() const
    {
        Node&lt; T&gt; *temp;
        int leng=0;
        temp=top;
        while (temp) {
            leng++;
            temp=temp-&gt;next;
        }
        return leng;
     }</pre>
<p>Another easy and short implementation. It gives us the element in the top of the stack, which is the only possibility. As you remember, in Stacks, we just have access at the top element.</p>
<pre class="brush: cpp; title: ; notranslate"> template&lt; class T&gt; const T&amp; Stack&lt; T&gt;::top() const { return top-&gt;info; }</pre>
<p>A method to pop out the element in the top of the stack. Of course, it just pops out if the stack isn&#8217;t empty. That&#8217;s what the if((empty()) is for.</p>
<pre class="brush: cpp; title: ; notranslate">template&lt; class T&gt;
    void Stack::pop(T &amp; x)
    {
        if (!empty()) {
            x=top-&gt;info;
            Node&lt; T&gt;* temp;
            temp=top;
            top=top-&gt;next;
            delete temp ;
         }
     }
</pre>
<p>Push is the opposite of the Pop operation. It is there to insert an element in a stack and will stay in the top of the stack. Last in First Out (LIFO), remember?</p>
<pre class="brush: cpp; title: ; notranslate">template&lt; class T&gt;
    void Stack&lt; T&gt;::push(const T &amp;elem)
    {
        Node&lt; T&gt;* apnode= new Node&lt; T&gt;;
        apnode-&gt;info=elem;
        apnode-&gt;next=top;
        top=apnode;
    }</pre>
<p>Sometimes, it is useful to reverse the content of a stack. The element on the top should be in the bottom and the one in the bottom should be at the top, for easy access. That&#8217;s why we need this method, to reverse the stack. The stack is &#8220;destroyed/cleared&#8221; and through an auxiliary stack with the same content, we pass the elements to the empty stack (the one who was cleared). Since it&#8217;s a LIFO, the element on the top will now be on the bottom.</p>
<pre class="brush: cpp; title: ; notranslate">template&lt; class T&gt;
    const Stack&lt; T&gt;&amp; Stack&lt; T&gt;::reverse()
    {
        Stack&lt; T&gt; aux(*this) ;
        T x ;
        destroyStack();
        while (!aux.empty()) {
            aux.pop(x) ;
            push(x) ;
        }
        return *this ;
     }</pre>
<p>The attribution method is the one responsible to turn a stack to another one. Pay attention to the &#8220;aux.reverse()&#8221; line. It&#8217;s very important to ensure the elements will not be reversed. Remember again, it&#8217;s a LIFO structure. So, to make a &#8220;copy&#8221; stack we need to reverse the one that will be copied .</p>
<pre class="brush: cpp; title: ; notranslate">template &lt; class T&gt;
    const Stack&lt; T&gt;&amp; Stack&lt; T&gt;::operator = (const Stack&lt; T&gt; &amp; s) {
        Stack&lt; T&gt; aux(s) ;
        T item ;
        destroyStack();
        aux.reverse();
        while (!aux.empty()) {
            aux.pop(item) ;
            push(item) ;
        }
        return *this;
     }</pre>
<p>Nothing special here. We do the writing to an ostream and write to it later.</p>
<pre class="brush: cpp; title: ; notranslate">template&lt; class T&gt;
    void Stack::write(ostream &amp; ostr) const {
        Node&lt; T&gt;* temp=top;
        while (temp) {
            ostr &lt;&lt; temp-&gt;info &lt;&lt; &quot; &quot; ; temp=temp-&gt;next;
        }
    }</pre>
<p>&#8220;Hey, this one is not in the class definition!&#8221; You&#8217;re right, but it&#8217;s not necessary. It calls the method above (write) to write the content, so that in the main class we just need to do this: &lt;&lt;&#8221;name_of_the_class&#8217;s_instance&#8221;. It&#8217;s another very important practice in C++ called &#8220;Operator Overloading&#8221;.</p>
<pre class="brush: cpp; title: ; notranslate">template&lt; class T&gt;
    ostream &amp; operator &lt;&lt; (ostream &amp; ostr, const Stack&lt; T&gt; &amp; s) {
        s.write(ostr);
        return ostr;
}</pre>
<p>That&#8217;s all for today. Hope you like it. Next time we can maybe apply this class in a C++ Application.</p>
<img src="http://feeds.feedburner.com/~r/Codercastecom/~4/1soATgubSQc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codercaste.com/2011/03/05/explaining-how-stacks-work-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codercaste.com/2011/03/05/explaining-how-stacks-work-in-c/</feedburner:origLink></item>
		<item>
		<title>How to use Inheritance in C++ Programming</title>
		<link>http://feedproxy.google.com/~r/Codercastecom/~3/PboQqK8Z-JU/</link>
		<comments>http://www.codercaste.com/2011/03/03/how-to-use-inheritance-in-c-programming/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 21:12:23 +0000</pubDate>
		<dc:creator>Spyros</dc:creator>
				<category><![CDATA[C/C++ Programming]]></category>
		<category><![CDATA[c++ base class]]></category>
		<category><![CDATA[c++ derived]]></category>
		<category><![CDATA[c++ inheritance]]></category>
		<category><![CDATA[c++ public protected private]]></category>
		<category><![CDATA[multiple inheritance in c++]]></category>

		<guid isPermaLink="false">http://www.codercaste.com/?p=1021</guid>
		<description><![CDATA[C++ is rich because of its object oriented programming concepts. Inheritance is the ability to create a hierarchy of classes where a specific class inherits the properties of a generalized class. For example, if we consider Polygon to be a generic class, then shapes like Triangle and Rectangle can be regarded as specific classes. Surely, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.codercaste.com/wp-content/uploads/2011/03/inheritance.gif"><img class="alignleft size-thumbnail wp-image-1023" title="inheritance" src="http://www.codercaste.com/wp-content/uploads/2011/03/inheritance-150x150.gif" alt="" width="150" height="150" /></a>C++ is rich because of its object oriented programming concepts. Inheritance is the ability to create a hierarchy of classes where a specific class inherits the properties of a generalized class. For example, if we consider Polygon to be a generic class, then shapes like Triangle and Rectangle can be regarded as specific classes. Surely, all the polygons have attributes like height and width, whereas the way to calculate area is different for different shapes.<span id="more-1021"></span></p>
<h3>Base Class and Derived Class</h3>
<p>The generic class is termed as <strong>base class</strong> and the class which inherits from a base class is known as <strong>derived class</strong>. Normally, a derived class can access all the methods and attributes of the base class. If required, using some keywords, the derived class can be restricted from accessing the attributes of the base class. The keywords used to control the access are <strong>public, protected and private</strong>. If an attribute or method is declared as public, it can be accessed by the derived class as well as outside functions. That is, if it is part of an instance of the same class. If it is declared as protected, it can be accessed by any derived classes only. If the private keyword is used, the access is completely restricted by all other classes including any derived classes. A <strong>: (full colon)</strong> is used to indicate that a derived class is inheriting from a base class. The constructor and destructor of the base class cannot be inherited by a derived class.</p>
<h3>Multiple Inheritance</h3>
<p>It is also possible for a class to inherit from more than one class simultaneously. This is known as multiple inheritance. For example, suppose there are three classes : electronic products, educational products and computer. Here, a computer can inherit both from electronic products class and educational products class.</p>
<p>Now we will consider an example to know in detail of all the concepts explained above.</p>
<pre class="brush: cpp; title: ; notranslate">
class Polygon
{
    protected int width, height;
    public void setParameters (int w,int h)
    {
        width = w;
        height = h;
    }
};

class Rectangle : public Polygon
{
    public int calculateArea ()
    {
        return (width*height);
    }
};

class Triangle : public Polygon
{
    public int calculateArea ()
    {
        return( (width*height)/2);
    }
};

int main ()
{
    Rectangle rect;
    Triangle trgl;
    rect. setParameters (4,5);
    trgl. setParameters (4,5);
    cout &lt;&lt; rect. calculateArea () &lt;&lt; endl;
    cout &lt;&lt; trgl. calculateArea () &lt;&lt; endl;
    return 0;
}
</pre>
<p>The statements “Class Rectangle : public Polygon” and “class Triangle : public Polygon” indicate that classes Rectangle and Triangle inherit from the class Polygon. Polygon is the base class and Rectangle, Triangle are derived classes. In the above example, the attributes width and height are declared as protected inside the base class, as their access is intended to be within the derived class alone. Those attributes cannot be accessed within the main function directly. The method calculateArea() is defined differently in both the classes, Rectangle and Triangle.</p>
<h3>Advantages of inheritance</h3>
<p>The main advantage of inheritance is re-usability. We don’t have to again and again create classes with similar attributes and functions. Once a base class is created and compiled, it is ready to reuse. Even if there are some new features to be added we can inherit it from the existing class and add the required methods or attributes. This consequently saves time and effort for the programmer.</p>
<img src="http://feeds.feedburner.com/~r/Codercastecom/~4/PboQqK8Z-JU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codercaste.com/2011/03/03/how-to-use-inheritance-in-c-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codercaste.com/2011/03/03/how-to-use-inheritance-in-c-programming/</feedburner:origLink></item>
		<item>
		<title>Essential Data Structures in C++</title>
		<link>http://feedproxy.google.com/~r/Codercastecom/~3/pDyy7jtdZ9M/</link>
		<comments>http://www.codercaste.com/2011/03/02/essential-data-structures-in-c/#comments</comments>
		<pubDate>Wed, 02 Mar 2011 11:03:55 +0000</pubDate>
		<dc:creator>Spyros</dc:creator>
				<category><![CDATA[C/C++ Programming]]></category>
		<category><![CDATA[c++ data structures]]></category>
		<category><![CDATA[data structures]]></category>
		<category><![CDATA[dequeue c++]]></category>
		<category><![CDATA[dynamic arrays c++]]></category>
		<category><![CDATA[linked lists c++]]></category>
		<category><![CDATA[queue in c++]]></category>
		<category><![CDATA[stack in c++]]></category>

		<guid isPermaLink="false">http://www.codercaste.com/?p=1009</guid>
		<description><![CDATA[This is a guest post This tutorial is a simple explanation of some data structures that we can use in C++. I pretend you understand first how each structure works before you look at some code. However, we can’t avoid using some code and I ended adding templates of some structures. This tutorial doesn&#8217;t contain [...]]]></description>
			<content:encoded><![CDATA[<p><em><a href="http://www.codercaste.com/wp-content/uploads/2011/03/391px-Data_stack.svg_.png"><img class="alignleft size-thumbnail wp-image-1011" title="391px-Data_stack.svg" src="http://www.codercaste.com/wp-content/uploads/2011/03/391px-Data_stack.svg_-150x150.png" alt="" width="150" height="150" /></a>This is a guest post</em></p>
<p>This tutorial is a simple explanation of some data structures that we can use in C++. I pretend you understand first how each structure works before you look at some code. However, we can’t avoid using some code and I ended adding templates of some structures. This tutorial doesn&#8217;t contain all data structures but I&#8217;m sure the most important ones are here and this will be a big help in improving your skills in C++.<span id="more-1009"></span></p>
<h3>Array</h3>
<p>It&#8217;s a collection of elements of the same type directly accessed by an integer index;</p>
<p><strong>Static Array:</strong> has a fixed number of elements and it’s allocated during compilation time;</p>
<p>Ex: int x[20];</p>
<p><strong>Dynamic Array:</strong> it&#8217;s created using allocation techniques and dynamic memory management. Can be resized.</p>
<p>Ex: Int *x = new int [20];</p>
<h3>File</h3>
<p>It is an external data collection with an associated data structure named by &#8220;stream&#8221;; <strong>Direct Access</strong> – files in hard disk; <strong>Sequential access</strong> &#8211; files in tapes;</p>
<p>The reading operation withdraw data from an input stream;<br />
The writing operation merges new data at the end of output stream;</p>
<p>Files are used to save large amounts of data;</p>
<h3>Linked List</h3>
<p>• Sequential collection of elements;<br />
• No minimum or maximum limit of elements since it is resizable whether the elements are added or removed from the list;<br />
• Doesn&#8217;t allow direct access;<br />
• The elements can be disposed through a numeric or alphabetical ordering;<br />
• The elements can be accessed in any position of the list;</p>
<p>The implementation of this structure can be done through an array (the implementation is limited to the array size) or through a Linked List (the structures are created dynamically).</p>
<p>A linked least is composed by nodes. Each node has two fields:<br />
-the object including on the list;<br />
-a pointer to the next element (node) of the list;</p>
<p><strong>Characteristics:</strong><br />
-memory space filled by the list grow accordingly with the needs of the application;<br />
-the operations add() and remove() elements are realized by the local manipulation of the pointers;</p>
<p>A template of the class <strong>Linked List</strong> that will help a lot:</p>
<pre class="brush: cpp; title: ; notranslate">
template&lt; class T&gt;
class List{

    private:
        Node&lt; T&gt;* head;
        void destroylist();

    public:
        List(){head=NULL;};
        List(const List&lt; T&gt;&amp; l);
        ~List();
        bool empty() const{ return head==NULL;};
        void add(int k,const T&amp; elem);
        int lenght() const;
        void remove(int k,T&amp; x);
        bool find(int k, T&amp; x) const;
        const List&lt; T&gt;&amp; operator = (const List&lt; T&gt;&amp; l);
        void write(ostream&amp; out) const;
};
</pre>
<h3>Stack</h3>
<p>•the elements are added and removed just by one side of the stack, the top;<br />
•always an element is added or removed of the stack the top is updated;<br />
•it&#8217;s a structure where is applied the LIFO order (Last In First Out);</p>
<p>Stacks are used in:<br />
-Evaluation of Numerical Expressions;<br />
-Recursion;</p>
<p>A template for the class <strong>Stack</strong>:</p>
<pre class="brush: cpp; title: ; notranslate">
template&lt; class T&gt;
class Stack{

    private:
        Node&lt; T&gt;* top;
        void destroystack();
        const Stack&lt; T&gt;&amp; invert();

     public:
         Stack(){ top=NULL;}
         Stack(const Stack&lt; T&gt;&amp; s);
         ~Stack();
         bool empty() const{ return top==NULL;};
         void push(const T&amp; elem); //insert an element on the top of the stack
         void pop(T&amp; x); //remove the element on the top of the stack
         const T&amp; top() const{ return top-&gt;info;}
         int lenght() const; //return stack lenght
         const Stack&lt; T&gt;&amp; operator = (const Stack&lt; T&gt;&amp; s);
         void write(ostream&amp; ostr) const;
};
</pre>
<h3>Queue</h3>
<p>•The access to the elements it’s done using both sides of the queue;<br />
•The elements are “removed” by the front of the queue;<br />
•The elements are “added” by the back of the queue;<br />
•The elements stay always in the same order they arrived which means we have a FIFO type order (First in, First Out);</p>
<p>Queues are used in waiting lists:<br />
-simulation studies;<br />
-Task escalation in operative systems;</p>
<p>Template of class <strong>Queue</strong>:</p>
<pre class="brush: cpp; title: ; notranslate">
template&lt; class T&gt;
class Queue{

    private:
        Node&lt; T&gt;* begin;
        Node&lt; T&gt;* end;
        void destroyqueue();

    public:
        Queue&lt; T&gt;(){ begin=NULL; fim=NULL;};
        Queue&lt; T&gt;(const Queue&lt; T&gt;&amp; q);
        ~Queue&lt; T&gt;();
        bool empty() const{ return begin==NULL;};
        void push_back(const T&amp; elem);
        void pop_front(T&amp; x);
        const T&amp; front() const{ return begin-&gt;info;};
        const T&amp; back() const{ return end-&gt;info;};
        int lenght() const;
        const Queue&lt; T&gt;&amp; operator = (const Queue&lt; T&gt;&amp; q);
        void write(ostream&amp; ostr) const;
};
</pre>
<h3>Dequeue</h3>
<p>•Linear structure more general then the stacks and the queues;<br />
•It&#8217;s a special type of queue where the removes and the adds can be done in the front or in the back of the queue;<br />
•Like the queues this structure can be implemented with vector or linked list;</p>
<p>Simple template of <strong>Dequeue</strong>:</p>
<pre class="brush: cpp; title: ; notranslate">
template&lt; class T&gt;
class DQueue: public Queue&lt; T&gt;{

    public:
        DQueue();
        DQueue(const Dequeue&lt; T&gt;&amp; dq);
        ~DQueue();
        void push_front(const T&amp; x);
        void pop_back(T&amp; x);
};
</pre>
<p>And that&#8217;s it for today. Hope you learn something about data structures with this. Now it&#8217;s start practicing. Good work!</p>
<img src="http://feeds.feedburner.com/~r/Codercastecom/~4/pDyy7jtdZ9M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codercaste.com/2011/03/02/essential-data-structures-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codercaste.com/2011/03/02/essential-data-structures-in-c/</feedburner:origLink></item>
	</channel>
</rss>

