我们应该努力生成多少代码?

如果没有IntelliJ片段,Redux可能会令人讨厌

“男孩,如果我是 JavaScript的话 工程师 ,我不会写代码,我会整天写代码生成器……”

一个虔诚的家伙说。。。我的工作保护技巧上升了:“这个家伙显然不知道编写FE代码有多难!”,我大叫一声。 但是后来我退后一步想知道,我可以生成多少代码? 几个月后,这件事一直困扰着我……

所以我决定研究 能生成多少代码而不是编写代码?

这是我想出的(并完成了!):

代码生成类型:(根据我)

  1. 摘要生成器
  2. 子项目生成器
  3. 全项目生成器

-

摘要生成器

几乎在每个IDE中都可以找到的代码片段生成器是插入一小段代码的方法。 这是我在工作中使用的一些工具:

片段非常有用,特别是如果您学习如何快速制作和利用它们。 它们确实加快了您的开发时间。

子项目生成器

下一类是子项目生成器 ,它比代码片段更高,因为它们通常采用大型配置,并且可以生成要在现有项目中使用的独立代码段。

我发现的示例: https : //formbuilder.online/ —一个JQuery表单生成器

没有很多独立的“子项目”生成器,因为大多数生成到下一类…

-

全项目生成器

这些负责为您生成整个项目。

http://yeoman.io/-实际上会生成一个整个项目,然后经常为您提供组件生成器,例如角度控制器等。

https://jasonette.com/-一种将JSON对象转换为完整的本机应用程序的可爱方法。

这些对于“入门”来说是很棒的……但是其他任何东西都开始变得令人沮丧(例如JSONette)。

-

我尝试生成代码:“子项目Selenium生成器”

在完成所有这些研究之后,我得出结论: 如果代码生成非常重复或者您需要入门帮助,则仅尝试生成代码。

因此,在二月份,在我们的初创公司仪表板中加入了一系列新功能之后,我重新编写了Selenium代码。 我意识到这些东西是重复的…单击element,检查它是否存在,等等……

我写了一个称为Snaptest的chrome扩展工具,它输出一个Selenium测试文件夹。 然后将该文件夹添加到您现有的测试配置/设置中,并且可以更轻松地在该工具中进行维护和运行。

完成这种类型的代码生成后,我节省了数小时的时间。 因此,一个愚蠢的短语: “男孩,如果我是一名JavaScript工程师,我不会写代码,我会整天写代码生成器……”实际上确实有所帮助!

From: https://hackernoon.com/how-much-code-should-we-be-striving-to-generate-c4ac6b8f341

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,关于 Java 生成二维码的代码,你可以使用 zxing 库来实现。以下是一个简单的示例代码: ``` import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Map; import com.google.zxing.BarcodeFormat; import com.google.zxing.EncodeHintType; import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix; import com.google.zxing.qrcode.QRCodeWriter; import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; public class QRCodeGenerator { public static void main(String[] args) { String qrCodeData = "https://www.example.com"; String filePath = "qrcode.png"; int size = 250; String fileType = "png"; File qrFile = new File(filePath); try { createQRCode(qrFile, qrCodeData, size, fileType); System.out.println("QR Code generated successfully!"); } catch (WriterException | IOException e) { System.out.println("Error generating QR Code: " + e.getMessage()); } } private static void createQRCode(File qrFile, String qrCodeData, int size, String fileType) throws WriterException, IOException { // Create the QR code writer QRCodeWriter qrWriter = new QRCodeWriter(); // Set the encoding hint Map<EncodeHintType, Object> hints = new HashMap<>(); hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); // Generate the QR code matrix BitMatrix qrMatrix = qrWriter.encode(qrCodeData, BarcodeFormat.QR_CODE, size, size, hints); // Create the QR code image int matrixWidth = qrMatrix.getWidth(); int matrixHeight = qrMatrix.getHeight(); int[] pixels = new int[matrixWidth * matrixHeight]; for (int y = 0; y < matrixHeight; y++) { int offset = y * matrixWidth; for (int x = 0; x < matrixWidth; x++) { pixels[offset + x] = qrMatrix.get(x, y) ? 0xFF000000 : 0xFFFFFFFF; } } BufferedImage qrImage = new BufferedImage(matrixWidth, matrixHeight, BufferedImage.TYPE_INT_RGB); qrImage.setRGB(0, 0, matrixWidth, matrixHeight, pixels, 0, matrixWidth); // Write the QR code image to file ImageIO.write(qrImage, fileType, qrFile); } } ``` 这是一个基本的生成二维码的示例代码,你可以根据自己的需求进行适当的修改。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值