<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Software Development</title>
        <link>http://www.dotnetlog.com/category/10.aspx</link>
        <description>Software Development</description>
        <language>en-US</language>
        <copyright>Bigyan Rajbhandari</copyright>
        <managingEditor>bigyanr@gmail.com</managingEditor>
        <generator>Subtext Version 1.9.5.177</generator>
        <item>
            <title>Signed up to work for the software empire</title>
            <link>http://dotnetlog.com/archive/2008/06/16/signed-up-to-work-for-the-software-empire.aspx</link>
            <description>&lt;p&gt;&lt;font face="Arial"&gt;That’s right, I recently took a job offer from &lt;a title="" target="_blank" rel="" href="http://microsoft.com"&gt;Microsoft&lt;/a&gt; as a Software Engineer and will be starting there in July. After few months of grueling interview process and tough decision on my part, I decided that it was an opportunity that I couldn’t miss. &lt;br /&gt;
&lt;br /&gt;
So why &lt;a title="" target="_blank" rel="" href="http://microsoft.com"&gt;Microsoft&lt;/a&gt;? Well, there are few things. First ‘aspiration’, I have always wanted to work for the software giant, the fact that you have opportunity to impact millions of people by your work is impassable.  Second, working with smarter people and chance to learn new things every day is appealing. And rest like benefits, location etc.. are definitely added bonus.&lt;br /&gt;
&lt;br /&gt;
Why NOT &lt;a title="" target="_blank" rel="" href="http://microsoft.com"&gt;Microsoft&lt;/a&gt;?  Looking from outside in, I have had doubts if I should take the opportunity. Particularly, the way big corporation works and the “red tape” around the processes. And of course there is a big difference between aspiration and reality. Also, I have heard horror stories of people who came out of there. Someone even asked me if “I sold my soul to the evil empire”. And finally, the rainy weather and expensive real estate in Seattle. But in long term, these were trivial compared to the opportunity. And I should not even complain about the rain compared to snowy winters and humid summers here in Des Moines. And being near to Vancouver is a big bonus for my wife and our family.&lt;br /&gt;
&lt;br /&gt;
My job? It’s still .Net development. I’ll be working for Relationship Experience Division at Issaquah location near Seattle. Currently, I only know the high levels of the projects I might be working on; I guess I’ll find out more once I actually start there. Will I still be blogging? Definitely! I have heard MS is encouraging its employees to blog more. Though I probably won’t be able to blog everything, I’ll try to keep it as up to date as possible.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;When’s the big move? It’s probably going to be July 1st and its coming up pretty fast. Though it’s nice that they will be taking care of everything for the move, I still need to kind of plan for it on my side. And moving from one place to another is definitely not easy. Still need to tie all loose ends at my current work, move and settle in Seattle area in 1 week, enjoy a vacation the following week and then start the grind on Monday!&lt;br /&gt;
&lt;/font&gt;&lt;/p&gt;&lt;img src="http://dotnetlog.com/aggbug/57.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Bigyan Rajbhandari</dc:creator>
            <guid>http://dotnetlog.com/archive/2008/06/16/signed-up-to-work-for-the-software-empire.aspx</guid>
            <pubDate>Mon, 16 Jun 2008 15:02:58 GMT</pubDate>
            <wfw:comment>http://dotnetlog.com/comments/57.aspx</wfw:comment>
            <comments>http://dotnetlog.com/archive/2008/06/16/signed-up-to-work-for-the-software-empire.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://dotnetlog.com/comments/commentRss/57.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Best practice and effective way of using DataContext in Linq to SQL?</title>
            <link>http://dotnetlog.com/archive/2008/03/18/best-practice-and-effective-way-of-using-datacontext-in-linq.aspx</link>
            <description>&lt;p&gt;&lt;font size="2"&gt;&lt;strong&gt;NOTE: See my &lt;/strong&gt;&lt;a href="http://www.dotnetlog.com/archive/2008/03/20/follow-up--best-practice-and-effective-use-of-datacontext.aspx"&gt;&lt;strong&gt;follow up post here&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; for more info.&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;At work, Jeff and I have been throwing around ideas to find a best way to implement DataContext in Linq so that we can integrate it into the base class in our framework while achieving following goals. &lt;/font&gt;&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;font size="2"&gt;Implementation should be easy and non-redundant, so that we do not need to do &lt;span style="COLOR: blue"&gt;new DataContext(), &lt;/span&gt;every time we have to use one. &lt;/font&gt;&lt;/li&gt;
    &lt;li&gt;&lt;font size="2"&gt;Portability of the DataContext should be such that we do not need to pass it around as parameters from one tier to another. &lt;/font&gt;&lt;/li&gt;
    &lt;li&gt;&lt;font size="2"&gt;"Unit of work" pattern should be well represented and "very" transparent. &lt;/font&gt;&lt;/li&gt;
    &lt;li&gt;&lt;font size="2"&gt;Context should not be persisted without intent, or be open to manipulation from other methods, such that "unit of work" is compromised or a transaction is ill-represented &lt;/font&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;font size="2"&gt;These seem like simple goals given the features and flexibility of LINQ, however, in reality this has become much more difficult and annoying to achieve than we previously thought. Here are several ideas we have been kicking around, and problem it presents. &lt;strong&gt;I would like to hear from people who have effectively used LINQ Datacontext in these scenarios or in a pattern that's most effective. &lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;strong&gt;1. Creating and disposing LINQ as required.&lt;/strong&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;font face="Arial"&gt;&lt;span style="COLOR: #2b91af"&gt;DbDataContext&lt;/span&gt; myContext = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;DbDataContext&lt;/span&gt;(); &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: green"&gt;&lt;font face="Arial"&gt;//your code goes here &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;font face="Arial"&gt;myContext.SubmitChanges(); &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt"&gt;&lt;font size="2"&gt;&lt;strong&gt;Problems with this pattern:&lt;/strong&gt; &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul style="MARGIN-LEFT: 72pt"&gt;
    &lt;li&gt;&lt;span style="FONT-SIZE: 12pt"&gt;&lt;font size="2"&gt;Creating datacontext everytime we need to use is cumbersome and in my opinion just verbose. &lt;/font&gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;
    &lt;p&gt;&lt;span style="FONT-SIZE: 12pt"&gt;&lt;font size="2"&gt;If you have to use datacontext in any of the method this code calls, you'll have to pass the datacontext with it. This is one- too many parameters to pass around &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
    &lt;p&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/p&gt;
    &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;strong&gt;2. Creating a static DataContext and using it throughout the application.&lt;/strong&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;DataLayer.DataContext.Current&lt;/span&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 12pt"&gt;&lt;font size="2"&gt;&lt;strong&gt;Problems with this pattern:&lt;/strong&gt; &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul style="MARGIN-LEFT: 72pt"&gt;
    &lt;li&gt;&lt;span style="FONT-SIZE: 12pt"&gt;&lt;font size="2"&gt;Creating static object isn't always a good thing. In this case, the context is available for manipulation at any level. And unit of work quickly becomes very hard to maintain &lt;/font&gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;span style="FONT-SIZE: 12pt"&gt;&lt;font size="2"&gt;If manipulated by other threads or methods context isn't clean anymore and cannot be trusted&lt;br /&gt;
    &lt;/font&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 12pt"&gt;&lt;font size="2"&gt;&lt;strong&gt;3. Ambient DataContext (Currently using this)&lt;/strong&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 12pt"&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt"&gt;&lt;font size="2"&gt;The idea behind ambient datacontext is that context is created for a particular thread or a httpcontext(in asp.net) as soon as there is a first call for the DataContext. Then the same context is used for that thread or request unless it is disposed manually. This is done by storing the context in the request/thread data store. The approach to this pattern is similar to static DataContext, however, separation is provided for each thread and requests. This works really well in Asp.Net, however, is again plagued by some of the problems of static context.&lt;strong&gt; &lt;/strong&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 12pt"&gt;&lt;font size="2"&gt;&lt;strong&gt;Problems with this pattern:&lt;/strong&gt; &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul style="MARGIN-LEFT: 72pt"&gt;
    &lt;li&gt;&lt;span style="FONT-SIZE: 12pt"&gt;&lt;font size="2"&gt;The context is available for manipulation at any level. And quickly becomes very hard to maintain unit of work &lt;/font&gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;span style="FONT-SIZE: 12pt"&gt;&lt;font size="2"&gt;Portability across thread is very hard &lt;/font&gt;&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;span style="FONT-SIZE: 12pt"&gt;&lt;font size="2"&gt;Unit of work pattern is not transparent enough&lt;br /&gt;
    &lt;/font&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;strong&gt;4.  Finally, the last idea we've been trying to come up with is concept similar to TransactionScope.&lt;/strong&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;In this pattern, you would used &lt;strong&gt;using&lt;/strong&gt;{ } block to initialize your context and represent a "Datacontext Scope". Any method below that will automatically be able to figure out the proper context, through thread/request datastore. Then just before the dispose happens, you manually call the &lt;strong&gt;SubmitChanges&lt;/strong&gt;() method. This is the one I like so far, however, has few practical problems. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 12pt"&gt;&lt;font size="2"&gt;&lt;strong&gt;Problems with this pattern:&lt;/strong&gt; &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul style="MARGIN-LEFT: 72pt"&gt;
    &lt;li&gt;&lt;span style="FONT-SIZE: 12pt"&gt;&lt;font size="2"&gt;If sub method needs to implement a new context, we need to figure out how to exclude it from the parent context's using block. If allowing multiple contexts in multiple using blocks, how do you determine which context to use in sub-sub methods? &lt;/font&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;Please do comment on what you think is the best approach to solving this problem.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://dotnetlog.com/aggbug/53.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Bigyan Rajbhandari</dc:creator>
            <guid>http://dotnetlog.com/archive/2008/03/18/best-practice-and-effective-way-of-using-datacontext-in-linq.aspx</guid>
            <pubDate>Wed, 19 Mar 2008 01:51:33 GMT</pubDate>
            <wfw:comment>http://dotnetlog.com/comments/53.aspx</wfw:comment>
            <comments>http://dotnetlog.com/archive/2008/03/18/best-practice-and-effective-way-of-using-datacontext-in-linq.aspx#feedback</comments>
            <slash:comments>7</slash:comments>
            <wfw:commentRss>http://dotnetlog.com/comments/commentRss/53.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>