SAIF.Framework.BaseN architecture¶
SAIF.Framework.BaseN is a small, self-contained numeric base-conversion utility library implemented as a Strategy-pattern toolkit: an IConverter contract, an abstract ConverterBase template implementation, four concrete converters (binary, octal, hex, Excel-style base-26), a custom exception type, and a VB extension-method facade (BaseNConverter) that exposes fluent BaseNToDecimal/DecimalToBaseN conversion over any IConverter. It has no dependency on the SAIF BOF business-object framework, no data access, no web/UI layer, and no security integration.
Responsibilities¶
- Convert between decimal (
Long/Integer) values and alphanumeric string representations in a configurable numeric base (binary, octal, hexadecimal, or Excel-style base-26 column naming). - Define a common conversion contract (
IConverter) so callers can plug in different base-N strategies interchangeably. - Provide default template conversion logic (
ConverterBase) that concrete converters override only where their base's digit mapping or formatting differs. - Signal invalid digit values (exceeding a converter's base) via a dedicated exception type (
ConverterException). - Expose a fluent, extension-method-based API (
BaseNToDecimal,DecimalToBaseN) that decouples calling code from a converter's internal digit-array plumbing.
Component boundaries¶
IConverter: Public interface defining the conversion contract —Base,ConvertNumericToAlpha,ConvertAlphaToNumeric,FormatBaseN.ConverterBase: Abstract (MustInherit) base class implementingIConverter; supplies default digit-conversion and formatting logic that subclasses override selectively.BinaryConverter/OctalConverter: Concrete converters overriding onlyBase(2 and 8 respectively); they rely onConverterBase's default alpha/numeric conversion, including its silent-zero behavior for non-numeric input.HexConverter: Concrete converter for base 16; overridesBase,ConvertAlphaToNumeric, andConvertNumericToAlphato map hex digits A–F and throwsConverterExceptionon out-of-range values.ExcelConverter: Concrete converter for base 26; overridesBase,ConvertNumericToAlpha,ConvertAlphaToNumeric, andFormatBaseNto implement bijective Excel-style column-letter semantics (no zero digit), throwingConverterExceptionon out-of-range values.ConverterException: Exception type (inheritsSystem.Exception) thrown byHexConverterandExcelConverterwhen a digit exceeds the converter'sBase.BaseNConverter: Public VBModuleproviding the extension-method facade (BaseNToDecimal,DecimalToBaseNwithLong/Integeroverloads) and private helpers (ConvertBaseNToDecimal,ConvertDecimalToBaseN,ConvertToNumericArray) that orchestrate calls into anyIConverterimplementation.
Interaction model¶
- Calling code selects a concrete
IConverterimplementation (e.g.,HexConverter,ExcelConverter) and invokes conversion via theBaseNConverterextension methods ("<value>".BaseNToDecimal(converter)ordecimalValue.DecimalToBaseN(converter)), rather than calling converter methods directly. BaseNConverter's helpers drive the conversion: decoding converts each character viaconverter.ConvertAlphaToNumericinto a digit array, then sumsdigit * Base^position; encoding recursively divides byconverter.Baseto build a digit list, then callsconverter.FormatBaseNto render the final string.- Concrete converters supply only the base-specific behavior (digit mapping, bounds checking, formatting) through
IConvertermethod overrides;ConverterBasesupplies shared/default behavior for converters that do not need custom digit mapping (BinaryConverter,OctalConverter). - There are no other components in this repository that call into or are called by
SAIF.Framework.BaseN— no<ProjectReference>links exist in either direction based on the reviewed.vbprojfiles.*
Architecture diagram¶
The following diagram shows the Strategy-pattern component relationships within the library.
flowchart TD
A[Caller code] --> B[BaseNConverter<br>extension methods]
B --> C[IConverter contract]
C --> D[ConverterBase<br>default template logic]
D --> E[BinaryConverter<br>Base 2]
D --> F[OctalConverter<br>Base 8]
D --> G[HexConverter<br>Base 16]
D --> H[ExcelConverter<br>Base 26]
G --> I[ConverterException]
H --> I
Sequence diagram¶
The following diagram shows the primary decode (BaseNToDecimal) and encode (DecimalToBaseN) sequence.
sequenceDiagram
participant Caller
participant BaseNConverter
participant Converter as IConverter implementation
Caller->>BaseNConverter: "value".BaseNToDecimal(converter)
BaseNConverter->>Converter: ConvertAlphaToNumeric(char) per character
Converter-->>BaseNConverter: digit array
BaseNConverter-->>Caller: Long result (positional sum)
Caller->>BaseNConverter: decimalValue.DecimalToBaseN(converter)
BaseNConverter->>Converter: ConvertNumericToAlpha(digit) per digit (recursive divide/mod)
BaseNConverter->>Converter: FormatBaseN(digit array)
Converter-->>BaseNConverter: formatted string
BaseNConverter-->>Caller: BaseN string result
Design constraints¶
- No cross-layer or cross-project dependencies exist within the repository — the library is not referenced by, nor does it reference,
clsBusinessBase/clsBusinessCollectionBaseor any other SAIF BOF component.* - The library is packaged into the
SAIF.BOF.FrameworkNuGet package via a source-glob mechanism inSAIF.Framework.Core\SAIF.BOF.Framework.Core.nuspec(<file src="..\**\*.vb;..\**\*.cs" ... target="src"/>), not via a<ProjectReference>/IncludeReferencedProjectsbuild dependency. ConverterBase's defaultConvertAlphaToNumericsilently returns0for non-numeric input rather than throwing, which constrainsBinaryConverterandOctalConverter(which rely on this default) to non-strict input validation.HexConverterandExcelConverterenforce strict bounds checking and throwConverterExceptionfor out-of-range digit values, differing in strictness from the defaultConverterBasebehavior.- Target framework is .NET Framework 4.6.1 with only BCL/VB-runtime references (
System,System.Data,System.Xml,System.Core,System.Xml.Linq,System.Data.DataSetExtensions,Microsoft.VisualBasic); no NuGet package dependencies exist.
Related documentation¶
Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.
Sources¶
SAIF.Framework.BaseN\BaseNConverter.vbSAIF.Framework.BaseN\BinaryConverter.vbSAIF.Framework.BaseN\ConverterBase.vbSAIF.Framework.BaseN\ConverterException.vbSAIF.Framework.BaseN\ExcelConverter.vbSAIF.Framework.BaseN\HexConverter.vbSAIF.Framework.BaseN\IConverter.vbSAIF.Framework.BaseN\OctalConverter.vbSAIF.Framework.BaseN\SAIF.Framework.BaseN.vbprojSAIF.Framework.Core\SAIF.BOF.Framework.Core.nuspecPipelines\build-vars.yml