我们正在尝试决定在Web应用程序中维护状态的最佳决策.我们倾向于在浏览器上使用加密的cookie,但是我们的一些开发人员认为我们应该在服务器上使用Session变量.
我认为Cookie是最佳方法的主要原因仅仅是因为我们不会在负载平衡方案中依赖应用服务器.
反对使用cookie的主要原因是处理cookie可能会很混乱.
你对这个话题有什么看法?
编辑1:
好.我从第一篇文章中看到,这两种方法都不是最好的.那么愿望的方法是什么呢?
在使用Repository模式时,我发现很难理解使用TDD技术设计软件的原因,而实际上您必须在持久性数据集中实现存储库的接口.
为了明确我的观点,我将提交一个例子:
我的域模型上有以下界面:
public interface IUserRepository
{
IQueryable<User> FindAllUsers();
void AddUser(User newUser);
User GetUserByID(int userID);
void Update(User userToUpdate);
}
Run Code Online (Sandbox Code Playgroud)
我有以下用于测试目的的接口实现:
public class FakeUserRepository : IUserRepository
{
private IList<User> _repository;
public FakeUserRepository()
{
_repository = new List<User>();
... //create all users for testing purposes
}
public IQueryable<User> FindAllUsers()
{
return _repository.AsQueryable<User>(); //returns all users
}
Run Code Online (Sandbox Code Playgroud)
现在我创建一些测试:
我的问题是,我测试所有这些与我FakeUserRepository实施后,我要回去和执行我的实际持久性数据集中IUserRepository(IG SQL),我不得不再次实现代码,所以我的单元测试是不实际检查我实际在我的应用程序上使用的代码.
也许我错过了什么.
一如既往地谢谢!
下面是我的Persistent数据访问存储库,它应该是一个应该被测试的存储库(至少在我看来),但是我不应该测试挂钩到数据库:
public class SQLUserRepository : IUserRepository
{
private BusinessDomainModel.EntityModel.BusinessHelperAccountDBEntities _repository;
public SQLUserRepository()
{
_repository = new BusinessHelperAccountDBEntities();
} …Run Code Online (Sandbox Code Playgroud) 我们的开发团队正在寻找一个类似于vi或nano的IDE,甚至是用于Windows的文本板,它具有自动完成和针对Linux的bash或shell脚本的错误纠正功能.基本上类似于.NET自动完成的地方,你可以看到一个
if[ $# -ne 5 ]; then
Run Code Online (Sandbox Code Playgroud)
在5和]之间没有空间会告诉你.
我希望这个问题简单易行.我已经看到RHE中的vi使用了一些着色,但在CentOS5中它没有显示不同的颜色.其中没有使用错误检测或自动完成.
你知道在哪里可以找到Lucene相似度算法的高级解释.我想理解它,而不必破译搜索和索引所涉及的所有数学和术语.
doGet()servlet中的一个非常简单的java代码在GAE上获得超过一秒的cpu时间.我已经阅读了一些与配额相关的文档,显然我没有做错任何事.
//Request the user Agent info
String userAgent = req.getHeader("User-Agent");
Run Code Online (Sandbox Code Playgroud)
我想知道最多使用CPU的是什么,我使用谷歌帮助推荐.
//The two lines below will get the CPU before requesting User-Agent Information
QuotaService qs = QuotaServiceFactory.getQuotaService();
long start = qs.getCpuTimeInMegaCycles();
//Request the user Agent info
String userAgent = req.getHeader("User-Agent");
//The three lines below will get the CPU after requesting User-Agent Information
// and informed it to the application log.
long end = qs.getCpuTimeInMegaCycles();
double cpuSeconds = qs.convertMegacyclesToCpuSeconds(end - start);
log.warning("CPU Seconds on geting User Agent: " + cpuSeconds);
Run Code Online (Sandbox Code Playgroud)
上面代码告诉我的唯一事情是检查标头将使用超过一秒(1000毫秒)的CPU时间,这对于Google来说是日志面板上的警告.这似乎是一个非常简单的请求,仍然使用超过一秒的CPU. …
如果您要开始为Web应用程序开发API.是否有任何类型的指南,最佳实践或标准来构建Web服务.我在这个主题中看到了一些讨论,我想获得更多信息.
至少可以获得有关获取信息的位置的指示.
提前致谢.
我想分析并记录我们的一个svn存储库.我正在寻找最好的工具,它将根据svn存储库的日志为每个版本号标签,分支等进行报告.是否有可用的免费/付费工具?
我正在使用DotNetOpenAuth在我们的Web应用程序中集成openID.以下代码向提供商请求信息.
try
{
var req = openid.CreateRequest(Request.Form["openid_identifier"]);
req.AddExtension(new DotNetOpenAuth.OpenId.Extensions.SimpleRegistration.ClaimsRequest
{
Email = DotNetOpenAuth.OpenId.Extensions.SimpleRegistration.DemandLevel.Require,
FullName = DotNetOpenAuth.OpenId.Extensions.SimpleRegistration.DemandLevel.Require,
Nickname = DotNetOpenAuth.OpenId.Extensions.SimpleRegistration.DemandLevel.Request,
PostalCode = DotNetOpenAuth.OpenId.Extensions.SimpleRegistration.DemandLevel.Request
});
return req.RedirectingResponse.AsActionResult();
}
Run Code Online (Sandbox Code Playgroud)
出于某种原因,来自openID提供商的响应永远不会附带我要求的信息.以下是代码:
// Stage 3: OpenID Provider sending assertion response
switch (response.Status) {
case AuthenticationStatus.Authenticated:
Session["FriendlyIdentifier"] = response.FriendlyIdentifierForDisplay;
FormsAuthentication.SetAuthCookie(response.ClaimedIdentifier, false);
if (!string.IsNullOrEmpty(returnUrl)) {
return Redirect(returnUrl);
} else {
return RedirectToAction("Index", "Home");
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试过:response.ClaimedIdentifier以百万种方式而且它从来没有我可以做的有价值的信息.有任何想法吗?
我已经使用依赖注入模式实现了名为DefaultController的mvc基本控制器,以便能够构建测试用例.示例如下:
public class DefaultController : Controller
{
protected readonly ISessionHelper _sessionHelper;
string _thisUserOpenID;
protected IUsersRepository _UserRepository;
...
public DefaultController()
{ } //not for testing
public DefaultController(ISessionHelper session, IUserRepository repo)
{
_sessionHelper=session;
_UserRepository = repo;
}
}
Run Code Online (Sandbox Code Playgroud)
然后我使用这个控制器,homecontroller,usercontroller等我的控制器.
现在,构建一些测试用例我发现自己处于一种我不知道如何实际使用注入依赖模式的情况.
[TestMethod]
public void Welcome_Message_In_ViewData_Has_Coockie_User_Display_Name()
{
// Below I want to insert FakeRepositories using
//ISessionHelper and so on. but the constructor
//for homecontroller don't have it.
HomeController controller = new HomeController();
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
这个问题可以带来很多意见,但我想得到的是一系列措施,这些措施将帮助我和我的公司确定我们销售的产品的寿命终结.
我们销售CMS系统,通过这个系统我们创建了一些子产品
我们已经准备好开始我们的道路规划(2010年和2011年),我们正在努力确定什么时候将结束我们的应用程序.你们中的一些人可能认为一个架构很好的应用程序(我不认为我们的应用程序设计得很好)不需要寿命结束,但我们使用的这个应用程序至少可以追溯到6 - 7年几乎没有文件(现实生活).此时只有一个人知道如何改变核心功能(可怕).
请指教,
地理
谢谢大家!我非常感谢您对此主题的评论,意见和想法.
我将在下面的列表中解决一些回复后的问题
我会在你读完所有回复的同时不断添加答案.