I am developing a Java application that manages a bank loan database. I have some experience in application development, and I have a question that might be silly, but this is what I always talk about, since I learn languages ββand never received an answer to the pipeline.
In my program, I have many classes and methods that I use as common tools. For example, I have a class for writing to Excel, a class for reading / writing files, a class that manipulates strings differently, a class for displaying Dialogs / Messages in my default format, a class for certain mathematical functions (e.g. Math) and etc.
I cannot imagine these classes as real things (e.g. classes / objects), but they come to my mind as toolbars. That is why I make them static. So I write, for example,
excelWriter.create("C:\temp.xls"); excelWriter.append("mydata1\tmydata2\nmydata3\tmydata4"); excelWriter.close();
but not
ExcelWriter myExcelWriter; myExcelWriter.create("C:\temp.xls"); myExcelWriter.append("mydata1\tmydata2\nmydata3\tmydata4"); myExcelWriter.close();
This suits me better for the reason that I think of the toolbox as something that is always there for me, and I donβt need to create an object every time I want to use it. Isn't C ++ Math the same case and statics too? I discussed this with many of my colleagues and fellow coders, and most of them say that I need to create an object because it is object oriented programming.
I understand what they said in a different context: In my free time, I developed a card game using VB.net. There I had classes for the game, player, deck, hands. The objects that I did where a lot of each class, because I have a lot of games, players, decks, hands. And they can be imagined as real things. This is especially different if you are developing a game. Development of the game is much oriented to objects, because it contains the real thing.
I was wondering, am I somehow terribly wrong here? I would like to hear opponents about what oop is. I would also like to know for what static classes.
thanks