global variables in (financial) rapid development

In my financial projects, I realized people do worse things than global vars – copy/paste, super long method signatures, poor null checks, returning nulls…

My professional perl programs successfully use lots of globals. Be practical. Get Real.

C++ lets you easily use tons of globals, so I’d say “avoid it, but if no time then use it.”

In java, someone might want to create a to hold public static vars. This is actually better than scattering lots of mutable[1] non-private static variables into multiple classes. So before you dismiss someone for using, look for those mutable shared static vars.

For a bit of access control, you can use an class to hold such shared variables — Some classes will not get a reference to this singleton, so they can’t access the vars.

[1] Most final variables are mutable in java, unless the class is designed to be immutable.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s