DEV Community

Discussion on: Clean Code – Part 1

Collapse
 
shadowphoenix profile image
Rose

Great Article!
I've been using the guard clauses a lot in my recent framework.
While mine might look a bit more hacky, it does the same as your code snippet:

public OrderService(IEmailService emailService) {
    _ = emailService ?? throw new ArgumentNullException(nameof(emailService));

    // do rest of code here
}

I've been using that line throughout my code base, just to reduce internal screams. xD