aspose file tools*
The moose likes Beginning Java and the fly likes Books, the main(String[] method), non-object oriented programming, and beginners. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Books, the main(String[] method), non-object oriented programming, and beginners." Watch "Books, the main(String[] method), non-object oriented programming, and beginners." New topic
Author

Books, the main(String[] method), non-object oriented programming, and beginners.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40041
    
  28
First, I must apologise. About two weeks ago I commented about code which seemed to have everything in the main method, and suggested that was typical of the examples in Head First Java (HFJ), and offended Bert Bates, which I hadn't intended to do. I am very sorry.

What is more, I was mistaken about the book; the sort of example which has all its code in the main method isn't typical of what one finds in HFJ. So I have even more to apologise about.

BUT . . .

There are lots of books, and that includes the Java Tutorials, which do seem to put everything in a main method. It makes the code easier to read, and takes less space on the page, but some people say it is not object-oriented programming. [Note the comments in Bunkhouse Books about Objects First by Barnes and Kolling and "no procedural hello world" programs.]
I agree with these opinions, and I am sure I have mentioned them on the Ranch in the past.

Do people agree with me? Should there be health warnings about that sort of book and that sort of programming? Do we think it confuses beginners? It certainly confused me when I started. What do other people think?

CR
Andre Brito
Ranch Hand

Joined: Dec 13, 2007
Posts: 95

Originally posted by Campbell Ritchie:
Do people agree with me? Should there be health warnings about that sort of book and that sort of programming? Do we think it confuses beginners? It certainly confused me when I started. What do other people think?

CR


Hi Campbell.
I started with the Pascal language, then C and then Java. Now, Java, C++ and C. So, my studies have been in an increasing way.
When I started with Java, I used BlueJ IDE, so I did not have the main, just the class' diagram.
Neither in C we use just the main: the functions are the greatest part of the code. In my first code, I used just the main, but now... the main function is just for initialize my variables and objects.
Here in Brazil, me and my friends don't use just the main... and I guess no one should. Actually, I've never seen a code that is long and do not have functions and methods... really... just for HelloWorld and Sums that happen, but now... NEVER!
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14430
    
  23

Object-oriented programming is a big subject, and if you're totally new to programming, it will take (a lot of) time to learn it well. To learn it, you have to break it up into parts and learn one thing at a time. You can't learn the syntax and concepts of Java, the API and good OO design all at the same time, that would be too overwhelming. So if you are for example learning the syntax of Java, you don't need to be concerned with OO design and then the examples don't need to be all well-designed from the OO standpoint. Most example programs are very short and are meant to demonstrate one or a few concepts, and they should focus on those concepts and not pull in the rest of the world too.

So I don't think there's really a problem with example programs not always being great examples of OO design.

OO design does become important when your programs get larger than a few hundred lines.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40041
    
  28
Thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Books, the main(String[] method), non-object oriented programming, and beginners.