How to reduce cyclomatic complexity?

后端 未结 2 1375
你的背包
你的背包 2021-02-01 16:31

I\'m working on a class which sends a RequestDTO to a Web Service. I need to validate the request before it is sent.

The request can be sent from 3 different places and

2条回答
  •  日久生厌
    2021-02-01 17:17

    Another approach would be to enforce that contract in the Request object itself. If a field is required or can't be null, say so when the Request is created.

    Create the Request in such a way that it's 100% valid and ready to go when the constructor exists.

    I'd also create that String version in the Request toString() method. It should know how to render itself.

提交回复
热议问题