Re: [Eclipse] How to fix indentations.
- From: Lew <lew@xxxxxxxxxxxxx>
- Date: Sun, 16 Sep 2007 15:06:19 -0400
Pseudo Silk Kimono wrote:
I would like to know how to fix my
Eclipse installation so that it does proper indentation. I seem to
Set it to use spaces instead of TABs. You should not embed TABs in Usenet source listings.
If this doesn't look good just ignore it.
That's not really good advice. The layout affects the ability, and arguably the willingness of people to read your listing with the attention needed to help you.
private static ArrayList<String> listOfFortunes = new ArrayList();.... // more add() calls
{
listOfFortunes.add("I Like food");
listOfFortunes.add("You will be assimilated");
listOfFortunes.add("I am nothing");
}
This initialization will have the unfortunate effect of causing your fortunes list to grow each time you instantiate the object.
Why do you declare the list static but initialize it in the constructor? Wouldn't it be better to initialize the list statically, or else declare it as an instance variable?
Apropos of that collection, don't mix generics and raw types.
The variable should be of the interface type, not the concrete implementation.
It is inadvisable to build the implementation type into the variable name. "listOf" is redundant and will cause trouble if you decide later to change the implementation.
private static List<String> fortunes = new ArrayList<String>();
--
Lew
.
- Follow-Ups:
- Re: [Eclipse] How to fix indentations.
- From: Pseudo Silk Kimono
- Re: [Eclipse] How to fix indentations.
- From: Pseudo Silk Kimono
- Re: [Eclipse] How to fix indentations.
- References:
- [Eclipse] How to fix indentations.
- From: Pseudo Silk Kimono
- Re: [Eclipse] How to fix indentations.
- From: RedGrittyBrick
- Re: [Eclipse] How to fix indentations.
- From: Pseudo Silk Kimono
- [Eclipse] How to fix indentations.
- Prev by Date: Re: [Eclipse] How to fix indentations.
- Next by Date: Re: [Eclipse] How to fix indentations.
- Previous by thread: Re: [Eclipse] How to fix indentations.
- Next by thread: Re: [Eclipse] How to fix indentations.
- Index(es):
Relevant Pages
|