views:

103

answers:

3

I'm fairly new to programming and new to java, but I'd like to jump in the deep end with a little database driven website project. I've read quite a lot about requirements in the 'real world' requesting experience with Spring and Hibernate, so I have those installed on netbeans and a project created (if I hit run I get the default spring page). Now I just need a little guidance as to where to start designing my app (please tell me if I'm getting in a bit too over my head for a beginner!).

Should I start off with my classes? - create all my classes as they map to my database tables and decide which attributes and methods each will require?

Can anyone suggest any good books for maybe.. making a java based website from scratch (i.e. from design right through to deployment) that might be useful for a beginner?

Any help appreciated thanks.

Edit: since posting this I've found a brilliant book that fits my needs just right to get started. Firstly I tried both spring in action and hibernate in action - but found both to be a bit too heavy for my novice mind. Instead I got the Java EE 5 Development with Netbeans 6 book https://www.packtpub.com/java-ee5-development-with-netbeans-6/book and its been a great help. If you use netbeans and are in a similar position to me, I'd say pick it up!

+2  A: 

Too over your head? Depends on what you hope to accomplish. Are you trying to create a revenue-generating site to which users will be asked to trust credit card numbers and other sensitive information? Then yeah, you're getting way ahead of yourself. Is this a tool for personal use or a toy you're throwing together primarily as a learning experience? Then I say "Pffffft!" to the notion of over-the-head-ness. Go for it.

As to where to start, I say start with whatever portion of this beast is clearest to you. Have a solid idea of what the database is going to look like? Then start with it and its supporting classes. Have a clear vision of what the guts of the code are supposed to do? Start there. Etc. And if all things are equal, I'd say start at the bottom with the database layer and work your way up -- but that's just me.

And as for the books, can't help you there, but I'm sure somebody can.

BlairHippo
Thanks for this - yeah its just a learning experience. I actually have a database already created. I've already created the site in php but its procedural and completely spaghetti-ish (first real code and website) so I'm hoping to learn some OOP concepts and get some Java website experience by rebuilding it with the tools described in my original post!
Craig Whitley
Hmm. If the database is set, then creating the classes that access it should be quite straightforward and is worth banging out early. After that, best move might be to try and write some classes that de-spaghettify your old logic. And are you familiar with the MVC (Model-View-Controller) approach to design? It's not an end-all be-all, but I've found it a very useful way to organize both my thinking and my code; worth investigating. Good luck, regardless.
BlairHippo
Yeah I've already been advised to use the MVC design to aid code organization - another big problem is my old code isnt in the least bit DRY. I'm wondering just how I'll keep this new code DRY whilst implementing the CRUD. Would I create a superclass with the basic CRUD functionality, and somehow pass the variables (table, field etc.) from the child to the parent to perform the CRUD - or would I write SQL queries in the methods of each class for their own specific use? Thanks for your replies - appreciate it!
Craig Whitley
The fact that you're asking about CRUD functionality means you need to spend some more time learning Hibernate/Spring and the Java Persistence API in general. :-) Coming from an Enterprise Java Beans model I found the JPA a little tricky to wrap my head around, but if you get it set up properly, it is freakin' SLICK. A whole lot of functionality gets handled automagically and cuts way down on the number of SQL queries you have to create yourself.
BlairHippo
Ahh true, I've tried ruby on rails - are the spring/hibernate etc. like that? Where you don't really code any SQL queries, you call helper methods which do the majority of that for you? I'm just reading the hibernate site now - I literally threw it all together in netbeans, now I need to work my way through it all (and a few books / tutorials) to see how it all works!
Craig Whitley
+1  A: 

I suggest to take a look at web application frameworks such as Spring's Roo or Grails. Sadly I have no experience with Roo. But I do have some experience with Grails.

With Grails you will be working mostly with Groovy, a language similar to Python, but still using the JVM. You'll still have the option to use Java anywhere you like (I think). Grails (and maybe Roo too?) manages Spring and Hibernate for you.

As for books on Grails, I recommend "Grails in Action". I have read a little of "Grails 1.1 Web Application Development" and it also seems to be a good reference. BTW, netbeans supports Grails too.

ric.v
+1 for ROO or Grails suggestion, I would have loved to have those kind of frameworks around when I started java web development.
HeDinges
Grails looks really interesting - will give this a look and grab the netbeans plugin. Thanks :)
Craig Whitley
A: 

Not trying to gut your goals, but if you are wondering whether to start with your classes, I would suggest you work on your programming skills more.

I'd suggest taking a look at Larman's "Applying UML & Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development (3rd Edition)" as well as a book on relational database theory (you need to know how to model databases properly.)

You can try your hand at building a database driven web app, and it might give you an insight into how to do it, but you need have some programming maturity to take those skills into the non-trivial.

This is a completely personal opinion so please take it with a grain of salt: Before someone tackles the building of a data-driven application with the purpose of eventually being able to use it in non-trivial projects, that person needs to have a good exposure to programming (by good I mean a LOT, say 1-2 introductory courses, 1-2 intermediate and at least one junior-level course, perhaps a total of 15-30 credits.) Unless that person is a natural programming virtuoso, I don't see it happening otherwise.

I would suggest, if you are serious about programming, to spend a substantial amount on learning the fundamentals before tackling something like this.

Good luck.

luis.espinal
Thanks for the reply - I actually designed the database first before delving into anything else. I designed it whilst reading the http://apress.com/book/view/9781590597699 - Beginning Database Design: From Novice to Professional book. It seems to 'work' to be fair, and the database programming tutorials I've watched since have made me feel quite vindicated over the way it was designed. I shall definitley check the suggested book though - I definitley need help knowing where exactly to start! I'm beginning a computing degree in sept - trying to get a foot forward beforehand :)
Craig Whitley
Also, as a mature student applying to university on the back on GCSE's (and a years psychology at uni) I actually want to create something fairly sound to show to the course leader when I meet up with him for a chat in a few weeks (which is another reason I want to re-write the whole spaghetti php site).
Craig Whitley
@Craig -- you seem to be going in the right direction then :) Best of lucks!
luis.espinal