From edef5bf414f60704f2a18c0d41d4464f2fd7d2c0 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 24 May 2026 13:47:39 +0300 Subject: refactor(rpn): split ArithmeticOperator into 3 interfaces (task 9j) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ArithmeticOperator interface bundled basic arithmetic (+, -, *, /, ^, %), logarithmic operations (Log2, Log10, Ln), and metric conversion (Convert) into a single interface, violating ISP and LSP. Split into: - ArithmeticOperator — Add, Subtract, Multiply, Divide, Power, Modulo - LogarithmicOperator — Log2, Log10, Ln - MetricOperator — Convert Updated compile-time interface checks in operations.go and the trailing comment in operations_interfaces.go. No behavioral change. --- internal/rpn/operations_interfaces.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'internal/rpn/operations_interfaces.go') diff --git a/internal/rpn/operations_interfaces.go b/internal/rpn/operations_interfaces.go index 5acce62..6a543b9 100644 --- a/internal/rpn/operations_interfaces.go +++ b/internal/rpn/operations_interfaces.go @@ -11,9 +11,17 @@ type ArithmeticOperator interface { Divide(stack *Stack) error Power(stack *Stack) error Modulo(stack *Stack) error +} + +// LogarithmicOperator defines the interface for logarithmic operators. +type LogarithmicOperator interface { Log2(stack *Stack) error Log10(stack *Stack) error Ln(stack *Stack) error +} + +// MetricOperator defines the interface for metric unit conversion. +type MetricOperator interface { Convert(stack *Stack) error } @@ -69,8 +77,9 @@ type PowerIntOperator interface { } // Operator implementations are split across focused sub-interfaces -// (ArithmeticOperator, BooleanOperator, HyperOperator, StackOperator, -// VariableOperator, ConstantOperator, PowerIntOperator) for clarity. +// (ArithmeticOperator, LogarithmicOperator, MetricOperator, BooleanOperator, +// HyperOperator, StackOperator, VariableOperator, ConstantOperator, +// PowerIntOperator) for clarity. // The combined Operator interface was removed — RPN is the sole client // and Operations is the sole implementor, so the interface added // indirection without practical benefit (ISP). -- cgit v1.2.3