如果我们使用短语"MVC,MVP和MVVM设计模式之间有什么区别"来搜索Google,那么我们可能会得到一些URL ,它们在理论上讨论了MVC MVP和MVVM设计模式之间的区别:
MVP
在无法通过datacontext进行绑定的情况下使用.Windows Forms就是一个很好的例子.为了将视图与模型分开,需要演示者.由于视图无法直接绑定到演示者,因此必须通过接口(IView)将信息传递给视图.
MVVM
在可以通过datacontext进行绑定的情况下使用.为什么?删除了每个视图的各种IView接口,这意味着需要维护的代码更少.可以使用MVVM的一些示例包括使用Knockout的WPF和javascript项目.
MVC
用于视图与程序其余部分之间的连接并不总是可用的情况(并且您无法有效地使用MVVM或MVP).这清楚地描述了Web API与发送到客户端浏览器的数据分离的情况.Microsoft的ASP.NET MVC是一个管理这种情况的好工具,并提供了一个非常清晰的MVC框架
但我没有找到一篇文章,从理论上和示例代码讨论差异.
如果我得到一篇文章讨论这3种设计模式(MVC,MVP和MVVM)与代码之间的区别,那将是非常好的.
我想了解3个类似的CRUD应用程序的源代码,这些应用程序已经通过这三种设计模式(MVC,MVP和MVVM)实现.这样我就可以浏览代码并理解应该如何为这三种设计模式(MVC,MVP和MVVM)编写代码.
因此,如果存在任何此类文章讨论代码对于这3种设计模式(MVC,MVP和MVVM)的外观有何不同,那么请将我重定向到该文章.
看起来这两个宝石都执行非常相似的任务.任何人都可以举例说明一个宝石比另一宝石更有用吗?我没有具体的代码,我更想知道每个gem的一般用例.我知道这是一个简短的问题,我会根据要求填写空白.谢谢.
我在下面编写了简单的Java脚本,以便更多地了解TDD,IntelliJ和Java本身.
import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.both;
public class JUnit_Dummy {
private StringJoiner joiner;
private List<String> strings;
@Before
public void setUp() throws Exception {
strings = new ArrayList<String>();
joiner = new StringJoiner();
}
....
@Test
public void shouldContainBothStringsWhenListIsTwoStrings() {
strings.add("one");
strings.add("two");
assertThat(joiner.join(strings),
both(containsString("A")).
and(containsString("B")));
}
}
_____________
import java.util.List;
public class StringJoiner {
public String join(List<String> strings) {
if(strings.size() > 0) {
return (strings.get(0);
}
return …
Run Code Online (Sandbox Code Playgroud) TL;DR:假设我已经尝试了之前建议的解决方案(例如安装某些扩展)但似乎没有任何效果,如何在 VS Code 中运行我的 Jupyter notbook?
\n我有以下空白 .ipynb 文件:
\n\n我已经安装了 Microsoft 的 Jupyter 和 Python 扩展:
\n\n我通过命令选项板创建了上面屏幕截图 #1 中的文件Jupyter > Create New Blank Notebook
。我们看到一个单元格已从纯文本更改为 Python。我在编辑器中没有看到“运行”按钮,就像在VS Code + Jupyter 文档中看到的那样。我按 Shift-Enter 运行该单元,但系统没有提示我“为 Untitled-1.ipynb 选择内核”,而不是预期的输出:
我尝试输入我对它们所指的内核的最佳猜测(我在终端中使用 Python 3.9.5),但输入类似 和 的内容3.9.5
,Python
认为我可能会看到一个自动完成帮助程序或包含有效选项的下拉菜单可供选择,但这并没有发生。
“重新启动”和“中断”按钮呈灰色且禁用,这意味着 Jupyter 服务器未运行。然而,文档暗示我应该能够创建一个新的 Jupyter 笔记本并立即开始运行代码:
\n\n这里\xe2\x80\x99介绍了如何在 VS Code 中开始使用 Jupyter。
\n\n
- 如果\xe2\x80\x99t 已有 Jupyter Notebook 文件,请使用快捷键 CTRL + …
我现在正在阅读一些开源代码,我在这个 C 头文件的顶部看到以下代码行:
#ifndef __BASH_H__
#define __BASH_H__
Run Code Online (Sandbox Code Playgroud)
我没有__BASH_H__
在代码库的其他任何地方看到引用,所以我怀疑它是间接使用的(即由 shell、C 编译器或第三方库),而不是由代码本身使用。
我在谷歌上搜索了“ BASH_H ”,我看到它被其他开源库使用(即这里和这里),所以我假设我的假设方向是正确的。
然而,Google 搜索结果不包含任何关于此声明、其目的、用途等的官方文档。我只看到总共 2 页的搜索结果,其中大部分看起来无关紧要。
我假设它在某种程度上与 相关bash
,但我对缺乏官方文档感到困惑。有人能指出我正确的方向吗?
我尝试启动此服务,但是我不能,出现以下错误:
root@zabbix:/home/appliance# systemctl status nginx.service
nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2018-07-25 18:33:26 UTC; 1min 27s ago
Process: 30040 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Process: 30037 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Jul 25 18:33:25 zabbix nginx[30040]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98: Address already in use)
Jul 25 18:33:25 zabbix …
Run Code Online (Sandbox Code Playgroud) 我在命令行中启动了R并键入以下内容:
install.packages("XML")
Run Code Online (Sandbox Code Playgroud)
选择镜像站点后,我看到以下输出:
trying URL 'https://cloud.r-project.org/src/contrib/XML_3.98-1.4.tar.gz'
Content type 'application/x-gzip' length 1599214 bytes (1.5 MB)
==================================================
downloaded 1.5 MB
* installing *source* package ‘XML’ ...
** package ‘XML’ successfully unpacked and MD5 sums checked
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C …
Run Code Online (Sandbox Code Playgroud) 当我构建我的带有Safari扩展的macOS应用程序(我在Safari上运行)时,它会在运行几秒后崩溃(尽管它确实显示在扩展中).
这似乎是Safari尝试从本地Library文件夹获取数据的问题.它似乎也很难与Info.plist斗争.
这是崩溃日志:
2018-08-02 17:33:47.464379+0200 Safari[14693:1179568] [default] Unable to load Info.plist exceptions (eGPUOverrides)
2018-08-02 17:33:47.487993+0200 Safari[14693:1179565] [SQLiteStore] Failed to acquire database store coordination lock at /Users/lukasmuller/Library/Safari/Favicon Cache/favicons.db-lock: [35: Resource temporarily unavailable]
2018-08-02 17:33:47.488150+0200 Safari[14693:1179565] [SQLiteStore] Failed to acquire exclusive access to database at file:///Users/lukasmuller/Library/Safari/Favicon%20Cache/favicons.db.
2018-08-02 17:33:47.488580+0200 Safari[14693:1179565] [SQLiteStore] Failed to acquire database store coordination lock at /Users/lukasmuller/Library/Safari/Favicon Cache/favicons.db-lock: [35: Resource temporarily unavailable]
2018-08-02 17:33:47.488615+0200 Safari[14693:1179565] [SQLiteStore] Failed to acquire exclusive access to database at file:///Users/lukasmuller/Library/Safari/Favicon%20Cache/favicons.db.
2018-08-02 …
Run Code Online (Sandbox Code Playgroud) 我编写了以下代码,这不会导致我的浏览器中的AJAX调用:
$(document).ready(function () {
$('form').submit(function(event) {
event.preventDefault();
var action = $(this).attr('action');
var data = $(this).serialize();
$.post(action, data, function(response) {
$("#die").html(response);
});
});
});
Run Code Online (Sandbox Code Playgroud)
但是,我的教师在课堂上对以下代码进行了实时编码,这确实有效:
$(document).ready(function () {
$("form").on("submit", function(event) {
event.preventDefault();
var action = $(this).attr("action");
var formData = $(this).serialize();
$.post(action, formData, function(responseContent) {
$("#die").html(responseContent);
});
});
});
Run Code Online (Sandbox Code Playgroud)
据我所知,我的代码之间的唯一有意义的区别是他的"上"与使用的第2行其实"提交",就api.jquery.com/submit,jQuery的基金会规定"此方法是.on('submit',handler)..."的快捷方式.这让我感到困惑的是为什么这两个片段表现不同.