Skip to content

SAIF.Presentation.ConsoleApplication business rules

This library implements application lifecycle and diagnostic conventions, not insurance/claims-domain business rules. The rules below are documented for completeness per the analysis contract.

BR-001: Batch log stream must resolve to a valid file

Field Value
Statement A batch application's log stream (other than StandardFile) must be backed by a valid, non-empty environment variable naming a file path.
Trigger Call to WriteAppLogMsg(AppLogMsg, LogFile) where LogFile <> StandardFile and the corresponding environment variable is unset or empty.
Enforcement clsBatchBase.WriteAppLogMsg — Throw New Exception("Log stream " & LogNo & " is not a valid environment variable or file.").
Outcome Writing to an unconfigured log stream fails with an exception rather than silently writing nowhere.
Source Presentation\SAIF.Presentation.ConsoleApplication\clsBatchBase.vb

BR-002: Case-insensitive command-line switch matching

Field Value
Statement Command-line switches are matched case-insensitively and may use either / or - prefix; both are stripped before comparison.
Trigger Any call to Initialize(), GetParamName, GetParamValue, or ParamExists.
Enforcement clsConsoleBase.Initialize() strips a single leading / or - character and upper-cases each argument before storage; lookup methods compare against inName.ToUpper().
Outcome /Debug, -DEBUG, and /debug are all treated identically.
Source Presentation\SAIF.Presentation.ConsoleApplication\clsConsoleBase.vb

BR-003: Command-line validation gates application logic

Field Value
Statement If command-line validation fails, the application must not proceed to run its main logic; it must prompt the user and wait for input before exiting.
Trigger ValidateCommandLine() returns False inside Execute().
Enforcement clsConsoleBase.Execute() — the Else branch calls Console.WriteLine("Press enter to continue...") and Console.Read(), then still proceeds to Uninitialize().
Outcome RunAppLogic() is never invoked when command-line validation fails.
Source Presentation\SAIF.Presentation.ConsoleApplication\clsConsoleBase.vb

BR-004: Colon in a file-path value is not treated as a name/value separator

Field Value
Statement When splitting a stored command-line argument into a name and value at a colon, the colon is only treated as the name/value delimiter if the character immediately following it is not a backslash.
Trigger GetParamName(String), GetParamName(Integer), GetParamValue(String), or GetParamValue(Integer) is called against a stored argument that contains a colon.
Enforcement clsConsoleBase.GetParamName / GetParamValue — before splitting, each checks cmdArg.IndexOf(":"c) >= 0 AndAlso cmdArg.Substring(cmdArg.IndexOf(":"c) + 1, 1) <> "\".
Outcome An argument such as /LOGFILE:C:\Logs\app.log returns the full path C:\Logs\app.log as the value instead of splitting at the drive letter's own colon.
Confidence Verified
Source Presentation\SAIF.Presentation.ConsoleApplication\clsConsoleBase.vb

BR-005: Command-line parameter names match by prefix, not exact equality

Field Value
Statement Parameter existence and value/name lookups by name match a stored argument if it starts with the requested name (case-insensitive); an exact match is not required.
Trigger Any call to ParamExists(String), GetParamName(String), or GetParamValue(String).
Enforcement clsConsoleBase.ParamExists(String), GetParamName(String), and GetParamValue(String) each use cmdArg.StartsWith(inName.ToUpper) to test stored arguments against the requested name.
Outcome A lookup for a short switch name (e.g., "FILE") is satisfied by any stored argument that begins with it (e.g., "FILE0" or "FILEPATH:x"), which can produce unintended matches when switch names share a common prefix.
Confidence Verified
Source Presentation\SAIF.Presentation.ConsoleApplication\clsConsoleBase.vb

BR-006: StandardFile batch log stream is recreated on every write

Field Value
Statement Each call to WriteAppLogMsg targeting the StandardFile batch stream opens a new StreamWriter over the target log file, whereas named streams (File0–File4) open a StreamWriter only once and reuse it for subsequent writes.
Trigger clsBatchBase.WriteAppLogMsg(AppLogMsg, BatchStreams.StandardFile) is called more than once during a single run.
Enforcement clsBatchBase.WriteAppLogMsg — the Else (StandardFile) branch unconditionally executes m_AppLogs(LogNo) = New IO.StreamWriter(CurDir() & "\" & Appname & ".log") on every call, while the non-StandardFile branch only creates a new StreamWriter the first time, guarded by m_AppLogs(LogNo).GetType.ToString = "System.String".
Outcome Repeated StandardFile writes within the same run each reopen the underlying file via a new StreamWriter instance rather than appending through the previously opened one, unlike the named-stream behavior.*
Confidence Inferred
Source Presentation\SAIF.Presentation.ConsoleApplication\clsBatchBase.vb

Notes

  • These rules are application lifecycle and diagnostic conventions rather than insurance-domain business rules.

Sources

  • Presentation\SAIF.Presentation.ConsoleApplication\clsConsoleBase.vb
  • Presentation\SAIF.Presentation.ConsoleApplication\clsBatchBase.vb