2 questions about GUI and one for my curiousity(multi thread)
hi I am still pretty new to java and im trying out making a GUI for my program. so i was wondering is it better to start the program making the GUI and add the rest with it as the GUI comes together? or is it easier to write the program for command line and then add in a GUI?
this one is for my curiousity...when would a program benefit from being multithreaded? small programs that dont do much i guess wouldnt matter but when does it become beneficial to have it multi threaded?
sorry for all the questions lately i hope when i learn a bunch more i can contribute some help to everyone else too :D thanks for any info you can give me
Re: 2 questions about GUI and one for my curiousity(multi thread)
Question 1: In my opinion it's best to write the logic, algorithms, etc...(in other words the model) completely separate from any user interface, and later plug into said model with other components - be it command line, swing, web, or whatever. This is the basics of the MVC (model, view controller) design pattern, which facilitates code re-use, maintenance, and a whole slew of other things. Of course this all depends upon what you are doing.
Question 2: Multithreading allows parallel tasking. Take for instance a user interface, if the program needs to perform a long task the user interface may lock up while the task is being performed, so placing the long task into a thread will prevent this from happening. Another case might be a server handling requests from clients - doing so in multiple threads to handle each request.
Re: 2 questions about GUI and one for my curiousity(multi thread)
wow as always an excellent answer :D thanks very very much