0

I am developing an Android unit conversion and calculator application in which I have a 3 fragment ViewPager set up and was wondering what would be the best OOP design practice when attempting to use methods over many fragments. Should I set up a centralized calculate method and call it within each fragment?

I currently have each fragment isolated with their calculations, spinner values, and intermediary values. I am also sending a result of a calculation from a fragment back to another fragment through an intent on the Main Activity.

My code currently works, but as I am learning more Java I would like to start piecing together best design practices and efficient code. Thanks for any insight!

getsilly13
  • 25
  • 7
  • I would suggest creating a Utility class, but be careful that you don't needlessly throw all your methods in it. Read over this Q/A http://stackoverflow.com/questions/3340032/utility-classes-are-evil – anthonycr Jul 23 '14 at 14:45
  • Thanks for the link. I will thoroughly read it! – getsilly13 Jul 23 '14 at 14:54

1 Answers1

0

If possible, i'd write something like CalculationUtils.java and define every common method inside, as public static, and later call them with CalculationUtils.method1(...)

Sherekan
  • 536
  • 3
  • 14