当涉及到设计模式的使用时,我猜测有三种类型的商店.那些不知道模式的人如果碰到它们 - 这些通常更喜欢使用Ctrl-C/Ctrl-V方法进行代码重用.那些每天花费数小时搜索遗留代码的人希望实现一个更好的模式 - 这些通常花费更多的时间来重构简单程序的代码,而不是花费在百年维护中.最后,那些在有意义的时候使用模式走中间路径的人,以及为最低限度暴露的代码编写任何代码.
我想知道是否有人在软件开发生命周期中锁定了一种平衡的模式使用方法.此外,Web上最好的模式资源,激励因素和正确使用方式是什么?
谢谢.
我在以下代码中返回时收到此运行时检查失败.我相信类似的代码在程序的其他地方运行良好.有任何想法吗?
String GetVariableName(CString symbol, CString filepath)
{
char acLine[512];
char acPreviousLine[512];
CString csFile;
FILE *fp;
csFile.Format("%svariables.txt", filepath);
fp = fopen(csFile, "r");
if (! fp)
return("");
for (;;)
{
strcpy(acPreviousLine, acLine);
// NULL means we are out of lines in the file.
if (myfgets(acLine, 511, fp) == NULL)
break;
// "END" indicates end of file
if (! strcmp(acLine, "END"))
break;
if (! strcmp(acLine, csVarSymbol))
{
// Previous line should be variable name
fclose(fp);
// Following line results in Check Failure while …Run Code Online (Sandbox Code Playgroud)