<?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>AI Software LLC, Metro Detroit, Michigan.</title>
	<atom:link href="http://arborindia.com/blog/index.php" rel="self" type="application/rss+xml" />
	<link>http://arborindia.com/blog</link>
	<description>AI Software - web, mobile, windows application development</description>
	<lastBuildDate>Mon, 09 Jan 2012 19:45:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Similarities in your dentist and offshore development company</title>
		<link>http://arborindia.com/blog/similarities-in-your-dentist-and-offshore-development-company/</link>
		<comments>http://arborindia.com/blog/similarities-in-your-dentist-and-offshore-development-company/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 19:37:57 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
				<category><![CDATA[offshore]]></category>
		<category><![CDATA[outsourcing]]></category>

		<guid isPermaLink="false">http://arborindia.com/blog/?p=5353</guid>
		<description><![CDATA[The relationship with your off-shore development team is more like it with your dentist. It’s painful but you don’t see other way out. Your dentist is doing his job, has got his degree and you have seen many other patients in the lobby. You may have even heard from one of your friend or relative [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone" title="dentist and offshore development" src="http://raisingeli.com/wp-content/uploads/2009/06/dentist2-293x300.gif" alt="dentist and offshore development" width="293" height="300" /></p>
<p>The relationship with your off-shore development team is more like it with your dentist. It’s painful but you don’t see other way out.</p>
<p>Your dentist is doing his job, has got his degree and you have seen many other patients in the lobby. You may have even heard from one of your friend or relative that this dentist was good. You even saw very nice ad in the flier or news paper and you may even had a coupon. So, you were comfortable going to him for extraction or root canal or whatever you were going for. But he gave you pain, he charged you money that your insurance did not cover, he suggested few other teeth have to be extracted or a major surgery was required and you had pain in only one teeth. More, after visiting him, pains in other teeth started as well. He asked for regular cleaning every three months and you thought it was his way of making more money. <strong><em>Doesn’t this sound like a typical dentist experience? </em></strong>And now, there is no way out, if not this you will have to go to another dentist to save other teeth.</p>
<p>Now ask a project manager or director who just worked with an offshore team for his latest and greatest application. The offshore company had a great website, and a relative or friend or a competitor of yours used the same or similar offshore company for his project and saved lot of money. You sent email and were followed back by clearly understood English in foreign accent. You sent the requirements, held some meetings over the skype, phone, webex, go2meeting and they said “yes, agreed”, “completely understood”, “exactly”, “yup, that’s what you need”, “we have done the same thing for other clients” etc. And that was probably the last ‘nice’ talk you had. After that you thought ‘they don’t understand what we mean’, ‘they are not as fast as we want’, ‘the issues reported are still not fixed’, ‘the number of issues are going up and not down’, ‘are we going to meet the deadline’, ‘oh gosh! I better be dead’.</p>
<p>The project doesn’t meet deadline, and you have to allocate more money now. The things you thought should have been included in the scope are actually not and would cost extra. No the site does not work in Firefox, it works only in IE.</p>
<p>So, the process of getting this done is now ‘painful’. Your peer director or inhouse developer asks you how your outsourcing project is going and he smirks and you know what he means. What should you do now?</p>
<p>Now, let’s look at this from the other side.</p>
<p>&nbsp;</p>
<p>Your dentist thinks (about you) that</p>
<ul>
<li>You seem more polite than others I have seen</li>
<li>You even look educated and sophisticated so your teeth will be easier to deal with</li>
<li>You are financially well and your insurance covers everything</li>
</ul>
<p>&nbsp;</p>
<p>But, when you open the mouth,</p>
<ul>
<li>Oh yuck, it stinks</li>
<li>Why the h*** parents don’t teach how to brush</li>
<li>This guy definitely needs surgery but he won’t believe if I say this in the first meeting</li>
<li>Let’s quickly fix this pain and will suggest about other problems later on</li>
<li>Come on, he pays 30$ for oil change every three months, and can’t spend for teeth cleaning?</li>
</ul>
<p>&nbsp;</p>
<p>And so it goes with your off-shore development team as well. In the beginning when you approach, this is what they are thinking:</p>
<ul>
<li>This new project should be better than the last one</li>
<li>We should have more freedom about the technology in this project</li>
<li>We will learn new things</li>
<li>Client seems polite and understanding</li>
<li>Client offered to pay something in beginning so there won’t be problem in future</li>
<li>We can put this in portfolio and get good reference</li>
</ul>
<p>&nbsp;</p>
<p>And as the project grows, team starts thinking</p>
<ul>
<li>Why don’t they (you) say this in the beginning</li>
<li>Why they want to use free/open source tools</li>
<li>They work 8 hours a day and expect us to work 10 hours that’s unfair</li>
<li>If we work extra, where is the profit</li>
<li>No, we have to start saying no for any new requirements</li>
<li>They get what they are paying for</li>
<li>And it goes on…</li>
</ul>
<p>Yes, a healthy and trustful relationship between the off shore vendor and client is needed for a successful completion of the project. But all the projects that either fail or don’t meet deadlines go through some difficult time and conversation. It’s a topic for another post to discuss the factors for why offshore projects don’t go as smooth as we want.</p>
<p><em>(the image is taken from <a href="http://raisingeli.com/wp-content/uploads/2009/06/dentist2-293x300.gif">http://raisingeli.com/wp-content/uploads/2009/06/dentist2-293&#215;300.gif</a>. Please report in case of any concern.)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://arborindia.com/blog/similarities-in-your-dentist-and-offshore-development-company/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why developers don’t like JavaScript</title>
		<link>http://arborindia.com/blog/why-developers-dont-like-javascript/</link>
		<comments>http://arborindia.com/blog/why-developers-dont-like-javascript/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 19:52:19 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://arborindia.com/blog/?p=5343</guid>
		<description><![CDATA[Recruiters and non-technical project managers may not know this but you will find plenty of web developers who are not good at Javascript, HTML or CSS. In a way definition of being a web developer is to know these technologies. There are many developers who know PHP, ASP.Net, Java, C#, VB.Net or backend database, but [...]]]></description>
			<content:encoded><![CDATA[<p><a class="preload" title="" href="http://arborindia.com/blog/wp-content/uploads/2012/01/rhino-javascript.jpg" rel="prettyphoto"><img class="alignnone size-full wp-image-5345" title="rhino-javascript" src="http://arborindia.com/blog/wp-content/uploads/2012/01/rhino-javascript.jpg" alt="" width="320" height="244" /></a></p>
<p>Recruiters and non-technical project managers may not know this but you will find plenty of web developers who are not good at Javascript, HTML or CSS. In a way definition of being a web developer is to know these technologies. There are many developers who know PHP, ASP.Net, Java, C#, VB.Net or backend database, but they will be very less comfortable with HTML, CSS and Javascript.</p>
<p>&nbsp;</p>
<p>The reasons behind this are:</p>
<ol>
<li>HTML and CSS are not programming languages</li>
<li>JavaScript was not considered a serious programming language even though it is heavily used in industry.</li>
<li>Programming courses in Universities teach Java or C# (or C++) but not Javascript</li>
<li>Developers did not think knowing any of these three technologies is considered highly-intellectual work</li>
<li>All browsers implement these three technologies differently and there is gap among IE, Firefox, Chrome or Safari (and now Android browser)</li>
<li>Javascript does (did) not provide compilation, error checks, rich set of standard libraries or standard reusable components from companies like Microsoft</li>
<li>Companies like Microsoft, Sun/Java or Apple (it was not in picture earlier anyway) did not invest in JavaScript earlier to come up with some standards for design patterns and architecture patterns</li>
</ol>
<p>&nbsp;</p>
<p>This post may be kind of late in the game as in 2011, lot of libraries are available in JavaScript. The Web 2.0 and Ajax was like a resurrection time for JavaScript. JavaScript has been out there since late 1990 &#8211; since the early days of browsers. Microsoft was not much into internet programming then. And to rival JavaScript they came out with VB Script. But no-one thought of JavaScript more than handling some browser side validation of dates and empty fields.</p>
<p>&nbsp;</p>
<p>But then came AJAX – I heard of it around 2003-04. And JavaScript started becoming more and more popular since then. Some events took place after 2007 that contributed to popularity of JavaScript.</p>
<p>&nbsp;</p>
<ul>
<li>Arrival of Ajax based web 2.0 technology</li>
<li>Steve Job’s decision to not support Flash on iPhone and iPad</li>
<li>HTML 5</li>
<li>Popularity of jQuery and jQuery based libraries</li>
</ul>
<p>&nbsp;</p>
<p>Microsoft came up with Silverlight to undermine the use of JavaScript and Flash and providing MS developers their familiar development environment for browser side programming. While this was a good move, the non-MS factors played a huge role in popularity of JavaScript based libraries and finally Silverlight will lose. It cannot become the standard development tool for non-MS programmers. And JavaScript is here to stay.</p>
<p>In last 10 years, 2001-2011, many programmers became senior developers, architects or other roles, who grew up in the environment where JavaScript was used for very primitive purpose. And if they test a script on one browser it was not guaranteed that it will work on the other browser so it never became favorite tool to use. <strong><em>Hats off to recent development in these technologies and to those programmers who have made some amazing applications using browser technologies only.</em></strong></p>
<p>&nbsp;</p>
<p>At this time, if you want to find a good web developer make sure they at least know JavaScript. People who know HTML+CSS are more of a designer and they are very creating and of artistic nature. A developer may not be as artistic. So, if you want to get an aesthetic look for your UI, do not expect that from regular developer who is good at C# or Java or such server side programming languages. You want to hire a UI designer or UI expert who can tweak the CSS and HTML however they want.</p>
<p>&nbsp;</p>
<p>Now, if you are a .net or java developer, you better learn JavaScript now. It has got very elegant syntax for declaring class and objects. And you should use the 3<sup>rd</sup> party controls like Telerik or ExtJS who handle most of the skinning and commonly needed Javascript work for you so you don’t have to work with CSS and HTML too much. If you know programming but not JavaScript, you are like a football player who can do touch-down but can’t catch the ball.</p>
]]></content:encoded>
			<wfw:commentRss>http://arborindia.com/blog/why-developers-dont-like-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Horror stories of offshore development.</title>
		<link>http://arborindia.com/blog/horror-stories-of-offshore-development/</link>
		<comments>http://arborindia.com/blog/horror-stories-of-offshore-development/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 20:58:36 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
				<category><![CDATA[offshore]]></category>
		<category><![CDATA[outsourcing]]></category>

		<guid isPermaLink="false">http://arborindia.com/blog/?p=5284</guid>
		<description><![CDATA[If you are working in IT, you may have encountered a programmer from countries like India, China or some East Asian nation. Off-shore development is ubiquitous (if not popular) in US companies. And countries like Australia, New Zealand and Western Europe outsource their IT services and development to other countries as well. I am in [...]]]></description>
			<content:encoded><![CDATA[<p><a class="preload" href="http://arborindia.com/blog/wp-content/uploads/2012/01/horror.png" rel="prettyphoto"><img class="size-full wp-image-5285 alignleft" title="horror" src="http://arborindia.com/blog/wp-content/uploads/2012/01/horror.png" alt="" width="190" height="186" /></a></p>
<p>If you are working in IT, you may have encountered a programmer from countries like India, China or some East Asian nation. Off-shore development is ubiquitous (if not popular) in US companies. And countries like Australia, New Zealand and Western Europe outsource their IT services and development to other countries as well.</p>
<p>I am in IT industry, myself working as a coder (sr. developer, team lead, architect, consultant, owner of business etc. are just another nice titles that finally ends up making me write code anyway) for last 12 years or so. Everyone working in IT dept, who had to work with an offshore developer has some story to tell and I am sure there are more horror stories than pleasant ones.</p>
<p>Even though I have successfully completed many projects working with offshore team I have come across few cases that I learnt a lesson from.</p>
<p><strong>Year 2000:</strong> It was in 2000 that we first time worked with a company in Hyderabad, India. At that time we were working on a VB 6 and Oracle project for a company in health industry. Our team here had no one expert in Oracle and we were told the guys in Hyderabad were the expert. And they will do the VB 6 as well. So after few weeks the first set of code came back and while reviewing we noticed there was a code like:</p>
<pre><span style="color: #0000ff;">If (Keypressed = 13) { //do something }</span></pre>
<p>So, my first reaction was to ask them not to use any hard coding like this, and asked them to correct it. And next day the code came back looking like below:</p>
<pre><span style="color: #0000ff;">Dim someveriable as int Somevariable = 13 If (Keypressed = Somevariable) { //do something }</span></pre>
<p>This was enough to tell us the guys there did not understand what is ‘hard coding’. And things like this went on. I would write long mails every day pointing out lines of code in VB as well as Oracle PL/SQL  and it went on for few weeks. Finally, we took it over and completely finished ourselves.</p>
<p><strong>Lession Learnt:</strong> If you have to educate your team about the simple programming practices then the team will not succeed in the project. I have never seen any IT project where there is enough time for everyone to learn and then deliver. If you have such project, then you got enough money and you are not asked to use offshore team anyway.</p>
<p><strong>Year 2003/2004:</strong> This was the beginning of .Net era and Java was already a mature technology. I was assigned to an already developed project as a mediator between US users and Indian development team. The project was developed in VB and classic ASP. And the users were US sales team. We tried to install and release the software for the US team but they would not use it. So, I made a whole big list of issues why they were not using it and got the Indian team to fix those issues. Everyday, I would spend writing big emails and few hours talking over the phone early morning.  Team in India would work late nights and get those issues resolved.</p>
<p>But after all the effort, US team never used the software. The company was able to sell it in other Asian countries but not to their own team in US.</p>
<p>There were some positive things in this story:</p>
<ul>
<li>The development team was technically sound and they had their own technical architect, designer etc.</li>
<li>They looked at some industry leading software (like SAP) to create similar functionality</li>
<li>Turn-around time was reasonable</li>
</ul>
<p>But</p>
<ul>
<li>Sales team had probably seen better software in US market and were thinking that this was a cheaper model; so they were not inclined to use it</li>
<li>Software did not integrate with Outlook Calendar or Contact List so it did not provide any natural benefit to the team; it was one more thing to maintain in their daily routine of work</li>
<li>The company was making investment in older technology like ASP while new ASP.net was already getting popular.</li>
<li>Development team tried to use some code base from other software that they had developed; and that introduced many limitations.</li>
</ul>
<p><strong>Year 2008: </strong>One of my clients had got his project developed in India in .Net using Telerik controls. But the application would work so slow that it would be impossible to use it. He asked if we would be able to refactor or rewrite it.</p>
<p>And when we looked at the code, we noticed the whole application was one single ASPX page having different Panels in it getting visible or hidden. So, all the different screens in the UI were in different panels and they were displayed or hidden based on what menu item was clicked. This made the ViewState huge and of course the application was unusable.</p>
<p>We had to rewrite the application using AJAX.</p>
<p><strong>Year 2010/2011: </strong>One of my clients outsourced their project to a US based IT company. And this company is a publicly traded billion dollar company. So you may think what could go wrong. Well, everything went wrong – and at the core of it were one non-technical decision and one technical decision. Non-technical issue was, they tried to achieve too many things in one shot instead of creating a solid base and then evolving on it. Technical issue was the software did not support database transaction.</p>
<p>But the story did not end there – that was the beginning. Now, the client turned to an offshore company in Delhi, India. They hired almost 12 developers there making 2 of them technical leads cum designers and rest of them developers or senior developers.</p>
<p>We here in US were also termed as design leads and asked to guide the team in India. But the team leads in India probably did not like that and conflicts started. They thought their contribution to the project is more ‘technical’ and they did not care about the ‘business’.</p>
<p>Non-technical:</p>
<ul>
<li>We used Skype, but the programmers would not stay on Skype during our morning times and will be away.</li>
<li>They did not give us their phone numbers, neither desk numbers, nor cell number (until last month of project) so we could not call them. We had to email them asking to call us.</li>
<li>They would have to reserve a room to talk to us, so if that room was booked by any other team then they would not be able to talk to us.</li>
<li>We found that some other programmers were working on the project using assigned people’s Login Id. That means the programmers that we hired were being used for some other project.</li>
<li>I would request a meeting and get up early morning 6 AM to attend it and at 6 AM they would not show up and ask to postpone for another day.</li>
<li>People would be out on lunch around 3 or 4 PM Indian time.</li>
</ul>
<p>Technical:</p>
<ul>
<li>We wanted to follow MVP pattern in the WinForms project but all the code would be in View file and nothing in the presenter. Also, presenter was coded more like a model to get the data from database and that’s all.</li>
<li>A framework library was created but it had 10 to 12 different folders and different namespaces making it hard to use the framework classes.</li>
<li>WCF was used but it would hide all the error details and they could not understand in what cases the WCF should hide the exceptions and in what case it can expose it. This made it hard on the client side to find out the cause of the error or to check the stack trace.</li>
<li>Even though we had business objects and custom collections, developers used standard System.Data’s DataSet and DataTables to retrieve the data. The real object-oriented programming was either ignored or forgotten.</li>
<li>Similarly, to save the data, all data was stored in custom XML and saved instead of using objects and custom collection. This made it harder to debug the issues or even make modifications.</li>
<li>Programmers would write catch(Exception ex) { throw ex; } type of exception handling. Beat That J</li>
</ul>
<p>We again ended up taking over most of the development. We also stopped assigning issues and fixed them on our own. Though they helped fixing some issues it was always taking longer to communicate than to do it ourselves.</p>
<p><strong>Other Cases:</strong></p>
<ul>
<li>You might run into a company who would charge you less for the project you want done and then increase its price later on when it may be too late. If the increase is up to 10% you can bear it, but I had a company who wanted 33% raise and I could not tolerate that.</li>
</ul>
<ul>
<li>‘Hours’ is another important thing that may raise eyebrows. One of the companies I worked with reported 100 hours for the work done. I was okay with that and asked him to invoice with the agreed hourly rate. Then they realized they were getting less than expected amount. So they reported it took them 200 hours but by mistake they reported 100 hours.</li>
</ul>
<p><strong>Conclusion:</strong></p>
<p>We are still using offshore resources for some of our projects but we select the type of work that we want to send to offshore team and the type of project where their contribution will be worthwhile. After all these experience we don’t write it off. But many companies do this blindly. <strong>They think using offshore model is like buying a new TV or Laptop from a Thanksgiving deal. You can’t rush and get the deal because everyone else is getting it.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://arborindia.com/blog/horror-stories-of-offshore-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.Net Tip &#8211; Session</title>
		<link>http://arborindia.com/blog/asp-net-tip-session/</link>
		<comments>http://arborindia.com/blog/asp-net-tip-session/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 18:10:38 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
				<category><![CDATA[.net]]></category>

		<guid isPermaLink="false">http://arborindia.com/blog/?p=5277</guid>
		<description><![CDATA[Sessions are an important part of any web application. Session is more of a concept than a Class or Object or Keyword. ASP.Net’s Page class allows you to store and retrieve variables from current user session in following way: Session[“MyVariable”] = 2012; Session is unique to a user’s browser session. When user opens your application [...]]]></description>
			<content:encoded><![CDATA[<p><a class="preload" title="" href="http://arborindia.com/blog/wp-content/uploads/2012/01/aspnet-iis-session.png" rel="prettyphoto"><img class="alignnone size-full wp-image-5278" title="aspnet-iis-session" src="http://arborindia.com/blog/wp-content/uploads/2012/01/aspnet-iis-session.png" alt="" width="549" height="191" /></a></p>
<p>Sessions are an important part of any web application. Session is more of a concept than a Class or Object or Keyword. ASP.Net’s Page class allows you to store and retrieve variables from current user session in following way:</p>
<p>Session[“MyVariable”] = 2012;</p>
<p>Session is unique to a user’s browser session. When user opens your application in a browser, IIS assigns a Session ID (a guid like unique id) to the browser session. If user opens another browser (Firefox, Chrome, IE) from the same machine, IIS will assign a different Session Id to the newly opened browser session. Browser receives this Session Id and passes back to the server via Cookie for each request it makes. If your application is configured to maintain the cookie-less session then session id is passed as part of the URL for each request. When user opens your application from a different tab of the same browser then browser will use the same session Id.</p>
<p>Within .Net the session is actually available from: HttpContext.Current.Session object. So, even when you use Session[“MyVariable”] in your code behind, you are actually accessing HttpContext.Current.Session[“MyVariable”] object.</p>
<p><strong>The default practice is to use Session[“MyVariable”] type of syntax. But there are disadvantages to using this syntax:</strong></p>
<ol>
<li><strong>The return value is object so you will have to cast it to the type you need.</strong></li>
<li><strong>You don’t know if the variable is set already or not, so you will have to check for null.</strong></li>
<li><strong>If there is typo in the string “MyVariable” – there is no compilation error and you may receive run time error.</strong></li>
<li><strong>There is no intellisense to find out what session variables are already available to you.</strong></li>
</ol>
<p>Hence, better practice should be to make use of Singleton pattern and create your own session class. This practice defies all the disadvantages listed above.</p>
<p>Create a class SiteSession like following. You can give it any name that you like:</p>
<pre style="padding-left: 30px;"><span style="color: #0000ff;">[Serializable()]</span>
<span style="color: #0000ff;">public class SiteSession</span>
<span style="color: #0000ff;">{</span>
<span style="color: #0000ff;">    #region "Semi Singleton implementation"</span>
<span style="color: #0000ff;">    protected SiteSession()</span>
<span style="color: #0000ff;">    {</span>
<span style="color: #0000ff;">    }</span>
<span style="color: #0000ff;">    public static SiteSession Current</span>
<span style="color: #0000ff;">    {</span>
<span style="color: #0000ff;">        get</span>
<span style="color: #0000ff;">        {</span>
<span style="color: #0000ff;">            if (null == HttpContext.Current.Session)</span>
<span style="color: #0000ff;">                return null;</span>

<span style="color: #0000ff;">            if (null == HttpContext.Current.Session["SiteSession"])</span>
<span style="color: #0000ff;">            {</span>
<span style="color: #0000ff;">                HttpContext.Current.Session["SiteSession"] = new SiteSession();</span>
<span style="color: #0000ff;">            }</span>

<span style="color: #0000ff;">            return (SiteSession)HttpContext.Current.Session["SiteSession"];</span>
<span style="color: #0000ff;">        }</span>
<span style="color: #0000ff;">    }//Current</span>
<span style="color: #0000ff;">    #endregion</span>

<span style="color: #0000ff;">    public void Destroy()</span>
<span style="color: #0000ff;">    {</span>
<span style="color: #0000ff;">        HttpContext.Current.Session.Clear();</span>
<span style="color: #0000ff;">    }</span>

<span style="color: #0000ff;">//now declare all session variables</span>
<span style="color: #0000ff;">Public string CurrentState { get;set; }</span>
<span style="color: #0000ff;">Public string UserName { get; set; }</span>
<span style="color: #0000ff;">Public CustomObject CurrentObject { get; set; }</span>
<span style="color: #0000ff;">}</span></pre>
<p>The class needs to be declared [Serializable] to store it in Session. And this class is stored in Session using its ‘Current’ property. It follows singleton pattern so you cannot create the instance of it and its only instance is stored in the HttpContext.Current.Session object.</p>
<p>There are three session variables that are declared in above example – CurrentState, UserName, CurrentObject. In your code you can use them anywhere as SiteSession.Current.UserName or SiteSession.Current.CurrentObject. IntelliSense will show you the names as well as you do not have to do type-casting.</p>
<p>Please note that Session[“CurrentState”] or Session[“UserName”] is not equivalent to SiteSession.Current.CurrentState and SiteSession.Current.UserName. You should no more use Session[“MyVariable”] syntax.</p>
<p>If you see any disadvantage using this method, please give your feedback.</p>
]]></content:encoded>
			<wfw:commentRss>http://arborindia.com/blog/asp-net-tip-session/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sample architecture of a simple asp.net web application</title>
		<link>http://arborindia.com/blog/sample-architecture-of-a-simple-asp-net-web-application/</link>
		<comments>http://arborindia.com/blog/sample-architecture-of-a-simple-asp-net-web-application/#comments</comments>
		<pubDate>Tue, 03 Jan 2012 22:38:51 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
				<category><![CDATA[.net]]></category>

		<guid isPermaLink="false">http://arborindia.com/blog/?p=5271</guid>
		<description><![CDATA[This post is intended for a beginner to mid-senior level developers who need to create a new asp.net web application. While starting any new application or project, there is a set of questions that need to be answered and answers of most of the questions may remain same from project to project. If you are [...]]]></description>
			<content:encoded><![CDATA[<p>This post is intended for a beginner to mid-senior level developers who need to create a new asp.net web application. While starting any new application or project, there is a set of questions that need to be answered and answers of most of the questions may remain same from project to project. If you are an architect you may already like to create your framework around this, that you can reuse in different applications.</p>
<p>The typical questions are:</p>
<ol>
<li>Which database are we using?</li>
<li>How should we access the database?</li>
<li>Do we need Data Entity Objects?</li>
<li>How should the database transactions be handled?</li>
<li>How do we separate presentation/UI layer from business layer?</li>
<li>What should we do for application logging?</li>
<li>How to handle exceptions and application errors?</li>
<li>What are configuration items and where should we store them?</li>
<li>Is Load Balancing needed? How to handle it?</li>
<li>How to make application run faster?</li>
</ol>
<p><strong>Which database are we using? </strong></p>
<p>The answer to this may be beyond the developer’s authority as it is up to the product owners to decide which database they will use for a project. But while deciding about ‘which’ database, following points should be taken into consideration:</p>
<ul>
<li>Do we have budget to pay for licensing cost of the database? If not then the choices will be free databases like MySQL or MS SQL Express edition.</li>
<li>How many users should be able to access the database in parallel and how many transactions we are expecting per minute? If the site is expecting higher number of users per minute (or even hour) then you need a full fledge database system.</li>
<li>What is the maximum size of the database at a time? MS SQL Express edition has limit of 4GB per database. So, if your database may grow to be 4 GB or more then you cannot use Express Edition.</li>
<li>What is the amount data added per month? This is important to determine the total size of database in a year or 2 year. Because if you are adding 100 MB of data per month- you will roughly have 1.2 GB of data in a year and 4 GB in 3+ years. If you are designing database and application, you need to plan for purging the database periodically so that the size remains small and it does not grow beyond its planned size.</li>
<li>Backup schedule – do you need to take periodic back up of the database? And do you have enough space on the drive where you have setup the scheduled backup? If this is not planned, then you may get error (may be to spoil your holiday) while taking backup and many other things can go wrong if the disk is full.</li>
</ul>
<p>&nbsp;</p>
<p>Most of the typical .net applications use MS SQL Server – though the application can very well use other types of databases like MySQL, MS Access, Oracle and others. As long as a database provides ODBC or OLEDB driver, .Net is able to connect to these databases and developer can work with them.</p>
<p>&nbsp;</p>
<p><strong>How should we access the database? </strong></p>
<p>The developers will have to pay for whatever decision they take regarding the method to access the database. By reading some blogs or sample examples from web they may employ methods that may ultimately prove to be a mistake.</p>
<p>.Net has its own classes for ODBC and OLEDB via which developers can access the database. But a better practice should be to use the Microsoft Enterprise Architect Data Access Block. The Data Access Block allows developers a common interface to accessing any physical database. The best practice in any project is to write your business layer such a way that business layer does not have to know what physical database is being used.</p>
<p>You should use the Data Access Block to create a Data Access Layer (this is nothing but a Class Library project) that has a method for every atomic database operation that you want to carry out. Make sure that a method in your DAL does not call more than one stored procedure. Because it should be the responsibility of Business Layer to call one or more DAL methods – and DAL should not combine two separate operations into one method. For example, if you need to save a record in Customer table but at the same time need to add records in some Audit/Log table as well – DAL should provide one method to add ‘Customer’ and another methods to add ‘Log’ record. Then Business layer should call these separate DAL methods in a transaction to correctly add customer. It is responsibility of Business Layer (a separate class library project) to add ‘Log’ records while adding ‘Customer’ record.</p>
<p><strong>Do we need Data Entity Objects?</strong></p>
<p>Data Entity Objects are object representation of each table in the database. When the data is loaded from the database, ADO.Net allows you to store them in DataSet, DataTable, DataRow objects. But as you advance in programming you will understand that you should minimize the use of these objects. Because these System.Data objects are heavy and large when transferring over the wire via web-service or storing them in asp.net View State.</p>
<p>You can create Data Entity Objects by representing each table by a class in your choice of language – C# or VB.Net. If you care about creating DEOs, you normally are working in C#. Once you have DEO, you will be using collection of DEOs instead of DataTable. You may even have methods to convert the DataTable into collection of DEO. Your crud methods in the data access layer will have following type of definition:</p>
<p><em>Void Save(TableDeo1 obj);</em></p>
<p><em>Void SaveAll(List&lt;TableDeo1&gt; objList);</em></p>
<p><em>List&lt;TableDeo1&gt; GetAll();</em></p>
<p><em>TableDeo1 GetById(int id);</em></p>
<p>&nbsp;</p>
<p>The advantage of using DEO is that you can return them via Web-Service and the total response size will be smaller compared to having DataSet or DataTable. You can also store them in ViewState or Session. But the real advantage to programmer is intellisense. Since it’s a class defined in the solution, Visual Studio will show you all field/column names that you don’t get when you are using DataTable. You are less likely to make mistakes of storing Integer values in the String fields and String values into Integer fields. Your programming becomes easier.</p>
<p>You may think creating DEO for each table is lot of time consuming work – but you don’t have to write each class by hand. You can employ code generation tools like <a href="http://www.codesmithtools.com/">Code Smith</a> or <a href="http://blogs.msdn.com/b/t4/">T4</a> in such cases. You want to create a template for a DEO yourself (preferable over the default templates such tools have).</p>
<p><strong>How should the database transactions be handled?</strong></p>
<p>A Database Transaction is a single set of operations that need to be completed in entirety or it needs to fail altogether. For example, if you add a record to table A, it must be ensured to update some status or counter in table B. if the insertion in table A fails then update in table B should not occur. This is typical of a simple database transaction.</p>
<p>The visual studio project or the piece of code that handles such transaction should be considered your business layer. If you are placing BeginTransaction/CommitTransaction code in your code behind then you have some serious exercise to do. If you are doing this in your data access layer then you have a chance to separate it out.</p>
<ol>
<li>Create a layer (dll) separate from your UI layer (code behind or web project) that handles the transaction.</li>
<li>Within transaction access the methods of Data Access Layer to keep DAL separate from this layer. Do not call SP directly or queries directly from this layer. Use DAL for that purpose.</li>
<li>Do not make long wire calls within the transaction like calling web-service. You want to keep your transaction code as fast as possible.</li>
<li>Keep the business layer running on a server very close to the database server. This way the transaction code will be faster to execute and you will avoid any unnecessary deadlocks.</li>
</ol>
<p>In one of the projects I had joined earlier team made a mistake by creating web-service over the data access layer and then calling the web-service methods within transaction. This does not solve any problem but rather creates a problem – transaction should make local calls to the database to be able to rollback it.</p>
<p><strong>How do we separate presentation/UI layer from business layer?</strong></p>
<p>Each class in the business layer needs to implement an interface. Having an interface between the UI layer and business layer will allow separating them out.</p>
<p>A novice programmer may think what does ‘separating’ mean? ‘Separating’ mean that if we have to replace the business layer with some other code library then the presentation layer code does not need to change because it is making calls to business layer via interface only. Similarly any changes in the presentation layer do not affect the UI layer as long as the business layer implements the interface.</p>
<p>A common practice is that the interfaces are implemented by web-service client. Web-service client makes call to web-service and web-service is a wrapper over the business service that implements the same interface.</p>
<p><strong>What should we do for application logging?</strong></p>
<p>Error Logging and Exception Handling are two important aspects of any project. The logging should be used for Debugging as well as error logging. You should not let any error go without logging it. And when the error is logged, you must log the function name or parameters and possibly the stack trace.</p>
<p>Every application generates error when it is put in production. When an error is shown to user and if user does not have any other alternative then you will not only lose that user but also lose how to fix the error and what conditions generate the error.</p>
<p>You can use error logging tools like Log4net or Microsoft’s Logging Application Block. We like Log4net for its ease of configuration. You can configure Log4net to write errors to a Log File or a database table or there are other options like MSMQ that we never used. Many web-servers are restricted from creating any local file for security reasons – in that case you can log the errors to database table.</p>
<p>Most important rule(s) for logging is:</p>
<ul>
<li>In web application create a global.asax page and handle the Application_Error event. In this event log the error and clear the server error. Because if you don’t clear IIS may shut down your application and it won’t be available to any users. I had seen a client having such problem where their vendor did not clear the server error or did not handle the application-error event.</li>
<li>Optionally, you can log exceptions from each of the User-Event – like buttonClick, selectIndexChanged, PageLoad etc. If you handle any of such events, you want to provide appropriate message to the user and let user take different course of action to avoid such errors.</li>
<li>In DAL, you could log the parameters of methods whenever exception occurs that way you can find out what parameters are causing the error and fix the code.</li>
<li><strong><em>Remember your goal – information from the log file should help you recreate the problem and fix it so it never occurs again. To achieve this, whatever information you want to log, you should.</em></strong></li>
</ul>
<p><strong>How to handle exceptions and application errors?</strong></p>
<p>Many novice programmers don’t understand the meaning of ‘handling’ exception. So if you don’t understand, you are still a beginner. I have worked with programmers with 4-6 years of experience not understanding the concept – though they may know the syntax.</p>
<p>Merely knowing the syntax of try/catch/finally does not help you ‘handle’ the exception.</p>
<p>1<sup>st</sup> rule is when you ‘handle’ exception, you must ‘do’ something. For example,</p>
<p><em>Try {</em></p>
<p><em>//do something, make some dal call etc.</em></p>
<p><em>}</em></p>
<p><em>Catch(Exception ex)</em></p>
<p><em>{</em></p>
<p><em>}</em></p>
<p>The dangerous part in above is it loses the exception information. So, programmer will never know an error occurred in this code and will never be able to fix it. You have to do something in that catch block. If you want to deliberately ignore the exception then at least write a comment.</p>
<p>2<sup>nd</sup> – what you do in catch block should add value.</p>
<p><em>Try {</em></p>
<p><em>//do something, make some dal call etc.</em></p>
<p><em>}</em></p>
<p><em>Catch(Exception ex)</em></p>
<p><em>{</em></p>
<p><em>throw ex;</em></p>
<p><em>}</em></p>
<p>Above code adds no value whatsoever.</p>
<p>3<sup>rd </sup>– When you handle exception, based on the error, offer some solution or take corrective measures. For example, if user entered invalid value for an integer and you got exception while converting it to integer, ask user to enter valid value. In case of db calls, the most common thing to do in Exception block is to rollback the transaction.</p>
<p>In any user event entry, you should make sure that there is no exception thrown or if thrown, you are going to display appropriate message to the user. This way, you will guarantee that user does not see incorrect behavior of the application.</p>
<p><strong>What are configuration items and where should we store them?</strong></p>
<p>Each application should have some configuration items or some options. If you don’t have options then you have hardcoded some rules in your system which is a bad practice. Examples of items that you need to make configurable:</p>
<ul>
<li>Location of any input/output files</li>
<li>Email addresses</li>
<li>Number of records to display in a page</li>
<li>Theme Name if you have any</li>
</ul>
<p>You can store these options in two ways:</p>
<ol>
<li>In database create SystemOptions (or any name) table to store such options. – this is better</li>
<li>Web.config file</li>
</ol>
<p>If you use Web.config file, a better programming practice is to create following type of static class to fetch the config values.</p>
<p><em>public static class Config</em></p>
<p><em>{</em></p>
<p><em>public string FromEmailAddress {</em></p>
<p><em>          get {</em></p>
<p><em>           string email = ConfigurationSettings[“FromEmailAddress”];</em></p>
<p><em>           if (string.isnullorempty(email)) email = <a href="mailto:default@email.com">default@email.com</a>;</em></p>
<p><em>           return email;</em></p>
<p><em>}</em></p>
<p><em>}</em></p>
<p><em>}</em></p>
<p>&nbsp;</p>
<p>The advantage of such class is if the value is missing in the config file you can still supply a default value. Also, IntelliSense can help you get the Configuration values from such class easily. If you plan to store the options in a database table or some other settings file, you can modify this class to access each value.</p>
<p>&nbsp;</p>
<p><strong> </strong><strong>Is Load Balancing needed? How to handle it?</strong></p>
<p>Load Balancing is a concept by which you can install the same web-application on two different IIS servers but users will be accessing it via single URL as if it was only one server. The other term is web-farm where your IIS server creates multiple instances of the same web application running in parallel.</p>
<p>&nbsp;</p>
<p>In all scenarios, why Load Balancing is important factor to consider during development is because of ‘Session’. For example, when user connects via Server A – a session starts for the user and session data is stored locally on server A. User’s subsequent request may be diverted to Server B for load balancing purpose, now, if the B is unable to get the user’s session data then application will display errors.</p>
<p>&nbsp;</p>
<p>To handle such scenarios, applications need to store their sessions in database. This is very easy and web.config allows configuring the application session to use database. Microsoft also provides scripts to create session tables in the database.</p>
<p>&nbsp;</p>
<p>Now, if you are creating any files on the web-server you will have to guarantee that it’s available from other web-server too in the load-balance environment. Any web-server specific action has to be handled similarly.</p>
<p>&nbsp;</p>
<p><strong>How to make application run faster?</strong></p>
<p>This becomes the most important issue after the application is developed and it goes live. Programmers or even project managers do not worry about the performance till the end. And it may be too late by then. Many times programmer will suggest rewriting the application to make it run faster. And this does not go down well with the management.</p>
<p>&nbsp;</p>
<p>Better practice is to think about the performance from the beginning. Even after that, you may still need to revisit the performance again in future as you are nearing the end. But if you have already thought about the performance from the beginning it will be much easier to fix if needed.</p>
<p>&nbsp;</p>
<p>Some of the ideas that we have talked about earlier for better performance is:</p>
<ol>
<li>Try to keep all database transactions run as fast as possible.</li>
<li>Use Data Entity Objects and Business Objects and do not use Data Set or Data Tables</li>
<li>Keep the ASP.Net Page View State as small as possible. When not needed, do not keep the EnableViewState=True and specify it to False. Keeping View State smaller helps making the application much faster.</li>
<li>Create Cache for commonly used database items. There may be some tables/records in database that are not updated often, load them in cache to reduce the database hits.</li>
<li>Create database indexes appropriately to run the queries faster.</li>
<li>If you have to use third party web service calls, you may consider using Asynchronous calls.</li>
<li>Many non-critical items can be called asynchronously to reduce the page response time. For example, logging some entries or making some database auditing entries should be done asynchronously.</li>
</ol>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://arborindia.com/blog/sample-architecture-of-a-simple-asp-net-web-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

