Organizing GUI code

后端 未结 3 1139
我寻月下人不归
我寻月下人不归 2021-02-08 12:18

My question has two parts:

  • Does anyone have any tips or references to some documentation on the web about how to write GUI code that is easy to read, write, and

相关标签:
3条回答
  • 2021-02-08 12:41

    Some guidelines for the first question, from an OO perspective:

    • Break up large classes into smaller ones. Does that panel have a bunch of fairly modular subpanels? Make a smaller class for each subpanel, then have another, higher-level class put them all together.
    • Reduce duplication. Do you have two trees that share functionality? Make a superclass! Are all of your event handlers doing something similar? Create a method that they all call!

    Second question. I see two ways of doing this:

    • Listeners. If many components should respond to a change that occured in one component, have that component fire an event.
    • Global variables. If many components are reading and writing the same data, make it global (however you do that in your chosen language). For extra usefulness, combine the two approaches and let components listen for changes in the global data object.
    0 讨论(0)
  • 2021-02-08 12:49

    You should definitely look at Jeremy Miller's guide to rich client design. It is incomplete, but I believe he is writing a book on the subject.

    Another blog you should check out is Rich Newman's. He is writing about Composite Application Block which is a MS best practice guide on how to structure rich clients.

    You can also read this book which is only a very light read but gives you some good ideas.

    0 讨论(0)
  • 2021-02-08 12:53

    If you're using WPF, you might want to read the Composite Application Guideance for WPF.

    It discusses many of these topics (as well as many others). The main goal of that guideance is to make large scale applications in a flexible, maintainable manner.

    0 讨论(0)
提交回复
热议问题