A
A
azaznioo2015-04-30 01:49:46
Programming
azaznioo, 2015-04-30 01:49:46

How to pass and check many function parameters?

Hello, there are functions in which you need to pass a lot of parameters. In different functions, the parameters may change, but not much (some fields will not be there or others will be added). I decided to pass the parameters through a structure in which the fields are the parameters of the functions. It is necessary to check all these parameters beforehand before sending them. The problem is that the parameters of different functions are very similar, but not the same. I don't want to duplicate code (describe the structure and check) for every function. Is there some pattern or way to get around this nicely?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
ManWithBear, 2015-04-30
@azaznioo

Wrap everything in a class. with a verification method. All others inherit from him/from each other.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question