第42章:AI代码生成的质量标准——何时用AI、何时自己写

AI+Web3-从Solidity智能合约到AI Agent
专栏收录该内容
¥15.90
¥99.00
187 篇文章

本章你将收获

  • AI代码生成的质量分级标准:可用、稳定、安全、优雅
  • 一个决策矩阵:什么场景适合用AI,什么场景必须人工编写
  • 如何评估AI生成的代码质量(复杂度、可读性、安全性)
  • 实战对比:同一需求下AI生成代码 vs 人工编写代码
  • 团队落地:将质量标准集成到Code Review和CI流程
  • 我如何将团队AI代码接受率从70%提升到90%

42.1 一次让我对AI代码质量进行“分级”的经历

去年我们团队全面引入AI辅助编程后,代码生成速度上去了,但质量参差不齐。有的AI生成的代码几乎可以直接上线,有的却暗藏严重的性能问题或安全漏洞。更糟糕的是,一些年轻开发者产生了“AI写的代码就是对的”错觉,极少review直接合并。有一次,AI生成的一个订单处理逻辑,在并发场景下会导致数据错乱,差点造成生产事故。

我意识到:不能笼统地说“AI代码好用”或“AI代码不靠谱”,而要建立一个质量分级标准,根据不同的场景和风险等级,决定是否使用AI生成,以及如何使用。经过半年的实践,我们总结出了一套AI代码质量标准,并应用到日常开发中。从那以后,AI生成代码的接受率(无需修改直接使用)从70%提升到90%,安全事故降为零。

这一章,我会分享这套质量标准,以及如何在实际工作中判断“何时用AI、何时自己写”。


42.2

VIP AI编程分层模型:让代码生成从碰运气变成可控工程 分层架构是软件工程中管理复杂度的核心思想,它将系统拆解为职责清晰的模块,从而提升可维护性与可扩展性。在AI辅助开发领域,这一原理同样适用——当AI编程工具生成代码时,若缺乏分层约束,往往会导致上下文混乱、错误难以定位。通过引入意图、规划、上下文、执行、验证、反馈六层模型,开发者能够将提示词编写、代码生成、测试反馈等环节标准化,使AI编程从“碰运气”转变为可管理的工程行为。该模型适用于从个人项目到团队协作的多种场景,尤其适合处理复杂业务逻辑与长期迭代的代码库。本文结合真实项目案例,详细拆解每一层的实践方法,帮 开通可读全文·348 阅读·8 点赞·5 收藏 阅读全文

相关推荐

AI辅助软件度量阈值设定:个性化质量标准

在当今软件行业快速发展的背景下,软件的规模和复杂度不断增加,软件质量评估变得尤为重要。传统的软件度量阈值设定往往采用统一的标准,难以适应不同软件项目的个性化需求。本研究的目的是探索如何利用AI技术辅助软件度量阈值的设定,以实现个性化的软件质量标准。本研究的范围涵盖了从软件度量指标的选择到阈值设定的整个过程,涉及多种机器学习算法和数据分析方法。通过对实际软件项目数据的分析和处理,验证AI辅助阈值设定的有效性和可行性。本文共分为十个部分。第一部分为背景介绍,阐述了研究的目的、范围、预期读者和文档结构。

AI 领航者的博客 843

元编程技术:使AI Agent具备代码生成能力

7.1 最佳实践代码生成AI Agent设计与应用的最佳实践元编程技术在实际项目中的应用经验7.2 注意事项设计与使用代码生成AI Agent的注意事项元编程技术在AI Agent代码生成中的挑战7.3 拓展阅读相关领域的研究动态推荐阅读资料与进一步学习途径定义与分类AI Agent,即人工智能代理,是一种能够自主执行任务、与环境交互并采取行动的智能实体。任务型AI Agent:这类AI Agent专注于完成特定任务,如机器翻译、图像识别等。

AGI×大数据,开启智能时代的认知跃迁;解码AGI,赋能数据驱动的智能革命。 1042

4、AI-PACK:教师人工智能能力框架解析

本文介绍了AI-PACK教师人工智能能力框架,涵盖AI-K、AI-PK、AI-CK和AI-PCK四个核心领域,系统解析了教师在技术、教学、学科及跨学科层面应具备的人工智能能力。同时提出便携式人工智能学习实验室的设计与意义,旨在通过实践性学习活动提升学生对AI的理解与批判性思维,推动人工智能教育的发展与创新。

echo99的专栏 487

GAMES101学习-第8课进行shader的初步了解

详细理解课上展示的像素着色器GLSL,以及了解了API、OpenGL、DirectX到底是什么,还有shadertoy这个网站的初步探索。

qq_41835314的博客 1913

编译原理(东南大学)一:【编译原理期末冲刺救命笔记】速存!看完再上考场稳了!

本文详细介绍了编译原理的核心概念和流程,包括程序设计语言的分类、编译程序的各个阶段(如词法分析、语法分析、语义分析、中间代码生成、优化和目标代码生成)以及编译程序生成和构造的基础知识。文章还探讨了编译中的表格管理、出错处理和遍的概念,以及编译基础知识如高级语言、语法规则、字母表和符号串的运算。此外,文中还涉及文法与语言的关系,包括文法的概念、非终结符、终结符、产生式、推导和规约等。整体内容旨在为学习编译原理的学生提供全面的复习资料和考试准备指南。

一位搞嵌入式和前端的genius的博客 1020

LVGL按键触发回调函数的完整流程

如果是我的话我会怎么写:例如按键,我先定义一个结构体里面包含ID,事件名等和回调函数的链表节点结构体里面有具体函数的指针,也有指向下一个回调函数的链表节点的指针,初始化一个结构体变量的,通过BSP层来驱动触摸屏幕,再通过中间层与被按下时就会判断是长按还是短按还是其他,改变变量的事件例如:改成长按,生成事件包后再注册你长按的回调函数链表节点,再根据变量的事件到链表中遍历最后实现功能.父容器监听所有子列表项的点击事件,无需为每个列表项单独注册回调。的回调,打印所有事件日志,观察事件触发顺序。

solomonzw的博客 3232

V93000 SmarTest 8入门:从零搭建你的第一个半导体测试程序

半导体测试是芯片从设计走向量产的关键环节,而ATE(自动化测试设备)正是支撑这一环节的核心工具。理解ATE测试程序开发的基本原理,不仅需要掌握测试机台的硬件架构,还要熟悉其软件环境中的管脚映射、电平时序、测试流程等底层逻辑。V93000作为爱德万的主力平台,其SmarTest 8环境通过对象化与流程化设计,将复杂的芯片测试任务拆解为可配置、可复用的模块,极大提升了并行测试效率与调试的便利性。无论是数字逻辑芯片的功能验证,还是模拟混合信号器件的参数测量,掌握SmarTest 8的核心操作都能帮助你快速搭建出可

weixin_31476015的博客 231

Python办公自动化 2.1开发环境搭建:PyCharm社区版配置Anaconda开发环境

本篇文章主要讲述了如何在windows主机上配置 PyCharm + Anaconda开发环境、以及了如何配置 PyQt界面开发环境,安装过程超级详细,初学者可以照着一步一步来!

超级大洋葱的博客 2575

数据处理和分析之数据聚类:层次聚类(Hierarchical Clustering):单链接层次聚类方法

单链接层次聚类(Single-Linkage Hierarchical Clustering)是凝聚型层次聚类的一种,它基于数据点之间的最小距离来定义聚类间的相似性。在单链接层次聚类中,两个聚类之间的距离定义为这两个聚类中任意两个数据点之间的最短距离。这种聚类方法倾向于形成链状或线性的聚类,因为聚类的边界是由最远的数据点决定的,而不是聚类的平均或中心位置。单链接层次聚类通过计算簇间最近点的距离来决定簇的合并,这种方法简单直观,但可能导致簇的形状不规则,尤其是在数据点分布不均匀的情况下。

2401_87715305的博客 1436

【Claude】Auto Mode 触发安全分类器拦截的三种错误变体及对应处理 bug报错已解决

深度解析Claude Auto Mode安全分类器拦截的三种变体:内容拒绝、操作中断、累积触发,含完整排查流程与绕过策略。

博客 7554

Android 12 大屏时底下显示任务栏以及虚拟按键靠右问题

Android 12 点大屏时,底下导航栏变成显示任务栏,虚拟按键靠右的分析以及修改

Android系统开发笔记 4678

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

上一篇: 第41章:团队AI使用规范——如何建立团队的Prompt模板库
下一篇: 第43章:Code Review中的AI——如何结合人工审查和AI建议
sfishfly
博客等级 码龄1年 17粉丝 211原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值