Coupling question when dealing with lots of parameters.

Hey guys,

I am making a class that generates canned emails to my co-workers when my tool completes or fails a task.

I basically have a class for emailing, Emailer.vb that just takes the basic information, like subject, body, to, etc.

And for the canned messages, I made a base class that has everything each canned message will know about. Name of the person responsible, Id of their job (they queue up their jobs in an internal website), what application the job involves, the Id of the item in the CRM system their job is to be applied to, etc.

My derived classes are just like Successful message, Failed message, etc. They all use the same data points, but the email layout and etc. are defined in the derived classes. The base class provides a ToString method so they can just queue up an Emailer.Send(name, email, subject, cannedMessage.ToString()).

My coupling question is that my canned messages have like 10 or so parameters. Some of them are optional, some of them are mandatory. I feel like it looks weird to have all the possible parameters listed in the constructor because it looks clunky, only having the mandatory parameters in the constructor and optional parameters as properties looks disjointed, and defining a structure like CannedMessageArgs that houses all the parameters and then just passing in the CannedMessageArgs class to the CannedMessage Class seems like I’m just applying a bandaid.

Any thoughts on how I should set this up?

submitted by /u/IHateMyHandle
[link] [comments]

Leave a Reply