Archive for October 15th, 2007
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 -http://www.somewhereinblog.net/blog/hasan/28708715
usages of comment and coding
http://www.somewhereinblog.net/blog/hasan/28704020
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 -
http://abc.com/user/login
http://abc.com/user/register
http://abc.com/user/update
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
*/
JETTY RUNNER version 0.2
those who doesn’t know about JETTY RUNNER:
JETTY RUNNER is a standalone swing based application which is used to bundle java ee based application along with jetty container. it comes with simple web app configuration xml file and global properties manager through a simple properties file.
actually i have been using this project for my own development solution, so i belief this project will become a great strengthen feature gradually.
JETTY RUNNER is now running on max OSX, i have removed system try support in new tag v-0.2, soon i will release *.dmg package for mac osx. here are few screen snaps -

figure – 1: server console main window

figure – 2: global properties editor
change logs -
1. removed system tray support
2. removed default jmx configuration
3. added “start.sh” to launch JETTY RUNNER on *nix based platform where ruby script is installed.
here are few screen snaps, which i have taken from the newly added ruby script! -

figure – 3: newly added jetty runner on ruby

figure – 4: newly added jetty runner implementation in ruby
this script really great
, at least i like it




