Solved

Best way to group common functons in java

Posted on 2011-09-23
5
167 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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
expectj telnet failing 5 49
runtime exception 2 50
Delete Android all or certain applications data programmatically 9 106
Java syntax, or is it Selenium 6 37
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

685 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