-
January 31st, 2010, 02:27 PM
#1
[RESOLVED] MessageBox etc. in a constructor, would you do that?
what do you think, is showing a message box in a constructor of some class a bad practice? (or any other interaction with the user while initializing an object)
win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming
remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation
private lessons are not an option so please don't ask for help in private, I won't replay
if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know
-
January 31st, 2010, 02:54 PM
#2
Re: MessageBox etc. in a constructor, would you do that?
yours becomes jerking and looks ugly right from the start
-
January 31st, 2010, 03:17 PM
#3
Re: MessageBox etc. in a constructor, would you do that?
No, I wouldn't recommend doing that. Your object is then tightly coupled to your GUI. If you want user interaction to decide whether or not a task should take place, you should do that before constructing your object.
www.monotorrent.com For all your .NET bittorrent needs
NOTE: My code snippets are just snippets. They demonstrate an idea which can be adapted by you to solve your problem. They are not 100% complete and fully functional solutions equipped with error handling.
-
February 1st, 2010, 03:48 AM
#4
Re: MessageBox etc. in a constructor, would you do that?
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post.
-
February 1st, 2010, 12:21 PM
#5
Re: MessageBox etc. in a constructor, would you do that?
Originally Posted by boudino
Shortlly: No, it isn't.
Are you saying that it is not bad practice to show a messagebox from a class constructor? Going to have to disagree with you there. The UI layer should be responsible for the UI, otherwise you have this tangled mess of code and, when inevitably more than one messagebox is popping up because of some error, you have to start digging through class files to find them and get rid of them. Poor, poor design.
-
February 2nd, 2010, 03:12 AM
#6
Re: MessageBox etc. in a constructor, would you do that?
Damned! I've anwer another question... I definitely want to say that I consider it is bad practice to show message box in a constructor. Thanks for your notice.
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post.
-
February 2nd, 2010, 03:34 PM
#7
Re: MessageBox etc. in a constructor, would you do that?
ok, you've convinced me not to do it
win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming
remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation
private lessons are not an option so please don't ask for help in private, I won't replay
if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know
-
February 2nd, 2010, 07:35 PM
#8
Re: MessageBox etc. in a constructor, would you do that?
Great, now if we can just get you to use '_'.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|