scalp icon indicating copy to clipboard operation
scalp copied to clipboard

Complex type deconstruction

Open pawaclawczyk opened this issue 7 years ago • 0 comments

Scalp\PatternMatching\Deconstruction trait provides construct and deconstruct methods, holds internally data that represents construction arguments.

Problem related with current implementation:

  1. Destruction::construct must be called manually with right arguments. It's easy to forget or passed wrong arguments.
  2. Constructor arguments are duplicated, one copy is managed by object and second is hold inside trait.

Improvement proposals:

  1. Destruction::deconstruct could throw exception when trying to deconstruct object that was never constructed.
  2. Trait should be replaced with abstract class, __construct should be used to bind type construction arguments. In this case __construct should be protected agains extension in subclasses. Abstract method should be provided to let subclasses do finish object construction.

pawaclawczyk avatar Sep 23 '17 11:09 pawaclawczyk