Page copy protected against web site content infringement by Copyscape

Code Metrics in VS 2008

 I am not sure whether you have tried the Code Metrics tool in VS 2008. It is a very handy tool and simply answers the question "How difficult is your code to maintain?"

You need to know how to interpret different code metrics to take corrective actions:

Maintainability Index — Should be high as possible. 100 is the target you want to achieve. This index is an aggregate of all the code metrics indexes (code complexity, lines of code, inheritance depth and class coupling)

Cyclomatic Complexity — Number of branches your code takes (switch, case, if statements). You want to keep this number low.

Depth of Inheritance — Inheritance chain. You want to keep this value as low as possible. Every time you inherit, the value goes up by 1. You want to avoid the bad cascading effect (Poorly designed class will cause the entire inheritance chain difficult to maintain)

Class coupling — this shows the dependency between different class types. If this number is higher, it means your code will become difficult to maintain. Just imagine you had numerous classes calling each other methods without any discipline.

Lines of Code — Keep a tab on the number of lines of code you have to write. With the advancement of tools and technologies, people are moving towards lesser number of codes. Keep in mind the line of code does not include the number of lines used for attribute definition, comments declaration and constructs.

There is no hard and fast rule on what the code metrics index value should be. Your project can be complex and the index numbers could be high.

An insight into code metrics will help you identify the problem areas and help you refactor code if needed.

Page copy protected against web site content infringement by Copyscape

Let us take a performance snapshot on using Row Constructors in SQL 2008

Example table:

create table Customer
(customerID int primary key clustered identity(1,1)
,firstName varchar(30)
,lastname varchar(30)
, age int
)

— SQL 2005 method

begin transaction
insert into customer values ('Joe', 'Smith', 35)
insert into customer values ('Jane', 'Smith', 36)
insert into customer values ('Daniel', 'Smith', 37)
insert into customer values ('Daniel', 'Smith', 37)
commit transaction;

— SQL 2008 method (row constructors)

begin transaction
insert into customer values
('Joe', 'Smith', 35),
('Jane', 'Smith', 36),
('Daniel', 'Smith', 37),
('John', 'Smith', 38)
commit transaction;

As you examine the different variables, you will notice that SQL 2008 Row constructor method fares much better for the scenario described.

 

Page copy protected against web site content infringement by Copyscape

You may come across situations where you need to add custom styles (css) to edit text inside your content editor web part. To enable custom styles to you web part, open your master CSS file used for your site and add an entry that follows the naming convention of

.ms-rteCustom-xxxx

where xxxx is the custom name of your style.

Note: When you add custom style entries to your CSS file, the content editor will override the existing styles (ArticleByLine,ArticleHeadline,ArticleTitle) and only show the custom styles you had created.

.ms-rteCustom-SampleTitleByTK

{   

font-weight: bold;

font-family: Arial   

font-size: 14pt   

color: #8F2031;   

text-transform: capitalize;

}

Once this link is added, you will see the option available in your content editor web part as shown below