2
edw1o1
5y

There is something that bothers me at this moment, so basically I started structuring my methods like this: methodName({id}, {auth}) instead of methodName(id,auth), I did this so that I have to specify the id and auth inside the object variables in method and not be able to inverse the order, at this point I think that I did something extremely stupid and doesn’t make any sense or it is good for better strcturing, your toughts ?

P.S. Should have used typescript from the beginning

Comments
  • 0
  • 2
    You probably should have kept it like a normal function (id, auth). Maybe you can think about {id, auth} once you have lots of parameters or more than one optional parameter. But {id}, {auth}? Very unconventional.
  • 1
    Ues but for example, if I have a user object with {email, password}, {auth}, to me it makes more sense to have 2 separate objects, one containing params and the other containing context modules or whatever
  • 2
    Whatever works best for your code base, it's just something that I would avoid in general but if it's the cleanest option for you then go for it
Add Comment