Forums Register Login

Head First Java - Is over complicated bad?

+Pie Number of slices to send: Send
I just finished the 1st Chapter in Head First, but came to a different sollution to the PoolPuzzle. Mine is more complicated. Will this pose a problem as I, hopefully, delve deeping into Java? Examples:
Mine:

[code]

int x = 0;
while (x<4) { System.out.print("a");
if (x<1) {System.out.print(" ");}
x = x - 1;System.out.print("n");
if (x<0) {System.out.print("oise");
x = x + 1;}
if (x==1) {System.out.print("noys");}
if (x>1) {System.out.print(" oyster");}
System.out.println("");
x=x+2;
[//end code]

Head First:
[code]

int x = 0;
while (x<4) { System.out.print("a");
if (x<1) {System.out.print(" ");}
System.out.print("n");
if (x>1) {System.out.print(" oyster");
x = x + 2;}
if (x==1) {System.out.print("noys");}
if (x<1) {System.out.print("oise");}
System.out.println("");
x=x+1;
[//end code]

Thanks,
Charlie
[ April 29, 2008: Message edited by: Charlie Newman ]
+Pie Number of slices to send: Send
In general, if you can do things in a more simple way then that's better.

One of the difficult problems in software development is maintenance of the software. When you've done a project and built some software, then there will be programmers after you who will have to maintain the software - make some changes, fix bugs, add new features etc.

The more complex your software is, the harder it will be for other programmers (or even for yourself if you're looking at your code later) to understand and maintain.

However, don't worry. When you gain more experience with programming, you'll learn how to do things in a more simple and efficient way.
+Pie Number of slices to send: Send
Thank You Jesper,
My wife is an Oracle/data base gal and hasn't been able to answer all of my questions. I appreciate the short, direct, and timely, I might add, answer. I've learned a lot from coming to this site.
Thanks, Charlie
+Pie Number of slices to send: Send
Sometimes, discovering the simpler way can be a whole process of simplifying one small step at a time.

Most of the first programs (assignments) I wrote were long, convoluted, and when I tried to read them 2 weeks later I had trouble figuring out what I had been trying to do.

I remember once I spent - literally - three days trying to debug my program. I needed to manipulate 60 values stored an array, and I just couldn't get the darn things out of it. When I finally managed to pick my way back to the right portion of the code, and add a debug statement, I was seeing printed, over and over (60 times altogether)



Oh, yeah. I was referring to the length of the array rather than what was in it.

After that I started getting a little more interested in maintainable code and refactoring. Actually, I think the day after that 60, 60, 60 thing I went to the bookstore and found Head First Java.

So complicated isn't a bad place to be! It means that you thought about it, came up with a solution, and that solution even worked.

In my humble opinion, thinking about it - struggling a bit - that is very valuable.

And if you can later rework your code to be simpler, then all the better!
+Pie Number of slices to send: Send
Thank You - Moral support is always a good thing.
Charlie
You know it is dark times when the trees riot. I think this tiny ad is their leader:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1305 times.
Similar Threads
PoolPuzzle from Head First Java has me stumped
Head first Java Puzzle page 24
How to solve PoolPuzzleOne ?
JVM Error
Feeling stupid after Chapter 1 Pool Puzzle
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 04:48:10.