Naming: time you have to wait before something is valid - naming-conventions

We are tracking offline conversions in google adwords and have to wait 4-6 hours after the click before a conversion can be attached to it.
I have a constant that references this time and it is currently called CLICK_GESTATION_HOURS, which is kind of a play on the standard life-cycle terms such as 'expiry'.
It got me wondering, is there a standard computing term for the time you have to wait before something is valid?

I don't believe there is a standard computing term for "the time you have to wait before something is valid", but a common computing term used for waiting is (obviously!) "wait" or "delay".
In my opinion "CLICK_GESTATION_HOURS" is not a good choice of variable name as it is very ambiguous i.e. the term gestation implies that click is going to give birth to something (another click?!).
How about using an intention revealing name such as "ClickConversionAttachmentDelay"?

Related

Proprietary handling/collecting of user defined errors

I do not know how to implement a proprietary handling procedure of user defined errors (routines/algorithm stop) or warnings messages (routine/algorithm can proceed) without using Exceptions (i.e. failwith .... Standard System Exception).
Example: I have a Module with a series of Functions that uses a lot of input data to be checked and to be used to calculate the thickness of a Pressure Vessel Component.
The calculation procedure is complex, iterative and there are a lot of checks to be performed before getting a result, check that can generate "User Defined Errors" that stop the procedure/routine/algorithm or generate a "Warning Messages" proceeding on.
I need to collect these Errors and Messages to be shown to the User in a dedicated form (Wpf or Windows form). This later at the end.
Note: every time that I read a books of F# or C# or Visual basic or an Article in Internet, I found the same Phylosophy/Warning: raise of System/User-Defined Exception should be limited as much as possible: Exception are for unmanageable Exceptional Events ( not predictable) and cause "overload" to the Computer System.
I do not know which handling philosophy to implement. I'm confused. Limited sources available on internet on this particular argument.
Actually I'm planning to adopt this Phylosophy , taken from: "https://fsharpforfunandprofit.com/posts/recipe-part2/". It sounds good for me, ... complex, but good. No other references I was able to go find on this relevant argument.
Question: there are other Phylosophies that I can consider to create this Proprietary handling/collecting of user defined errors? Some books to read or some articles?
My decision will give a big impact on how to design and write my code (splitting problem in several functions, generate a "motor" that run in sequence functions or compose then in different ways depending on results, where to check for Errors/Warnings, how to store Errors and Warning Messages to understand what is going on or where "Errors/Warnings" are genetate and caused "By Which Function"?).
Many thanks in advance.
The F# way is to encode the errors in the types as much as possible. The easiest example is an option type where you would return None if the operation failed ans Some value when it succeeded. Surprisingly, very often this is enough! If not, then you can encode different types of errors AND a success "state" in a discriminated union, e.g.
[<Measure>]
type psi
type VesselPressureResult =
| PressureOk
| WarningApproachingLimit
| ErrorOverLimitBy of int<psi>
and then you will use pattern matching to "decide" what to do in each case. If you need to add more variants, e.g. ErrorTooLow, then you would add that to the DU and then the compiler will "tell" you about all places where you need to fix the logic.
Here is the perfect source with detailed information: https://fsharpforfunandprofit.com/series/designing-with-types.html

How to get the current value of a Signal in Elm?

Is there a way to get the current value of a given signal? Or, is this something that I shouldn't want to do when writing idiomatic Elm?
Normal code
You shouldn't want to do that when writing idiomatic Elm.
It's also not possible to get the current value of a signal. This would be a side-effecting function (returning different values at different times in the program execution), which would allow all kinds of nasty bugs to crop up. To do something with the value on a signal, you can map over the signal with Signal.map but I suspect you already know that one.
Testing
If you're asking about this for testing purposes rather than normal code, you can hack around the limitation using the technique that's used in package Apanatshka/elm-signal-extra to write tests for signal-related functions. (Note that although I'm the author of that package, kudos for the testing system should go to rgremple for conceiving of and contributing it)
The way I understand it, the concept of "current value" has no meaning in Elm.
Sure, if you Signal.map a function over a signal, you can say that that function will always receive the "current value" but I don't think that this is what you meant.
The idea of "current value" involves time. It involves the idea of having a "before I ask for the current value" and an "after I ask for the current value". This is something that you might find in an imperative language but Elm is declarative and as such, the concept of before and after have no meaning.

Parameter naming for "time since this happened"

I'm working on building a simple API to consume data sent from small network-connected sensors/devices (think arduino, raspberry pi, etc). I want to log a reasonably accurate timestamp of when an event occurred on this remote device. Due to potential connectivity issues, the event might not always get sent back to the server right away. I don't want to rely on synchronizing a clock on the device if I can avoid it, so I'm going to try sending back a parameter that just contains the number of seconds since the event occurred. So, for example, an event is detected on the device, but for some reason it gets sent to the server 5 seconds later. The data would include a number "5" signifying that this happened 5 seconds ago based on the device's internal clock. The server then would take it's own clock-time, and subtract 5 seconds to generate the timestamp.
I'd like to come up with a parameter name that describes this time span that makes sense. Some options may include:
TimeSince
TimeAgo
DurationSince
However since this is a simple numeric field, I want the name to include the unit of measure for extra clarity, such as:
SecondsSince
SecondsAgo
TimeAgoSeconds
Has anyone come across common and/or sensible naming conventions for this kind of thing? Time since an event, and additionally, where and how to indicate units in a parameter name? None of my naming ideas really feel "right" but perhaps some discussion here might help identify one approach as being better than another.
Thanks.
My feeling is that ElapsedSeconds sounds reasonable.
Now, are you buffering those events? If they are meant to happening "every n seconds", how do you handle a missed value? I mean, you can buffer for n events, if they are not transmitted than you probably would overwrite the first of those n. When you transmit all your buffer how do you account for the missing one? Depending on the application it would be interest to fill a NaN for the event on that moment.
Does this make sense?

NSSpeechRecognizer with wildcard command elements

The docs for NSSpeechRecognizer state that complex, multi-step actions can be executed from single spoken commands, such as:
“schedule a meeting with Adam and John tomorrow at ten o’clock.”
I'm able to execute simple commands which are preprogrammed, but I don't see how the above could be interpreted using the class. It seems like
“schedule a * with * *”
should be a command. Any idea if something like this is possible? Or are we just supposed to pass an infinite number of possible commands to the recognizer?
It does not appear to me from the NSSpeechRecognizer documentation that it will support using complex phrases like the example you have given. To get the semantic meaning from a phrase like this you would use a system that supports multislot grammars like most IVR systems that support the VoiceXML standard. It looks to me that this speech recognition API only supports passing in simple commands as an array and not specifying complex grammar rules. With this type of system you would have to implement what is called a directed dialog, which might go something like this:
C: What would you like to do?
U: Schedule a meeting.
C: Tell me the first person that you would like to attend?
U: Adam.
C: Tell me the next person that will attend or say "done" if the attendee list is complete.
U: John.
C: Tell me the next person that will attend or say "done" if the attendee list is complete.
U: Done.
C: What day is this meeting?
U: Tomorrow.
C: What time is the meeting?
U: Ten O'Clock.
C: Thank you. Your meeting has been scheduled.
Using a directed dialog you can restrict the expected commands/utterances to a much more defined list. Although your list of possible names could be quite large unless you cull them from a users contact list.
My interpretation of the docs is that you would need to accumulate and operate on any compound state on your own. You provide NSSpeechRecognizer with a set of discrete words/phrases that it should recognize as 'commands', and it reports to you when it has recognized them.
For the example you've given, I think you'll run into problems when you get to the "Adam and John" part -- it's not an arbitrary dictation engine. But, for fun, let's try to imagine how we might do this:
You might tell it you want to recognize the following phrases as 'commands':
"schedule a"
"meeting" (and perhaps "appointment", "playdate", etc)
"with"
"Adam and John"
"tomorrow" (and probably other related things like "today", "two days from now", all the days of the week, etc)
"ten o'clock"
As words/phrases are recognized, you could create a stack of semantically related words/phrases based on previously recognized words/phrases. So, for instance, it recognizes the "schedule a" phrase, and you know that there should be more info coming to fill out the semantic context, so you push that phrase onto the stack. Next, it recognizes "meeting". Your app says 'sure, a meeting is something that can be scheduled' and pushes it onto the stack as well. If the next word it recognized wasn't germane to the previously-recognized "schedule a" command, then it would clear the stack. If, at any point, the elements on the stack satisfy some pre-defined criteria for a fully formed expression of semantic intent, then your app can take the appropriate action based on that intent. There's obviously a temporal element to this as well. If the next thing required to establish semantic context doesn't arrive in a reasonable amount of time, the semantic context stack should get cleared.
A similar system, conceptually, is the iOS/MacOS touch/trackpad gesture recognition system. When a tap touch happens, the OS has to recognize the single tap, and acknowledge the possibility that that is the entire user intent, but it also has to manage the possibility that it might receive another tap very shortly, turning the single tap into a double tap. It will have to accumulate this state over time, and infer the user intent by looking at the combination of discrete events.
You're not going to get such functionality from NSSpeechRecognizer for free, and being that it's not a dictation engine, you also won't get arbitrary 'tokens' from it (like "Adam and John", assuming you're not registering some giant list of names all as potential commands.) Even so, that doesn't mean it couldn't be leveraged to do some pretty neat stuff using a mechanism like I described. It's just that you're gonna have to write it yourself.
Good luck!

Google analytics variables limitations

We are in the process of deciding if we go for Omniture or Google Analytics.
Some information regarding GA seems outdated on the Net, and it is not easy to find the relevant answers to our questions.
In particular, I would appreciate some pointers regarding, in Google Analytics
is there a limitation of the number of custom variables?
is there a limitation of the type of variables that can be used?
and besides,
what is your experience in the delay between the moment the data is recorded GA side, and the time it is made available to the GA account (read 2~10 hours?)
Thanks
There are 5 custom variable slots. Any given pageview/visit/visitor can only occupy up to 5. In theory, you could have thousands of different variables, but the slots are overriding. ie, you can't store 'Is Logged In' in the same slot as 'Is Paid User' if you want to be able to track both on the same pageview, session, or user. But, you could use the same slot for mutually-exclusive variables that you know won't ever overlap (like, 'banned user' and 'Admin').
There's also a 6th possible variable value known as "User Defined Variable" (called by _setVar), which is the deprecated ancestor to Custom Variables, but for backwards compatibility reasons will likely always be around. It is a single slot, visitor level, that lets you define one key-value pair.
The 'type' is basically any key-value string pair, with a limitation that the combined length of any given custom variable's key and value cannot exceed 128 characters. You can set the scope of the custom variable to be at the page-level (pageview), session-level (visit), or user-level (visitor).
The length of time for data processing is inconsistent. Sometimes, the most basic data from pageviews, transactions and events appears within minutes, but then some of the accompanying data (source information, custom variable values, etc) does not process for another few hours. Only on vary rare occasions does it take longer than 24 hours for a full snapshot of a day to be available.
I would like to add that GA and SC are in no way comparable products when you are talking about measurement you want to base decisions on.
GA wins hands down on setup and configuration (and no cost, especially no extra costs), but if you want to measure anything on visitor level, need real time figures or want to have any support, choose something else than GA. Based on you question and the very informative answer provided, I think you did.
In Google Universal Analytics, you can set up to 20 "Custom Dimensions" and "Custom Metrics", see https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets
These enable you do just about everything you currently do with custom variables. Only downside is that they are not displayed in any standard reports, but are very powerful when used in custom reports.