Tuesday, July 26, 2011

Top TEN Tips for code reusability, maintainability, and flexibility

Top TEN Tips for code reusability, maintainability, and flexibility

Writing a product is not an overnight job. It is the practice of implementing combination of the identified requirements in field and interest of field in future. Successfull product needs several processes, which are enforced from the one liner requirement to the completion of the product. The process are evolved and fine-tuned to improvise the quality and user experience. Product developers has to focus on the best practices in coding which avoid surprises in customer environment.

Development time – An individual has to love, to write more code. Optimization (Code coverage) time - An individual has to hate the code written already.

Reusability, Maintainability, and Flexibility are the major key factors to keep the product stable and long-lived.

  1. If happened to type same set of lines again , please move them to new method.

  2. If same set of lines exist already in a method, wanted to reuse it, please move that piece of code to new method. And , existing piece of lines has to be removed and new method has to be get called.

  3. If found new method may be used by other classes, and found as utility API, then it has to be moved to necessary class with 'public static' access.

  4. If Double quoted string needs to be used in the code and found it may be required to capture in other classes too, then create a class field(constant)with 'public static final' access. Where field name keeping in UPPERCASE would be good.

  5. Writing method with approx 1000 lines with hundreds of local variable , will perform slower than splitting into 10 to 15 methods with hundreds of local variable. In addition, it helps to improve the code readability and reusability. Methods needs to be very precise to do particular task as per name of the method. For instance, method name is purge(), then collecting or filtering purgeable data logic has to be placed in other methods. In this method, only purge logic such as API calls to purge or transaction API calls can be written.

  6. JUNIT testcases has to be added to test negative usecase where incorrect values for the argument get passed, and positive test has to be done by passing possible values. This helps to cover and confirm , possible values for the arguments. And, regression bugs will be avoided more than 99 percentage.

  7. In J2EE application, maintaining the actual business implementation away from the EJB methods would be good. EJB methods has to act like deligate method and calls the method which has actual implementation in other class. This business implementation may be reused in WS, JMS and/or other J2EE technology.

  8. In an application, a JAVA Class has to be introduced to keep only rt.jar based utilities ( public APIs). These APIs can be used by application , or developer for testing dirctly without associating any other jars from the dependency components.

  9. Utility methods needs to have JAVA Doc comments with @author . Whenever the method gets modified by other developer, it is easy to cross check with the developer.

  10. Dependency component's jar/classes has to be accessed through a single class(Wrapper around the component). If depedency component usage is more then a package can be introduced to deal with that component.


divyapriya said...

Great information you have been shared and it will be useful to everyone.
Spoken English Classes in Chennai
Best Spoken English Classes in Chennai
German Classes in Chennai
TOEFL Coaching in Chennai
IELTS Coaching in Chennai
spanish language in chennai
Spoken English Classes in OMR
Spoken English Classes in Porur

sheela rajesh said...

Thanks for your interesting ideas.the information's in this blog is very much useful
for me to improve my knowledge.
Python Training in Chennai
Python course in Chennai
Big data training in chennai
JAVA Training in Chennai
Selenium Training in Chennai
Python Training in Chennai
Python Course in Chennai

sultana said...

Thanks for sharing this valuable information to our vision. You have posted a worthy blog keep sharing.
Tally Course in Chennai
Tally Classes in Chennai
ui design course in chennai
CCNA Training in Chennai
ReactJS Training in Chennai
microsoft dynamics crm training in chennai
Tally Training in Chennai

velraj said...

This information is quite useful, I truly enjoyed. Thanks for this blog.
Appium Training in Chennai
Mobile Appium course in Chennai
Appium Training in T Nagar
JMeter Training in Chennai
learn JMeter
core java training in chennai
C C++ Training in Chennai
javascript training in chennai

kiruthika said...

Such an excellent and interesting blog, do post like this more with more information, this was very useful, Thank you.
best aviation academy in Chennai
air hostess training academy in Chennai
diploma in airport management in Chennai
Ground staff training in Chennai
Aviation Academy in Chennai
air hostess training in Chennai
airport management courses in Chennai
ground staff training in Chennai

Kerrthika K said...

It's a magnificent blog!thanks for sharing this information
film making courses in chennai
film courses in chennai
best film school in chennai
acting course in chennai
film editing course fees in chennai
film institute in chennai
part time film direction course in chennai

Anjali Siva said...

Such an amazing blog with new updates. I love to learn more about this topic. Waiting for more like this.
Microsoft Dynamics Training in Chennai
Microsoft Dynamics crm Training institutes in Chennai
Salesforce Training in Chennai
AngularJS Training in Chennai
Microsoft Dynamics crm Training in Velachery
Microsoft Dynamics crm Training in T Nagar
Microsoft Dynamics crm Training in OMR

Post a Comment

Recent Posts

Unix Commands | List all My Posts


This blog intended to share the knowledge and contribute to JAVA Community such a way that by providing samples and pointing right documents/webpages. We try to give our knowledege level best and no guarantee can be claimed on truth. Copyright and Terms of Policy refer blogspot.com