我在repl控制台中玩了很多代码,我该如何清除它?我想要一个新的,而不重新启动它.可以这样做吗?
Gateway和Service Activator作为消息端点(在企业集成模式方面)有什么区别?
说我在clojure中创建一个程序,我必须将它传递给客户端.客户端确实有一些计算机知识,但他不知道/想要启动repl,加载我的程序,然后运行它.他想双击exe文件或运行shell脚本
我如何打包我的程序并交付(程序本身与clojure罐)?
Clojure如何实现关注点分离?由于代码是数据,函数可以作为参数传递并用作返回...
并且,因为有这样的原则"更好的1000个函数可以在1个数据结构上工作,而不是100个函数在100个数据结构上"(或类似的东西).
我的意思是,将所有内容打包成地图,给它一个关键字作为关键字,就是这样吗?功能,标量,集合,一切......
通过Aspects(面向方面编程)和注释,在Java中实现了Separation of Concerns的概念.这是我对这个概念的看法,可能有些限制,所以不要把它视为理所当然.
什么是正确的方式(惯用的方式)在Clojure,以避免其他程序员的WTFs _
Clojure有什么原则吗?
一个.像Java这样的OO语言的SOLID面向对象设计原则?
湾 或者其他更具启发性的,比如"告诉不要问","赞成组合与继承","与接口交谈"?
是否有任何设计模式(灵活的代码)?
功能编程基础的对应部分是什么,比如面向对象的封装?
知道这些资源吗?
让我们尝试一些对"类型"函数的调用:
user=> (type 10)
java.lang.Integer
user=> (type 10.0)
java.lang.Double
user=> (type :keyword?)
clojure.lang.Keyword
Run Code Online (Sandbox Code Playgroud)
现在有一个匿名函数:
user=> (type #(str "wonder" "what" "this" "is"))
user$eval7$fn__8
Run Code Online (Sandbox Code Playgroud)
A)这意味着"user $ eval7 $ fn__8"是什么意思? B)什么类型的功能?
"类型"的来源是:
user=> (source type)
(defn type
"Returns the :type metadata of x, or its Class if none"
{:added "1.0"}
[x]
(or (:type (meta x)) (class x)))
nil
Run Code Online (Sandbox Code Playgroud)
所以函数需要具有元数据的特定部分或者是类
检查匿名函数的元产生nada:
user=> (meta #(str "wonder" "what" "this" "is"))
nil
Run Code Online (Sandbox Code Playgroud)
尝试不同的方法:
user=> (defn woot [] (str "wonder" "what" "this" "is"))
#'user/woot
user=> (meta …Run Code Online (Sandbox Code Playgroud) 这是测试:
import static junit.framework.Assert.assertTrue;
import static org.powermock.api.mockito.PowerMockito.mock;
import static org.powermock.api.mockito.PowerMockito.whenNew;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@PrepareForTest( {ClassUnderTesting.class} )
public class ClassUnderTestingTest {
@Test
public void shouldInitializeMocks() throws Exception {
CollaboratorToBeMocked mockedCollaborator = mock(CollaboratorToBeMocked.class);
suppress(constructor(CollaboratorToBeMocked.class, InjectedIntoCollaborator.class));
whenNew(CollaboratorToBeMocked.class)
.withArguments(InjectedAsTypeIntoCollaborator.class)
.thenReturn(mockedCollaborator);
new ClassUnderTesting().methodUnderTesting();
assertTrue(true);
}
}
Run Code Online (Sandbox Code Playgroud)
这些是类:
public class ClassUnderTesting {
public void methodUnderTesting() {
new CollaboratorToBeMocked(InjectedAsTypeIntoCollaborator.class);
}
}
public class CollaboratorToBeMocked {
public CollaboratorToBeMocked(Class<InjectedAsTypeIntoCollaborator> clazz) {
}
public CollaboratorToBeMocked(InjectedIntoCollaborator someCollaborator) {
}
public CollaboratorToBeMocked() {
}
}
public …Run Code Online (Sandbox Code Playgroud) 假设一个项目使用Spring并在XML中定义它的bean?它有一些bean在构造函数中接受Map.
通常,此映射被定义为bean下的属性,并在其下具有条目.
但如果参赛名单很大呢?它将使XML大量繁荣......
是否(地图)可以在XML文件中以某种方式定义,然后由需要它的bean进行重新引用?怎么样 ?