I am learning java these days for a project and found this forum to be really helpful for clearing lots of beginners doubts. Thanks to all the moderators here.
Ok. So, I am using Netbeans for my project, I have to create an application where I have to search some texts in a .txt file and replace it with something else from another file(database).
To get started, I have created a form where I could browse for the file and to select it. Now I have the file path of the .txt file in a Textfield in this form.
I have inserted another button. Now, I have another button which does all the searching and automatically replace the text.
So, my question is, is it advsible to create a new class for this entire search and replace algorithm and call it in the event or just write down all the codes in the action performed area of the corresponding button.
Please advise. also when I tried to do that, I get some error and it showed some clue that I could use EXception. So what exactly is this exception. I have seen in some codes about Exception. (Is it something to avoid errors? )
Expecting a reply soon. Thanks
Write it elsewhere.
In general your GUI classes should just deal with displaying stuff.
Any events that involve "business logic" (ie dealing with data) should be done as a separate layer, written with no thought to the GUI layer. That is, this layer could be picked up and moved to a completely different architecture. A side effect of this is that you can then test this code entirely separately from your GUI code to ensure it is working correctly.