关于.net GUI应用程序结构的想法(Ideas for structure of .net GUI app)
我正在寻找一个关于如何构建VB.net GUI应用程序的策略。 我有一个基本上是数据库接口的应用程序。 它由带有6个选项卡的TabControl组成,每个选项卡都有一些自定义控件,并对数据库执行业务操作。
标签功能:
将XLS解析为SQL插入并提交到db
从db查询结果生成XLS
从db查询结果生成XLS
从db快速访问数据查找(写入日志框)
通过GUI表单手动修改数据库(插入/更新语句执行)
数据库连接设置
通用代码功能:
连接/断开DB
执行非查询
执行查询
迭代查询结果
写入XLS
公共子查询(DB提供程序不允许查看)
目前,我已经将大部分操作内置到GUI线程上的事件处理函数中。 我想转向更面向对象的结构,以实现代码可重用性和更轻松的多线程。
我正在努力解决一些设计问题:
什么对象/类有意义?
是否有关于分离GUI和后端功能的行业标准最佳实践或设计模式? 我应该阅读哪些特别好的文章?
BackgroundWorker是执行后端功能的最佳方式吗?
谢谢-
乔纳森
I'm looking for a strategy on how to structure a VB.net GUI app. I have a application that is basically an interface to a database. It is comprised of a TabControl with 6 tabs, each tab has a few custom controls and performs a business operation on the database.
Tab Functions:
Parse an XLS into SQL inserts and commit to db
Generate an XLS from db query results
Generate an XLS from db query results
Quick access data lookup from the db (write to log box)
Manual database modification via GUI form (insert / update statement execution)
DB connection settings
Common Code Functions:
Connecting/disconnecting to/from the DB
Executing non-queries
Executing queries
Iterating over query results
Writing to an XLS
Common subqueries (DB provider doesn't allow views)
Currently I've got most all of the operations built into event handler functions on the GUI thread. I'd like to move to a more object-oriented structure for code reusability and easier multi-threading.
I'm struggling with a few design things:
What objects / classes makes sense?
Are there industry-standard best practices or design patterns around separating GUI and backend functionality? Any particularly good articles I should read?
Is BackgroundWorker the best way to execute the backend functions?
Thanks-
Jonathan
原文:https://stackoverflow.com/questions/2035175
最满意答案
- coffeescript的
@
只是简写this.
所以你原来的js有:
if (input1.val().length <= 4 ...
你的咖啡因应该有
if input1.val() <= 4
如果你的原始js中有
$(this)
,你的coffeescript中仍然需要$(this)
。 所以或@ input1.map( - > this.val()。match(/ \ s + / g))。length not 0
应该:
or @input1.map(-> $(this).val().match(/\s+/g)).length not 0
我无法随意看到任何其他问题 - 尝试一下,让我们看看它是否有效,或者是否还有错误。
[编辑]
还有其他问题,很大程度上与
not 0
,也包括在内。 这是一个有效的(我认为)coffeescript:if input1.val() <= 4 \ or (input1.map(-> $(this).val().match(/\s+/g)).length != 0) \ or (input1.map(-> $(this).val().match(/[^A-Za-z0-9]/g)).length != 0) then input1.attr('id','error-highlight'); else input1.attr('id','success-highlight');
它成为了:
(function() { if (input1.val() <= 4 || (input1.map(function() { return $(this).val().match(/\s+/g); }).length !== 0) || (input1.map(function() { return $(this).val().match(/[^A-Za-z0-9]/g); }).length !== 0)) { input1.attr('id', 'error-highlight'); } else { input1.attr('id', 'success-highlight'); } }).call(this);
哪个看起来很对。
- coffeescript's
@
is just shorthand forthis.
So where your original js has:
if (input1.val().length <= 4 ...
your coffeescript should have
if input1.val() <= 4
Where you have
$(this)
in your original js, you still need$(this)
in your coffeescript. Soor @input1.map(-> this.val().match(/\s+/g)).length not 0
should be:
or @input1.map(-> $(this).val().match(/\s+/g)).length not 0
I can't offhand see any other issues - try it and let's see if that gets it working, or if there are still errors.
[Edit]
There were other issues, largely related as mentioned to the
not 0
and also to bracketing. Here's a working (I think) coffeescript:if input1.val() <= 4 \ or (input1.map(-> $(this).val().match(/\s+/g)).length != 0) \ or (input1.map(-> $(this).val().match(/[^A-Za-z0-9]/g)).length != 0) then input1.attr('id','error-highlight'); else input1.attr('id','success-highlight');
It becomes:
(function() { if (input1.val() <= 4 || (input1.map(function() { return $(this).val().match(/\s+/g); }).length !== 0) || (input1.map(function() { return $(this).val().match(/[^A-Za-z0-9]/g); }).length !== 0)) { input1.attr('id', 'error-highlight'); } else { input1.attr('id', 'success-highlight'); } }).call(this);
Which looks about right.
相关问答
更多-
$.ajax没有done选项。 有一个complete选择 在请求完成时调用(执行成功和错误回调之后)。 所以也许你的意思是: jQuery.ajax( #... complete: => @ajaxdone() ) 代替。 在jqXHR上有一个done方法,所以你可以说: jQuery.ajax( #... ).done => @ajaxdone() 但done是“ success回调选项的替代构造”,因此如果出现错误则不会调用它。 如果你想让ajaxdone始终被调用,那么使用alway ...
-
标准CoffeeScript-Compiler在CoffeeSCript中实现。 所以它需要在一些JavaScript环境下运行。 但是有一个JCOffeeSCript-Implementation: Java库将coffeescript转换为javascript或编译的java可执行文件? 那可以做你想要的。 但我建议在交付之前在构建包装过程中将CoffeeScript编译为JavaScript,如果这是一个选项。 这将为您的客户带来更简单的安装过程,您不必运送任何编译器和构建脚本。 The stdand ...
-
Coffescript编译错误(Coffescript wrong compilation)[2022-05-31]
您是否尝试过重写它以使用CoffeeScript为您提供的类功能? 我无法100%确定以下内容是否有效,但它可能是您开始的好地方。 class SeatReservation constructor: (@name, initialMeal) -> @meal = ko.observable initialMeal @formattedPrice = ko.computed => price = @meal().price; if price? p ... -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
这是我认为应该是这样的: Meteor.users.deny({ update: () => true; }); deny是一个接收对象作为参数的函数。 您的代码集deny新功能。 This is what I believe it should look like: Meteor.users.deny({ update: () => true; }); deny is a function that receives an object as a parameter. Your code se ...
-
coffescript自定义折叠(coffescript custom folding)[2022-03-30]
由于我不知道咖啡,而且我不知道它支持哪些文字对象,所以我无法帮助。 然而,你想要什么,可以通过这个设置来实现(可以将其转换为模式行): :setl fdm=expr fde=getline(v:lnum)=~'->$'?'>1':getline(v:lnum)=~'^\\s*$'?0:'=' 你没有指定要在折叠上显示的内容,所以我将其忽略了。 你可以使用foldtext设置。 请参阅:h fold-foldtext 。 As I don't know cofee, and I don't know wha ... -
是的,这是正确的..但是在性能方面,最好使用文档中可用的静态父元素,然后使用文档本身。 $(document) .on('click', '#employee-select',function(){ //<--- replace document with closest static parentelement if (!$('#employee-search-panel').is(':visible')) employeeLiveSearch() $('#employee-s ...
-
coffeescript的@只是简写this. 所以你原来的js有: if (input1.val().length <= 4 ... 你的咖啡因应该有 if input1.val() <= 4 如果你的原始js中有$(this) ,你的coffeescript中仍然需要$(this) 。 所以 或@ input1.map( - > this.val()。match(/ \ s + / g))。length not 0 应该: or @input1.map(-> $(this).val().m ...
-
感谢Infinity和新的控制台错误输入,我注意到了 jsRoutes.controllers.Questions.create.ajax 一定是 jsRoutes.controllers.Questions.create().ajax Thanks to Infinity and the new console error input I noticed that jsRoutes.controllers.Questions.create.ajax must be jsRoutes.controll ...
-
尝试: v for k,v of tablesDict when k isnt 'notifications_table' 过滤CoffeeScript 文档中的示例: # Health conscious meal. foods = ['broccoli', 'spinach', 'chocolate'] eat food for food in foods when food isnt 'chocolate' Try: v for k,v of tablesDict when k isnt 'not ...