如果我提交这个“初稿代码”程序员会喜欢它还是讨厌它?
我是一名工厂员工,只做过一点编程。我想建议我们的计算机轮班报告为我们做一些计算,这样我就不必每天多次将它们输入计算器。我不想只是说“我希望计算机获取我在其他地方输入的净重和皮重并告诉我毛重”,我想提交一些带有我的建议的代码或伪代码:
function calculategross () {
int gross = fldshf_skidnet + fldshf_tare;
//use fldshf_skidnet, not fldshf_net in case of multiple rolls per skid.
}
因为我确切地知道我要进行哪些计算需要做什么以及数据库表中哪些变量可用,伪代码可以为应用程序程序员节省很多思考。它应该使我的建议看起来更可行,并且编写新代码很有趣。但真正的程序员可能宁愿有详细的规范或其他东西,而无需我对技术特性的看法。如果经理要求您编写一些代码并提交一些无法编译的“代码”,您会说“嘿,很好的路线图”或“天哪,得到线索”吗?
背景:班次报告是数据库表的选项卡式视图,由 Alpha V5 制作。所以你有一个看起来有点像第一个结果的前端 此处,以及如果按 F8,您将查看数据库中的基础表。 (这就是我知道所有变量名称的方式。)我的计算器页面将位于其自己的选项卡上。它使用的一些数据将由用户在其他选项卡中输入,有些则在页面本身上输入。
这是我正在考虑的一些“代码初稿”。我不太满意的界面位于顶部附近,一些计算器功能位于底部。
Button GetDataButton = new Button();
GetDataButton.onclick() = UpdateAllUneditedVariables() {
//Populate all fields on this tab with data entered elsewhere
//Don't update fields the user changed on this page.
//I didn't actually write this function, I'm just describing it.
}
Button CalculateAll = new Button();
CalculateAll.onclick() {
FillEmptyFieldsWithDefaultValues();
CallAllCalculatorFunctions();
DisplayAllCalculationResults();
}
sub CallAllCalculatorFunctions() {
CalculateGross();
CalculateAverage();
CalculateNetPoundsPerHour();
//I feel like this is a non-programmer way to structure this...
}
//Here's a couple of the mathier functions -- not that hard, but complicated
//enough that I'd rather not have the programmer have to think through them.
function SkidsPerJob () {
//How many skids must we divide this job into based on weight limits?
int max_by_weight = ceil (fldshf_total_lbs / max_lbs_skid);
//How many based on height limits?
float total_height = fldshf_gauge * fldshf_total_sheets;
int max_by_height = ceil(total_height / max_height / stacks_per_skid);
int total_skids = max (max_by_weight, max_by_height);
}
function CalculateNetPoundsPerHour () {
int netpph = sheet_weight / sheet_length * feet_per_minute * 12 * 60;
if (number_of_webs > 1) {netpph *= number_of_webs;
}
如果您认为这不好,您是否建议通过温习 Microsoft Access 表单来刷新我的编码能力? (我以前已经制作过它们,带有下拉菜单和所有内容,只是最近没有。)从 Scriptlance 获取编辑器来修复命名约定和编码错误?或者我应该只专注于页面的外观并描述我需要的功能而不是尝试自己设计它?
I am a factory employee who's done just a little programming. I want to suggest that our computer shift reports do a couple calculations for us so I don't have to punch them into a calculator several times a day. Rather than just saying "I would like the computer to take the net net weight and tare weight I entered elsewhere and tell me the gross weight", I would like to submit some code or pseudocode with my suggestion:
function calculategross () {
int gross = fldshf_skidnet + fldshf_tare;
//use fldshf_skidnet, not fldshf_net in case of multiple rolls per skid.
}
Since I know exactly which calculations I need done and which variables are available in the database table, pseudocode could save the application programmer a lot of thought. It should make my suggestion look more viable as well, and writing new code is just fun. But a real programmer might rather have a detailed spec or something without my opinion on the technical features. If a manager asked you to code something and submitted some non-compiling "code", would you say "hey, good roadmap" or "geez, get a clue"?
Background: The shift report is a tabbed form view of a database table, made in Alpha V5. So you have a front end that looks somewhat like the first result here, and if you hit F8 you are looking at the underlying table in the database. (This is how I know all the variable names.) My calculator page would be on its own tab. Some of the data it uses will be user-entered in other tabs, some on the page itself.
Here's some of the "first draft code" I'm considering. The interface stuff that I'm shakier on is near the top, some of the calculator functions are at the bottom.
Button GetDataButton = new Button();
GetDataButton.onclick() = UpdateAllUneditedVariables() {
//Populate all fields on this tab with data entered elsewhere
//Don't update fields the user changed on this page.
//I didn't actually write this function, I'm just describing it.
}
Button CalculateAll = new Button();
CalculateAll.onclick() {
FillEmptyFieldsWithDefaultValues();
CallAllCalculatorFunctions();
DisplayAllCalculationResults();
}
sub CallAllCalculatorFunctions() {
CalculateGross();
CalculateAverage();
CalculateNetPoundsPerHour();
//I feel like this is a non-programmer way to structure this...
}
//Here's a couple of the mathier functions -- not that hard, but complicated
//enough that I'd rather not have the programmer have to think through them.
function SkidsPerJob () {
//How many skids must we divide this job into based on weight limits?
int max_by_weight = ceil (fldshf_total_lbs / max_lbs_skid);
//How many based on height limits?
float total_height = fldshf_gauge * fldshf_total_sheets;
int max_by_height = ceil(total_height / max_height / stacks_per_skid);
int total_skids = max (max_by_weight, max_by_height);
}
function CalculateNetPoundsPerHour () {
int netpph = sheet_weight / sheet_length * feet_per_minute * 12 * 60;
if (number_of_webs > 1) {netpph *= number_of_webs;
}
If you don't think this is good, would you recommend just refreshing my coding ability by brushing up on Microsoft Access forms? (I have made them before, with dropdowns and everything, just not recently.) Get an editor from Scriptlance to fix naming conventions and coding errors? Or should I just concentrate on the look of the page and describing the functions I need and not try to design it myself?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
编写规范时,您必须用您和开发人员都能理解的语言来表达您想要的内容。我认为利用您的编程经验并表达业务逻辑 使用类似编程的语言。我不会为编码错误或命名约定而烦恼:更重要的是您获得正确的命名(来自
不过,不要在这上面花太多时间。专注于您的域特有的事物。
When writing a specification, you have to express what you want in a language that both you and the developer understands. I think it is a good idea to make use of your programming experience and express the business logic in a programming-like language. I wouldn't bother with coding errors or naming conventions: It is more important that you get the naming right (from a domain perspective) than syntactical correctness.
Don't spend too much time on this, though. Focus on the things that are unique to your domain.
在敏捷世界中,您倾向于避免尝试预先规范所有内容,接受这几乎是不可能的,而是允许设计通过持续的原型设计和与开发人员的交互来发展(请参阅Scrum 或 DSDM 用于 例子)。
我的建议是关注业务需求并让开发人员准确决定如何最好地实现它们,这是他的工作,他会比你知道如何做得更好。毫无疑问,他还将拥有诸如编码标准和他可能想要重复使用的现有代码库之类的东西。您应该主要关注与他密切合作,以确保他理解您的要求(我建议您将它们分成小的、离散的“块”),以便他生产的产品满足您的需求,并且在交货日不会出现意外。
In the agile world you would tend to avoid trying to spec everything up front, accepting that this is nigh on impossible, and instead allow the design to evolve through continual prototyping and interaction with the developer (see Scrum or DSDM for example).
My advice is to focus on the business requirements and allow the developer to decide exactly how best to implement them, that's his job and he will know how to do it better than you. Doubtless he will also have things like coding standards and existing libraries of code he may want to re-use. You should be primarily concerned with working closely with him to ensure that he understands your requirements (I would advise you to break them up into small, discrete 'chunks') so that what he produces addresses your needs and there are no surprises come delivery day.
正如其他人(Anders Lindahl 和 Simon)所说,您应该专注于确保程序员了解您的业务需求。
作为一名程序员,我宁愿将规范视为屏幕图,其中描述了每个按钮(或其他活动控件)的功能,而不是屏幕创建伪代码。然而,我认为在伪代码中指定计算没有任何问题,特别是当它们很棘手时。如果操作顺序很关键(无论是从用户的角度还是“这个值取决于该计算”),我也欢迎使用类似于英语的高级伪代码来指定关键位。
As others have already said (Anders Lindahl & Simon), you should be focusing on making sure the programmer understands your business requirements.
As a progammer, I'd rather see the spec as a screeen diagram, with descriptions of what each button (or other active control) does, than screen-creation pseudocode. However, I see nothing wrong with specifying the calculations in pseudocode, particularly if they're tricky. If the order of operations is critical (either from a user perspecitve or a "this value depends on that calculation" one), I'd also welcome high-level English-like pseudocode to specify the crucial bits.