我正在编写一个从小型到中型的clojure应用程序.我们目前正在使用导入模块
(ns foo (:use bar))
(fn-in-bar)
Run Code Online (Sandbox Code Playgroud)
但我认为切换到
(ns foo
(:require [bar :as b]))
(b/fn-in-bar)
Run Code Online (Sandbox Code Playgroud)
有助于清晰度和代码理解.这是一个做事的好方法吗?有没有更好的办法?
我发现UML对于记录OO系统的各个方面非常有用,特别是整体架构和序列图的类图,以说明特定的例程.我想为我的clojure应用程序做同样的事情.我目前对模型驱动开发不感兴趣,只是简单地介绍应用程序的工作方式.
UML是一种常见/合理的函数式编程建模方法吗?FP的UML有更好的替代方案吗?
我经常需要从servlet/restlet或其他任何东西动态生成内容,并且不知道提前的长度.如果客户端是浏览器,则进度条无法正常工作,因为我没有设置Content-Length标头.有没有办法设置估计的内容长度,所以进度条"或多或少"?
与此问题相关,提供静态内容的默认 servlet 的想法是跨 servlet 容器的标准(即使是事实上的),还是它的使用限制部署到 Tomcat / Jetty?
例如,1显示了获取默认调度程序的方法:
final RequestDispatcher rd = getServletContext().getNamedDispatcher("default");
Run Code Online (Sandbox Code Playgroud)
从快速搜索来看,这似乎也适用于 Jetty。这种技术在获取默认 servlet 方面的作用有多大?对于具有默认 servlet 的 servlet 容器,它是否始终是静态内容 servlet?
我听说过人们应该总是使用Iterator模式来控制循环,而不是抛出异常(这是在Python迭代器中完成的方式)或使用Sentinel模式,从而返回一个特殊的,哨兵值(通常null)表示迭代的结束.
最佳做法是否建议不要使用哨兵模式?如果是这样,为什么?(除了它不使用foreachJava 1.5中的语法).
编辑:代码示例1 - Sentinel模式
Reader r = ...;
for( int val = r.read(); val != -1; val = r.read()) {
doSomethingWith(val);
}
Run Code Online (Sandbox Code Playgroud)
代码示例2 - 迭代器模式
for(Iterator<Thing> it = getAnIterator() ; it.hasNext(); ) {
Thing t = it.next();
doSomethingWith(t);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试在使用的托管模式下运行的GWT应用程序上设置系统属性mvn gwt:run.从事物的外观来看,这个属性并没有被设定.在我pom.xml的插件配置是: -
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.2.0</version>
<executions>
<execution>
<configuration>
<module>com.foo</module>
</configuration>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<runTarget>index.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<systemProperties>
<property>
<name>configDir</name>
<value>${basedir}/local/staging</value>
</property>
</systemProperties>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud) java ×3
clojure ×2
servlets ×2
gwt ×1
http ×1
http-headers ×1
maven-2 ×1
modeling ×1
namespaces ×1
uml ×1