提高编码效率_这5种简单的策略可提高您的编码效率

提高编码效率

As a developer, your productivity is not gauged by how much code you churn out, but by how much value you deliver. Gone are the days where lines of code are a worthwhile performance metric. If you want to master your craft and hone your productivity, you will need to embrace the age-old adage — “Work smarter, not harder”.

作为开发人员,您的生产率不是由您投入多少代码来衡量的,而是由您交付多少价值来衡量的。 如今,行代码成为有价值的性能指标的日子已经一去不复返了。 如果您想精通Craft.io并提高生产力,则需要接受古老的格言-“更聪明地工作,而不是更努力”。

These are 5 methods and principles you can employ today to start seeing immediate returns in your productivity.

您现在可以采用以下5种方法和原则来开始看到生产力的即时回报。

认真思考要实现的目标 (Be deliberate in what you want to achieve)

There is no way to know how productive you are if you have nothing to measure against. One of the biggest boosts to productivity you can get without having to do much at all is to set deliberate goals for what you want to do today and this week.

如果没有什么可衡量的,就无法知道自己的生产力。 无需做任何事情就可以最大程度地提高生产力的方法之一就是为您今天和本周想要做的事情设定故意的目标。

At the start of each week, take a moment to think about 3 things you want to have ticked off by the end of Friday. These should be high-level items, and your daily objectives will help you meet these goals.

在每个星期的开始,花点时间考虑一下您想在周五结束前完成的三件事。 这些应该是高级项目,您的日常目标将帮助您实现这些目标。

At the start of each day, consider what you have accomplished so far this week, and what you would need to do today to stay on track. Write down 3 objectives somewhere (I prefer a physical medium, but apps like Sunsama work great for this too). As you go through the day, when you finish a goal, tick off the item.

每天开始时,请考虑本周到目前为止所取得的成就,以及今天需要做些什么才能保持正轨。 在某处写下3个目标(我更喜欢物理媒介,但Sunsama之类的应用程序也可以很好地实现这一目标)。 一天中完成目标时,请勾选该项目。

It can take a bit of calibration to get a good feel for how big these tasks should be. I found myself writing down far too much at first. I was lucky if I was able to finish the first item on the list. After about a week of tweaking, I’ve reached a scope that works well for me. This technique is invaluable when it comes to projecting how much work I will get done in a week, and making it happen.

可能需要一些校准才能很好地了解这些任务的大小。 一开始我发现自己写下的东西太多了。 我很幸运能够完成清单上的第一项。 经过大约一周的调整,我已经达到了适合我的范围。 当计划我一周将完成的工作量并使其实现时,这项技术是无价的。

不要写完美的代码 (Don’t write perfect code)

Not straight away, at least. Many developers have fallen prey to the temptation to write perfect code in a single go. It rarely happens. Think of writing code the same way you would draw a picture. Start with a rough outline of what you want, and iteratively add details until you end up with something great.

至少不是马上。 许多开发人员不愿意一次编写完美的代码。 它很少发生。 考虑用与绘制图片相同的方式编写代码。 从大致概述您想要的内容开始,然后迭代添加细节,直到最终得到一些很棒的东西。

Leonardo da Vinci didn’t paint the Mona Lisa by perfecting her head before moving on to her neck, he worked through countless iterative refinements over the whole image.

莱昂纳多·达·芬奇(Leonardo da Vinci)没画过蒙娜丽莎(Mona Lisa)的画像,而是在移到脖子上之前先完善了头部,他在整个图像上进行了无数次迭代改进。

A good principle to help remember this is the “3 E’s of code”

记住这一点的一个好原则是“代码的3 E”

  • Effective — Write the code solve the problem

    有效-编写代码解决问题
  • Efficient — Improve the code to make it more optimised

    高效-改进代码以使其更优化
  • Elegant — Refine the code to make it beautiful (don’t skip this step. Efficient code isn’t worth much if no one can read it)

    优雅—完善代码以使其美观(不要跳过此步骤。高效的代码如果没有人看懂,就不值钱了)

In that order. Don’t start the next step until the previous one is complete.

以该顺序。 在上一步完成之前,请勿开始下一步。

This methodology ties in well with the next point.

该方法与下一点很好地联系在一起。

尽可能使用TDD (Use TDD wherever you can)

Test-Driven Development is great. It is basically a free productivity boost. Writing your tests as you go and refactoring code once it passes fits in perfect lock-step with the 3 E’s mentioned above. Don’t write your tests after you are finished with the code. If you do this, one of two things are likely to happen:

测试驱动开发很棒。 这基本上是免费的生产力提升。 随手编写测试,并在代码通过后进行重构,可以完美地锁定上述3E。 完成代码后,请勿编写测试。 如果执行此操作,则可能会发生以下两种情况之一:

  1. You will be told to skip the tests and move on

    系统会告诉您跳过测试并继续前进
  2. If you do write the tests, you will base them on the output of the code, and if you have bugs, so will the tests

    如果确实编写测试,则将基于代码的输出,如果存在错误,则测试也将基于它们

Writing tests as specifications — distilled business requirements — ensures that your code is working as you write it and that the testing cannot be skipped. This results in higher quality work, fewer bugs, and less cause to come back and rework things later. If that isn’t a productivity gain, I don’t know what is.

按照规范编写测试(精炼的业务需求)可确保您的代码在编写时就可以正常工作,并且不会跳过测试。 这样可以提高工作质量,减少错误,并减少以后返工和返工的原因。 如果那不是生产力的提高,我不知道这是什么。

分批工作 (Work in batches)

A fact of life for most jobs is that you will often receive small tasks which people ask you to do. Being a developer is no different, and depending on your role you might get a couple of these a week, or dozens of them per day!

大多数工作的现实生活是,您经常会收到人们要求您完成的小任务。 成为开发人员也没有什么不同,根据您的角色,您一周可能会得到其中的一些,或者每天可能得到数十种!

The key thing here is that many of these tasks are not urgent at all, and can be delayed without any adverse impact. If you delay enough similar tasks, you will be able to group them all together and action them all at once. This approach of doing the work in batches has various benefits. On the one hand, you are reducing the amount of context-switching you do, so you will naturally get productivity gains there. You will also be able to consolidate the setup and teardown overhead associated with small tasks. In most cases, the setup work required to do one task is the same as the work required to do 10 similar tasks. consolidating this overhead can save you a lot of time which could be better spent elsewhere.

这里的关键是,这些任务中的许多任务根本都不紧急,可以拖延而不会产生任何不利影响。 如果延迟足够多的相似任务,则可以将它们组合在一起并立即执行所有操作。 这种分批完成工作的方法具有多种好处。 一方面,您正在减少上下文切换的数量,因此您自然会在那里获得生产力的提高。 您还可以合并与小任务相关的设置和拆卸费用。 在大多数情况下,执行一项任务所需的设置工作与执行十项类似任务所需的工作相同。 合并这些开销可以节省大量时间,最好在其他地方花费。

坚持不懈 (Be Relentless)

Perhaps the most important thing when it comes to getting stuff done. Sometimes you have to just power through. Using the other tactics described above will put you in a position to identify the work which needs to be done, and give you tools to do it efficiently, but at the end of the day, you just have to do it. I set myself a hard requirement of AT LEAST checking off the first item on my 3 item list every day. On good days I can get two or three high-level items checked off, but if you check off one meaningful objective each day — as long as you have set yourself valuable targets — you will be smashing out work and ticking boxes like nobody’s business.

完成工作可能是最重要的事情。 有时,您只需要接通电源即可。 使用上述其他策略将使您能够确定需要完成的工作,并为您提供有效完成工作的工具,但总之,您只需要完成工作即可。 我对自己提出了一个严格的要求,即每天至少要检查我的3个项目列表中的第一个项目。 在美好的日子里,我可以检查两到三个高级项目,但是如果您每天检查一个有意义的目标(只要您为自己设定了重要的目标),您就会无所事事,无所事事。

翻译自: https://medium.com/dev-genius/boost-your-coding-productivity-with-these-5-simple-tactics-dca7b617cb65

提高编码效率

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 简单哈夫曼编码是一基于字符频率的无损压缩算法。其压缩过程主要包括两个步骤:建立编码表和将原文本按编码表进行编码。解压缩则是对编码后的数据进行解码,还原为原始文本。 在建立编码表的步骤中,首先需要统计原文本中每个字符的频率,并按频率进行排序。然后从频率最低的两个字符开始,不断合并形成新的节点,直到只剩下一个根节点。这个过程类似于二叉树的构建。在合并节点的过程中,会为每个节点分配一个二进制编码,通过向左走表示编码位0,向右走表示编码位1。最终,所有字符的编码位通过遍历树的路径得到,构成了编码表。 在编码过程中,根据编码表将原文本中的每个字符用相应的二进制编码进行替换。由于编码表保证了每个字符的编码都是唯一的且互不重叠,所以通过替换后的编码所得到的二进制数据长度更短,实现了压缩效果。 解压缩过程中,根据编码表将编码后的二进制数据进行解码。从根节点开始,按照解码规则依次向左或向右移动,直到达到叶节点。到达叶节点后,就可以得到对应的字符。重复此过程,直到解码完所有的二进制数据,就能够得到原始文本。 简单哈夫曼编码的压缩与解压缩过程简单高效,可以有效地减小数据的存储空间,同时不会损失任何信息。然而,它的效果受限于原文本中字符频率的分布情况,如果字符频率分布不均匀,有些字符频率很高,有些频率很低,那么简单哈夫曼编码的压缩效果可能不太明显。 ### 回答2: 简单哈夫曼编码是一常见的数据压缩算法,它通过对字符出现频率进行统计,然后将频率较高的字符用较短的二进制码表示,频率较低的字符用较长的二进制码表示,从而实现对数据的压缩。 对于压缩,首先需要进行编码。步骤如下: 1. 统计输入的字符频率。 2. 根据字符频率构建哈夫曼树。此时,每个字符都表示一个叶子节点,其权值为字符的频率。 3. 从根节点遍历哈夫曼树,记录路径,将路径上的0和1分别表示为二进制码的0和1。 4. 将编码后的结果写入到输出文件中。 对于解压缩,首先需要进行解码。步骤如下: 1. 读取压缩文件的内容,构建哈夫曼树。 2. 从根节点开始,按照读取到的0和1,依次从哈夫曼树的左右子节点中选择。直到达到叶子节点,将其对应的字符写入解压文件中。 简单哈夫曼编码虽然简单,但是却有一些限制。例如,它无法处理包含大量重复字符的数据,因为在哈夫曼树中,较高频率的字符对应的编码较短,而重复字符的编码会变得很长,导致整体压缩效果不佳。此外,简单哈夫曼编码不支持随机访问,因为解码时需要按顺序读取压缩文件的内容。 尽管存在一些限制,简单哈夫曼编码仍然是一常用的数据压缩算法,因为它相对简单,且在某些情况下能够获得很好的压缩效果。通过合理的设计编码策略,能够进一步提升压缩效果。 ### 回答3: 哈夫曼编码是一常用的数据压缩算法,其原理是将出现频率较高的字符用较短的编码表示,而出现频率较低的字符用较长的编码表示,这样可以实现对数据的有效压缩。 简单哈夫曼编码主要分为两个步骤:构建哈夫曼树和生成编码表。 在压缩过程中,首先需要统计待压缩数据中每个字符的频率,然后根据频率构建哈夫曼树。构建哈夫曼树的过程如下:将所有字符和对应的频率作为叶子节点,然后将频率最小的两个叶子节点合并为一个新的节点,其频率为原来两个节点频率之和;重复进行这个过程,直到只剩下一个根节点为止,此时构建完整的哈夫曼树。 生成编码表的过程如下:从根节点开始,遍历哈夫曼树的每个节点,当到达叶子节点时,记录路径上的编码值。 在解压缩过程中,首先读取压缩文件中的哈夫曼编码表和压缩数据,然后根据哈夫曼编码表重构哈夫曼树。接下来按位读取压缩数据,根据哈夫曼树进行解码,直到解码完所有数据,即可得到原始数据。 简单哈夫曼编码的压缩与解压缩过程可以通过C语言实现。在压缩过程中,可以使用优先队列来实现哈夫曼树的构建,并使用动态字符数组来存储编码表。在解压缩过程中,可以使用位操作来读取压缩数据,并根据哈夫曼树逐位解码。具体实现的细节会涉及到数据结构和文件操作等方面的知识。 总的来说,简单哈夫曼编码通过统计字符频率,并构建哈夫曼树生成编码表,实现对数据的压缩和解压缩。在实际应用中,哈夫曼编码可以大大减小数据的存储空间,提高数据传输的效率

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值