开发者

Managing Form's code in VB.net

开发者 https://www.devze.com 2023-04-07 13:41 出处:网络
Whats the best way to organize code responsible for Form\'s content. In my case, there is a DataGridView and list, next to it, with a few options available (projects, managers, employees, etc...). Ch

Whats the best way to organize code responsible for Form's content.

In my case, there is a DataGridView and list, next to it, with a few options available (projects, managers, employees, etc...). Choosing any list's element fills DataGrid with proper data from database.

Now, GridFill functions + handling of all add/delete/edit buttons of each list element gives quite a code in the Form's source, which bothers me a bit.

How to split it then to avoid problems in the future? While googling, I've seen some advices to use partial classes, modules or just classes. Moving all functions relating the Projects, Managers, ... , to own separate class sounds like a nice idea but then comes the question how to pass all necessary data to the class functions. Is passing the reference of the whole form a go开发者_如何学JAVAod idea?


If you're using Winforms, take a look at the MVP (Model, View, Presenter) pattern, which helps separate code related to data, business logic and user interface. This question could also help as the answers provide quite a few interesting links on the subject.

0

精彩评论

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

关注公众号