Saturday, May 31, 2008

Tools to Write Solid code!!!

Today I am going to blog about two important tools most of the developers should have to write solid code.


1)FxCop

This is a free tool from Microsoft which will run through your .dll files and will point out where yo have made design mistakes or where you have violated coding standards.

I started to use this tool sometime back and its really neat.

I would recommend other software developer to use this tool.


2)Stylecop or Source Analysis.

Very nice tool from Microsoft which is free now. Get a copy. It is integrated with visual studio .

Just run it and make your code more readable and pretty.

Happy Programming!!!

Yash

How to Write Solid Piece of Code

The most important point to consider while designing and writing code

1) Always design code in such a way that it is Open for extension but Closed for modification.

i.e when a new requirement comes don't add new code to the classes that work but create new classes to fulfill those requirement . i.e the previous code is locked.

The more code code you add to the existing working code the more possibility of introducing new bugs and ofcourse you have to change the UnitTest Code too.

ALWAYS TRY TO USE DESIGN PATTERN LIKE FACTORY,SINGLETON ETC.

USE OOP CONCEPTS TO KEEP THE DEPENDENCY TO MINIMUM.

I will give you an example here...

Create a Abstract base class... and derive your classes from that i.e different version of classes.

This way you can use the factory pattern and create the appropriate version of the classes depending upon the requirement.

This way you keep the dependency to minimum.

VERY USEFUL TECHNIQUE----

2) ALWAYS GO BACK AND REFACTOR YOUR CODE (Very Important)

As new requirement come always go back and try to refactor you code, create new classes, delegate functionality to different classes, this makes the individual code more testable.

Very important while writing code.

When you have implement something..

a)Start with simple things... make then work as desired.
b) Then go back and add new functionality to it.
c) Side by Side your integration code should go on, i.e think about how you will integrate with you add i.e creating MSI, installers etc...

If you write code this way, there are more chances of finding the edge cases and your code will be more solid. Always implement small components i.e small projects and then integrate with the main application.

Don't code the whole thing in one shot, Very important concept to remember.

When designing api's, try to separate out the common things from the things that differ. Designing good api is a very important thing in software developers life (atleast for me it is the single most important thing) .

If you follow this, your code will definitely be more solid and testable.

These are some of the points I learned from my Manager here in Redmond, WA.

Update:

Before writing code two things to remember

1) Code should be as testable as possible.
2) Code should be reusable.

Consider each functionality as a seperate set of class.-- Always think how I can refactor this functionality into different set of classes. (Very important for good design.)

Happy Programming!!!

Yash

Wednesday, May 28, 2008

Hello There!!!

Hello Friends,

Its been a long time, I have not blogged. Lot of things happened during the last couple of months.

Most important was I left my Job at Telecom Industry to join one of the biggest companies in software development.

I loved my job back in Oklahoma but I had to make the tough decision as I am still learning lot of new things in software development and coming here in Seattle,WA was a very important decision in my life.

I believe that no decision is right or wrong. Everything depends on the how we look at it.

I struggled a lot here in Seattle initially, but now I have feel like I have come to terms with the new job.

Learning curve is huge. Lot of new ways of builing apps, writing apps among other things.

I miss my freinds in tulsa,OK but life goes on ...

Will be writing some new blogs about the things I learnt here in Seattle, WA.

Thanks,
Yash