The Only Correct Indent Style

本文通过一次投票调查了程序员中最受欢迎的代码缩进风格。展示了K&R、Allman、Whitesmith、GNU、Horstman、Pico和Banner等7种不同的代码缩进方式,并附上了投票结果。
部署运行你感兴趣的模型镜像

I know we discussed indent styles once before, but I figured we might as well do it again. This time, I figured we might as well make it a poll and see which of these styles appears to be the most popular one.

Since not everyone knows these styles by name, let me give you an example of each one to refresh your memory. Usually, most programmers only acknowledge one true indent style and consider all the other ones an unholy abomination unto God. So here are the styles to pick from:

K&R

if (x == y) {
    x++;
    foo();
} else {
    x--;
    bar();
}

Allman

if (x == y) 
{
    x++;
    foo();
} 
else 
{
    x--;
    bar();
}

Whitesmith

if (x == y) 
   {
   x++;
   foo();
   } 
else 
   {
   x--;
   bar();
   }

GNU

if (x == y) 
  {
     x++;
     foo();
  } 
else 
  {
     x--;
     bar();
  }

Horstman

if (x == y) 
{   x++;
    foo();
} 
else 
{   x--;
    bar();
}

Pico

if (x == y) {
    x++;
    foo(); } 
else {
    x--;
    bar(); }

Banner

if (x == y) {
    x++;
    foo(); 
    } 
else {
    x--;
    bar(); 
    }
The only correct indent style
Total Votes: 1619 Started: April 6, 2009

I actually prefer the Allman style. The braces should go underneath the opening block statement. I hate when the K&R people put them on the same line. All the other styles are just to bizarre.

How about you? Which style do you prefer?


====

http://www.terminally-incoherent.com/blog/2009/04/10/the-only-correct-indent-style/

您可能感兴趣的与本文相关的镜像

Llama Factory

Llama Factory

模型微调
LLama-Factory

LLaMA Factory 是一个简单易用且高效的大型语言模型(Large Language Model)训练与微调平台。通过 LLaMA Factory,可以在无需编写任何代码的前提下,在本地完成上百种预训练模型的微调

StringBuilder text = new StringBuilder(); text.append("<!DOCTYPE html>\n" + "<html lang=\"en\">\n" + "<head>\n" + " <meta charset=\"UTF-8\">\n" + " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n" + " <title>Dahua Firmware Upgrade Information</title>\n" + " <style>\n" + " body {\n" + " font-family: Arial, sans-serif;\n" + " line-height: 1.6;\n" + " max-width: 800px;\n" + " margin: 0 auto;\n" + " padding: 20px;\n" + " }\n" + " table {\n" + " border-collapse: collapse;\n" + " width: 100%;\n" + " margin: 20px 0;\n" + " }\n" + " table, th, td {\n" + " border: 1px solid #333;\n" + " }\n" + " th, td {\n" + " padding: 10px;\n" + " text-align: center;\n" + " }\n" + " th {\n" + " background-color: #f0f0f0;\n" + " font-weight: bold;\n" + " }\n" + " strong {\n" + " font-weight: bold;\n" + " }\n" + " .section {\n" + " margin: 20px 0;\n" + " }\n" + " ol, ul {\n" + " margin-left: 30px;\n" + " }\n" + " li {\n" + " margin: 5px 0;\n" + " }\n\n" + ".configtool-image {\n" + "display: block;\n" + "margin: 20px auto;\n" + "width: 13.2cm;\n" + "height: 7.67cm;\n" + "object-fit: contain;\n" + "border: 1px solid #ddd;\n" + "}" + " </style>\n" + "</head>\n" + "<body>\n" + " <div>\n" + " <h3>Dear Customer:</h3>\n" + " <p style = \"text-indent: 2em;\">Thank you for choosing Dahua products.</p>\n" + " <p style = \"text-indent: 2em;\">Attached to this email is the link of the Dahua product firmware. Please review the following terms carefully before deciding whether to download or proceed with the upgrade.</p>\n" + " <p style = \"text-indent: 2em;\">If you have any questions, please contact your local <strong>technical support</strong> or the Dahua customer service hotline at <a href=\"https://support.dahuasecurity.com/en/Support/Hotlines\">Service Hotlines - Support - Dahua Technology</a>.</p>\n" + " \n" + " <div>\n" + " <p><strong>Important Notice:</strong></p>\n" + " <ol>\n" + " <li><strong>When using video surveillance device, please strictly comply with all applicable laws and regulations.</strong> Any use of such device for illegal purposes, including infringing on others' privacy, is strictly prohibited.</li>\n" + " <li><strong>Do not power off the device during the firmware upgrade in process.</strong> Firmware upgrades is risky; please confirm firmware update is necessary before proceeding.</li>\n" + " <li><strong>After completing the device upgrading, certain parameters may be restored to default settings.</strong> It is recommended that you back up the device configuration prior to upgrading. The best practice before performing any firmware upgrade is to consult Dahua technical support team.</li>\n" + " <li><strong>When upgrading multiple devices of the same model, firmware version, and material number, it is recommended to first upgrade a single unit.</strong> Once the upgrade is successful, you may proceed with batch upgrades.</li>\n" + " </ol>\n" + " </div>\n" + " \n" + " <div class=\"section\">\n" + " <p><strong>I. Upgrade Firmware Information Link Which You Need</strong></p>\n" + " <table>\n" + " <tr>\n" + " <th>Applicable device serial number</th>\n" + " <th>Applicable device model</th>\n" + " <th>Your device's current version</th>\n" + " <th>The version of the firmware we provide</th>\n" + " <th>Firmware download link (valid for 3 days)</th>\n" + " <th>Remarks</th>\n" + " </tr>"); text.append(emailInfo); text.append("</table>\n" + " </div>\n" + " \n" + " <div class=\"section\">\n" + " <p><strong>II. Upgrade Method:</strong></p>\n" + " <p>Following is the firmware upgrade through the device's web interface (the image below is for reference only).</p>\n" + "<img src=\"https://supportfile-public.dahuasecurity.com/public_files/A9B8E631-533B-4209-97C7-2EDD9C90DE.png\" alt=\"ConfigTool Upgrade Interface\" class=\"configtool-image\">\n" + "<ol>\n" + " <li><strong>Upgrade remotely using the ConfigTool:</strong>\n" + " <ol>\n" + " <li>Double-click to open the ConfigTool.</li>\n" + " <li>In the menu bar, select \"Device Upgrade.\"</li>\n" + " <li>Click on the option corresponding to the device that needs to be upgraded and select the upgrade file. Select the firmware files whose names start with \"<strong>DH_NVR</strong>\" or \"<strong>DH_IPC</strong>\" etc.</li>\n" + " <li>Click \"Upgrade\" to begin upgrading the device.</li>\n" + " <li>After the upgrade is completed, the device will automatically restart. If the device is disconnected, the tool will automatically redo the upgrade.</li>\n" + " <li>If the message shows \"Upgrade Successful\", means the version of the device is successfully upgraded to the latest version firmware.</li>\n" + " <li>If prompted with \"Waiting to retry\", please wait for 1 to 2 minutes.</li>\n" + " <li>If prompted with \"Upgrade timeout\" or \"Upgrade failed\", means you need to search the device and upgrade do the again.</li>\n" + " </ol>\n" + " </li>\n" + " <li><strong>USB Drive upgrade at the recorder local GUI:</strong>\n" + " <ol>\n" + " <li>Connect the USB flash drive to the recorder's USB port. When the on-screen prompt <strong>\"USB device detected\"</strong> appears, select <strong>\"System Upgrade\"</strong> from the pop-up window.</li>\n" + " <li>In the System Upgrade interface, click the <strong>\"System Upgrade\"</strong> button.</li>\n" + " <li>In the file browser window, select the firmware file beginning with \"<strong>DH_NVR</strong>\", or similar prefixes, then click <strong>\"OK\"</strong> to begin the upgrade.</li>\n" + " </ol>\n" + " </li>\n" + " </ol>\n" + " </div>\n" + " \n" + " <div class=\"section\">\n" + " <p><strong>III. Frequently Asked Questions</strong></p>\n" + " \n" + " <ol>\n" + " <li><strong>Upgrade Failed</strong><br>\n" + " Firmware is typically provided as compressed files and must be extracted before use. Please ensure that the imported file is a BIN file. If an error still occurs after extraction, please verify if the serial number you entered to obtaining the firmware and download the firmware again.</li>\n" + " \n" + " <li><strong>Upgrade Progress Stuck</strong><br>\n" + " This issue is usually caused by using an incorrect firmware. If the correct firmware is used and the progress bar still does not move, it may be due to network issues at the site. In this case, it is recommended to connect directly to the device to perform the upgrade.</li>\n" + " \n" + " <li><strong>Device Fails to Boot After Upgrade</strong><br>\n" + " Some older devices require upgrading to an intermediate (transitional) firmware before upgrading to the latest version. If the device is upgraded directly to the latest version, it may fail to start. In such cases, please contact your local technical support, the Dahua technical support hotline or service center for assistance.</li>\n" + " </ol>\n" + " </div>\n" + " \n" + " <div class=\"section\">\n" + " <p><strong>IV. Disclaimer:</strong></p>\n" + " \n" + " <ol>\n" + " <li>By performing any action to install or configure this firmware, you acknowledge and accept all of the following terms. Your permission to download or use the firmware signifies that you fully understand and agree to these terms. If you do not agree with any part of the terms, you are not authorized to use this firmware and must immediately stop the installation and uninstall it.</li>\n" + " \n" + " <li>The firmware provided is intended only for designated regions and specific device models. Before upgrading or updating, please verify that the firmware is applicable to the correct region and device model.</li>\n" + " \n" + " <li>Zhejiang Dahua owns, or is legally authorized to use, all rights and intellectual property related to firmware, including any accompanying user guides, help materials, and documentation.</li>\n" + " \n" + " <li>Firmware upgrades are implemented to optimize product functionality and may include updates to the user interface. Such updates do not indicate any quality issues with the product.</li>\n" + " \n" + " <li>You must strictly comply with the \"User Notification for Dahua Device Firmware Download and Upgrade\" during the upgrade process. Failure to do so may result in consequences and repair costs for which you will be solely responsible.</li>\n" + " \n" + " <li>You are prohibited from engaging in the following activities. Any violation may result in legal liability for infringement, and you will bear all associated adverse consequences:\n" + " <ol>\n" + " <li>Copying firmware, except for reasonable and necessary copies made for internal backup purposes;</li>\n" + " <li>Bypassing the terms of this statement to use the firmware or transferring the firmware to any third party;</li>\n" + " <li>Modifying the firmware or creating derivative works based on it;</li>\n" + " <li>Reverse engineering, decompiling, or disassembling the firmware.</li>\n" + " </ol>\n" + " </li>\n" + " \n" + " <li>Firmware is provided solely for use by authorized users. Its structure, organization, and source code constitute valuable trade secrets and proprietary confidential information of Zhejiang Dahua and its licensors. You agree not to provide or disclose any such confidential information contained in or derived from the firmware to any third party.</li>\n" + " </ol>\n" + " </div>\n" + " \n" + " <div class=\"section\">\n" + " <p><strong>V. Contact us:</strong></p>\n" + " <p>If you have any questions regarding our products or services, please contact us via the local service hotline. For information on local hotline numbers, please refer to: <a href=\"https://support.dahuasecurity.com/en/Support/Hotlines\">Service Hotlines - Support - Dahua Technology</a>.</p>\n" + " </div>\n" + " </div>\n" + "</body>\n" + "</html>"); MailDTO mailDTO = new MailDTO(); mailDTO.setText(text.toString()); mailDTO.setFrom("SUPPORT"); mailDTO.setSubject("Package upgrade"); mailDTO.setTo(selectCheckPachageVO.getEmail()); try { log.error("邮件发送出现内容 : {}", JSON.toJSONString(mailDTO)); mailDTO.setFrom(springMailRecipients); MailUtils.sendHtmlMail(javaMailSender, mailDTO); } catch (Exception e) { log.error("邮件发送出现异常 异常信息为 : {}", com.alibaba.fastjson2.JSON.toJSONString(e)); throw new DTOCheckException("Email sending failed!"); }这段代码中的img标签中的图片打不开,帮我看下是什么问题,或者帮我换个方式
11-28
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值