Solved

Best way to group common functons in java

Posted on 2011-09-23
5
164 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:gurvinder372
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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

911 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now