Symfony2 - extending entities, abstract entity

后端 未结 2 1143
暖寄归人
暖寄归人 2021-01-07 04:11

I have 2 entities with the same fields - parent, children, order. Actually it is a mechanism and this 3 fields not applicable to content of this entity - like name, title, c

2条回答
  •  隐瞒了意图╮
    2021-01-07 04:31

    I had that issue some time ago. I also wanted to have nice abstraction for entities (or value objects, whatever) just to be a little lazy. But It is not the good way IMHO.

    What if name from one entity has to have other length than the other? What if you want to add new field, add it to one entity, and some time later you wanted it in the other entity, but you forget to move it to abstraction?

    I think entity is such autonomic thing that it is pointless and confusing to move some part of it to the abstraction.

    Remember about KISS principle.

提交回复
热议问题