<?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>electrofriends.com</title>
	<atom:link href="http://electrofriends.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://electrofriends.com</link>
	<description>...bringing innovative minds together</description>
	<lastBuildDate>Fri, 11 May 2012 08:44:59 +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>Handheld Vehicle Lock Control System Using Wireless Communication (IR / RF)</title>
		<link>http://electrofriends.com/projects/microcontrollers/handheld-vehicle-lock-control-system-wireless-communication-ir-rf/</link>
		<comments>http://electrofriends.com/projects/microcontrollers/handheld-vehicle-lock-control-system-wireless-communication-ir-rf/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 11:18:46 +0000</pubDate>
		<dc:creator>venugopal</dc:creator>
				<category><![CDATA[Microcontrollers]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=2679</guid>
		<description><![CDATA[ABSTRACT: In this project we are using IR communication to implement the handheld vehicle lock control system. Infrared (IR) radiation is electromagnetic radiation whose wavelength is longer than that of visible light (400-700 nm), but shorter than that of terahertz radiation (1 µm &#8211; 1mm) and microwaves (~30,000 µm). Infrared radiation spans roughly three orders [...]]]></description>
			<content:encoded><![CDATA[<p><strong>ABSTRACT:</strong></p>
<p>In this project we are using IR communication to implement the handheld vehicle lock control system. Infrared (IR) radiation is electromagnetic radiation whose wavelength is longer than that of visible light (400-700 nm), but shorter than that of terahertz radiation (1 µm &#8211; 1mm) and microwaves (~30,000 µm). Infrared radiation spans roughly three orders of magnitude (750 nm and 100 µm).</p>
<p>A remote control locks operation system for a vehicle capable of unlocking a mechanical locking mechanism for mechanically disabling traveling of the vehicle by an infrared signal, without using the key. Components of the system include a handheld remote control transmitter, a receiver, a mechanical locking mechanism, a lock actuator and control unit, and wiring sections for connecting the lock actuator and the receiver to the control unit mounted in a common module housing contained on the vehicle body. The main components of the system, including the wiring section leading to the lock actuator, are unitized and integrate into the common module housing in order to prevent unauthorized unlocking of the lock.</p>
<p>To implement this application required components are one microcontroller, TV remote, IR receiver (TSOP1738), LCD, l293D and DC motor.  Whenever user want to open the door, he has to press one remote switch which is related to ON. For that user has to develop one application program in EMBEDDED-C. At the same time for close the door separate key is assigned.</p>
<p><strong>BLOCK DIAGRAM:</strong></p>
<p><strong><img class="aligncenter size-medium wp-image-2680" src="http://electrofriends.com/wp-content/uploads/2012/02/block-diagram-300x179.png" alt="" width="300" height="179" /></strong></p>
<p><strong>HARDWARE REQUIREMENTS</strong></p>
<ul>
<li>AT89S52</li>
<li>LCD DISPLAY</li>
<li>TV REMOTE</li>
<li>IR RECEIVER (TSOP1738)</li>
<li>L293D</li>
<li>DOOR (DC MOTOR)</li>
<li> BUZZER</li>
</ul>
<p><strong>SOFTWARE REQUIREMENTS</strong></p>
<ul>
<li>KEIL C Compiler</li>
<li>PROGRAMMING IN EMBEDDED C</li>
<li>ISP PROGRAMMER</li>
</ul>
<p><strong>SCHEMATIC DIAGRAM:</strong></p>
<p><strong><a href="http://electrofriends.com/wp-content/uploads/2012/02/schematic-diagram.png"><img class="aligncenter size-full wp-image-2681" src="http://electrofriends.com/wp-content/uploads/2012/02/schematic-diagram.png" alt="" width="627" height="518" /></a><br />
</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/projects/microcontrollers/handheld-vehicle-lock-control-system-wireless-communication-ir-rf/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>What is a global variable?</title>
		<link>http://electrofriends.com/qna/software-languages/c-cpp-faq/global-variable/</link>
		<comments>http://electrofriends.com/qna/software-languages/c-cpp-faq/global-variable/#comments</comments>
		<pubDate>Tue, 14 Feb 2012 17:59:36 +0000</pubDate>
		<dc:creator>chitra</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[global]]></category>
		<category><![CDATA[local and global]]></category>
		<category><![CDATA[local and global variables]]></category>
		<category><![CDATA[variable types]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=2665</guid>
		<description><![CDATA[variables that are known throughout the program and may be used by any piece of code is called a global variable. Also, they will hold their value throughout the program&#8217;s execution. Global variables can be created by declaring them outside of any function. Global variables are helpful when many functions in the program use the [...]]]></description>
			<content:encoded><![CDATA[<p>variables that are known throughout the program and may be used by any piece of code is called a global variable. Also, they will hold their value throughout the program&#8217;s execution. Global variables can be created by declaring them outside of any function.</p>
<p>Global variables are helpful when many functions in the program use the same data. Storage for global variables is in a fixed region of memory set aside for this purpose by the compiler.</p>
<p>In the following program, the variable count has been declared outside of all functions.</p>
<p>Example:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &quot;stdio.h&quot;</span>
<span style="color: #993333;">int</span> count<span style="color: #339933;">;</span>  <span style="color: #808080; font-style: italic;">/* count is global  */</span>
<span style="color: #993333;">void</span> func1<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  count <span style="color: #339933;">=</span> <span style="color: #0000dd;">100</span><span style="color: #339933;">;</span>
  func1<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #993333;">void</span> func1<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;count is %
d&quot;</span><span style="color: #339933;">,</span> count<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/* will print 100 */</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/qna/software-languages/c-cpp-faq/global-variable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is a local variable?</title>
		<link>http://electrofriends.com/qna/software-languages/c-cpp-faq/local-variable/</link>
		<comments>http://electrofriends.com/qna/software-languages/c-cpp-faq/local-variable/#comments</comments>
		<pubDate>Tue, 14 Feb 2012 09:47:40 +0000</pubDate>
		<dc:creator>chitra</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[auto]]></category>
		<category><![CDATA[automatic]]></category>
		<category><![CDATA[automatic variables]]></category>
		<category><![CDATA[local and global]]></category>
		<category><![CDATA[variable types]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=2661</guid>
		<description><![CDATA[Variables that are declared inside a function are called local variables. Local variables can be used only by statements that are inside the block in which the variables are declared. In other words, local variables are not known outside their own code block. A block of code begins with an opening curly brace and terminates [...]]]></description>
			<content:encoded><![CDATA[<p>Variables that are declared inside a function are called local variables. Local variables can be used only by statements that are inside the block in which the variables are declared. In other words, local variables are not known outside their own code block. A block of code begins with an opening curly brace and terminates with a closing curly brace.</p>
<p>Local variables exist only while the block of code in which they are declared is executing. That is, a local variable is created upon entry into its block and destroyed upon exit. Furthermore, a variable declared within one code block has no bearing on or relationship to another variable with the same name declared within a different code block.</p>
<p>Example:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">void</span> func1<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span> 
  <span style="color: #993333;">int</span> y<span style="color: #339933;">;</span> 
  y <span style="color: #339933;">=</span> <span style="color: #0000dd;">10</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #993333;">void</span> func2<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span> 
  <span style="color: #993333;">int</span> y<span style="color: #339933;">;</span>
  y <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #0000dd;">199</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The integer variable y is declared twice, once in func1( ) and once in func2( ). The y in func1( ) has no relationship to the y in func2( ). This is because each y is known only to the code within the block in which it is declared.</p>
<p>The C language contains the keyword auto, which can be used to declare local variables. However, since all variables are, by default, assumed to be auto, this keyword is virtually never used. </p>
]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/qna/software-languages/c-cpp-faq/local-variable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is the use of sizeof() operator in C?</title>
		<link>http://electrofriends.com/qna/software-languages/c-cpp-faq/sizeof-operator/</link>
		<comments>http://electrofriends.com/qna/software-languages/c-cpp-faq/sizeof-operator/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 08:41:28 +0000</pubDate>
		<dc:creator>chitra</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[c opertors]]></category>
		<category><![CDATA[operators in c]]></category>
		<category><![CDATA[size of]]></category>
		<category><![CDATA[sizeof]]></category>
		<category><![CDATA[sizeof in c]]></category>
		<category><![CDATA[sizeof operator]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=2653</guid>
		<description><![CDATA[The sizeof operator returns the size in bytes of its operand. Operand may be a variable or data type.]]></description>
			<content:encoded><![CDATA[<p>The sizeof operator returns the size in bytes of its operand. Operand may be a variable or data type.</p>
<p>Here are few examples,</p>
<p>Example 1:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">char</span> c<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%d,%d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span> c<span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/* returns 1, 4*/</span>
 <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Example 2:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #009900;">&#40;</span>main<span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
	 <span style="color: #993333;">struct</span> 
	 <span style="color: #009900;">&#123;</span>
	   <span style="color: #993333;">int</span> a<span style="color: #339933;">;</span>
	   <span style="color: #993333;">int</span> b<span style="color: #339933;">;</span>
	 <span style="color: #009900;">&#125;</span>s<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066;">printf</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;% d \ n&quot;</span><span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span> <span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/* returns 8*/</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Example 3:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">short</span> array <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">2</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">3</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">4</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">5</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #993333;">short</span> la <span style="color: #339933;">=</span> <span style="color: #993333;">sizeof</span> <span style="color: #009900;">&#40;</span>array<span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #339933;">*</span> returns <span style="color: #0000dd;">10</span> <span style="color: #339933;">*</span> <span style="color: #339933;">/</span>
 <span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/qna/software-languages/c-cpp-faq/sizeof-operator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remote System Monitoring and Controlling via Web based Mobile or Desktop Application</title>
		<link>http://electrofriends.com/projects/computer-programming/remote-system-monitoring-controlling-web-based-mobile-desktop-application/</link>
		<comments>http://electrofriends.com/projects/computer-programming/remote-system-monitoring-controlling-web-based-mobile-desktop-application/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 09:41:22 +0000</pubDate>
		<dc:creator>Ranjan</dc:creator>
				<category><![CDATA[Computer Programming]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=2631</guid>
		<description><![CDATA[Introduction The idea of remote system monitoring and controlling application is to do some of the actions like ex: Shutdown, Reboot, Hibernate of the users systems remotely. The user can also make use of this application to query additional details of the systems. Consider a scenario where you have a set of systems (Computers) and [...]]]></description>
			<content:encoded><![CDATA[<h2><span style="font-weight: bold"><!--pagetitle:Remote System Monitoring and Controlling via Web based Mobile or Desktop Application-->Introduction</span></h2>
<p>The idea of remote system monitoring and controlling application is to do some of the actions like ex: Shutdown, Reboot, Hibernate of the users systems remotely. The user can also make use of this application to query additional details of the systems.</p>
<p>Consider a scenario where you have a set of systems (Computers) and you want to control them from your mobile or any other desktop anywhere from the world. So this started as initial requirement of how we can implement the same to control numerous systems remotely.</p>
<p>Consider another scenario of how you can retrieve the information of a particular system remotely from your handheld devices or through desktops. By retrieving information, one may be interested in knowing the following</p>
<ol>
<li>Machine Name</li>
<li>CPU information</li>
<li>Username</li>
<li>Domain Name</li>
<li>OS Version</li>
</ol>
<h2><strong>Software Requirements Specification</strong></h2>
<ol>
<li>Aim: The aim of this project is to provide a facility for the end user to remotely control their systems through desktop or mobile based web application.</li>
<li>Purpose: The purpose of this project is to implement a proof or concept of the same. And to show how easily it can be done with .NET technology</li>
<li>Scope: The scope of this project is very limited to controlling the system with few actions like Shutdown, Reboot, Hibernate, Logoff, Force close all applications etc. The user registration is done only at the client application and the it should be always running in-order to control the system remotely.</li>
<li>User Characteristics:  The Following things are taken into consideration with this software development
<ol>
<li>Users can have multiple systems for controlling. There is absolutely no limit in the number of systems being controlled by the users.</li>
<li>The user can either control her/his systems through mobile or desktop based web application.</li>
<li>Each user can control his/her system only and don’t have access to control others systems.</li>
<li>Right now there is only one type of user of this system i.e. the System Administrators who will be using this system to control or fetch additional information of the system on their own interest.</li>
</ol>
</li>
</ol>
<p><strong><br />
</strong></p>
<p><strong> </strong></p>
<h2><strong>Software and Hardware Requirement</strong></h2>
<p><strong>Software Requirements:</strong></p>
<ul>
<li>Operating system: Microsoft Windows XP / Win 7 / Vista</li>
<li>.NET framework 4.0</li>
<li>SQL Server 2008</li>
</ul>
<p><strong>Hardware Requirements:</strong></p>
<ul>
<li>Processor Pentium 4</li>
<li>RAM- 256Mb</li>
<li>HDD-10GB</li>
</ul>
<p><span style="font-weight: bold">Technologies Used</span></p>
<p>Visual Studio.NET</p>
<ul>
<li>The       Client Application is developed with .NET C# Winform technology</li>
<li>The Server       side web application is developed with ASP.NET MVC3 technology.</li>
</ul>
<p>Internet based / Cloud based Microsoft SQL Server 2008</p>
<ul>
<li>This       software is designed with Software as a Service model with a common single       cloud database which stores all the users and their system information.</li>
</ul>
<h2><strong>How does the software functions?</strong><strong> </strong></h2>
<p>Client Application:</p>
<p>When you run the client application for the first time, you will have to register yourself with the username and password. The same has to be provided as log on information which will authenticate the user in client and server applications.</p>
<p>Once authenticated, the user has to click on the Start button for continuous monitoring of the system behind the scene. The system registers by itself by putting an entry in database (this happens only for the first usage of the client app) so that the user can control that particular machine.  When the user closes the client application, the entry in the database for that system will be deactivated.  For subsequent usable of the client application, the system will be activated for monitoring and controlling.</p>
<p>Server Application:</p>
<p>It is a web based application, on requesting the user will be authenticated. The use has to provide the same username and password he/she has provided at the time of user registration in client app.</p>
<p>On successful authentication, the list of active systems will be displayed in a screen. The user can select one and perform the actions like Shutdown, Reboot etc.</p>
<p><strong> </strong></p>
<p><strong><br />
</strong></p>
<p><strong> </strong></p>
<h2><strong>Database Entity Relationship Design Diagram</strong></h2>
<p><a href="http://electrofriends.com/wp-content/uploads/2012/01/DatabaseEntityDiagram-e1327829836286.png"><img class="alignleft size-full wp-image-2632" src="http://electrofriends.com/wp-content/uploads/2012/01/DatabaseEntityDiagram-e1327829836286.png" alt="" width="500" height="760" /></a></p>
<p><strong><br />
</strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<h2><span style="font-weight: bold"></p>
]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/projects/computer-programming/remote-system-monitoring-controlling-web-based-mobile-desktop-application/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Dependency Injection in C# .NET</title>
		<link>http://electrofriends.com/articles/dependency-injection/</link>
		<comments>http://electrofriends.com/articles/dependency-injection/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 01:56:01 +0000</pubDate>
		<dc:creator>Ranjan</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Computer Science]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=2578</guid>
		<description><![CDATA[Dependency injection basically allows us to create loosely coupled, reusable, and testable objects in your software designs by removing dependencies. We will take a look into the Object dependencies before digging in more. Consider a scenario of fetching an employee details and show display in UI. Let us say create a Business logic layer class [...]]]></description>
			<content:encoded><![CDATA[<p>Dependency injection basically allows us to create loosely coupled, reusable, and testable objects in your software designs by removing dependencies.</p>
<p>We will take a look into the Object dependencies before digging in more.<br />
Consider a scenario of fetching an employee details and show display in UI. Let us say create a Business logic layer class named EmployeeBAL and a data access layer class named EmployeeDAO</p>
<p>public class EmployeeDao<br />
{<br />
//Some code<br />
}</p>
<p>public class EmployeeBAL<br />
{<br />
var employeeDAO = new EmployeeDao();<br />
//Some code<br />
}</p>
<p>From the above code you will notice one thing that we are creating EmployeeDAO instance inside the Business logic layer class. So here comes the dependency</p>
<h2><strong>What is wrong if we have a dependency?</strong></h2>
<p>Think about whether your code is unit testable. We cannot fully unit test the EmployeeBAL as it has a dependency on Employee DAO. So we can say as long as the composition of the DAO exists within the BAL we cannot unit test the EmployeeBAL.</p>
<p>You will also notice one more thing here; with this type of implementation you will see a high coupling of BAL and DAL.</p>
<h2><strong>How to make it loose coupling?</strong></h2>
<p>The basic idea behind Dependency Injection is that you should isolate the implementation of an object from the construction of objects on which it depends.</p>
<p>Coming to the example, we should be isolating the implementation of EmployeeBAL object and the construction of the dependent EmployeeDAO object.</p>
<p>We will see how we can make loosely coupled objects in detail</p>
<h2><strong> Constructor based dependency injection</strong></h2>
<p>We will have to modify the EmployeeBAL to accept an EmployeeDAO instance within its constructor.</p>
<p>public class EmployeeDao<br />
{<br />
//Some code<br />
}</p>
<p>public class EmployeeBAL<br />
{<br />
EmployeeDao employeeDAO;</p>
<p>public EmployeeBAL(EmployeeDAO employeeDao){<br />
this.employeeDAO  = employeeDao;<br />
}<br />
//Some code<br />
}</p>
<h2><strong> Property based dependency injection</strong></h2>
<p>With property based injection we will have a public getter and setter Property of type EmployeeDao so that the dependency can be externally set.</p>
<p>public class EmployeeBAL<br />
{<br />
Public EmployeeDao EmployeeDataAccess{ get; set; }<br />
}</p>
<p>var employeeBAL = new EmployeeBAL();<br />
EmployeeBAL.EmployeeDataAccess = new EmployeeDao();</p>
<p>Wait!!!</p>
<p>The above ones are just some techniques of injecting the dependency. We are still yet to discuss one more interesting thing Unit Testing.</p>
<p>Are you agreeing that we have removed the DAO creation from the Business Logic EmployeeBAL? Yes it is good but it still depends on the actual instance of EmployeeDao.</p>
<p>Consider the below mentioned implementation of the same sample senarios</p>
<p>interface IDataAccess<br />
{<br />
//Some code<br />
}</p>
<p>class EmployeeDao : IDataAccess<br />
{<br />
//Some code<br />
}</p>
<p>public class EmployeeBAL<br />
{<br />
private IDataAccess dataAccess;<br />
public BusinessFacade(IDataAccess dao)<br />
{<br />
dataAccess = dao;<br />
}<br />
}</p>
<p>You can notice we are doing a constructor dependency injection but most important thing here<br />
is we are using Interface type than creating a strongly typed object.</p>
<p>The advantage that we are getting here is we can have an in memory data access object of<br />
IDataAccess interface type and we can  easily inject the dependency to the EmployeeBAL.<br />
By this way we no need to have the actual database dependency.</p>
<p>Are you happy that we can unit test the BAL without the data access dependency?</p>
<h2><strong>Advantages of Dependency Injection</strong></h2>
<p><strong></strong><br />
The primary advantages of dependency injection are:<br />
Loose coupling<br />
Centralized configuration<br />
Easily testable</p>
]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/articles/dependency-injection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>what is Void Pointer?</title>
		<link>http://electrofriends.com/qna/software-languages/c-cpp-faq/void-pointer/</link>
		<comments>http://electrofriends.com/qna/software-languages/c-cpp-faq/void-pointer/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 07:18:21 +0000</pubDate>
		<dc:creator>chitra</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[pointer concept]]></category>
		<category><![CDATA[pointers in c]]></category>
		<category><![CDATA[void pointer]]></category>
		<category><![CDATA[void pointers]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=2609</guid>
		<description><![CDATA[Void pointer or generic pointer is a special type of pointer that can be pointed at objects of any data type. A void pointer is declared like a normal pointer, using the void keyword as the pointer’s type. Pointers defined using specific data type cannot hold the address of the some other type of variable [...]]]></description>
			<content:encoded><![CDATA[<p>Void pointer or generic pointer is a special type of pointer that can be pointed at objects of any data type. A void pointer is declared like a normal pointer, using the void keyword as the pointer’s type.</p>
<p>Pointers defined using specific data type cannot hold the address of the some other type of variable i.e., it is incorrect in C++ to assign the address of an integer variable to a pointer of type float.</p>
<p>Example:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">float</span> <span style="color: #339933;">*</span>f<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//pointer of type float</span>
<span style="color: #993333;">int</span> i<span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">//integer variable</span>
f <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>i<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//compilation error</span></pre></div></div>

<p>The above problem can be solved by general purpose pointer called void pointer.</p>
<p>Void pointer can be declared as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">void</span> <span style="color: #339933;">*</span>v <span style="color: #666666; font-style: italic;">// defines a pointer of type void</span></pre></div></div>

<p>The pointer defined in this manner do not have any type associated with them and can hold the address of any type of variable.</p>
<p>Example:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">void</span> <span style="color: #339933;">*</span>v<span style="color: #339933;">;</span> 
<span style="color: #993333;">int</span> <span style="color: #339933;">*</span>i<span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> ivar<span style="color: #339933;">;</span>
<span style="color: #993333;">char</span> chvar<span style="color: #339933;">;</span>
<span style="color: #993333;">float</span> fvar<span style="color: #339933;">;</span>
v <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>ivar<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// valid</span>
v <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>chvar<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//valid</span>
v <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>fvar<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// valid</span>
i <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>ivar<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//valid</span>
i <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>chvar<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//invalid</span>
i <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>fvar<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//invalid</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/qna/software-languages/c-cpp-faq/void-pointer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is dangling pointer?</title>
		<link>http://electrofriends.com/qna/software-languages/c-cpp-faq/dangling-pointer/</link>
		<comments>http://electrofriends.com/qna/software-languages/c-cpp-faq/dangling-pointer/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 10:43:23 +0000</pubDate>
		<dc:creator>chitra</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[dangling]]></category>
		<category><![CDATA[dangling pointer]]></category>
		<category><![CDATA[dangling pointers]]></category>
		<category><![CDATA[pointer]]></category>
		<category><![CDATA[pointer concept]]></category>
		<category><![CDATA[pointers]]></category>
		<category><![CDATA[pointers dangling]]></category>
		<category><![CDATA[pointers in c]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=2601</guid>
		<description><![CDATA[Dangling pointers and wild pointers in computer programming are pointers that do not point to a valid object of the appropriate type. In many applications memory is allocated for holding data objects. After using these objects, tha aplication will de-allocate this memory so that the memory can be re-used. In some cases the alications may [...]]]></description>
			<content:encoded><![CDATA[<p>Dangling pointers and wild pointers in computer programming are pointers that do not point to a valid object of the appropriate type.</p>
<p>In many applications memory is allocated for holding data objects. After using these objects, tha aplication will de-allocate this memory so that the memory can be re-used. In some cases the alications may use a pointer to an object whose memory is already de-allocated. This may lead to application crash or an unpredictable behavior.</p>
<p>scenarios which leads to dangling pointer</p>
<ol>
<li>Application makes use of a object after it has been released, and there by access to an invalid memory location.</li>
<li>A function returns a pointer to one of its local variables, and since this local variable is defined only fro the function, the pointer becomes invalid once the function ends.</li>
</ol>
<p>The most common result of this bug is the crash of the application or its running thread.</p>
<p><strong>Examle 1:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &quot;stdlib.h&quot;</span>
&nbsp;
<span style="color: #993333;">void</span> func<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>dp <span style="color: #339933;">=</span> malloc<span style="color: #009900;">&#40;</span>A_CONST<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #808080; font-style: italic;">/* ... */</span>
    free<span style="color: #009900;">&#40;</span>dp<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>         <span style="color: #808080; font-style: italic;">/* dp now becomes a dangling pointer */</span>
    <span style="color: #808080; font-style: italic;">/* ... */</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>Example 2:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
   <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>dp <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
   <span style="color: #808080; font-style: italic;">/* ... */</span>
   <span style="color: #009900;">&#123;</span>
       <span style="color: #993333;">char</span> c<span style="color: #339933;">;</span>
       dp <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>c<span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span> <span style="color: #808080; font-style: italic;">/* c falls out of scope */</span>
     <span style="color: #808080; font-style: italic;">/* dp is now a dangling pointer */</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>Example 3:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &quot;stdio.h&quot;</span>
&nbsp;
<span style="color: #993333;">int</span> <span style="color: #339933;">*</span>call<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #993333;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #993333;">int</span> <span style="color: #339933;">*</span>ptr<span style="color: #339933;">;</span>
ptr<span style="color: #339933;">=</span>call<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
fflush<span style="color: #009900;">&#40;</span>stdin<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%d&quot;</span><span style="color: #339933;">,*</span>ptr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">int</span> <span style="color: #339933;">*</span> call<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #993333;">int</span> x<span style="color: #339933;">=</span><span style="color: #0000dd;">25</span><span style="color: #339933;">;</span>
<span style="color: #339933;">++</span>x<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">return</span> <span style="color: #339933;">&amp;</span>x<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/qna/software-languages/c-cpp-faq/dangling-pointer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delegate and Events in C# .NET</title>
		<link>http://electrofriends.com/articles/delegate-events-net/</link>
		<comments>http://electrofriends.com/articles/delegate-events-net/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 16:54:06 +0000</pubDate>
		<dc:creator>Ranjan</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Delegates]]></category>
		<category><![CDATA[Events]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=2560</guid>
		<description><![CDATA[Delegates A delegate in C# is similar to a function pointer in C or C++. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Delegates</strong></p>
<p>A delegate in C# is similar to a function pointer in C or C++. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked.</p>
<p>The signature of a single cast delegate is shown below:</p>
<p><strong>delegate result-type identifier ([parameters]);</strong></p>
<p>where:</p>
<ul>
<li>result-type: The result type, which matches      the return type of the function.</li>
<li>identifier: The delegate name.</li>
<li>parameters: The Parameters that the function      takes.</li>
</ul>
<p>Delegates allow a clearer separation of specification and implementation. A delegate specifies the signature of a method, and authors can write methods that are compatible with the delegate specification.</p>
<p><strong>Multicast delegates</strong><strong></strong></p>
<p>With multicast delegate, it is just like a normal delegate but it can point to multiple functions so on invocation of such delegate it will invoke all the methods and functions associated with the same one after another sequentially.</p>
<p><strong>Events: </strong></p>
<p>Events are wrapper around the delegate. It sits on top of the delegate and provides only the necessary encapsulation so that the destination objects can subscribe to the Event and not have full control on the delegate object.</p>
<p>Events are declared using delegates. The delegate object encapsulates a method so that it can be called anonymously. An event is a way for a class to allow clients to give it delegates to methods that should be called when the event occurs. When the event occurs, the delegate(s) given to it by its clients are invoked.<br />
We will consider an example implementation of Logger application, which can be used to log messages in Console, File or Database etc.</p>
<p><div id="attachment_2585" class="wp-caption alignleft" style="width: 275px"><a href="http://electrofriends.com/wp-content/uploads/2012/01/ClassDiagram-e1326646129665.png"><img src="http://electrofriends.com/wp-content/uploads/2012/01/ClassDiagram-e1326646265275.png" alt="ClassDiagram of Logger Application" width="265" height="300" class="size-medium wp-image-2585" /></a><p class="wp-caption-text">Logger Application ClassDiagram</p></div><br />
We will declare a delegate named LogWriteDelegate which accepts one parameter named message.</p>
<p><code>public delegate void LogWriteDelegate(string message);</code></p>
<p>Next we will declare an Event of type LogWriteDelegate</p>
<p><code>public event LogWriteDelegate LogWriteEvent;</code></p>
<p>In our sample Logger the FileLogger and ConsoleLogger will subscribe or register to the above mentioned event so that when the Write method of logger is called the respective logic within the Write method of FileLogger and ConsolLogger will also gets invoked.</p>
<p><code>using (var logger = new Logger("testing", EntryType.Debug))<br />
{<br />
    logger.LogWriteEvent += new Logger.LogWriteDelegate(consoleLogger.Write);<br />
    logger.LogWriteEvent += new Logger.LogWriteDelegate(fileLogger.Write);<br />
    logger.Write();<br />
}</code></p>
<p>You can notice here a multicast delegate; the LogWriteEvent is being registered with Console and File log write methods.</p>
<p>While firing an Event within the Logger object, it is always a good practice to check whether the event is registered or not.</p>
<p><code>public void Write()<br />
{<br />
if (LogWriteEvent != null)<br />
LogWriteEvent(ToString());<br />
}</code></p>
<p>Here the LogWriteEvent holds the address of the methods console.Write and fileLogger.Write. When firing an event it will sequentially call the respective methods which are pre-registered to this Event.</p>
<p>Note: The Logger application is designed in such a way that in future you can have multiple implementations of Loggers. Right now we have Console and File Logger; if you are interested in implementing a Database logger we can create a new Class named DatabaseLogger which will implement ILogger interface. Provide necessary Write method logic so that it will log messages to database.</p>
<p>Ones you have done with the DatabaseLogger implementation, you just have to create an instance and register the event as we have done for Console and File Loggers.</p>
<p><a href="http://electrofriends.com/wp-content/uploads/2012/01/LoggerLibrary.zip">Download Sample Logger Application</a></p>
]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/articles/delegate-events-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mobile Information Device Profile (MIDP 2.0) in J2ME</title>
		<link>http://electrofriends.com/articles/mobile-information-device-profile-midp-20-j2me/</link>
		<comments>http://electrofriends.com/articles/mobile-information-device-profile-midp-20-j2me/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 11:25:42 +0000</pubDate>
		<dc:creator>Ranjan</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Computer Science]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=2573</guid>
		<description><![CDATA[MIDP in general is one of the J2ME profile, a profile consists of Java classes. MIDP provides high-level API’s using which J2ME developer can easily develop applications, which is easy to use, highly graphical, with optimized for small computing devices such as Mobile phone. Also provides low-level user interface API’s giving the developers a control [...]]]></description>
			<content:encoded><![CDATA[<p><strong><br />
</strong></p>
<p>MIDP in general is one of the J2ME profile, a profile consists of Java classes. MIDP provides high-level API’s using which J2ME developer can easily develop applications, which is easy to use, highly graphical, with optimized for small computing devices such as Mobile phone. Also provides low-level user interface API’s giving the developers a control over the graphics and input. Thus reduces the development effort.</p>
<p>MIDP is targeted at a class of devices known as <em>mobile information devices</em> (MIDs). These are devices that have the following minimal characteristics:</p>
<p>1)      Enough memory to run MIDP applications</p>
<p>2)      A bit addressable display at least 96 pixels wide by 56 pixels high, either monochrome or color.</p>
<p>3)      A keypad, keyboard, or touch screen.</p>
<p>4)      Two-way wireless networking capability</p>
<p>Before we start up with MIDP 2.0 we will look over MIDP 1.0, which basically provides local storage, a user interface, networking capabilities and ability to operate in disconnected mode, ability to write applications in Java. But it was lacking end-to-end security and some other new features which is existing in MIDP 2.0</p>
<p>With MIDP 2.0, end-to-end security is now supported. MIDP 2.0 introduces the security concepts of <em>application signing</em> and <em>privileged domains</em>. With application signing applications can be trusted or not based on the ability to corroborate, via the use of a X.509 digital certificate, the application&#8217;s origin and integrity. These new features protect the device against unauthorized applications accessing data and functions. Also standard security protocols such as HTTPS, TLS/SSL and WTLS allows for secure transmission by encrypting the data. It is important to understand that MIDP in general is targeted at cell phones and low-end PDAs</p>
<p>The new MIDP 2.0 also includes support for an enhanced user interface API that allow developers create more functional and attractive business or consumer applications with less effort. It also includes new gaming and media APIs that can be used for business-applications.</p>
<p>MIDP 2.0 has expanded network connectivity support beyond HTTP, with support for UDP datagrams, TCP sockets, and serial port communication. Also a powerful feature called the push registry that activates dormant applications when new information is available. For example, with push support, server software can activate an application on the device to notify employees when a new calendar event has been scheduled or new sales lead generated, even if the application is not currently running.</p>
<p>The new Over-The-Air (OTA) application provisioning standardizes support for client-initiated download of applications over the wireless network. It allows users to find and install <em>authorized</em> applications wirelessly. It also allows application providers to track the installation and removal of applications for billing (or other) purposes.</p>
<p>MIDP also supports Short messaging service (SMS) and Cell Broadcast Service (CBS)</p>
<p><strong>What does it MIDP provide?</strong></p>
<p>The MIDP adds the following packages on top of the CLDC:</p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="111">javax.microediton.lcdui</td>
<td width="513">Provides classes for user interface.</td>
</tr>
<tr>
<td width="111">javax.microedition.midlet</td>
<td width="513">Defines MIDP applications and the interactions between the application and the environment in which the application runs.</td>
</tr>
<tr>
<td width="111">javax.microedition.rms</td>
<td width="513">Provides persistent storage (Record Management System).</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/articles/mobile-information-device-profile-midp-20-j2me/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.971 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-05-22 12:15:18 -->

