26
Feb 14

Change Tracking (CT), Change Data Capture (CDC) and Comparison between CT and CDC

This week I had to learn more about the Change Tracking (CT) and Change Data Capture (CDC) that was introduced in SQL Server 2008.

To learn more about the subject I read the 3 articles written by Chandra Sekhar.

1) Change Tracking (CT)

2) Change data Capture (CDC) 

3) Comparison between CT and CDC

Background:

Prior to SQL Server 2008, developers had to create some custom tracking solutions using DML Trigger and additional tables to track the data which we have modified.

  • DML Triggers: These are the part of our transaction which contains the DML by which it is triggered. As we all know that, triggers are very expensive and we are using them in our transaction, the execution time will increase so that the performance of our project will be affected
  • Additional tables: By running the above DML triggers, we are able to track the data. But there is nothing to store these changes. To store this changed data, we need to create these additional tables. These tables will have similar columns as the tables which we need to track.

Drawbacks

  • Takes much time to develop/create DML triggers and additional tables
  • Performance hit
  • Very complex process

SQL Server 2008

To overcome the above drawbacks, SQL Server 2008 introduced powerful and efficient tracking mechanisms called Change Tracking (CT) and Change data Capture (CDC) 

Similarities:

  • Both Track DML changes
  • Both Track whether column data has changes or not
  • Required to enable them on table as well as on database

Differences:

S.No.
Change Tracking
Change Data Capture
1 It tracks only whether the data has been changed or not. But never captures the modified values It captures values also
2 It follows synchronous tracking mechanism to track the data It follows asynchronous tracking mechanism which reads data changes from ldf file
3 It works in all the editions of SQL Server like Express, Workgroup, Web, Standard, Enterprise, DataCenter It works only in Enterprise and DataCenter editions
4 Does not hold historical data Holds historical data
5 No need to access ldf file of that particular database Needs to access ldf file of that particular database
6 Uses temp db Uses Transaction log (ldf file)
7 Returns less information regarding the changes in the data Returns more information compared to CT
8 Little bit difficult to get the full data of the table for which we have to join CHANGETABLE with the table based on primary key We can query directly from tables
9 SQL Server agent is not required to track the data SQL Server Agent should be enabled to capture the data
10 We can enable it on a table when the table has primary key on it No restriction as it is in the CT
11 User can truncate the table when it is enabled on the table User can not truncate when it is enabled on the table
12 We can turn off auto clean up We can’t turn off
13 Only SYSADMIN can enable CT Only DBOwner can enable CDC

21
Feb 14

Yield return and dynamic gotchas with explicit interface implementation

This week while I’m doing a little demo to measure the time using a yield return method vs return a static list. I decided to use the keyword dynamic to simplify my code and avoid  the methods overload. Quickly i found when I called the yield return method it simple crashed with a kinda gotchas between dynamic and IEnumerable<T>. It fails when yield code explicitly implements its interfaces. The solution is to help the execution-time overload resolution to find the most specific method. 

Code demo:

using System;
using System.Collections.Generic;
using System.Collections;
using System.Diagnostics;

namespace YieldDemo
{
    public class States1
    {
          public static IEnumerable<string> GetNames()
        {
            yield return "Alabama";
            yield return "Alaska";
            yield return "Arizona";
            yield return "Arkansas";
            yield return "California";
            yield return "Others ...";
        }
    }

    public class States2
    {
        private static readonly IList<string> _names;

        static States2()
        {
            _names = new List<string>() {"Alabama", 
                                     "Alaska",
                                     "Arizona",
                                     "Arkansas",
                                     "California",
                                     "Others ..." };

        }

        public static IList<string> GetNames()
        {
            return _names;
        }
    }

    public class Program
    {

        static void Main()
        {
            Test(States2.GetNames());
            Test(States1.GetNames());

            Console.ReadLine();
        }

        public static void Test(dynamic state)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            Iterate(state);            
            stopwatch.Stop();

            Console.WriteLine("Time elapsed: {0}", stopwatch.Elapsed);
        }

        public static void Iterate(dynamic itemList)
        {
            var enumerator = itemList.GetEnumerator();

            while (enumerator.MoveNext())
            {
                Console.WriteLine(enumerator.Current);
            }
        }
    }
}

When i call the following method:

Test(States1.GetNames())

I received the error “Additional information: ‘object’ does not contain a definition for ‘GetEnumerator'”.

Without any clue why this is happening. I posted a question in StackOverflow and I got some help.

“The problem is that the iterator block implementation uses explicit interface implementation to implement IEnumerable<T>… and explicit interface implementation doesn’t play nicely with dynamic typing in general. (You don’t need to use iterator blocks to see that. See my article on Gotchas in Dynamic Typing for more details.)”

“It fails because the IEnumerable<string> class generated by your yield code explicitly implements its interfaces (including the GetEnumerator you’re trying to use).”

So …

One way of avoiding the explicit interface implementation issue is to use dynamic typing to perform execution-time overload resolution to find the most specific method … the compiler won’t always know which overload to choose.

Solution 1:

Using the foreach to iterate.

public static void Iterate(dynamic itemList)
{
    foreach (dynamic item in itemList)
    {
        Console.WriteLine(item);
    }
}

Solution 2:

public static void Iterate(dynamic itemList)
{
    var enumerator = ((IEnumerable)itemList).GetEnumerator();

    while (enumerator.MoveNext())
    {
        Console.WriteLine(enumerator.Current);
    }
}

Solution 3:

public static void Iterate(IEnumerable itemList)
{
    var enumerator = itemList.GetEnumerator();

    while (enumerator.MoveNext())
    {
        Console.WriteLine(enumerator.Current);
    }
}

Solution 4:

public static void Iterate<T>(IEnumerable<T> itemList)
{
    var enumerator = itemList.GetEnumerator();

    while (enumerator.MoveNext())
    {
        Console.WriteLine(enumerator.Current);
    }
}

27
Dec 13

More about Visual Studio 2013 Part 2

From Microsoft:

What’s New in Visual Studio 2013: (01) What’s New in the IDE
Authored by:  Christopher Harrison and Susan Ibach

What’s New in Visual Studio 2013: (02) New Features for Web Developers
Authored by:  Christopher Harrison and Susan Ibach

What’s New in Visual Studio 2013: (03) Application Lifecycle Management
Authored by:  Christopher Harrison and Susan Ibach

What’s New in Visual Studio 2013: (04) What’s New for App Developers
Authored by:  Christopher Harrison and Susan Ibach

Link: Visual Studio 2013 Part 1


15
Nov 13

More about Visual Studio 2013 Part 1

From Microsoft:

Keynote: Transforming software development in a world of devices and services
Authored by: S. Somasegar, Brian Harry, Scott Guthrie, Scott Hanselman

Visual Studio 2013 Launch Keynote Recap with S. Somasegar
Authored by: S. Somasegar, Brian Keller

What’s New for Web Developers in Visual Studio 2013
Authored by: Scott Hunter, Mads Kristensen, Damian Edwards

What’s New in the Visual Studio 2013 IDE
Authored by: David Starr, Cathy Sullivan

From Pluralsight

Mastering Visual Studio 2013

This course covers the newest features of Visual Studio including new IDE features, code editor improvements, XAML coding enhancements, updated debugging features, and the awesome new CodeLens.

Authored by: Deborah Kurata
Duration: 2h 50m
Level: Intermediate
Released: 10/22/2013

Click here to check the course!


25
Jul 13

Hacker Tools You Should Know and Worry About

When we investigate cybercrime we often find traces of commonly known hacker tools, trojans, etc. In this highly interactive demo session, we show you the hacking tools of today, the damage they can do, and how you can recognize them when they are used to attack your infrastructure. This is an extremely valuable and important session for anybody interested in protecting their own IT environment.

Click here to visit original post!


23
Jul 13

What’s New in .NET Development Build 2013

The latest version of .NET delivers a number of new innovations while maintaining a high compatibility bar. In this presentation, we will walk through the latest features in .NET that focus on Developer Productivity, Application Performance and Continuous Delivery. Examples will include diagnostics improvements, library enhancements and new features in Windows Store development.

Developer Productivity

64-bit Edit and continue
Method return value inspection
Async Debugging Enhancements
Windows Store development improvements
EF/ADO.NET Connection Resilency

Application Performance

ASP.NET application suspension
Multi-core JIT improvements
On-demand large object heap compaction
Consistent performance before and after servicing the .NET Framework

Continuous Innovation

.NET Framework updates
NuGet releases
Curated.NET Framework NuGet packages

Click here to visit original post!


24
May 13

Open-source JavaScript framework AngularJS

Last week a fellow worker (Bruno Camara) show me a demo that uses the open-source JavaScript framework called AngularJS.

AngularJS is an open-source JavaScript framework, maintained by Google, that assists with running what are known as single-page applications. Its goal is to augment browser-based applications with model–view–controller (MVC) capability, in an effort to make both development and testing easier.

After viewing this simple demo. It’s time to dive a little more.

Resources:

Design Decisions in AngularJS
AngularJS Fundamentals in 60-ish Minutes
Pluralsight – AngularJS Fundamentals
http://angularjs.org
http://docs.angularjs.org/tutorial
http://builtwith.angularjs.org
http://angular-ui.github.io
http://mgcrea.github.io/angular-strap
https://github.com/angular/angular-seed


01
Jul 12

How to update option rom / bios raid drivers.

I have described below the steps I take to update my Option ROM on the motherboard P5QLE (I found these steps on Asus forum).

1. Get MMTool_3.22_Mod_21FiX
2. Open MMTool and "Load ROM" to open your BIOS ROM
3. Highlight the Option ROM (typically under the name column there will be "PCI Option ROM" and has a "RunLoc" of 8086:2822 for the ICH10). IF YOUR RUNLOC IS DIFFERENT LOCATE THE CORRECT ONE! 8086 means the manufacturer is Intel and 2822 means it is a ICH10 chipset ROM. For a list of Vendor and Device IDs goto www.pcidatabase.com
4. Once you have the CORRECT option ROM highlighted, select the "Replace" tab. (Do NOT delete and insert the updated ROM)
5. On the Replace tab, click Browse to find your updated Option Rom.
6. Once the correct ROM has been selected, click Replace.
7. Use "Save ROM as…" to make a new ROM file and keep your stock ROM intact.
8. Use the Asus EZ Flash 2 utility in your BIOS to update your Option ROM.

Note: You can download the latest Intel Raid Rom and Intel Rapid Storage Technology from http://forums.tweaktown.com

WARRANTY!!

works-on-my-machine-starburst_3

I AM NOT RESPONSIBLE IF YOU BRICK YOUR MOTHERBOARD!


01
Mar 12

A lesson that every developer must know about multiple class cascade in CSS

The text above was taken from http://css-discuss.incutio.com

Please read the red text below at least 10 times… 🙂

“What’s the expected behavior when an element has multiple classes which redefine properties? Here’s an example:

<style type="text/css">  
  .headline { border: 3px solid red } 
  .newsitem { border: 2px solid red }  
  .blurb    { border: 1px solid red }
</style>
...
<h1 class="headline newsitem blurb">French Noblewoman Advocates Increased Cake Consumption Among Peasants</h1>

Will the border of the H1 element be 3, 2, or 1 pixel wide?

To answer this question you need to understand how Selector Specificity works in CSS. In this case the (rough) answer is the “last highest-weighted rule wins”, so the border will be 1px. Note that it’s the order of the rules in the stylesheet that controls which takes precedence; the order of the class names in the class attribute is irrelevant.”


01
Jan 12

11 Things every Software Developer should be doing in 2012 by Michael Crump

Do you need help to improve your personal quest to be a better developer?

Read this blog post created by Michael Crump.

Click here to visit original post!

“Introduction

2011 is winding down and 2012 is upon us. Have you set any goals for 2012 both professionally/personally? Regardless of the answer, I’m sure one or two of the items listed below can help. I usually don’t blog many opinion posts, due to the fact that I like to keep my blog technical. This post is an exception. 🙂

11 Things every Software Developer should be doing in 2012.
  1. Get on Twitter – If you’re not using Twitter and are a Software Developer then you are missing out. I believe that Twitter is the one of theMOST important tool a Software Developer can use. Why?
    1. Regardless if you have 10 followers or 10000 followers, any coding question can be found and answered in a matter of seconds using Twitter Hashtags. 
    2. Get software developer news straight from the source by following other developers.
    3. Again hashtags – To monitor topics important to you. For example, I use it to monitor #wp7, #silverlight and #wpf. 
    4. To stay engaged in a conversation with other developers and to see what projects they are working on. 
  2. Read StackOverflow Daily – StackOverflow is the number one forum for asking a coding question. Even if you don’t have an account, it’s worth it just for browsing questions and learning. I think it is a wise investment of your time to spend at least 20 minutes a day reading StackOverflow.
  3. Start a Blog – I believe that every Developer should have a blog. Why?
    1. It is a footprint that we leave for other developers studying our craft.
    2. It allows you to become engaged in the community.
    3. It helps you market yourself as a professional.
  4. Get out there – Get out of your shell and start talking to other developers at local user groups/other meet ups/conferences. I will let you in on a secret – most everyone is shy at first. If you start a conversation with them then it usually takes off very fast.
    1. Networking with other developers is big – really big. You start building connections in the industry and if you ever need help then you have someone to go to.
  5. Carry around a modern phone – If you’re a developer and carrying around an older phone then its time to upgrade. I remember a manager at one of my jobs that had to walk back to his desk to email me something. I remember thinking, “This guy is in IT?” Just like some industries you need to drive a fancy car, have nice clothes or the latest jewelry. In technology, we need to stay current with our computers, software and mobile phones.
  6. Embrace Mobile  – Do you think this “mobile” thing is going away? Well, it is just getting started. You need to know more than how to develop for the iPhone, WP7 or Android. You need to learn how to create web applications that will run on every mobile device. (Including phones, iPads, Windows and Android slates). I believe that every developer will have to create a mobile application in his/her programming career. This is something a modern developer cannot ignore.
  7. Learn at least one design pattern- I am not going to tell you which one you should learn or focus on, but you need at least one. I prefer MVVM for myself because I am a Silverlight/WPF/WP7 Developer. If you are familiar with at least one design pattern then it would make me feel better about hiring you.
    1. I’d start with this book: Gang of Four – Design Patterns: Elements of Reusable OOS.
  8. Set reachable goals each and every year – Create a short-list of goals that you are looking to accomplish in the next year. Not only should you be challenging yourself with a set of goals, you should also create a quarterly outlook/Gmail reminder to evaluate your progress. I am a believer that you should start small with a goal and build up from there. I did this with my MCPD certification. I shot for the MCP, then MCTS then the MCPD.
  9. Learn a different programming language –  Simply put, it broadens your perspective and permits a deeper understanding of how a computer and programming languages actually work.
    1. If the only tool you have is a hammer, you’ll treat every problem as a nail.
  10. Boost your confidence – It always amazes me how few developers are confident in themselves. If you feel like you’re behind on something then learn it. I can’t find any excuse for staying ignorant in this industry. There is just too many FREE resources on the web. 
  11. Read Blogs/Programming Books/Magazine – How many programming books have you read this year? What about good developer magazines? I believe a good developer would read at least 5 programming books a year and at least a magazine or two monthly. Even if you don’t have a subscription to MSDN you can get the .PDF for free a month after release.  How can you get better if your not constantly reading?”