January 17, 2014

Enterprise Library 6 Changes - Exception Handling and Logging Application blocks configuration

I was developing a framework services project for my new assignment .. (getting hands dirty after a while .. :) ).. Seems that there is a change in the way we configure our helper classes to log and handle  exception

For Logging:

common approach to create a log entry using the following code-

LogEntry entry = new LogEntry();
entry.Message = "I am logging";

 works fine with Enterprise Library 5.0. But in 6.0 it gives the error "The LogWriter has not been set for the Logger static class. Set it invoking the Logger.SetLogWriter method" 

Following snippet will fix the issue

IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
LogWriterFactory logWriterFactory = new LogWriterFactory(configurationSource);
LogEntry entry = new LogEntry();
entry.Message = "I am logging";

For Exception Handling

 public static bool HandleException(Exception exceptionToHandle)
            IConfigurationSource config = ConfigurationSourceFactory.Create();
            ExceptionPolicyFactory factory = new ExceptionPolicyFactory(config);
            return ExceptionPolicy.HandleException(exceptionToHandle, 

Don't forget to add reference to "System.Configuration" assembly to your project, else you will get error and add it in the "using" list.

June 8, 2011

Some useful SQL Queries on Date functions

TO Calculate first day of month
select DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)

First Day of Year
select DATEADD(yy, DATEDIFF(yy,0,getdate()), 0)

First Day of the Quarter
select DATEADD(qq, DATEDIFF(qq,0,getdate()), 0)

Last day of Prior month
select dateadd(ms,-3,DATEADD(mm, DATEDIFF(mm,0,getdate() ), 0))

Last Day of Prior Year
select dateadd(ms,-3,DATEADD(yy, DATEDIFF(yy,0,getdate() ), 0))

Last day of current month
select dateadd(ms,-3,DATEADD(mm, DATEDIFF(m,0,getdate() )+1, 0))

Last Day of Current Year
select dateadd(ms,-3,DATEADD(yy, DATEDIFF(yy,0,getdate() )+1, 0))

January 10, 2011

Web Application Performance Best Practices

Some of the thumb rules to flare better perfomance in web applications

§Appropriate usage of Caching
§Minimize HTTP Requests
§Removed unwanted HTML / JS / CSS
§Remove White Spaces
§Place CSS at Top of the page
§Move JS reference to the bottom of the page
§Reduce Image Size
§Cache Static content (Images / CSS / JS)
§Enable HTTP Compression
§Remove Duplicate Scripts

•Use a Content Delivery Network
•Add an Expires or a Cache-Control Header
•Avoid CSS Expressions
•Make JavaScript and CSS External
•Remove Duplicate Scripts
•Don’t scale images in HTML
•Flush the Buffer Early
•Reduce the Number of DOM Elements
•Minimize the Number of iframes
•No 404s
•Minimize DOM Access
•Optimize CSS Sprites
•Keep Components under 25K

Analysis Services 101

Here is intro course to BI Analytics...

1. Facts(Measures) is a summable numeric value
2. Only events tracking in Fact table known as fasctless fact tables, in that case add column with value 1 to track them.
3. Grain is the lowest possible level of information in fact, make it as lowest as possible. Atomic level.
4. Facts are verb in Business process where as Dimesnions are nouns.
5. Dimension shared across more than 1 business process is known as Conformed Dimension
6. Surrogate keys (Meaningless , non-natural, artificial, ) is int value associayrf with each rown in dimesnion
7. Dimensions with Changeable attribute is called Slowly Changing Dimesnions (SCDs)
Type 1 SCDs overwrite old value
Type 2 SCDs have new row for every new change
Type 3 SCDs provide option of columns (not commonly followed and not scalable)
8. Data Dimension classic example for role Playing Dimension... better to have surrogate keys in year-month0date format since 20050221(would help for partitioning)
9.Dimension that doesn't have attributes are known as Degenerated Dimensions (e.g TransactionID)
10.Discourage Snowflake schema, Analysis 2000 has little inclination towards it but not 2005
11. Bridge table required when we have many-many dimensions, called Intermediate Fact Tables in Analysis Services 2005
12. Fact Table types, Periodic Snapshot, transaction and accumulating snapshot

DB Normalization in simple

This is one of the most frequently used question..lot times we know the thing have difficulty in expressing it...thot would write a simple post for it...

First Normal Form (1NF)
  • Eliminate duplicative columns from the same table.
  • Create separate tables for each group of related data and identify each row with a unique column or set of columns (the primary key).

Second Normal Form (2NF)

  • Meet all the requirements of the first normal form.
  • Remove subsets of data that apply to multiple rows of a table and place them in separate tables. Create relationships between these new tables and their predecessors through the use of foreign keys.

Third Normal Form (3NF)

  • Meet all the requirements of the second normal form.
  • Remove columns that are not dependent upon the primary key.

Fourth Normal Form (4NF)

  • Meet all the requirements of the third normal form.
  • A relation is in 4NF if it has no multi-valued dependencies.

Review your Architecture

Last week I bumped in to a book "Enterprise Application Arch 2ed". I read abot reviewing S/W arch by some proven methodlogies..thot would blog for starters.. good read...

Scenario-based evaluations are a powerful method for reviewing an architecture design. In a scenario-based evaluation, the focus is on the scenarios that are most important from the business perspective, and which have the greatest impact on the architecture. Consider using one of the following common review methodologies:

Software Architecture Analysis Method (SAAM). SAAM was originally designed for assessing modifiability, but later was extended for reviewing architecture with respect to quality attributes such as modifiability, portability, extensibility, integratability, and functional coverage.

Architecture Tradeoff Analysis Method (ATAM). ATAM is a refined and improved version of SAAM that helps you review architectural decisions with respect to the quality attributes requirements, and how well they satisfy particular quality goals.

Active Design Review (ADR). ADR is best suited for incomplete or in-progress architectures. The main difference is that the review is more focused on a set of issues or individual sections of the architecture at a time, rather than performing a general review.

Active Reviews of Intermediate Designs (ARID). ARID combines the ADR aspect of reviewing in-progress architecture with a focus on a set of issues, and the ATAM and SAAM approach of scenario-based review focused on quality attributes.

Cost Benefit Analysis Method (CBAM). This CBAM focuses on analyzing the costs, benefits, and schedule implications of architectural decisions.

Architecture Level Modifiability Analysis (ALMA). ALMA evaluates the modifiability of architecture for business information systems (BIS).

Family Architecture Assessment Method (FAAM). FAAM evaluates information system family architectures for interoperability and extensibility.

Refer this URL

February 20, 2010

Iterating over JSON object (string ) with jquery

We had a scenario where in we need to search for particular object in collection. Whenever the user changes something in dropdown in ASP.NET we need to show some value in a label. If we take the drop down value to server it would take time.... so what we thot is we searialized the object using JavascriptSerializer in ASP.NET and converted to JSON string.. passsed to a javascript function to search.... (whenever dropdown changes)... I was literally amazed with the power of JSON and jquery combination... thot i would share with people in need.....

Here is the JSON string...in Javascript...

var obj = [{"Description":"No jquery pricing group may be used for Testing", "ID":1, "TempID":1, "CompareID":3}, {"Description":"No jquery pricing group may be used for Testing", "ID":2, "TempID":2, "CompareID":3}, {"Description":"No jquery pricing group may be used for Testing", "ID":3, "TempID":3, "CompareID":3}, {"Description":"No jquery pricing group may be used for Testing", "ID":4, "TempID":4, "CompareID":3}, {"Description":"No jquery pricing group may be used for Testing", "ID":5, "TempID":1, "CompareID":4}, {"Description":"Jquery required for pricing Testing", "ID":6, "TempID":2, "CompareID":4}, {"Description":"Jquery required for pricing Testing", "ID":7, "TempID":3, "CompareID":4}, {"Description":"Jquery required for pricing Testing", "ID":8, "TempID":4, "CompareID":4}, {"Description":"No jquery pricing group may be used for Testing", "ID":9, "TempID":1, "CompareID":5}, {"Description":"Jquery required for pricing Testing", "ID":10, "TempID":2, "CompareID":5}, {"Description":"Jquery required for pricing Testing", "ID":11, "TempID":3, "CompareID":5}, {"Description":"Jquery required for pricing Testing", "ID":12, "TempID":4, "CompareID":5}];

We had a requirement to searhch the description for matching TempID and COmpareID...

Our Javascript function was amazingly...

function Myfunc(ID1,Exp1){jQuery.each(obj, function Test(x) { if (obj[x].TempID == ID1 && obj[x].CompareID == Exp1) //return obj[x].Description; alert(obj[x].Description);}); }

This would have helped you to understand the power of jqeury