[Mono-list] Questions about coding style
Jonathan Pryor
jonpryor at vt.edu
Mon Aug 20 17:11:34 UTC 2012
On Aug 17, 2012, at 5:49 PM, Philippe Grohrock <philippe.grohrock at gmail.com> wrote:
> 1. Is it bad/good style to have a public class that implements global variables?
How do you define "global variable"? :-)
`public static` fields are Very Bad™, unless they're `readonly`. This is because there's no way to prevent modification of the field from anything else in your process.
`public static` properties are (generally) fine, and are common in the Base Class Library.
Best, though, is to keep things `internal` or `private` unless they _really_ need to be public.
> My program readys a DB connection right at the start which is queried by multiple different GTK windows.
This is a case where `internal` should normally be preferred over `public`, unless another assembly in your app needs access to the value.
- Jon
More information about the Mono-list
mailing list