Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Best way to group common functons in java

Posted on 2011-09-23
5
Medium Priority
?
172 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

705 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