需要使我的代码对团队中的其他程序员更具可读性
我正在delphi中工作一个项目,并且正在为该应用程序创建安装程序,主要包括三个部分。 PostgreSQL安装/卸载 myapplication(使用nsi创建myapplication的安装程序)安装/卸载。 通过脚本(批处理文件)在Postgres中创建表。 一切正常运行,但是如果出现故障,我创建了一个LogToFileger,它将在过程的每个步骤中记录LogToFile, 如下所示 LogToFileToFile.LogToFile('[DatabaseInstallation] : [ACTION]:Postgres installation started'); 函数LogToFileToFile.LogToFile()This将内容写入文件。这工作得很好,但是问题是这使代码混乱了,因为它变得很难读取代码,因为一个ca只能LogToFileToFile.LogToFile()在代码中到处看到函数调用。 一个例子 if Not FileExists(SystemDrive+'\FileName.txt') then begin if CopyFile(PChar(FilePathBase+'FileName.txt'), PChar(SystemDrive+'\FileName.txt'), False) then LogToFileToFile.LogToFile('[DatabaseInstallation] : copying FileName.txt to '+SystemDrive+'\ done') else LogToFileToFile.LogToFile('[DatabaseInstallation] : copying FileName.txt to '+SystemDrive+'\ Failed'); end; if Not FileExists(SystemDrive+'\SecondFileName.txt') then begin if CopyFile(PChar(FilePathBase+'SecondFileName.txt'), PChar('c:\SecondFileName.txt'), False) then LogToFileToFile.LogToFile('[DatabaseInstallation] …