在文献(关于企业架构的博客,文章,书籍......)中,似乎EA中存在一个真实(且独有)的SOA设备.如果我们认为DDD和SOA共享共同的架构原则但在许多其他原则上有所不同,那么DDD在EA学科中的位置是什么?
architecture enterprise domain-driven-design architectural-patterns
我有一个问题可能不是专门针对实现而是提示/最佳实践的问题.
我正在研究Swift中的一个类,它以JSON格式从在线源获取数据.我希望在这个类中有特定的方法连接到在线源并以Dictionary类型返回结果.功能可能是这样的:
func getListFromOnline()->[String:String]{
var resultList : [String:String]=[:]
...
/*
Some HTTP request is sent to the online source with NSURLRequest
Then I parse the result and assign it to the resultList
*/
...
return resultList
}
Run Code Online (Sandbox Code Playgroud)
我在这个实现中得到的,没有多线程,resultList显然是在从在线源获取之前返回的.毫不奇怪,它会导致程序失败.
任何想法或提示如何实现相反的目标?我在这个实例中对多线程有点困惑,因为我想稍后从另一个类异步调用这个公共方法,我知道如何做到这一点,但是我不知道如何让返回参数的方法在多个内部进行多线程处理本身.
或者根本不是多线程,我在这里没有看到明显的解决方案?
谁能描述一下设计模式、架构模式、架构风格和架构之间的区别?提前致谢。
我读过一些关于在 Android 中使用 MVP 模式的文章。对我来说最好的方法是创建合同(每个模型、视图和演示者一个界面)。问题是我是否应该为每个 Activity 创建这样的合同,或者如果我的应用程序中有几个 Activity,如何实现它。谢谢
在我的代码中,我有许多带有此签名的函数(params + return类型),它们都使用同一个try-catch子句.
public ActionResult methodName(int id)
{
try
{
//Some specific code here
return new HttpStatusCodeResult(HttpStatusCode.OK);
}
catch (Exception ex)
{
return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message);
}
}
Run Code Online (Sandbox Code Playgroud)
现在,这是一遍又一遍地复制,我知道复制很糟糕.发生这种情况的原因是因为我希望代码能够返回多个HttpStatusCodeResult但我不知道更好的方法.
在此示例中,我返回内部服务器错误和正常答案.但是,如果我想返回另一种类型的错误怎么办?
public ActionResult methodName(int id)
{
try
{
//Some specific code here
if(conditionA)
return return new HttpStatusCodeResult(HttpStatusCode.NotFound, "No Hamsters found!")
return new HttpStatusCodeResult(HttpStatusCode.OK);
}
catch (Exception ex)
{
return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message);
}
}
Run Code Online (Sandbox Code Playgroud)
在我的代码中是否有一种模块化的行为方式,没有复制?我可以使用设计或建筑模式吗?如果是这样,哪一个?
c# design-patterns exception-handling architectural-patterns