Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Best way to group common functons in java

Posted on 2011-09-23
5
Medium Priority
?
175 Views
Last Modified: 2013-11-23
Could anybody suggest me a best way to group all common function's in a java project ?
0
Comment
Question by:manugeek
5 Comments
 
LVL 20

Expert Comment

by:a_b
ID: 36585467
Depends on what you mean by common functions.

If they are helper functions you can group them in a singleton utility class.

Else as per the object oriented programming guidelines you add associated functions to an object.
0
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 36585485
besides what @a_b has mentioned, if the methods are too similar, you can also refactor and combine then into one. If the difference is minor only, an if condition can be added for the same
0
 
LVL 13

Expert Comment

by:Hugh McCurdy
ID: 36597019
Perhaps some context would help.  Do you have some methods (functions) in mind?
0
 

Author Comment

by:manugeek
ID: 36597271
I am writing a testng program and would like to use the following methods fetch(), validate(), createReport() across my testng functions
0
 
LVL 20

Accepted Solution

by:
a_b earned 2000 total points
ID: 36597283
Does the class containing these methods have any state?

If not, then create a singleton test utility class and write those methods.
If yes, then you need to follow the OOPs concepts.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question