Skip to main content
gamedev.net
🔒 Locked

[java] RE: Setting up a Java project

Started by Sir_Spritely 4 replies 300+ views
Original Post
Sir_Spritely
Sir_Spritely
Having been a user of C++ I have set projects up with a header file to hold all the class prototypes and then the .cpp file to hold the implementation of the class. My question is with Java what is the traditional method of writing projects. I have not seen any projects written in such a manner in Java, so is this never done? Rather with Java is it a case of five different classes with their prototypes and implentations just shoved into one huge file. Any tips appreciated. Thanks, Pk
Arild Fines
Arild Fines
quote:
Original post by Sir_Spritely
Rather with Java is it a case of five different classes with their prototypes and implentations just shoved into one huge file.


1 - Java doesnt differentiate between prototype and implementation(and thank <insert appropriate higher being here> for that)
2 - You use one file per class(There are exceptions, but consider this the basic rule).



Faith. n. Belief without evidence in what is told by one who speaks without knowledge, of things without parallel. -- Ambrose Bierce
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
Viro
Viro
In java, each file should have only 1 public class. So, while you can have 5 classes stuffed in 1 source file, you can only make 1 of those public.
"Linux is not about free software, it is about community," -- Steve Balmer, Microsoft Chief Executive.
HenryApe
HenryApe
It might be worth mentioning that Java has an abstract type called interface that you use instead of a class when you want to separate the specification from the implementation. Classes can implement (inherit) multiple interfaces (implement the functionality of several specifications) which gives Java a sort of multiple inheritance for interfaces.
Petr Stedry
Petr Stedry
Hi,

after reading your post I had to reply (don''t ask me why .

You asked:
"What is the traditional method of writing projects?"

And I''m afraid there is no "traditional method of writing projects". There''s one and only reason for that.

From the Java perspective there are numerous ways to give structure to your ideas.

On the basic level there are such "constructs" as abstract (and "plain") classes and interfaces. These are the basic blocks.

One level up you usually find packages grouping classes, that are part of one functionality, together. Imagine packages as directories (and explore the package hierarchy of standard classes to learn how people who created Java used them).

Well ... you find nothing more in the language itself, that helps you in writing a project.

There are many project management tools found in any better IDE.

So feel free to check out at least one of the following:
NetBeans - supported by Sun (and my personal favourite
Eclipse - supported by IBM

If you want to know about others, just start a thread called: "What''s your personal favourite IDE"

... and have a nice day


Petr Stedry
Petr Stedry

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.