开发者

C# - Basic class design question

I'm writing an application,

The main purpose of the application is to be able to rapidly send emails using one's Gmail account (NOT reading emails, just sending).

I have a "GmailAccount" class which creates an SmtpClient object within its constructor using the user's Username and Password. It also has a "Send" method which takes a MailMessage that is going to be built by my UI and passed over.

The problem I have, is that I would quite like to also poll Gmail's contact list so that I can 'autofill' when the user is typing email addresses.

Should I split this class up, or should I also do this:

1) 开发者_StackOverflow社区Download client contact list to disk

2) Have a keystroke method on my to/cc/bcc fields that for every char typed polls the GmailAccount.FindContact() method to see if there is a match?

3) If there's a match, pass the full address over.

Thanks for the help!


It's all about what's appropriate to you, and how your (whole) application works.

Personally, I'd have the contacts under GmailAccount, because the contacts are part of the Gmail account. You may disagree, and you are completely correct in doing so, because class design is something subjective.

I've seen many class designs which have a single property and have class, which then has another class + one field in them. The author of that program may find it good to do so, but I would personally disagree with his class design. Thing is, we are both correct.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜