Maverick

Thursday, April 19, 2007

.NET Framework Tools

Filed under: .NET Framework, C# — debasishpramanik @ 9:13 am

Its quite amazing Microsoft has provided so many .NET framework tools, the question comes then in my mind how many we know or how many we have used. My answer was ignorance. So decided to list some of the tools that framework provides. In some of next posts I will try to elaborate some of these once I really understand how to use them. The complete list can be find in the following link
http://msdn2.microsoft.com/en-us/library/d9kh6s92(VS.80).aspx

  1. ASP.NET Compilation Tool
  2. ASP.NET IIS Registration Tool
  3. Assembly Cache Viewer
  4. Global Assembly Cache Tool
  5. Installer Tool
  6. Native Image Generator
  7. XML Serialization Tool Generator
  8. WSDL tool
  9. XML Schema Definition tool
  10. MS CLR Debugger Tool
  11. SOS Debugging Extension
  12. Strong Name Tool
  13. MSIL Disassembler
  14. MSIL Assembler
  15. Resource File Generator tool

Wednesday, April 18, 2007

Manipulating managed data using unsafe

Filed under: C# — debasishpramanik @ 5:30 pm

 While exploring the GC classes got a idea can we access a managed data using unmanaged code. So tried the following and got excited so here is the code

class Program
{
void Main(string[] args)
{
int a = 0;
unsafe
{
int *p = &a;
Console.WriteLine(“the value of a thru p={0}”,*p)
(*p)++;
}
Console.WriteLine(a);
}
}

Guess the output
The o/p is
the value of a thru p=0
1

It works fine with value type. I’m still struggiling to do the same for reference type. Looking for some hack…

Tuesday, April 17, 2007

Business Rules in Devloper’s life- II

Filed under: BRMS — debasishpramanik @ 12:50 pm

This post is dedicated to my friend who have taken great effort to add many business rules that she thinks should be added in my earlier post of Business Rules in Developer Life.

Customer Support
1. QA scripts and tools must be updated as per any fix/bug, as a followup to customer support.
2. Whether the fix have been migrated to all the latest versions.

Technical Front
1. Awareness of latest technolgical advance around us.
2. Identifying what is relevant for a developer.
3. Learning the new stuff.
4. Applying the new stuff.

Thanks to her…

Sunday, April 15, 2007

Business Rule’s in Developer Life

Filed under: BRMS — debasishpramanik @ 5:53 pm

As a developer writing code for many years may be more than a decade(including college and school days), I never thought of that I may be working with a set of business rules coincidently but today while going through a book on Business Rules by Tony Morgan they seems all to be Business Rules. So I decided to list them all.

Writing Code

1. Naming Convention for file.
2. Writing Code in a particular namespace.
3. Following Coding Guidelines.
4. Compiling the code and remove all errors.
5. Follow Source Safe guidelines before check-in the code.

Customer Support

1. Acknowledgment to customer.
2. Analysing the support case.
3. If its critical then respond immediately.
4. If its not critical then schedule the fix and release.
5. Communicate to the customer.

The last but not the least sending the status report on every Friday to the Manager :) .

Business Rules are everywhere whether we acknowledge them or not, they are just their. We just need to open our eyes and started recognizing them.Life is full of Business Rules so lets start recognizing them and start making them better and efficient.

[**Let me know if you guys think there are items other then listed....]

Wednesday, April 11, 2007

Sending Data using SOAP Header in Web Service

Filed under: ASP.NET — debasishpramanik @ 2:32 pm

While writting Web Service in ASP.NET for our Business Layer, I came across a pattern where I found developers sending house keeping data as part of the method signature.

For e.g

CreateStockItem(int SessionID, int UserID, String StockItemXML)

I had a intution there will be better way of sending these data instead of the way we are sending and I came across the SOAP Header.

The following is the manner I implemented

1. Create a class derived from SoapHeader. The namespace is System.Web.Services.Protocols
public class InternalData:SoapHeader 
{
    public int SessionID;
    public   int UserID;
}

2. In the Web Service class create a object of above derived type. This should be public.
public class MyWebService: WebService
{
   public InternalData Header; 
}

3.  Add a SoapHeader attribute for a WebMethod indicating that the web method should be passed the SoapHeader data. Passed the name of the variable which will be filled by ASP.NET runtime
[SoapHeader("Header")]
[WebMethod]
public string CreateStockItem(string StockItemXML)
{
     SessionID = Header.SessionID;
    UserID      = Header.UserID;
}

4. Program that consume web Service will create an instance of the Header

      InternalData myHeader = new InternalData();
      myHeader.SessionID = 12233;
      myHeader.UserID = 122;

5. Now create the object of the MyWebService

    MyWebService wsObj = new MyWebService();

6. Set the HeaderValue property of Webservice object to myHeader

   wsObj.HeaderValue = myHeader;

7. Call the Web Service method.

This will send the data in the header.

Tuesday, April 10, 2007

Rule Engine: The Inevitable

Filed under: BRMS — debasishpramanik @ 9:30 am

It was a hurricane task coming to an end when we finished the framework of our product. It was a project that we started two years and was able to finish with almost all the features that we thought of. This was a framework on top of which all business layer will be developed. The great thing was any new business layer(BL) development will not take much time to develop as they will all follow a similar pattern.

This thought of similar pattern really strike me. If all BL will follow similar pattern why we need to program every time why we can’t write a rule engine which will read rules written by developer and then execute methods on the framework. My intention was

  1. Developer now need to express BL methods in the form of XML.
  2. A tool can be developed which will allow business analyst or external project manager to write such rules or customize existing BL methods.

When I presented this to my CEO he had reservation and he said the following

  1. Developer will need to learn a new language instead of C#.
  2. The Rule Engine will be very complex and will require lot of development and maintenance effort.

Although he rejected my idea but he agreed that the product need a Rule Engine as the product caters to a market where business rules keeps on changing and embedding these in code really makes the product rigid. It can become a USP of the product as it will allow us to market product where we can claim “Change Business Rule without any cost…”

Recently I joined a leading BRMS vendor. Before joining this firm I really started thinking whats the future of the entire domain and why we required such thing. What I came with a statement

“In next ten year every Enterprise software system should be Rule Engine based .”

The reason for my above belief

  1. Business Rules change are inevitable.
  2. Enterprise system are based on Business Rules.
  3. Change in Business Rule causes triggering of Change Management which involves cost and more important time.
  4. The factors above may lead to work with old system which may be inefficient.
  5. Having a Rule Engine based system where Business Rules are captured outside an enterprise system will empowered enterprises to go ahead with efficient process improvement without thinking of time and cost.
  6. Enterprise system’s will invoke the rules using the Rule Engine based on certain well defined interface.
  7. This will Enterprise’s IT department to manage all Business Rules in a single repository in more efficient manner.
  8. The IT department can generate all sort of analytics about the Business Rules currently in use or Business Rules which are no longer is in practice or history of Business Rules within an enterprise.

Monday, April 9, 2007

Troubleshooting Application Server

Filed under: Troubleshooting — debasishpramanik @ 12:23 pm

It was the same client that I discussed in the previous blog Troubleshooting Server Crash that we encountered another server crash related issue long back this issue occurred. The issue was our Application Server was crashing once sometimes twice in a day and the resolution was restart the Application Server. The Application Server was a Windows Service and the backend database was SQL Server 2000.

This problem almost run for months. We initially start speculating the problem to be related with number of database connection in the pool so as a first step we increased the number of database connection. But this didn’t helped us. So we started the usual process of instrumenting the application code and checking the log files. It took us sometime to come with a clear picture. The reason for the crash was identified. The reason was the Application Server used to send mails as part of some workflow process, so while sending the mail it used hung up and caused the database to go into a blocked state i.e. the tables used by that particular request’s database connection were locked. Slowly slowly all the database connection used to wait for the tables locks to be released.

There were two solution we could suggest

  1. Have a dedicated process for sending mails.
  2. Close the database connection before sending mails. So that tables are not locked even if there is an issue while sending mails.

After lot of thoughts the first solution was used for the following reasons

  1. Restart of application server is much more expensive then the restart of Mail Service.
  2. The logic of the program for some reason required the connection to be open while sending mails, so we could not close the database connection while sending mails.

After the changes were send to the production server we didn’t face the issue again as while writting the new mail service we created Watcher thread that will monitor the mail sending process. If the mail sender thread doesn’t return in a configured amount of time we killed that thread and start the mail sender again. this was quite useful as it really helped us to solve the issue.

Thursday, April 5, 2007

Troubleshooting Server Crash

Filed under: Troubleshooting — debasishpramanik @ 10:02 am

I was working on this project for almost 5 months and it was unfortunate and my bad luck that every time we thought we are done some issue or other would come and create a havoc for us. It was really a tough time and client was infact more tougher and demanding. So atlast when we resolved all issues somehow (hit n trial) and given the system for final QA to client. Within 5 minutes of testing the system crashed and we had no clue why it could have happen.

It become more troublesome for me when I received a mail from the external project manager address to my CEO. Suddenly there was lot of pressure on me and trust me it took 2 weeks to find what cause the crash. In those two weeks life was hell and I used every possible debugging tool available on web but all point to different things. There were no two logs providing me same results. Infact the system starts crashing because of using the tool. Lot of discussion went with me and my senior colleague to nail down the issue and atlast we were able to reproduce the issue and found that if we rapid click on all links on the left bar of the application it crashes the system. Trust me we were very happy. Atleast we have something to tell our client.

But now it was more tougher job how do we overcome this issue. We thought and thought and keep on thinking.  We started isolating the pages and found that one particular page is causing the issue. I didn’t have any answer why this page should crash the IIS. It was big question mark for me. The same weekend while travelling to mumbai I started thinking again and found that the only differnece between this and other page is MULTI THREADING. This page uses multi threading to render its content while others don’t use it.

The first thing on Monday morning I did was identify can we do without multi threading as it was important for performance. But as it was crashing I have no other option. We did the following

  1. Reduced the number of queries to database.
  2. Reduced to number of unnecessary iterations that create in memory objects from DB.
  3. Serialize the code that were using threads.

The results were great

  1. Crash problem got resolved.
  2. We achieved the same performance that was with Multi Threading.

It was great feeling.

Blog at WordPress.com.