Re: Any Checkstyle users?
- From: "mikm" <m.mckinley@xxxxxxxxx>
- Date: 30 Jan 2006 19:55:27 -0800
Dah. I should clarify myself. For example, imagine you have a Hotel
class and want to keep track of your guests
import java.util.HashMap;
public class Hotel
{ private HashMap guests;
//...
public Hotel()
{ guests = new HashMap(50);
}
//...
}
In this example "50" is ambiguous. Why 50?
A slightly better way would be
public class Hotel
{ private HashMap guests;
private static final int MAX_GUESTS = 50;
//...
public Hotel()
{ guests = new HashMap(MAX_GUESTS);
}
//...
}
Now, anybody looking at your code knows that the maximum number of
guests is 50 and that the HashMap "guests" can hold that much data.
.
- Follow-Ups:
- Re: Any Checkstyle users?
- From: Chris Uppal
- Re: Any Checkstyle users?
- From: Tony Morris
- Re: Any Checkstyle users?
- References:
- Any Checkstyle users?
- From: slippymississippi
- Re: Any Checkstyle users?
- From: mikm
- Any Checkstyle users?
- Prev by Date: Re: Any Checkstyle users?
- Next by Date: Re: How to byte[ ] --> char[ ] and char[ ] --> byte[ ]?
- Previous by thread: Re: Any Checkstyle users?
- Next by thread: Re: Any Checkstyle users?
- Index(es):