首页 \ 问答 \ 没有依赖注入的DOA模式(DOA pattern without dependency injection)

没有依赖注入的DOA模式(DOA pattern without dependency injection)

在我们公司,我们几乎在每个项目中都使用DAO模式。 这有一些优点和缺点,但问题不在于此。 我们刚刚启动了另一个项目,但与其他项目相比,它非常简单,并且不是基于DI框架。 只是一个在云上运行的简单servlet。

我的问题是:当DI不可用时如何实现DAO模式。 如何在以后模拟DAO? 他们必须在某个服务类内部初始化。 在测试期间使用反射并用模拟替换真正的DAO是一个好习惯吗? 另一种观点是使用factoryDAO ..但如何使用工厂返回模拟对象?


In our company we use DAO pattern in almost every project. This has some pros and cons but the question is not about that. We just started another project but in comparison with the others it is very simple and is not based on a DI framework. Just a simple servlet run on a cloud.

My question is: How to implement DAO pattern when DI is not available. How to mock DAOs later? They have to initialized somewhere probably inside a service class. Is it a good practice to use reflection during the tests and replace real DAOs with mocks? Another view is to use factoryDAO .. but how to use factory to return mock objects?


原文:
更新时间:2022-03-12 15:03

最满意答案

这是React Native 0.14中修复的错误。 升级或者挑选这个提交


This is a bug fixed in React Native 0.14. Upgrade or cherry pick this commit.

相关问答

更多
  • 使用波纹管代码并按照下面的说明操作 CATransition *navTransition = [CATransition animation]; navTransition.duration = 0.65; navTransition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; [navTransition se ...
  • 定义两个具有两种背景的不同Div:
    将一个css设置 ...
  • 你需要使用if (...) {...} else if (...) {...}模式而不是2 if blocks。 例如,当前在您的代码中,如果cas === 1则 第一个if块将cas更改为2 。 第二个if的条件是cus === 2; // true cus === 2; // true 调用进入第二个if块 第二个if块会覆盖第一个块所做的更改 因此,您的颜色没有明显变化。 if (cas === 1) { blocus.style.color = "rgb(58, 83, 155)"; ...
  • 迷你效果插件在这里应该更简单 - 如果从UI效果库(除了那些其他必需品,“悸动”,“摇晃”和“bob”)这些都是你需要的,那么这个插件应该更加简单明显。 简单易用 - 只需加载你需要的迷你效果插件,然后在你想闪烁的元素上调用blink()。 然后,在一些大的鲜艳资源上调用blink(): $(".selector"). ...
  • 你的问题是,当调用Blink2()时,它会查找一个在那段时间内没有创建的对象“text”。 因此,您应首先检查是否存在名为“text”的对象。 这是你的新blink2()函数: function Blink2() if text ~= nil then if (text.alpha > 0) then transition.to(text, {time=1500, alpha=0}) else transition.to ...
  • 试试以下代码: - private void loadingAmin(final TextView loading) { final Animation pokeLoadingAnim = new Animation() { int step = 0; @Override protected void applyTransformation(floa ...
  • 回答了我自己的问题,回答了展望未来的人们。 SystemInformation.CaretBlinkTime Answered my own question, answer for people looking in the future. SystemInformation.CaretBlinkTime
  • 您可以尝试更改media / red.png以获取“闪烁”的media / red.gif,如果它不起作用,请将marker.optimized更改为false :(代码来自.gif标记google maps answer) var marker = new google.maps.Marker({ position: latLng, map: map, icon: iconoMarca, optimized: false }); 看起来像: var icons=["m ...
  • 如果有更好的方法来使用这个方法完成而不使用SetActive(false)而不是 是的,除了使用SetActive功能之外,还有更好的方法。 您应该将GameObject的alpha color从0前后更改为1 。 之后,您可以使用SetActive禁用GameObject。 这样可以节省重复调用SetActive函数时生成的垃圾量。 如果这是3D GameObject,请将渲染模式从不透明(默认)更改为淡入淡出或透明 。 一个简单的功能,可以做到这一点: void blink(GameObject obj ...
  • 这是React Native 0.14中修复的错误。 升级或者挑选这个提交 。 This is a bug fixed in React Native 0.14. Upgrade or cherry pick this commit.

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)