I have a question here.
I learned java,and i want to know what is the good practice for me to produce neat and easy understand coding with UML diagram
I want to create an complete GUI that can used in my real life.
Here got the condition that im confused now:
First:
If im using file/database, I create a few GUI for my apps,in the apps ,it do let users to carry out some process that will insert data into my file/database. In this case, i dont create any object class. Example,i want to insert Food data into my file/database,i dont create object(or can say i dont even create Food.java) ,i directly getText from the textfield from the GUI and insert into my file/database. It do works and less work needed,right?
Second:
If im using file/database, I create a few GUI for my apps,in the apps ,it do let users to carry out some process that will insert data into my file/database.However, in this case, i create object class first, Like example, i create Food.java and in the same momment, i create Food object when the users insert data at my GUI. It actually store in Vector<Food> and,after that ,i get the vector then only store the data into the file/database. I guess this case do more work and sound feel complicated..
So,im trying to get some feedback or advice that What should i do (procedure) that create a good coding practice software product.
*Addition*
Anyone here got source that can learn MySQL database with linking to GUI(program).I need some more advanced material/source(it can be book/ebook/online source) ,not just only connect to MySQL and the coding for get the data or insert the data. Intro to me if you got it ...And any GUI MySQL software can be used that i can used when im create/link my software Mysql...currently im using netbean,it something like,when i insert somedata,i can directly see/update through the software but not from the cmd(currently if i use MySQL ,i have to see my data in cmd >< )
One last thing is ,is that php and java can be related ? I can developed a software that using MySql and it is online based,just like my website is java based and i do my stuff inside the website and get data from the MySql server (this is the extra thing ,if you all know ,just give me this area of info,thanks)
Kindly explain more if you have more time =) Appreciated your help and feedback! Thanks you very muchie
4 replies to this topic
#1
Posted 09 September 2011 - 05:27 AM
|
|
|
#2
Posted 09 September 2011 - 07:19 AM
First:
Unfortunately, that ties your GUI directly to the database. Now you have to pollute your GUI class if you need to change it from connecting to Oracle to MySQL or event XML. This really isn't a good idea.
Second:
This is a much better option. Sure, it's more work up front, but now the GUI doesn't need to know how Food saves to the database. It doesn't even need to know when Food saves to the database, or even what it saves to/loads from. This also allows you to create a dummy Food object for unit testing of your GUI, and lets you have a dummy GUI to do unit testing on Food.
Addition:
You may want to start by grabbing SQuirreL SQL Client. It will let you connect to a MySQL database and experiment with SQL statements. You can also download the source code to see how it uses the MySQL JDBC driver.
Unfortunately, that ties your GUI directly to the database. Now you have to pollute your GUI class if you need to change it from connecting to Oracle to MySQL or event XML. This really isn't a good idea.
Second:
This is a much better option. Sure, it's more work up front, but now the GUI doesn't need to know how Food saves to the database. It doesn't even need to know when Food saves to the database, or even what it saves to/loads from. This also allows you to create a dummy Food object for unit testing of your GUI, and lets you have a dummy GUI to do unit testing on Food.
Addition:
You may want to start by grabbing SQuirreL SQL Client. It will let you connect to a MySQL database and experiment with SQL statements. You can also download the source code to see how it uses the MySQL JDBC driver.
#3
Posted 09 September 2011 - 07:43 AM
hi,thanks your reply....im not very understand about your second explaination...can you give some further explaination or realistic example for me?
thanks thanks..
thanks thanks..
#4
Posted 09 September 2011 - 08:02 AM
Think about it like this.
Suppose you have a single class: GUI.java. It is responsible for connecting to the database, doing validation logic, and displaying the interface to the user. How do you test the validation logic to ensure it works correctly? There's only one way: set up a database for the test, enter data in the GUI, and see what happens.
Now, split it up into three or more classes: GUI.java, DB.java, logic.java. Now, if you want to test the logic, you can have two new classes (GUI-test.java and DB-test.java) that can be used to emulate the classes logic.java normally interacts with. GUI-test can make the same calls GUI would make, but in an automated way. DB-test can provide the same data DB would provide, but in a controlled manner that is always the same. This way, you don't have to worry about a screwy database state or mistyping something in your GUI during the test.
Suppose you have a single class: GUI.java. It is responsible for connecting to the database, doing validation logic, and displaying the interface to the user. How do you test the validation logic to ensure it works correctly? There's only one way: set up a database for the test, enter data in the GUI, and see what happens.
Now, split it up into three or more classes: GUI.java, DB.java, logic.java. Now, if you want to test the logic, you can have two new classes (GUI-test.java and DB-test.java) that can be used to emulate the classes logic.java normally interacts with. GUI-test can make the same calls GUI would make, but in an automated way. DB-test can provide the same data DB would provide, but in a controlled manner that is always the same. This way, you don't have to worry about a screwy database state or mistyping something in your GUI during the test.
#5
Posted 09 September 2011 - 07:48 PM
ya,thats really clear about it =) thanks you very much...
I tested it out what you suggest SQuirreL..it was nice and easy plus there is help section tat something like tutorial..=)
do you have any addition source for learning advanced coding for database?
I tested it out what you suggest SQuirreL..it was nice and easy plus there is help section tat something like tutorial..=)
do you have any addition source for learning advanced coding for database?
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









