3
b2plane
1y

Since updating already has the same fields as while registering minus a few fields (password roles etc), is it better practice to:

1) create a brand new model class dedicated with the exact same duplicate fields that are required to be set in order to be updated (has the exact fields allowed to be updated)

2) or use the same model class that was used to register the whole thing (this has all the fields including the ones which arent allowed to be updated, so programmatically you'd have to target only fields that you want to update)

Comments
  • 2
    1) create a new model.
    It might look redundant and a violation of DRY, but it‘s a different use case. In this case duplication is better than abusing the same model for different cases.
  • 2
    1) redundancy is better.

    To add to @Lensflare ... What usually happens is an abuse of NULL or default values.

    Abuse as the model now depicts several different use cases - NULL now means set, not set (intended use case), not set (different use case).

    Can lead to a lot of unpleasant surprises.
Add Comment