Naveen's Weblog

Bridge to future

Archive for the ‘Solutions’ Category

Here you will find solutions for some of the common errors.

Sensible coding part I – Howz your product???

Posted by codingsense on March 26, 2014

After few years of experiencing development in various projects and technologies, I started to think of reflecting my past on what went right and what went wrong in terms of development for self appraisal.

While analyzing I found couple of common things that happens in a life time of a product and people working on it.

Kick off a project – Happy birthday to our new project (Year 0):
Product is getting born, very much in versatile state. Lets name it Mr Perfect. Management bless Mr Perfect to be built with world class code and can sustain any changes in the requirement and will live long and long with good health and bring a very good name to the company.
Best competent people are selected for the team. Everyone in the team are excited about the new deliverable that are planned, we can see the excitement and energy in the team. All are busy in learning a new technology or new version of technology, people come up with different approaches for any given problem. Working with such team seems wonderful.

First release of Mr Perfect (Year 1):
Product has survived the first release and any changes or bug fixes have not effected it. People start working on new requirements and changes that comes from the filed users very positively.

Second release of Mr Perfect (Year 2):
Lots of changes and bug fixes were done, new and new features are getting pushed into the product. Deadlines are short, managers ask for quicker deliveries, customer asks for quicker fixes. People start to doing hard work and ignore smart work to achieve the goals.

Third release of Mr Perfect (Year 3):
The product has grown big with more than half million lines of code. People have created a mindset on which feature is good and which feature is bad ( few techies call it legacy code 🙂 ). The feature that are labelled legacy, is creating panic in the people who are associated with it. If there is any bug raised in it, they start to panic and get frustrated sometimes.

Fourth release of Mr Perfect (Year 4):
Our marketing and requirement guys go to customer to check how do they feel about the product and what else they need. They come up with a big list of new features, scrap some features and list of customer complaints on improper support.
Development team is unable to digest the changes, they start looking for workarounds, hiding some features, implementing new features.

BOOOOMMMMMMMM!!!!

What are the probable outcomes?? any guesses??
Check which all of the below listed would be true.

  • A bug fix in one module, starts creating impact on some other module.
  • The code is hard to understand, very fragile and not versatile.
  • Duplicate code is introduced everywhere, any fixes at one place should be fixed everywhere.
  • Performance of the product is very low.
  • Loads of memory leaks results in slow performance and crashes the tool often.
  • Removing a feature is not easy since some of its classes is used by many of them.
  • Development team asks for much higher estimations to achieve even a small change.
  • Bugs reported in critical features (Legacy code) are ignored and delayed as much as possible.
  • Quality team raises non compliance on some features with more bugs.
  • Managers are worried about their competent team.
  • Development team suggests lets refactor the features or build a new product.

Blah Blah Blah..

Guess what would happen to such Mr Perfect product or the customers who rely on them?

Has anyone seen these problems in the product?? What went wrong suddenly just last year everything was fine?? Is there any solution for this??

Let me know your comments if you have seen such issues or are living with it or overcame it.
hmm I bet there has to be some solution for such 🙂

Next >> Sensible Code part-ii What is software quality?

Happy Learning 🙂

Posted in C#, Codingsense, Solutions | Tagged: , | Leave a Comment »

Why and how use comments effectively

Posted by codingsense on May 22, 2010

A code is said to be good by the quality of comments it contains. A code with good quality of comments will save a lot of time and help to understand the code quick and better and while maintaining software and avoid regression bugs. Many products and companies do not strictly follow writing of comments in the product. So if your product has no comments or little then start writing the proper comments.

We should have Comments for

  1. Classes
    • What does the class do?
    • Which other classes are used by it?
  2. Methods
    • What does the method do?
    • What are the inputs and return type?
    • What changes to the system is done by that method (if it is updating a database or xml file or a static variable of some other class etc)
  3. Comment Complex lines
    • Emphasis more on why the below line is required than what the below line does (e.g. assume the scenario in which we are iterating a list and we are incrementing the List index by one, instead of writing the obvious “Increment the index by one” write “move to the next element in the list by incrementing the index by one”)
    • Write comments to only the lines which are not obvious. Comments will be required majorly for algorithms or if it’s changing the behavior of a system.
  4. Give appropriate names to variables and Methods
    • Giving proper names to variables and methods for what it does help to understand the obvious lines much better, avoid comments for such lines. Like if I have a variable named hasOperationFailed, by just looking it I can be sure that it’s a Boolean fields and while checking the conditions like If(hasOperationFailed) makes me understand what condition am I checking.
  5. Read the comment twice after writing
    • This may seem to waste time but trust me, after reading the written comment again we tend to re write the lines many times. Since the value of comments can only be said by the reader who uses it. So if the lines are simple to understand and appropriate then your efforts will be considered.

There are software’s that fetches the comments from your code and gives the output in different formats so that you can verify your comments and it can be used as a guide for what your classes and methods does.
Here are the list of some

Other references:
http://www.codeproject.com/KB/XML/csharpcodedocumentation.aspx?msg=1679454

Happy learning,
Codingsense 🙂

Posted in Solutions | Tagged: | 1 Comment »

Steps to improve maintainability of your code

Posted by codingsense on May 13, 2010

Hi,

I have seen people always telling that maintaining a product is harder. All people want to go into the product or module where its building from the scratch and pass the older code to our juniors. Why?? Is it that we want to learn new things or we don’t want to waste time in the product where we have put lots of effort to ruin it or are we afraid??

Is there any easy way to convert bad code to good code. Its not like moving a magic wand and all code is straight. First of all we should accept that its our mistake, unless we accept our mistake we keep giving hundreds of reasons to run away from it. We should have interest in making it good, plan properly and execute with determination. Here’s my story wherein I have gone through phases from good to bad and bad to good.

Two years back in Feb 2008 I started a product and was playing a role of tech lead. There were lots of eyes and concerns on that product that it will be a game changer for our company. There was a long list of feature given by our functional team, plan to combine 2 existing product functionality into one, easy navigation, and the old saying was repeated “URGENT REQUIREMENT” we were given 1 year for the first product release. So it began, planning of modules, prioritizing the features, coding standards was revisited, right features were assigned to right persons etc etc. Full team was motivated to work in the upcoming successful product.

Days passed… somewhere after 6 months an internal release was planned for the functional team and for the stakeholders. Great all were happy, I and my team got many awards, good recognition in the company and got some suggestions (also known as changes) in the software. All changes were incorporated successfully with the new features parallel development.

All was going great, until after some 5 months (1 month left for delivery) some expert gave (very late) a very good suggestion to the management for future perspective. When we received the document of changes they were huge, major changes had to be done in many of the key classes. All teammates were sort of disappointed that their feature which was done with lot of hard work and interest would be corrupted. They started blaming the management, for such changes. But all cooperated since we were the experts and it would be shame to go against the changes expected.

Now started the actual impact, changes were planned, one change would affects other flow, dependency between the classes was more, poor commented code, testers started doing stress testing on the bug tracking tool by putting more and more bugs in it.All team was under stress, daily pig meetings were started to know the status. Day by day the deadlines were nearing and the features and bugs were poured more on us.

Finally we ended up not giving the full product in the expected deadline. The days of the awards and recognition were gone. For next week I and some senior members were very busy in answering what went wrong and why we dint reach the target. Since there was intense pressure from the marketing team the product was shipped to the customers who were waiting for it. There were still more changes pitching in and we were very much tensed how to incorporate those without creating regression bugs in our product. Many bugs were reported by the customer and fixing them was a huge task for us.

On one evening was not feeling to go home so stayed till night I thougth that I and my team were responsible for the bad code and we are the one going to fix those and show our potential. I started recollecting all the mistakes that were done by me and my team and started documenting it, further found some tips across the web and added those. After analyzing the entire problem I found angle of deviation that we had been from our actual goal and plans and listed all the faults that we had done. Made up my mind to speak to the management in the early morning regarding it and get some time to refactor and restructure the code. The following steps were planned to be executed with intense care.

  • Put proper comments
  • Fix coding standards and project conventions
  • Remove unnecessary code
  • Identifying and breaking up big classes
  • Breaking up big methods
  • Refactor existing code
  • Remove memory leaks
  • Restructuring
  • Write automated unit tests

After following each step properly with collecting the daily status from the team, sharing the problems and discussing some new solutions, finally it took around 7 months to complete the product.
Even though we were late by 8 months we had reached the goal properly and were ready to accept any further changes. From last year the product was sent to the market and there was very good response from our customers and the days of awards had begun again.
From next posts I am planning to go in depth of execution of each of the steps followed.

For any clarification please revert back.

Happy Coding
Naveen Prabhu 🙂

Posted in C#, Solutions | Tagged: , , | Leave a Comment »

An attempt to attach an auto-named database for file xxxx.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

Posted by codingsense on October 20, 2009


I got this error while opening a connection. So i googled for the solution and found that some changes are to be done in config file. But nothing happened after changing it as mentioned.

Then i noticed the error correctly and it was pointing correct MDF file but the path was wrong. Eventhough it was correctly mentioned in Config file.

Solution :
So i went to Properties folder -> Settings.Settings and saw that the connection string was not refreshed in it. Then i manually changed it to point to proper location of MDF file and all went right.

Thanks
Naveen Prabhu

Posted in Solutions | Tagged: | 7 Comments »

Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.

Posted by codingsense on June 25, 2009


Problem :
When we open any dot net exe we can find this error.

Solutions :

There are many possible solutions for the same error arising from different conditions. My problem was solved with the first solution, if still your problem exist check other possible conditions too.

Thanks,
Naveen Prabhu

Posted in Solutions | Tagged: | Leave a Comment »

.Net Framework Initialization error

Posted by codingsense on February 24, 2009

Problem :

When .Net exe opens the following message is thrown.
“.Net Framework Initialization error. Unable to find the version of the runtime to run this application”

Solutions:

1) Check if .Net is installed with laterst service pack available.

2) Copy the exe and the dll that are referenced in the exe, from a system in which your application is working fine, and replace in the system in which this problem is found.

3) Reinstall latest version of .net. While reInstalling turn off antivirus programs.

4) If any other version of .net is installed in the machine, remove the version and try.

for me each of these solutions worked at different places, try all.

Posted in Solutions | Tagged: | 2 Comments »

.Net Problem in 64 Bit OS

Posted by codingsense on February 6, 2009

Problem :

We may get a problem with .Net exe in 64 Bit OS, it runs properly in 32 Bit OS but will not open or throw some exception when opened in 64 bit OS.

Solution :

The target platform for the project has to be set to x86 and built.

The settings can be found at Right click on project in solution explorer -> Porperties -> build -> Platform Target -> Select x86

Build the exe and check, it would work fine.

Posted in Solutions | Tagged: | Leave a Comment »