EiD recipe special : few conventions and best practice for software developer

i just gathered a few of my known conventions and best practices. i belief this will help many of us.

few of my previously written posts –
usages of “final” keyword in java –

usages of comment and coding

let’s check out my recipes –

1. code from your peer developer perspective view.
while you writing your code, always think your code will be reviewed by some other developers, who is not like you,
who is very serious in simple fault and ignorance in writing code. your code will reflect who you are, so better be careful while you exposing yourselves (through writing code).

2. variable convention –
never write short variable name, always write variable which reflects it usages.
for example –

$user = new User() instead of $u = new User(). follow same convention when you have nested “loop”

3. source file naming convention (except java)
set your file name in such a way that will reflect the usages of the file.
for example –

verify_user_authentication.php (or in a packaging manner – user_util_verify_authentication.php). in java you better know how to write package.

4. keep your url domain centric

all urls should be inherited by some specific problem domain for example –


here “user” is problem domain and “login|register|update” are actions or you could say problem.

5. method naming convention –
write method name in such a format that will reflect it usages. or simply make it self describing.
for example –

function verify_user_credentials() {}
def verify_whether_user_profile_is_complete() {}
private void checkUserFlyLimit() {}

6. don’t write query from controller:
build or execute query from DAO or helper or utility or domain itself. don’t put it over controller which limits the reuability and later extendability and interception

7. single concern
while coding, keep your method slim and less concerned about other implementation. for example –

private void isAuthorizedUser(pUser, pAction) {
if (userAlreadyLoggedOn(pUser) && userIsNotBlocked(pUser) && userHasPermission(pUser, pAction)) {
// boooooooooooooooomm…

8. think from testability
while writing your code always think from testable perspective view. this means, how you could testify your work or module
or bunch of code which your company is paying for.

9. follow coding norms –
i. think before coding

whatever you want to put on your code try to think or imagine before start coding.

ii. dump your think in comment

whatever you thought just write it down over comment or paper or in a common place where you or future developers could have look on. (better place in comment)

iii. write your algorithm in comment.

whatever you planned write in comment before kick start your coding.

iv. set up your unit test case.

find all probable assertion points from use case, put them over your unit test case.

v. write your code
vi. coding routine –

(1) test -> (2) code – go to > (1) [recursively]

10. always put your tag over the source file,
whatever you wrote, that reflects your confident and work efficiency, so better you tag your name over every source code you have written or modified. good for tech lead or project manager, because tagging each file with author name, it creates a hidden responsibility for the author 🙂 good for both parties.
for example –

* @author someone


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

my tweets

October 2007
« Sep   Nov »

Flickr Photos

RSS my shared links on google reader

  • An error has occurred; the feed is probably down. Try again later.
%d bloggers like this: