This week's book giveaway is in the Agile and Other Processes forum. We're giving away four copies of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java and have Dr. Raoul-Gabriel Urma & Richard Warburton on-line! See this thread for details.
I have a simple inventory program that I will be adding a GUI to for an online programming class. I don't want to start off on the wrong foot, so before I do that, I will ask. Should I implement a new class for my GUI and invoke my other methods from there, or should I modify my existing class to incorporate the GUI elements? My best guess is that I should implement a new class, but being a newbie, don't want to unnecessarily complicate my life. Thanks in advance for the help.
Anybody who worries about their classes getting complicated is on the right path . . . but we usually discuss GUIs on a different forum, so I shall move you there.
posted 10 years ago
I was hoping this would be easier, but it doesn't appear to be. I have been at this since 10 am... stopped to get food and bring it back to my isolated room, and went at it again. I have read a myriad of materials, tutorials and even tried my hand at some code, but keep ending up with the same problems. How do I connect the code I have with this GUI? Specifically the code in my main method from //print welcome statement to //end method main which needs to print in a GUI. No bells and whistles yet, just a display. I figured that my code in my main method needed to be more modularized, so I tried that for a few hours.. getting nowhere. I also tried just referencing some other methods and also got nowhere. It is now 8:30 at night and I am humbly asking for help (again). I would insert the banghead at this point, but I am too tired to do this.. I will just cry Below is what I have accomplished... please don't laugh I am totally new at this.
There is one more class of code, however I don't think it is relevant to this discussion so I won't bore you... Thanks in advance.... and thanks from my husband and children who are missing me and want me to come out of this room.... Only two more weeks of this class, then I will study this at a more reasonable pace! I like it, but really need more time to absorb the wealth of information necessary to code properly!
Hello Debra. Your current approach can be simplify so much in my opinion. Given you have your old non-GUI version working as it. Now the main program/class is the non-GUI version. You building the GUI class. So all you need to do is 1) duplicate the non-GUI main class as its separate class then 2) modify your main program to call either non-gui or gui.
And if you really want modularity and OO - look into class design (eg sharing methods and stuff), separate the common stuff to its own class and modify the non-gui and gui class accordingly.
K. Tsang CEng MBCS PMP PMI-ACP OCPJEA OCPJP
I'm sure glad that he's gone. Now I can read this tiny ad in peace!