Monday, October 24, 2011

Database normalization levels

Normalization is the process of organizing data. This includes creation tables and establishing relationships between those tables. The goal of normalization is to eliminate redundancy and incontinent dependency.

Level of dependencies.
First Level 
Eliminate repeated groups of fields
- Create table for each repeated group
- Identify a records in each tables with prime key
Second Level
- Move repeated group of values to the separate table
- Relate the table be a foreign key
Third Level
- Move related data that do not depend on the prime key to a separate table
There are possible more level, but there are not considered important for real application

Three above level can be illustrated on the sample table Student with the following columns
Student# Adviser Adv-Room, Class1, Class2, Class3

Level First
Student modified to
Student# Adviser Adv-Room, Class

Level Second
Student modified to
Student#, Adviser, Adv-Room
Registration
Student#, Class

Level Three
Student modified to
Student#, Adviser
Registration
Department
Adviser, Room, Department
http://support.microsoft.com/kb/q100139/


Monday, June 6, 2011

What class members require initializer list in definition of constructor

Member objects of classes without default constructors
Const members
Reference members

Assume that T2 in the following does not have default constructor
Class MyClass
{
       string name;
       const int i;
       T1&  obj1;
       T2 obj2;
       MyClass(){};           //wrong - i, T1, T2 require initialization in the initializer list
}

Adding  following constructor(and corresponding declaration in the class declaration) would fix the issue
MyClass::MyClass(const int _i, T1& _obj1, T2 _obj2):_i(i), obj1(_obj1), obj2(_obj2){}

Ref. C++ Language, The (3rd Edition) by Bjarne Stroustrup , page 248.

Friday, June 3, 2011

Automatic destruction of dynamic object

Use unique_ptr<> template object for that.
Ex
{
       unique_ptr<T> p = new T();
}
Dynamic object that is referred by p is destroyed when control thread exits the block.
This is achieved by coupling automatic variable p with the dynamic object. It is ensured by unique_ptr 

Excellent  article on www.stackoverflow.com by Matthieu M.

Thursday, May 26, 2011

Strongly typed resources

To make resource strongly typed select Public from dropdown Access Modifier in resource editor. If dropdwon is disable go to *.resx file property and set Custom Toll PublicResXFileCodeGenerator. You might want also to set Build Action to Embedded Resource. This will not work for project type of Web Site. If project is type of Web Site *.resx file does not have property Custom Tool shown in Properties window, while it is available in project of type  Application.

Tuesday, May 17, 2011

Friday, May 13, 2011

ASP.NET vs ASP.NET MVC

Good article that provides comparison of WebForm and MVC approaches for building Web Application

ASP.net MVC Vs ASP.net Web Form

Here are main points


Advantages of MVC Model

  1. Enable clean separation of concerns (SoC) .
  2. Enable full control over the rendered HTML.
  3. Enable Test Driven Development (TDD) (built with TDD in mind).
  4. SEO and REST friendly URL.
  5. Easy integration with JavaScript frameworks.
  6. Support third-party view engines such as NVelocity, Brail, NHaml.
  7. No ViewState and PostBack events.
  8. Follows the stateless nature of web.
  9. Extensible and Pluggable framework. 
  10. Ideal platform for Web 2.0 applications.
Advantages of Web Form Model
  1. Provides RAD development.
  2. Easy development model for heavy data-driven LOB applications.
  3. Provides rich controls.
  4. Familiar model for windows form developers.

Tuesday, May 10, 2011

IBM versus Microsoft data integration slugfest

In data integration field IBM and Microsoft offer ETL tools DataStage and SISS respectfully.
Here is a good article that compares these two tools.

http://it.toolbox.com/blogs/infosphere/ibm-versus-microsoft-data-integration-slugfest-7319

What is ETL?

ETL stands for ExtractTransferLoad data warehouse technology

Sunday, March 20, 2011

Add export functionality to VS Ultimate modeling tool

Follow posting http://blogs.msdn.com/b/camerons/archive/2010/11/29/xmi-export-sample.aspx by Cameron in Skinner's blog. It provide example tool's extension XMIExportSample. The sample builds the installation for new  Export feature to VS
Requirement:
VS SDK
Visualization and Modeling SDK

Note that import is provided by VS through Architect menu. 

Wednesday, March 16, 2011

Find all files checked out by anyone for a team project

Check out by a certain user
tf.exe status /user:<domain>\<username> $/<project> /r
Checked out by all users
tf status /user:* $/teamProject /r

Friday, March 4, 2011

Form tag. Default value of attribute method.

Default value is GET.

Method attribute of Form tag controls type of request, usually GET or POST.
e.g
<form action="url" >
    <input id="searchkeyword" type="text" name="searchkeyword" />
    <input type="submit">ClickMe</input>
</form>
ClickMe button triggers GET request. Text entered into searchkeyword textbox will be sent in QueryString as
searchkeyword=[text]

Explicit method setup.
Post request
  <form action="url"  method="POST">
Get request
  <form action="url"  method="GET">

Wednesday, February 16, 2011

Handling UI error with ModelState

ModelState gives nice way to collect errors for reporting back to user. ModelState is basically a dictionary.
MVC provides Html extension, named ValidatioonMessage, that return a formated message based on the controller name.
Sample:
//save error
ModelState.AddModelError("Phone", attemptVal, "Dude it is wrong phone")
//placing msg on the page
<span><%Html.ValidationMessage("Phone")%></span>

Here is nice article ASP.NET MVC UI Error Handling - ModelState and AddModelError from David Hyden

Sunday, January 9, 2011

'this' within JavaScript function

Sometime we want to reference within event handler function to the element on which the event occurred. Keyword this gives reference to the element.

Saturday, January 8, 2011

Microsoft AJAX returning JSON needs JavaScriptSerializer for deserialization

Microsoft AJAX  require JavaScriptSerializer to deserialize return object into JSON object. Use get-data() to extract object prior to deserialization.
Consider the code snip 
View
  <%using (Ajax.BeginForm("GetJSONGreeting", new AjaxOptions
                                                  {
                                                      OnComplete = "onComplete"
                                                  }))

...

 <script type="text/javascript">
           function onComplete(data) {
               var obj = Sys.Serialization.JavaScriptSerializer.deserialize(data.get_data());
               alert(obj.Message);
           }
    </script>
Controller
 public JsonResult GetJSONGreeting(string name)
        { 
            return Json( new {Message = string.Format("Hello {0} from JSON", name)});
        }