Saturday, April 12, 2008

To create or to inherit 1

Don't read this if you are not software developer., is boring

Programming is an art, like writing a novel or drawing a picture. You need creativity, but to create is difficult, so sometimes look at other developer's code, will improve your programming skills. Is nothing wrong to borrow some ideas from other software developers, just avoid copyright infringement.

Most software developers that I know, especially talented software developers with strong programming skills, hate to maintain or make improvement on other software developers' work. They always think that create their own code and program is easier that maintain and make improvement over others' code.

Create is more easy? How can it be? One of the main problem with today's software developer is, the codes are very badly written, and there is no developer guide documentation (so how do I start?). Sometimes I don't even find one line of comment in the code, and no proper indent for code block (eg. code in if (condition) { } block are not inline).

If you examine other programmer's coding, there are signatures inside the program. Everyone have their own style of coding.

An easy and simple example of coding style is, how you place your parenthesis ( '{' and '}' ) for condition block?

1.
if (condition)
{
    statement 1;
}

2.
if (condition)
    {
    statement 1;
    }

3.
if (condition) {
    statement ;
    }


There are more examples... and you can name it.

Which style do you prefer? Your style of coding will be your signature in the program even without putting your name in. So learn other programmers coding style, use it within the same program, so the program code looks consistent.

Another example of coding style is how you name the variable and functions. Like user_name, UserName, or userName? Normally naming convention will be stated in the developer guide. Some programming language will have their prefer way for naming convention, like Java's function and variable name always start with a capital letter for each word, except the first starting alphabet (eg. userName).

To maintain the original coding style, you have to make it look consistent, this is another difficulty to continue others work, or else the next developer after you, will drop all your hard work and create their own program as a start.

Netscape navigator codes are difficult to maintain, that's why there is a lot of bugs and problem after version 4. Netscape 5.0 has never been released, it was scraped and rewritten as Netscape 6, but a lot of users started to switch to IE browser during that time.

To create or just continue with existing code (in software development), both is not easy. To avoid the hard work source code scrap in the future, a good software developer should know how to create, to continue, and write code which is easy to be maintained.

No comments: