当前位置: 首页 > 编程日记 > 正文

影像锐化工具_如何以及为什么要进行工具改造:花在锐化斧头上的时间永远不会浪费...

影像锐化工具

by Harshdeep S Jawanda

通过Harshdeep S Jawanda

如何以及为什么要进行工具改造:花在锐化斧头上的时间永远不会浪费 (How and why you should tool-up: time spent sharpening your axe is never wasted)

There is this old anecdote about two friends who went to the forest to chop up some firewood for their homes. The first friend kept at it without a break for four hours, whereas the other friend would rest for 5 minutes or so every hour. When they were done the first friend was surprised to see that the other’s woodpile was much larger than his.

这个古老的故事讲述了两个朋友去森林砍柴为家。 第一个朋友在这里休息了四个小时,而另一个朋友每小时要休息5分钟左右。 当他们做完后,第一个朋友惊讶地发现对方的木头堆比他的大得多。

Incredulous, he asked, “How did you chop more wood than me!? I worked continuously while you took so many breaks.”

他怀疑地问道:“你怎么砍了比我还多的木头!? 您休息了这么长时间,我一直在工作。”

His friend replied, “While resting, I would sharpen my axe, so that I could chop up wood more efficiently the rest of the time.”

他的朋友回答说:“在休息的同时,我会锐化斧头,以便在剩下的时间里更有效地砍柴。”

That’s what I mean by “Tool-Up!”: equipping yourself with the right tools to make you more productive while ensuring higher quality work output.

这就是我所说的“动手做!”的意思:为自己配备合适的工具,以提高工作效率,同时确保更高质量的工作输出。

What follows is aimed at developers, and uses Java to illustrate examples. But the general advice applies to everybody.

接下来的内容面向开发人员,并使用Java举例说明。 但是一般性建议适用于每个人

放聪明点 (Be smart)

The example above is not to meant to send you running to your keyboard to start banging out utility classes/libraries that will supposedly help you out. Not at all! Be smart about what exactly it is that you need. Maximize the Return On your (time) Investment (ROI). An important part of being smart means that you…

上面的示例并不是要让您奔跑到键盘上来开始敲响应该可以帮助您的实用程序类/库。 一点也不! 明智地了解您到底需要什么。 最大化您(时间)的投资回报率(ROI)。 聪明的重要一环意味着您……

更喜欢预先构建的解决方案来推出自己的解决方案 (Prefer pre-built solutions to rolling out your own)

For developers, the right tool is often a library that provides you with the required functionality. Whether it is the Optional<;T> class of the Guava library (for use in pre-Java 8 code) or its ImmutableList<T> implementation, these tools have been developed to cover many use cases. They also typically have many generations of evolution behind them, and have been thoroughly tested, both by developers and by users. As such they offer the benefits of good design and mature implementations.

对于开发人员而言,正确的工具通常是为您提供所需功能的库。 无论是Guava库的Optional< ; T>类(供Java 8之前的代码使用)还是r its ImmutableL <T>实现,这些工具都已开发为涵盖许多用例。 它们通常还具有许多代的演变过程,并且已经过开发人员和用户的全面测试。 因此,它们提供了良好的设计和成熟的实现的好处。

Remember: don’t re-invent the wheel!

记住:不要重新发明轮子!

始终使用您的工具 (Use your tools consistently)

If you use a tool or technique, try to use it consistently throughout your work as much as you’re able. This will help reduce the mental load of having to do a context switch between different paradigms and situations.

如果您使用工具或技术,请​​尝试在整个工作中尽可能地一致地使用它。 这将有助于减轻必须在不同的范式和情况之间进行上下文切换的精神负担。

Often this means refactoring legacy code. In such situations, you should seriously consider scheduling time for it. If time is a limiting factor — as it often is — try to prioritize high-impact parts of your codebase.

通常,这意味着重构遗留代码。 在这种情况下,您应该认真考虑安排时间。 如果时间(通常是时间)是一个限制因素,请尝试确定代码库中影响较大的部分的优先级。

何时该自己做 (When it’s time to do it yourself)

The stage will likely come (as it almost invariably does) that pre-built solutions are not good enough, or they fail to fill some of the very specific gaps you need filled. Don’t feel pressured to create humongous, perfectly-designed, everything-and-the-kitchen-sink libraries. Start small. Create a solution that’s just enough for your current needs. Perhaps instead of creating a library, think only about creating a utility class, and then take things from there.

预先建立的解决方案可能还不够好,或者无法填补您需要填补的某些非常具体的空白(几乎总是如此)。 创建巨大的,设计完美的,万事俱备的厨房接收器库时不要感到压力。 从小开始 。 创建一个足以满足您当前需求的解决方案 。 也许不用创建一个库,而只考虑创建一个实用程序类,然后从那里开始。

一点可以走很长的路 (A little can go a long way)

You’ll be surprised by how much utility and convenience even 3–4 lines of ordinary code can deliver.

您甚至会对3至4行普通代码所能提供的实用性和便利性感到惊讶。

There were a number of places in my code where I had to get specific values from specific indices in Lists. What’s more simple than:

我的代码中有很多地方必须从List的特定索引中获取特定值。 比这更简单:

Object listValue = myList.get(index)

Right? Not so fast! That simple line of code can potentially throw two different exceptions (can you figure out which ones and why?). Ok, so you wrap your code with some try-catch goodness and now you’re done, right? What value are you going to assign to listValue in case of an exception? Your code now begins to look something like:

对? 没那么快! 这段简单的代码可能会引发两个不同的异常(您能找出哪个异常以及为什么吗?)。 好的,因此您将代码包装为具有try-catch优点,现在就完成了,对吗? 如果发生异常,您要为listValue分配什么值? 您的代码现在开始看起来像:

Object listValue = null; // default value assignmenttry {    listValue = myList.get(index);} catch (Exception e) {    // Do nothing (if that is what you want to do)}

Simple, straightforward code — but it’s not exactly a pretty sight or very convenient. Not to mention that similar fragments will be littered all over your code. Sooner or later you will also forget to cater for all eventualities. And then: boom!!

简单,直接的代码-但这并不完全是视觉效果或非常方便。 更不用说类似的片段会在您的代码中乱七八糟。 迟早您还会忘记照顾所有可能发生的情况。 然后: 繁荣!

Compare that to:

比较一下:

Object listValue = Lists.get(myList, index, null);

where the Lists utility class contains the following convenience method:

Lists实用程序类包含以下便捷方法:

public static <T> T get(List<T> list, int position, T defaultValue) {    if (null != list && position >= 0 && position < list.size())        return list.get(position);    return defaultValue;}

It’s an extremely simple method, yet very useful (for a specific use case).

这是一种非常简单的方法,但非常有用(对于特定的用例)。

Of course, this may not be exactly what you need. You could also argue that instead of throwing an ArrayIndexOutOfBounds exception, this code hides incorrect indices and could lead to insidious errors, and that’s why you don’t find code like this in general-purpose libraries (where failing early is a virtue)…That’s all valid, but that is also why I wrote this particular utility method for my use case.

当然,这可能并不是您真正需要的。 您还可能会争辩说,此代码没有引发ArrayIndexOutOfBounds异常,而是隐藏了错误的索引并可能导致隐患,这就是为什么您在通用库中找不到这样的代码(尽早失败是一种美德)的原因……全部有效,但这也是为什么我为用例编写了这种特殊的实用程序方法的原因

This illustrates my point: beyond the point you can/will/should write utility code for your specific use cases, just be aware of potential pitfalls, if any.

这说明了我的观点:超出您可以/将/应该为您的特定用例编写实用程序代码的时候,请注意潜在的陷阱(如果有)。

寻找重复的图案 (Look for repeating patterns)

As I mentioned before, there’s no need to rush into anything. A good and easy way to identify scenarios where a higher level of abstraction would be useful is to look for things that are:

正如我之前提到的,无需着急。 确定较高抽象级别的方案的简便方法是查找以下内容:

  • cumbersome

    麻烦的
  • have repeated usage

    反复使用
  • are error-prone

    容易出错

Let this be your guide. Basically, look for repeating patterns in your code or your actions to get the most bang for your buck.

让这作为您的指南。 基本上,在代码或操作中寻找重复的模式 ,以最大程度地发挥作用。

As you start to improve the most obvious scenarios, other — often higher-level — patterns will begin to emerge. Things that did not seem so inconvenient before will suddenly start looking unweildy/error-prone in comparison. That will automatically guide you towards the next tool/abstraction you should develop.

随着您开始改善最明显的场景,其他(通常是更高级别)的模式将开始出现。 与以前相比,以前似乎不太方便的事情将突然看起来不可靠/容易出错。 这将自动指导您进行下一个应开发的工具/摘要。

Rinse, repeat.

冲洗,重复。

不要强迫 (Don’t Force It)

Let your tool usage/adoption grow organically as you deal with your pain points and bottlenecks (Agile mindset?). Don’t set a hard-coded limit of X hours spent per week to satisfy some externally-imposed metric of what constitutes “good practice.”

当您处理痛点和瓶颈时(敏捷思维方式?),让您的工具使用/采用方式有机地增长。 不要设置每周花费X个小时的硬编码限制,以满足构成“良好实践”的某些外部指标。

Forced tool usage can sometimes be counter-productive: you’ll get much better results when you and your people feel the need for improvement. The motivation level and the perception of reward (when the improvement happens) is just so much higher.

强迫使用工具有时会适得其反:当您和您的员工感到需要改进时,您将获得更好的结果。 动机水平和对奖励的感知(当改进发生时)要高得多。

最后但并非最不重要的…… (Last but definitely not least…)

Practice continuous learning and self-improvement.

练习不断学习和自我完善。

These are the two most important tools you can equip yourself with. Once you inculcate these habits, they will have the longest-lasting impact on your life and career.

这是您可以装备的两个最重要的工具。 一旦您养成这些习惯,它们就会对您的生活和职业产生最长久的影响。

最后… (Finally…)

If you found this article helpful, please don’t forget to clap ;-)!

如果您发现这篇文章对您有所帮助,请别忘了鼓掌;-)!

Constructive discussions and corrections are most welcome.

欢迎进行建设性的讨论和更正。

翻译自: https://www.freecodecamp.org/news/how-and-why-you-should-tool-up-time-spent-sharpening-your-axe-is-never-wasted-ef74e05e85d0/

影像锐化工具

相关文章:

ListT随机返回一个

/// <summary> /// 随机返回一条数据 /// </summary> /// <param name"list"></param> /// <returns></returns> protected string GetRandomData(List<string> list) {return list.OrderBy(_ > Guid.NewGuid()).First…

微信小程序插件功能页开发详细流程

有问题可以扫码加我微信&#xff0c;有偿解决问题。承接小程序开发。 微信小程序开发交流qq群 173683895 、 526474645 &#xff1b; 正文&#xff1a; 关于新出的微信小程序插件功能页做一下记录&#xff0c;希望能帮到大家 步骤&#xff1a; 1.打开开发者工具&#x…

(拆点+最小路径覆盖) bzoj 2150

2150: 部落战争 Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 518 Solved: 298[Submit][Status][Discuss]Description lanzerb的部落在A国的上部&#xff0c;他们不满天寒地冻的环境&#xff0c;于是准备向A国的下部征战来获得更大的领土。 A国是一个M*N的矩阵&#xff0…

使用Flow检查React,Redux和React-Redux的全面指南

by Fabian Terh由Fabian Terh 使用Flow检查React&#xff0c;Redux和React-Redux的全面指南 (A comprehensive guide to type checking React, Redux, and React-Redux with Flow) This article is divided into 4 sections:本文分为4个部分&#xff1a; Type checking Redux…

微信小程序WebSocket实现聊天对话功能完整源码

相关文章&#xff1a; 1.小程序聊天群&#xff0c;发送语音&#xff0c;文字&#xff0c;图片。 2.微信小程序集成腾讯IM&#xff0c;实现实时音视频通话&#xff0c;1V1聊天 3.云开发微信小程序聊天群 4.接入网易云信IM即时通讯的微信小程序聊天室 5.微信小程序聊天功能 …

codevs 1203 判断浮点数是否相等

1203 判断浮点数是否相等 时间限制: 1 s空间限制: 128000 KB题目等级 : 青铜 Bronze题目描述 Description给出两个浮点数&#xff0c;请你判断这两个浮点数是否相等输入描述 Input Description输入仅一行&#xff0c;包含两个浮点数输出描述 Output Description输出仅一行&…

通过代码自定义cell(cell的高度不一致)

我们知道&#xff0c;在iOS中&#xff0c;自定义cell的方式有两种&#xff1a; 一是通过xib创建 .二是通过代码自定义cell 这里我说下通过代码自定义的cell。 当我们的应用显示的cell比较复杂&#xff0c;显示的行高都不一样&#xff0c;比如新浪微博 这时用系统自带的cell…

通过构建城市来解释HTML,CSS和JavaScript之间的关系

by Kevin Kononenko凯文科诺年科(Kevin Kononenko) 通过构建城市来解释HTML&#xff0c;CSS和JavaScript之间的关系 (The relationship between HTML, CSS and JavaScript explained by building a city) If you have ever visited a walkable city like New York, then you c…

url参数解析 url解析 ?解析成对象

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 代码&#xff1a; // url参数解析 function getUrlkey(url) {var params {};var urls url.split("?");if (urls[1]) {var arr urls[1].split("&");for …

【bzoj1070】[SCOI2007]修车 最小费用流

原文地址&#xff1a;http://www.cnblogs.com/GXZlegend/p/6798411.html 题目描述 同一时刻有N位车主带着他们的爱车来到了汽车维修中心。维修中心共有M位技术人员&#xff0c;不同的技术人员对不同的车进行维修所用的时间是不同的。现在需要安排这M位技术人员所维修的车及顺序…

“Assign Random Colors” is not working in 3ds Max 2015

Go to Customize -> Preferences…-> General (tab) Uncheck “Default to By Layer for New Nodes”转载于:https://www.cnblogs.com/cindy-hu-23/p/4476293.html

计算机编程课程顺序_您可以在6月开始参加630项免费的在线编程和计算机科学课程...

计算机编程课程顺序Six years ago, universities like MIT and Stanford first opened up free online courses to the public. Today, more than 800 schools around the world have created thousands of free online courses.六年前&#xff0c;麻省理工学院和斯坦福大学等大…

卡片右上角三角形效果,按钮点击变色

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 效果图&#xff1a; 实现代码&#xff1a; <view classprivilege_list><view classprivilege_card {{in_right_top1?"bg":""}} bindtapin_card id1&g…

数据挖掘基本任务

数据挖掘基本任务 数据挖掘主要做什么&#xff1f;换而言之&#xff0c;数据挖掘主要解决什么问题呢&#xff1f;这些问题&#xff0c;可以归结为数据挖掘的基本任务。 数据挖掘的基本任务包括分类与预测、聚类分析、关联规则、奇异值检测和智能推荐等。通过完成这些任务&#…

41-First Missing Positive

【题目】 Given an unsorted integer array, find the first missing positive integer. For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2. Your algorithm should run in O(n) time and uses constant space. 【analyze】 1.由于是无序的&#xff0c;所以处理起来…

javascript迭代器_JavaScript符号,迭代器,生成器,异步/等待和异步迭代器-全部简单解释...

javascript迭代器by rajaraodv通过rajaraodv JavaScript符号&#xff0c;迭代器&#xff0c;生成器&#xff0c;异步/等待和异步迭代器-全部简单解释 (JavaScript Symbols, Iterators, Generators, Async/Await, and Async Iterators — All Explained Simply) Some JavaScrip…

jquery总结和注意事项

1、关于页面元素的引用通过jquery的$()引用元素包括通过id、class、元素名以及元素的层级关系及dom或者xpath条件等方法&#xff0c;且返回的对象为jquery对象&#xff08;集合对象&#xff09;&#xff0c;不能直接调用dom定义的方法。 2、jQuery对象与dom对象的转换只有jquer…

第4次作业类测试代码+043+杨晨宇

triangle的代码&#xff1a; package triangle;import java.text.DecimalFormat;public class Triangle {public Triangle() {}/** 判断三角形的类型*/public String triangleshape(int a, int b, int c) {if ((a < 1 || a > 100) || (b < 1 || b > 100) || (c <…

微信小程序让屏幕自动向下滚动

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; wx.pageScrollTo(OBJECT) 基础库 1.4.0 开始支持&#xff0c;低版本需做兼容处理 将页面滚动到目标位置。 OBJECT参数说明&#xff1a; 参数名类型必填说明scrollTopNumber是滚动到…

这就是为什么我们需要在React的类组件中绑定事件处理程序

by Saurabh Misra索拉米斯拉(Saurabh Misra) 这就是为什么我们需要在React的类组件中绑定事件处理程序 (This is why we need to bind event handlers in Class Components in React) While working on React, you must have come across controlled components and event han…

深入JDK源码,这里总有你不知道的知识点!

Java的基础知识有很多&#xff0c;但是我认为最基础的知识应该要属jdk的基础代码&#xff0c;jdk的基础代码里面&#xff0c;有分了很多基础模块&#xff0c;其中又属jdk包下面的lang包最为基础。 我们下面将总结和分析一下lang包下面最为基础和常用的几个部分。 1:常用的对象类…

JS同时上传表单图片和表单信息并把上传信息存入数据库,带php后端源码

微信小程序开发交流qq群 581478349 承接微信小程序开发。扫码加微信。 利用JQ&#xff0c;jquery.form.js&#xff0c;bootstrap实现上传表单图片和表单信息并把上传的图片地址&#xff0c;input填写的信息存入数据库&#xff0c;上传的图片存入服务器。 效果 前端&#xff…

java 的回调函数

在Java中&#xff0c;通常就是编写另外一个类或类库的人&#xff08;李四&#xff09;规定一个接口&#xff0c;然后你&#xff08;张三&#xff09;来实现这个接口&#xff0c;然后把这个实现类的一个对象作为参数传给别人的程序&#xff0c;别人的程序必要时就会通过那个接口…

无导师学习_如何找到一位导师并加快学习速度:新手指南。

无导师学习by Victor Cassone由Victor Cassone 如何找到一位导师并加快学习速度&#xff1a;新手指南。 (How to find a mentor and accelerate your learning: a beginner’s guide.) One of my biggest regrets while learning to program was that I isolated myself too m…

wamp环境下安装imagick扩展

先上图&#xff0c;如下是安装成功后的phpinfo()界面: 安装步骤&#xff1a; 1、先确定安装版本&#xff0c;比如我的的php &#xff1a; php7.0.12 x86 ts 那么就需要三方版本 要一致&#xff1a;imagick软件本身( 如x86 )、php本身( x86 ts (thread safe) )、php扩展php_ima…

php批量修改文件名

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 代码 <?php header("Content-type: text/html; charsetutf-8"); //利用PHP目录和文件函数遍历用户给出目录的所有的文件和文件夹&#xff0c;修改文件名称 function f…

领域驱动设计 敏捷_反馈失败:发现敏捷数据驱动的致命弱点的风险

领域驱动设计 敏捷by Phil Seaton菲尔西顿(Phil Seaton) 反馈失败&#xff1a;发现敏捷数据驱动的致命弱点的风险 (Feedback fail: discover the risk of Agile’s data-driven Achilles heel) 您是否有遭受数据驱动欺骗的危险&#xff1f; (Are you in danger of data-driven…

微信小程序 点击卡片切换 动画效果

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; html <view classaa><image animation"{{animationData0}}" classimg0 stylez-index: {{index_0}}; bindtapbindtap_img id0 src"{{clubs[0].image}}"&…

Log4J的配置

Log4J简介日志记录功能是一个项目中重要的组成部分&#xff0c;Log4J是APache下的一个开源日志组件&#xff0c;为java开发者提供了很大的便利。 Loggers,日志信息的优先级日志信息的优先级从高到低有ERROR、WARN、 INFO、DEBUG&#xff0c;分别用来指定这条日志信息的重要程度…

Xcode中的NSLog详解

探究原因基本上这种事情一定可以在Apple文档中找到&#xff0c;看NSLog的文档&#xff0c;第一句话就说&#xff1a;Logs an error message to the Apple System Log facility.&#xff0c;所以首先&#xff0c;NSLog就不是设计作为普通的debug log的&#xff0c;而是error log…