Okay frnds, I'm almost a beginner in coding. And I've taken up this new project. I need to know if my thought process on the project is correct or not.
Objective: Create a Dynamic Web Project with JSP pages oon the front.
There is a Welcome page, which has AddEntry and ViewEntry options.
AddEntry asks you to enter a username. When you click submit, this entry is saved alongwith a random generated number in a hashmap. Now, I've still not decided whether to store it in a text file or use hibernate. Then there is a usual ThankYOu page which redirects to the first page.
The ViewEntry page asks you the userName and displays the username alongwith that random number which was generated. Then the same ThankYou page and stuff.
So, I've created the JSP pages and the struts.xml file.
Now I think I need to go create the POJO required, the validation file, and the mapping file and then integrate them somehow.
I'm ready to work on this, but I need to know how should I proceed in this situation.
Please don't give me any code. I want to write it myself.
posted 6 years ago
Make a user class with attributes userName and gender.
Make the user enter that username and gender on the jsp. Retreive it to your class of user.
Randomly generate a number and put it alongwith the hashMap.
Convert that hashmap to a list
Store the hashMap in the database, or a text file. I prefer text file.
The jsp page will give you the username to be shown. Now retreive that username from the database alongwith the list associated with it.
Display the list on the jsp page.
The displayed will contain a username, gender and the randomly generated number.
Fame Devon wrote:...AddEntry asks you to enter a username. When you click submit, this entry is saved alongwith a random generated number in a hashmap. Now, I've still not decided whether to store it in a text file or use hibernate...
I'm not a great expert on webby stuff, so this is more of a piece of general advice:
You're still at the design stage, yet your description suggests that you're already thinking about implementation.
The giveaway is in phrases like "JSP", "HashMap", "random generated number" and "Hibernate". These are all decisions about how you're going to accomplish your task.
Worry first about what you're going to do, NOT how you're going to do it. It's quite difficult, because a lot of that "how" stuff is probably buzzing around in your head, but resist the urge to cast it in stone.
Describe, in detail, WHAT your app is is going to do. One of the products of a description like that might be a list of functions, eg:
addNewUser which you can even turn into Java-style method stubs, eg:
public User addNewUser(String name, Date dateOfBirth, String passWord); but don't worry about coding them - at least not yet. There'll be plenty of time for that later on.
The idea is to postpone decisions about implementation for as long a possible. Obviously, you'll have to do it eventually, but tying yourself into an implementation too early is a sure-fire way to code re-writes.
One of my favourite quotes from the second book I ever read about Object-Orientation:
Lucius Cary, 2nd Viscount Falkland, wrote:When it is not necessary to make a decision, it is necessary not to make a decision.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here