开发者

C# Design Pattern

I'm new to C开发者_开发问答# Programming, I'm having three events like Mouse Key Down,Up and Drag.

On all this events I need to repaint the screen. Is there any Design pattern to do this.

Since, I need to call this Repaint method repeatedly on each events??


You have three events and you want to call Repaint from all of them. That's three lines of code. Any abstraction you do to try to hide that repainting is going to cost you way more than three lines of code so you need a much more complicated use case before you can justify a more complex solution than just putting Repaint into each of your three event handlers.

Edit:

I want to add that you are taking a lot of heat for your question and I for one do not agree. I think It's a simple sincere question and one asked clearly. It's actually a great beginner design question: "Should I use abstraction in such-and-such situation?" So, no, I don't think you should in this situation. But good for you for trying to use abstraction every chance you get and don't worry because you will get plenty of legitimate reasons soon enough!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜