• Post Reply Bookmark Topic Watch Topic
  • New Topic

Object Oriented Design / Program Examples  RSS feed

 
Greg Hatt
Greenhorn
Posts: 14
Java Linux Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Learning Java has been coming along quite nicely, I've mostly been working through Big Java: Early Objects and Core Java: Volume One. What I've found both these texts lack is enough examples of complete programs demonstrating good OOP design.

To get to my question: I was wondering if anyone had any suggestions for a site/place to find code examples of good object oriented design for a beginning programmer. An example might be a chess program with a GUI. To put it another way, as a beginning programmer I'm looking to read more code but I'm struggling to find a good resource for example programs. Any suggestions would be greatly appreciated.

- Greg
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg Hatt wrote:An example might be a chess program with a GUI...

It might; but it'd almost certainly be a mistake. A chess program (even a simple robot that simply "adjudicates" moves made by external players) is a fabulously complex problem; and definitely not one I'd give to a beginner. And GUIs are also very involved (at least to get right they are), and require a LOT of code - usually far more than any normal program.

To put it another way, as a beginning programmer I'm looking to read more code but I'm struggling to find a good resource for example programs. Any suggestions would be greatly appreciated.

Unfortunately, it depends entirely on your background. Are you a beginner to programming in general, or just to Java?

If the first, then my advice would be to read the tutorials and do ALL the exercises; and at the same time try to find examples that fit your level (or, ideally, just a bit ahead), so that you can see how other people solve similar problems. That'll allow you to learn incrementally, without getting too frustrated. Simple example: If you want a game to have a crack at, why not try Mastermind before you tackle chess?

If the latter (I'd been programming for 25 years when I was introduced to Java), then one of the first things is probably to learn how Java does things differently from what you're used to. And (unfortunately) that requires a bit of humility - something we programmers aren't renowned for .
If you go into the process with the mindset that you're going to bitch and moan about "why Java does it this way, when C, or C++, or Python does it so much better", then you're likely to be disappointed. If, on the other hand, you accept that it's just another language, and try to understand why it does things differently, you may be pleasantly surprised.

Either way (and this is a purely a personal opinion): Steer clear of GUIs until you're pretty proficient at solving problems. GUIs may "look nice", but they're a major PITA to write (and, as I said earlier, to get right). About the best analogy I can come up with is this:
If you were studying the law, would you also want to be studying it in German ... or Pharsee?

Learn the basics first. Then learn how GUIs work.

HIH

Winston
 
Greg Hatt
Greenhorn
Posts: 14
Java Linux Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's actually really excellent advice, thanks. By "The Tutorials" I assume you mean the Java tutorials found at http://docs.oracle.com/javase/tutorial/ ?

I'm certainly not in the "been programming for twenty-five years" category by any means. I'm a student who just finished his first year of studies and has a bit off time during the summer to study. The books I mentioned above are fantastic at demonstrating different concepts but fail to present many fully formed programs. I'll have a look at the tutorials and see if the satisfy my need.

What I'm NOT looking for is simple one method programs whose sole purpose it is to demonstrate a single concept; my books have plenty of those. Like I said, I'll have a look through those tutorials.

Thanks again,

- Greg
 
Rico Felix
Ranch Hand
Posts: 411
5
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you like you can download and browse my source code for the first complex GUI application that I hand coded when I began learning Java... Its a simple database application which mimics the look and feel of a shell window...

Since this was my first GUI app that actually does something, you shouldn't have any problems comprehending its design...
 
Greg Hatt
Greenhorn
Posts: 14
Java Linux Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My mention of a GUI chess program was probably a bit misleading; it just came to me as an example of a program that would implement OOP concepts in constructing the different elements of the game (board, piece(s), etc). I was more or less just looking for general examples of what people consider to be model OOP designs so I could see some of the decisions people made in designing their objects.

Also, Winston, is the above link the one you were thinking of?

- Greg
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg Hatt wrote:Also, Winston, is the above link the one you were thinking of?

Pretty much. The stuff you're likely to want to begin with is under the "Trails Covering the Basics" section.

Sorry. I had a much more comprehensive reply to this question, but don't know where it's gone. Probably hit the wrong key when I meant "Submit". If you have any other questions, please feel free to ask.

Winston
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!