首页 \ 问答 \ 关于.net GUI应用程序结构的想法(Ideas for structure of .net GUI app)

关于.net GUI应用程序结构的想法(Ideas for structure of .net GUI app)

我正在寻找一个关于如何构建VB.net GUI应用程序的策略。 我有一个基本上是数据库接口的应用程序。 它由带有6个选项卡的TabControl组成,每个选项卡都有一些自定义控件,并对数据库执行业务操作。

标签功能:

  1. 将XLS解析为SQL插入并提交到db

  2. 从db查询结果生成XLS

  3. 从db查询结果生成XLS

  4. 从db快速访问数据查找(写入日志框)

  5. 通过GUI表单手动修改数据库(插入/更新语句执行)

  6. 数据库连接设置

通用代码功能:

  1. 连接/断开DB

  2. 执行非查询

  3. 执行查询

  4. 迭代查询结果

  5. 写入XLS

  6. 公共子查询(DB提供程序不允许查看)

目前,我已经将大部分操作内置到GUI线程上的事件处理函数中。 我想转向更面向对象的结构,以实现代码可重用性和更轻松的多线程。

我正在努力解决一些设计问题:

  1. 什么对象/类有意义?

  2. 是否有关于分离GUI和后端功能的行业标准最佳实践或设计模式? 我应该阅读哪些特别好的文章?

  3. 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:

  1. Parse an XLS into SQL inserts and commit to db

  2. Generate an XLS from db query results

  3. Generate an XLS from db query results

  4. Quick access data lookup from the db (write to log box)

  5. Manual database modification via GUI form (insert / update statement execution)

  6. DB connection settings

Common Code Functions:

  1. Connecting/disconnecting to/from the DB

  2. Executing non-queries

  3. Executing queries

  4. Iterating over query results

  5. Writing to an XLS

  6. 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:

  1. What objects / classes makes sense?

  2. Are there industry-standard best practices or design patterns around separating GUI and backend functionality? Any particularly good articles I should read?

  3. Is BackgroundWorker the best way to execute the backend functions?

Thanks-

Jonathan


原文:https://stackoverflow.com/questions/2035175
更新时间:2024-03-25 09:03

最满意答案

  1. coffeescript的@只是简写this.

所以你原来的js有:

if (input1.val().length <= 4 ...

你的咖啡因应该有

if   input1.val() <= 4 
  1. 如果你的原始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);

哪个看起来很对。


  1. coffeescript's @ is just shorthand for this.

So where your original js has:

if (input1.val().length <= 4 ...

your coffeescript should have

if   input1.val() <= 4 
  1. Where you have $(this) in your original js, you still need $(this) in your coffeescript. So

    or @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 ...
  • 您是否尝试过重写它以使用CoffeeScript为您提供的类功能? 我无法100%确定以下内容是否有效,但它可能是您开始的好地方。 class SeatReservation constructor: (@name, initialMeal) -> @meal = ko.observable initialMeal @formattedPrice = ko.computed => price = @meal().price; if price? p ...
  • 这是我认为应该是这样的: 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 ...
  • 由于我不知道咖啡,而且我不知道它支持哪些文字对象,所以我无法帮助。 然而,你想要什么,可以通过这个设置来实现(可以将其转换为模式行): :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 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。