测试中文编码_如何通过带回家的编码测试

测试中文编码

A coding test is a crucial part of the interview process for a Software Developer role. A take-home coding test combined with a follow-up interview can tell interviewers a lot about the candidate’s prior experience and potential performance at the new job. It is also a great opportunity for candidates to demonstrate their skills.

对于软件开发人员而言,编码测试是面试过程中至关重要的部分。 带回家的编码测试与后续面试相结合可以使面试官对候选人的先前经验和在新工作中的潜在表现有很多了解。 这也是候选人展示其技能的绝好机会。

Let’s take a look at a few recommendations for software developers on how they can approach a coding test to increase their chance of passing it successfully and getting a job.

让我们看一下针对软件开发人员的一些建议,以帮助他们开发编码测试,以增加成功通过测试和找到工作的机会。

仔细阅读说明 (Read the Instructions Carefully)

Start with carefully reading the coding test instructions and understanding what is required from you. If you don’t understand something — just ask the person who has sent you the task.

首先,请仔细阅读编码测试说明并了解您的要求。 如果您不了解某些内容,请向发送任务的人员询问。

Having read the instructions, think about the implementation details and make a plan: what to implement first, what scenarios to test, which edge cases to expect, etc.

阅读说明后,请考虑实施细节并制定计划:首先实施哪些内容,要测试哪些方案,预期哪些边缘情况等。

If you have a few days to implement the test, you may want to read the task as soon as you receive it and leave the actual coding till the next day. During that time your brain will be processing the task “in the background” which may help you to come up with interesting implementation ideas.

如果您有几天的时间来执行测试,则可能希望在收到任务后立即阅读该任务,并将实际的编码保留到第二天。 在这段时间内,您的大脑将在“后台”处理任务,这可能会帮助您提出有趣的实现想法。

使用Git (Use Git)

Use Git from the moment you start working on the implementation. Commit your changes often, use short and meaningful commit messages that summarise the purpose of the change. Your interviewers will likely want to take a look at the commit log to understand your thought process.

从开始实施实现的那一刻起就使用Git。 经常提交更改,使用简短有意义的提交消息来总结更改的目的。 您的面试官可能希望查看提交日志以了解您的思考过程。

In my experience, 10–15 commits should be enough. However, if you spend more time polishing your implementation and commit your code 50 times, that won’t be an issue.

以我的经验,10-15次提交就足够了。 但是,如果您花费更多时间完善实现并提交代码50次,那将不是问题。

首先实施基本方案 (Implement the Basic Scenario First)

The first thing to implement is the scenario for the most basic use case. For example, if the task is to read the data from a file, process it, and then print out the transformed data, then the basic scenario would be reading, processing, and outputting data first without taking into account edge cases like missing, invalid, or too large files.

首先要实现的是最基本用例的场景。 例如,如果任务是从文件中读取数据,进行处理,然后打印出转换后的数据,则基本方案将是先读取,处理和输出数据,而无需考虑丢失,无效等极端情况。 ,或者文件太大。

Once your implementation supports the basic scenario, you can account for various edge cases and errors: empty or missing input files, invalid input data format, extremely large input files.

一旦实现支持基本方案,就可以解决各种极端情况和错误:输入文件为空或丢失,无效的输入数据格式,极大的输入文件。

If your programming language of choice supports exception handling, demonstrate that you are familiar with catching and throwing meaningful exceptions.

如果您选择的编程语言支持异常处理,请证明您熟悉捕获和引发有意义的异常。

使用测试 (Use Tests)

Add tests to verify that your code works as expected, handles unexpected input and edge-cases. Use mainstream testing libraries and frameworks such as RSpec for Ruby or Jest for Javascript.

添加测试以验证您的代码是否按预期工作,处理意外的输入和小写情况。 使用主流的测试库和框架,例如用于Ruby的RSpec或用于Javascript的Jest。

Make your tests readable as the documentation for your code. Check the current best practices for your testing library and follow them where possible.

使您的测试作为代码文档可读。 检查您的测试库的当前最佳实践,并在可能的情况下遵循它们。

If the task allows you to use unit tests and integration tests then you should add both.

如果任务允许您使用单元测试和集成测试,则应同时添加两者。

使用TDD (Use TDD)

The best way to produce well-tested code is to use Test-Driven Development. Even if you haven’t mastered this practice, try to use it anyway.

生成经过良好测试的代码的最佳方法是使用“测试驱动开发”。 即使您还没有掌握这种做法,也请尝试使用它。

To demonstrate that to the interviewers, you can add and commit failing tests first, and then write code that would make those tests pass.

为了向访问员证明这一点,您可以先添加和提交失败的测试,然后编写使这些测试通过的代码。

Good test coverage that verifies the code behaviour in various edge cases and when handling invalid input should demonstrate to the interviewers that you can write robust production-ready code.

良好的测试覆盖率可以验证各种极端情况下的代码行为,并且在处理无效输入时应向采访者表明,您可以编写可靠的生产就绪代码。

编写可读且可维护的代码 (Write Readable and Maintainable Code)

Use meaningful names for variables, types, classes, functions, and methods. This will most likely be one of the evaluation criteria.

为变量,类型,类,函数和方法使用有意义的名称。 这很可能是评估标准之一。

As a rule of thumb, if you can read a source code file line by line and understand what is going on without frequently jumping to other files, then the code is pretty readable.

根据经验,如果您可以逐行读取源代码文件并了解发生了什么,而无需经常跳转到其他文件,则该代码非常易读。

Another readability criteria is to ask yourself — would you be able to understand this code and fix a bug in it at 2am in the morning.

另一个可读性标准是问自己-您是否能够理解此代码并在凌晨2点修复其中的错误。

做域建模(如果适用) (Do Domain Modelling (If Applicable))

If you are using an object-oriented programming language to implement the test, then you should model the essential entities as classes. For example, if you are implementing this coding test — https://codereview.stackexchange.com/questions/96181/robot-toy-simulator then you may want to introduce at least Robot and Table classes.

如果您使用面向对象的编程语言来实现测试,则应将基本实体建模为类。 例如,如果您正在实施此编码测试— https://codereview.stackexchange.com/questions/96181/robot-toy-simulator,则您可能希望至少介绍Robot和Table类。

适当使用设计模式 (Use Design Patterns Appropriately)

If you are familiar with design patterns and you see that you can use a few of them in your implementation, that’s great. However, avoid using too many as it can make your code over-complicated. A couple of patterns is enough.

如果您熟悉设计模式,并且发现可以在实现中使用其中的一些,那就太好了。 但是,请避免使用太多,因为这会使您的代码过于复杂。 几个模式就足够了。

Likewise, don’t use every possible language feature to keep your code simpler.

同样,不要使用所有可能的语言功能来简化代码。

使用高效的算法和数据结构 (Use Efficient Algorithms and Data Structures)

If your coding test implementation performs sorting and searching, or loads, scans, or creates large data files, then you should think about how well it would perform on large data sets and try to make your implementation as efficient as possible.

如果您的编码测试实现执行排序和搜索,或加载,扫描或创建大数据文件,那么您应该考虑一下它在大数据集上的表现如何,并尝试使您的实现尽可能高效。

Implementation performance may be one of the evaluation criteria. The interviewers may want to see if you can write performant code. Ideally, you should understand O(n) notation and be able to evaluate complexity of an algorithm. Such as if it grows linearly, logarithmically, or exponentially with the increase in the dataset size.

实施绩效可能是评估标准之一。 面试官可能想看看您是否可以编写绩效代码。 理想情况下,您应该了解O(n)表示法并能够评估算法的复杂性。 例如,它随着数据集大小的增加呈线性,对数或指数增长。

不要为钱使用浮点数 (Don’t Use Floating Point Numbers for Money)

If the coding test deals with currency amounts, never use Float or Double to represent them. The reason is that floating point numbers just don’t represent exact base-10 values. This is most likely a little trick to see if you understand at least the basics of Computer Science and how computers work.

如果编码测试处理的是货币金额,请不要使用浮点或双精度来表示它们。 原因是浮点数并不代表精确的以10为底的值。 如果您至少了解计算机科学的基础知识以及计算机如何工作,这很可能是一个小技巧。

Use either Decimals or, even better, represent amounts in cents as Integers. Alternatively, you can use a third-party library for that. If a coding test deals with money, at the follow-up interview your interviewers will probably ask you why you have picked a specific way to represent currency amounts.

使用小数,或者甚至更好地,将以美分表示的金额表示为整数。 或者,您可以为此使用第三方库。 如果编码测试涉及金钱,那么在后续采访中,您的访问者可能会问您为什么选择了一种表示货币金额的特定方法。

使用社区标准和最佳实践 (Use Community Standards and Best Practices)

Apply the current best practices and the standards widely used by the community of developers who use the programming language and/or the framework that you are implementing the coding test in. It is best to run your implementation through a code analysis tool (ESLint, rubocop, etc.) to check its code quality and fix errors and warnings.

应用当前的最佳实践和标准,这些最佳实践和标准是开发人员社区广泛使用的标准,这些开发人员使用编程语言和/或在其中实施编码测试的框架。最好通过代码分析工具(ESLint,rubocop)运行您的实施等),以检查其代码质量并修复错误和警告。

避免源代码中的注释 (Avoid Comments in Source Code)

Many interviewers prefer not to see comments in the code and treat them as a sign of unreadable code. The code and tests should be sufficient to understand how the implementation works. Well-written code almost never needs comments. If you feel that you just have to write a comment, try changing the code instead to make it easier to understand.

许多访问者宁愿不要在代码中看到注释,也不要将注释视为不可读代码的标志。 代码和测试应足以了解实现的工作原理。 编写良好的代码几乎不需要注释。 如果您觉得只需要写注释,请尝试更改代码以使其更易于理解。

使用主流工具,库和技术 (Use Mainstream Tools, Libraries, and Techniques)

Use mainstream tools and libraries in your implementation. Make your implementation predictable. A non-conventional implementation may be rejected because the interviewers might not understand it or may decide that the candidate might use rare tools and exotic techniques when working with production code, which will result in hard-to-maintain code.

在实施中使用主流工具和库。 使您的实现可预测。 非常规的实现可能会被拒绝,因为面试官可能不理解它,或者可能会决定候选人在使用生产代码时可能使用稀有工具和奇特的技术,这将导致代码难以维护。

However, if you are applying for a very senior engineering role, that’s where a creative implementation may be welcome. The interviewers may actually want to find a candidate who can use the programming language, frameworks and libraries creatively.

但是,如果您申请的是非常高级的工程职位,那么可能会欢迎您进行创造性的实施。 面试官实际上可能希望找到可以创造性地使用编程语言,框架和库的候选人。

编写可扩展的代码,但不要过度设计 (Write Extendable Code But Don’t Over-Engineer)

It is great if you can write an implementation that is maintainable and extendable. For example, if the task involves reading input data from JSON files, you may implement that in a way that would allow you to easily add other data formats such as XML or CSV.

如果您可以编写可维护和可扩展的实现,那就太好了。 例如,如果任务涉及从JSON文件读取输入数据,则可以以允许您轻松添加其他数据格式(例如XML或CSV)的方式实施该操作。

Moreover, at the follow-up interview you may be asked to extend your implementation in a similar way. So, it would be a good idea to prepare for that in advance and think about how the interviewers may ask you to modify your code.

此外,在后续采访中,可能会要求您以类似方式扩展实施。 因此,事先做好准备并考虑面试官可能会如何要求您修改代码是一个好主意。

Note that you don’t need to account for every possible direction that the evolution of your implementation may take. Leaving one or two “extension points” is fine just to demonstrate that you can design future-proof applications. But adding too many of those will only bloat the source code and increase the chance of making mistakes.

请注意,您无需考虑实现的发展可能采取的每个可能的方向。 仅留一个或两个“扩展点”就可以证明您可以设计面向未来的应用程序。 但是添加太多这样只会使源代码肿,并增加犯错的机会。

提交前重构代码 (Refactor Your Code Before Submitting)

Make sure that you re-read and refactor your implementation a bit before sending your code back to the interviewers. Do the variable names make sense? Have you considered enough edge cases? Is test coverage sufficient? Is the code nicely formatted? Have you implemented all the requirements from the task?

在将代码发送回采访者之前,请确保您重新阅读并重构了实现。 变量名有意义吗? 您是否考虑过足够的边缘情况? 测试覆盖范围是否足够? 代码格式正确吗? 您是否已实现任务中的所有要求?

Have a fresh look at your code. If something doesn’t look right — fix it.

重新查看您的代码。 如果看起来不正确,请修复它。

Make sure your implementation is the best code that you can write right now. Many interviewers will be considering your code as such, which is absolutely reasonable. After all, if you send a very average implementation back to them, that may be a sign that you either don’t care about the job in their organisation or don’t have good programming skills. So it is best if your code can make a good impression.

确保您的实现是您现在可以编写的最佳代码。 许多面试官会考虑您的代码,这是绝对合理的。 毕竟,如果您将非常普通的实施方案发送给他们,则可能表明您要么不在乎他们组织中的工作,要么没有良好的编程技能。 因此,最好是您的代码能给人留下深刻的印象。

确保您的代码可在其他计算机上运行 (Ensure Your Code Works on Different Computers)

Your local development environment might be unique and your implementation might not run on the computers of your interviewers for various reasons. So, it is best if you confirm that your implementation works in other environments too.

您的本地开发环境可能是唯一的,并且由于各种原因,您的实现可能无法在访问者的计算机上运行。 因此,最好是确认您的实现也可以在其他环境中使用。

If you have another computer to try running your code — you can use it. Alternatively, you can run tests for your implementation on a CI server. I used to publish my code on GitHub and connect the repo to Travis CI which is free for open-source projects. If the tests passed on different versions of the programming language (I was using Ruby), that was a sign that I could safely send it to the interviewers. You probably can do the same for many other programming languages.

如果您有另一台计算机尝试运行代码,则可以使用它。 或者,您可以在CI服务器上为实现进行运行测试。 我曾经在GitHub上发布我的代码,然后将回购协议连接到Travis CI,后者对开源项目是免费的。 如果测试通过了不同版本的编程语言(我使用的是Ruby),则表明我可以安全地将其发送给面试官。 您可能可以对许多其他编程语言执行相同的操作。

写自述 (Write A Readme)

Make reviewing your code easier for the interviewers. Write a readme for them to explain your approach, process, and assumptions, as they may be unclear to others. If you used any third party libraries in your implementation, elaborate why you had picked them. Include instructions on how to run your code.

使面试官更容易审查代码。 为他们写一个自述文件,以解释您的方法,过程和假设,因为其他人可能不清楚。 如果在实现中使用了任何第三方库,请详细说明为什么选择它们。 包括有关如何运行代码的说明。

Keep the readme brief. Short sentences and bullet points should be good. Markdown is probably the most appropriate format. It is readable if the implementation is published on GitHub and it is almost as readable as just a text file.

保持自述文件简短。 简短的句子和要点应该很好。 Markdown可能是最合适的格式。 如果实现在GitHub上发布,则可读,几乎与文本文件一样可读。

To recap, start with reading and understanding the instructions; implement the basic scenario and then handle edge cases; write readable, maintainable, and extendable code; demonstrate that you are familiar with the language features and current best practices and design patterns widely used by developer community; add tests and use TDD; frequently commit your changes; ensure your implementation would run in different environments not just your laptop; write a readme for interviewers.

回顾一下,首先要阅读并理解说明; 实施基本方案,然后处理极端情况; 编写可读,可维护和可扩展的代码; 证明您熟悉开发人员社区广泛使用的语言功能以及当前的最佳实践和设计模式; 添加测试并使用TDD; 经常进行更改; 确保您的实施可以在不同的环境中运行,而不仅仅是您的笔记本电脑; 为面试官写一个自述。

I hope that this quick guide will help you to write a great implementation for a coding test and do really well at that stage of the job interview process.

我希望这份快速指南能帮助您编写出色的编码测试实施方案,并在面试过程的那个阶段做得很好。

翻译自: https://levelup.gitconnected.com/how-to-pass-a-take-home-coding-test-8374c5b641ef

测试中文编码

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值