Summary
The NoTransientInstancesOfPersistentClass conditional define should be removed and the check should always be enforced.
Background
Currently, creating transient instances of persistent classes is conditionally prevented via {$IFDEF NoTransientInstancesOfPersistentClass} in BoldSystem.pas. This define is enabled under the Attracs configuration but disabled otherwise.
Problem
There is no valid use case for creating transient instances of persistent classes:
- Temporary objects can use undo/rollback or separate DTO classes
- Preview/simulation scenarios should use separate in-memory systems
- Template objects can be stored in DB or use non-persistent classes
The conditional define:
- Implies the feature might be useful (it isn't)
- Allows bugs in builds without the define
- Adds unnecessary complexity
- The
AddTransientFromSystem procedure in BoldObjectListControllers.pas becomes dead code
Proposed Solution
- Remove
{$DEFINE NoTransientInstancesOfPersistentClass} from Bold.inc
- Remove
{$UNDEF NoTransientInstancesOfPersistentClass} from non-Attracs block
- Make the check in BoldSystem.pas unconditional
- Remove dead code
AddTransientFromSystem from BoldObjectListControllers.pas
- Update tests that relied on this feature
Summary
The
NoTransientInstancesOfPersistentClassconditional define should be removed and the check should always be enforced.Background
Currently, creating transient instances of persistent classes is conditionally prevented via
{$IFDEF NoTransientInstancesOfPersistentClass}in BoldSystem.pas. This define is enabled under theAttracsconfiguration but disabled otherwise.Problem
There is no valid use case for creating transient instances of persistent classes:
The conditional define:
AddTransientFromSystemprocedure in BoldObjectListControllers.pas becomes dead codeProposed Solution
{$DEFINE NoTransientInstancesOfPersistentClass}from Bold.inc{$UNDEF NoTransientInstancesOfPersistentClass}from non-Attracs blockAddTransientFromSystemfrom BoldObjectListControllers.pas