I'm very new to OOP and am trying my hardest to keep things strictly class based, while using good coding principles.
I'm a fair ways into my project now and I have a lot of general use methods I want to put into an utilities class. Is there a best way to create a utilities class?
public class Utilities
{
int test;
public Utilities()
{
}
public int sum(int number1, int number2)
{
test = number1 + number2;
}
return test;
}
After creating this Utilities class, do I just create an Utilities object, and run the methods of my choosing? Do I have this Utilities class idea correct?
You will be better off using a
static
class withstatic
methods. Then you won't need to instantiate your utilities class to use it. It will look something like this:Then you can use it like this: