Tips on model design

Revision as of 01:05, 23 November 2019 by Max (talk | contribs) (Created page with "Here some tips and best practices for models that are easier to build, understand, debug, and extend. == Don't embed numbers in expressions == In models build by novice mode...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Here some tips and best practices for models that are easier to build, understand, debug, and extend.

Don't embed numbers in expressions

In models build by novice modelers, you often see variables like this:

Variable Energy_consumption := Gas_consumption * 239.2972

It might not be clear from looking at the Definition what the number 239.2972 means. It is actually the energy units conversion factor from million BTU per Kilowatt-hours. It's much better to create a separate Constant for that number:

Constant KWH_per_MMBTU := 239.2972
Variable Energy_consumption := Gas_consumption * KWH_per_MMBTU 

Hopefully, you remembered to specify the units for each quantity:

Units OF Gas_consumption := 'MMBtu'
Units OF Energy_consumption := 'kWh'

Using a named constant makes it much clearer what the number means. Plus you can use this Constant KWH_per_MMBTU wherever you need it without having to look it up and retype it each time.

Don't repeat expressions in cells of a table

If you find yourself entering the same or similar expressions into some or all the cells of an edit table -- there's almost certainly a simpler and clearer way to do what you want. Consider this table:

Variable
Comments


You are not allowed to post comments.