[java] RE: Setting up a Java project
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
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
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.
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.
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
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
The various comments so far are all quite good and
on the money as far as the inherent Java concepts
(classes, one public class in a file, multiple
inner classes allowed, abstract classes, interfaces,
packages).
But as far as organizing your project goes, ant from
Jakarta seems to be by far the most popular tool. It
has a command-line interface but these days most IDEs
have built-in ant support. Ant is essentially a "make"
work-alike, using XML project files, written in java.
Ant files are a _lot_ easier to deal with than make
files.
Ant can be used with any language, by the by, not just
java. I don''t know which languages ant already has
support for - obviously it has a lot of support for
java options already - but it''s pretty easy to extend,
from what I''ve heard and seen.
Puff
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement