Tech Students World
Subscribe
Subscribe to get the update Newsletters. This site is updated daily. Don't miss to check what's added.
                 Technology of the Week: iPod Basics *  Help of the Week: Blu-ray Technology
Skip Navigation Links
ContactUs
StudentsLibraryExpand StudentsLibrary
ExplanationOfTechnologiesExpand ExplanationOfTechnologies
TechEducationExpand TechEducation
TechTipsExpand TechTips
UsefulStudent ResourcesExpand UsefulStudent Resources
TodaySpecialsExpand TodaySpecials
WeekSpecialsExpand WeekSpecials
                                                    
Free Downloads Skip Navigation LinksHome > Developing Java Project
Skip Navigation Links
Home
Buying ComputersExpand Buying Computers
CertificationsExpand Certifications
Computer BasicsExpand Computer Basics
Computer DevicesExpand Computer Devices
Computer MaintenanceExpand Computer Maintenance
Computer SettingsExpand Computer Settings
Operating SystemsExpand Operating Systems
ProcessorsExpand Processors
Using MS-WindowsExpand Using MS-Windows
Internet BasicsExpand Internet Basics
Internet ServicesExpand Internet Services
Software AttacksExpand Software Attacks
Useful Links
New Student Resources
. Student Employment
. Cover Letter
. Applying for Graduate Assistantships
. SCJP Preparation
. Applying for US Universities

Developing a good Maintainable Project in Java

Question of the Week

What are the principles to be followed for developing a good maintainable project in an Object Oriented Programming language like Java?

Read this article if you have at least some experience as a Java programmer and knowledge of OOPs concepts. Try to follow these basic details while developing the project so that you can achieve good level of maintainability.

(1) Hide Implementation details

As Java is an object oriented programming language, it provides encapsulation. Always hide the implementation details by utilizing the encapsulation. Encapsulation hides the internal state of the object and performs all the interactions through methods. So, the internal implementation details will be safe from outside hackers.

(2) Don’t do much subclassing

It is always better not to subclass more than two to three levels deep. Only create a subclass if it is strongly necessary for adding important specific functionality in a separate class.

(3) Use local variables when possible rather than instance variables

When applicable, it is always better to make use of variables that have small scope like local variables declared in blocks, methods or loops.

(4) Initialize local variables

Local variables have to be assigned a value before they are used because local variables are not initialized automatically like the instance or static variables.

(5) Utilize Overloading

If two or more methods are doing the same job but have to handle different method arguments, assign the same name to all those methods but with unique method arguments.

(6) Don’t use too much arguments in a method

If the method is taking too much arguments then think of creating its own class with all that stuff.

(7) Utilize Interfaces

If you want to protect your code by showing only the definition to outside world and hiding the implementation details, make use of interfaces

(8) Only create an object when it is really necessary

Avoid creating objects thinking that they may come to use later in the code as this may lead to lag in the performance and unnecessary confusions.

(9) Manage objects

Always watch the objects you have created. If they are no longer useful, set them to null for better memory management and avoid confusion.

(10) Don’t nest if or if else blocks heavily

Always better to design and follow simple logics rather than using deeply nested blocks. Consider writing separate methods for inserting those logics.

                                        

(11) Use meaningful names

Always use meaningful names for variables, methods, classes, interfaces and Exceptions.

(12) Declare a method as static only if necessary

Using non-static methods is always better than using static methods as the non-static methods contain the knowledge of the current object. But if you want to know some things which are not object specific, then make use of static methods.

(13) Getters and Setters

Using getter and setter methods for accessing and setting the value of a property is a good standard.

(14) Make use of standard classes

Utilize the classes and code that are already in core Java APIs rather than writing your own code for the already existing ones. This will provide the opportunity for you to concentrate more on your business logic.

(15) Use Exceptions and be specific while throwing Exceptions

Go for exceptions options rather than error codes. Declare specific Exception types rather than the generic ones. Always provide useful messages while throwing Exceptions which will help for the users to easily fix the code. You can also create your own Exceptions according to your code if you can’t find the appropriate one in java.lang.

Good Luck with Java Project.

What's New
. Blu-ray
. iPod Basics
. Doing Java Project
. Symmetric MP
. Digital Cameras
. Virus,Spyware
. Sound to WebPage
. Wi-Fi
Popular Articles
. UNIX Commands
. Software Attacks
.
Adding RAM
. US Universities
. Free Java Tutorial
. Student Jobs
. Learn Spanish
. Java Notes
Let The World Know How Knowledgeable You Are
By sharing Your Knowledge With Others
If you would like to share your knowledge relating to Technology, you can send it to us at dailyquestion@techstudentsworld.com. If it is good, it will be published in this site along with your name or picture.
                  Copyright © 2008, Techstudentsworld.com. All Rights Reserved.