• Post Reply Bookmark Topic Watch Topic
  • New Topic

Head First Headache (Not a complaint, loving the book).  RSS feed

 
Matthew Taheri
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all,

First, I'd like to say thank you for allowing me to be part of the community.

I scanned through the forums and didn't see this being addressed so I was hoping you all might be able to offer some non-technical device.

I've just reached the same program (GuessingGame) located on page 39 of the 2nd edition and...ouch.

I'm a very low level programmer and my only experience has been a bit Python. I'm just starting to delve into OO and this was the book I picked.

After all that explanation, the question: At this stage in the book (2nd chapter), am I supposed to understand this program? It's explained as being low level and clunky, but after reviewing it and repeatedly typing it for a few HOURS, it seems brilliant and out of reach to me. The associations and relations between the different classes and objects isn't explained at this point and it blows my mind a bit.

Mainly, I'm just concerned that the rest of the book wont address this and I'll be left to time wasting confusion in every chapter.

Any input is more than welcome.
 
Stephen Day
Greenhorn
Posts: 4
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello! I am currently working through the same book myself. I have previous experience developing in other languages so I haven't encountered this issue, but would love to try and help you out. What specific questions do you have? What parts of it are you struggling with understanding?
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Agree with SD; which parts can't you understand?
 
Scott Winterbourne
Ranch Hand
Posts: 116
2
Eclipse IDE Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I worked through this book a few years ago so I don't remember the specific program.

At the time I had some programming experience but was still pretty new to OOP. I do remember being a little confused early on. When I get home tonight I will dig out the book and take a look at the example in the book again. If there are specific parts of the code that confuse you, please post examples of the code and your questions and we can talk you through them.
 
Matthew Taheri
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for all the offers of assistance.

My problem isn't with one segment of the code. I just have trouble finding the interaction of the objects and how they are defined. Maybe it has to do with the bulk of the program being presented before the main and object classes. Basically, I'm having trouble "drawing the line" between the object defined in a class and i t being called within the bulk of the program.

For example:

p1 = new Player()
(Player being a seperate class).

Then there's ammendments to p1. I imagine that this creates an "instance" of the player object and then modifies it. I think I understand that pretty well now but that came after reviewing the code for a long time.

The prog later goes on to call the math.Random() * 10 line. I image this invokes a public math class and draws on it's random function, and then defines it to between 0-9, but again, this came after an hour of interpretation.

None of this has been explained or laid out in any way previous to the code example. My big question is: Will it be at some point or is it assumed I already know these things. If the former, no problem; if the latter...I might need supplemental education. I'm hoping it's the former as I already own this book and like the way it's written.
 
Scott Winterbourne
Ranch Hand
Posts: 116
2
Eclipse IDE Java PHP
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The example they show in page 39 is a bit more complex than anything else they have shown in Chapter 2.

The main take away for this chapter is really the example on page 36. How to create a class, then instantiate that class into an object (Dog d = new Dog();) and then use that Dog reference "d" to modify and interact with that new Dog object you created.

They haven't covered any of the build in Java packages and classes yet including the Math class. I think they'll get into those more later. They're just using it to show an example of how to use your own classes/object.

What they've done in the example on page 39 is instead of running all of the game code right in the main() method, they have moved it all into the startGame() method in the GuessGame class. They needed to show how that class is defined before showing how to call it in the main method. Here, the main() method is just the entry point of the application and it just passes execution to the GuessGame class to run the whole program.

Bottom line, if you don't understand every line of the example on page 39 I don't think you should worry. I think you can safely move on to the next chapter and then come back to this example a little later and it will start making more sense.

Also by copying and running this program yourself on your computer might help you to walk through it and understand it a little better to see how it reacts and executes. change some of the lines of code and see how the output changes.
 
Matthew Taheri
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scott: That's exactly what I was hoping to hear. Thank you.

Also, I took your suggestion at some point last night and it did help. But it was sort of putting together a sentence with excellent grammatical structure without knowing the meaning of the words. Glad to hear I'll get to the dictionary later.
 
Matthew Taheri
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Man...wasted a lot of time worrying. I'm cranking through Chapter 3 and it pretty much answers all the questions. Glad I didn't put this on pause while looking for another book.
 
Scott Winterbourne
Ranch Hand
Posts: 116
2
Eclipse IDE Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great! I'm so glad you are moving right along now and finding the answers you were looking for.

I know many people that have had success with this book including myself so stick with it. There are many other books to add after this one to augment your knowledge but stick with this one to the end first.

Just my thoughts.
 
Matthew Taheri
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the input.

Hopefully I'll be back here for a list of the rest sooner rather than later.

I need to get out of helpdesk before I let the job leech away whatever creativity remains.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!