CalcEngine Plus

User-authored calculations for .NET

Expressions and Tags

An expression can be thought of as a formula, or a function. Examples might be

max(feeder1, feeder2)

6.674E-11 * m1 * m2 / (r*r)

A tag is the name for a value that CalcEnginePlus cannot resolve by itself. You could think of tags as “variables” or “entities”. A tag is the name your users give to various entities in their business domain. A tag might represent an ever-changing value from a manufacturing plant, e.g. 'H2O_Flowrate'. Or it might represent a concept from database, e.g. 'SupportDeptHeadcount'

A familiar real-world usage might be a share-trading application that uses well-known tags (think “AAPL” for Apple, “MSFT” for Microsoft, “GOOG” for Google) to refer to the stock price of a company.

 

Named expressions look just like tagnames and are used interchangeably with them. If your application provides a capability to define calculated expressions and give them a name, then your users can break a problem down into smaller parts, and re-use those parts.

So, named expressions are configured through your UI and their definitions are stored in your application's database. Tags resolve to entities outside your application database. It's a fairly minor distinction, because function arguments can be tags, named expressions or literal numbers - CalcenginePlus doesn't differentiate.

 

I'm still not sure I get this “tag” thing…

Sure, let's take a step back and look at the big picture. You're unlikely to be writing a piece of .NET software so that your end-users can calculate “123 * 456” – they have calculators and Excel for that. You’re writing a piece of software so your users can author their own calculations inside a software framework you’re building for them.

Your users will be building calculation expressions like “voltage/resistance”, or “max(Paris.TotalSales, NewYork.TotalSales, London.TotalSales)”. Those things - “voltage” or “Paris.TotalSales” – are the tags.

In reality, when you look at the data store your users have asked you to integrate, it will usually be obvious which entities constitute 'tags'. Even if you have to concatenate a couple of field names in order to achieve uniqueness. The tag names must have meaning to your users. It is your job as a developer return a value for each 'tag' when CalcEnginePlus requests it.

 

We figure that you developers will know your users well enough to have a pretty good feel for the type of language they use, and what they see as a tag. But you folk do some pretty amazing things, and we certainly don’t pretend to cover every domain of expertise. Please contact us if the concept of a “tag” is vague or ambiguous in your world - perhaps a conversation might help.

 

Is it a lot of work to integrate CalcEngine Plus with my tags and subexpressions?

We think not. Most applications will only need to implement two interfaces:

Each interface only has one simple function, so that's only two functions to implement.