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

编程基础 垃圾回收_为什么我回收编程问题

编程基础 垃圾回收

by Amy M Haddad

通过艾米·M·哈达德(Amy M Haddad)

为什么我回收编程问题 (Why I Recycle Programming Problems)

Many programmers are given the same advice: solve as many problems as possible. It’s true that solving new problems can help you gain experience and enhance your knowledge. I, too, seek out new problems and projects.

许多程序员都得到了相同的建议:解决尽可能多的问题。 解决新问题确实可以帮助您获得经验并增强知识。 我也寻求新的问题和项目。

But I’ve found it equally important to recycle problems: repeating them multiple times, each time with a different intent. There’s a lot to gain from repetition with a purpose.

但是我发现循环问题同样重要:多次重复问题,每次重复都有不同的意图。 有目的的重复有很多好处。

知道我不知道 (Knowing What I Don’t Know)

Just because I’ve solved a problem once doesn’t always mean I can solve it again.

仅仅因为我已经解决了一个问题,并不总是意味着我可以再次解决它。

I was in the library the other day, working on a problem I’d completed earlier in the week, when I got stuck. In a matter of days, I’d forgotten how to solve the problem. Instead of breezing through the exercise, I found myself struggling: working through error after error.

前几天,我在图书馆里,解决了本周初卡住的问题。 几天之内,我就忘记了如何解决问题。 我没有精疲力尽,而是发现自己在挣扎:在一个接一个的错误中工作。

The experience showed me that I need to work more on conditionals and functions. Similar situations have happened before, which is why recycling problems matters: it tests my knowledge and reveals my trouble spots.

经验告诉我,我需要在条件和函数上做更多的工作。 以前也发生过类似的情况,这就是循环问题很重要的原因:它测试了我的知识并揭示了我的麻烦点。

Resolving problems also reinforces concepts. It’s great that I can solve a problem that uses classes when I’m studying them and when the material is fresh in my mind. But can I recall how to use classes a week or two later? Taking a second pass at a problem is a way to find out.

解决问题也加强了概念。 当我学习类并在我的材料中崭露头角时,我可以解决使用类的问题,这是非常棒的。 但是我能记得一两周后如何使用课程吗? 对问题进行第二次通过是找出问题的一种方法。

旧问题,新技巧 (Old Problems, New Tricks)

Adding self-imposed constraints is a second way I recycle programming problems. For instance, I recently used a for loop to solve a problem involving pangrams. On my second time through, I gave myself a simple constraint: solve the problem again without a for loop. In other words, I had to try another approach.

添加自我施加的约束是我回收编程问题的第二种方法。 例如,我最近使用了一个for循环来解决涉及pangram的问题。 第二次,我给自己一个简单的约束: 无需 for循环即可再次解决问题。 换句话说,我不得不尝试另一种方法。

So I tried using a set, and my resulting program became cleaner and more readable. Then, I took it one step further with another constraint: solve the problem with another variation of a set. In total, I reduced the amount of code for this program by more than 50%. And I learned a lot about sets in the process!

因此,我尝试使用一套工具,结果程序变得更简洁易读。 然后,我又走了另一步,又遇到了另一个约束:用另一个变体集解决问题。 总的来说,我将该程序的代码量减少了50%以上。 而且我在此过程中学到了很多东西!

Other times constraints end up complicating my code. In one recycled problem I gave myself the constraint to use a while loop, and the program became long and complex; the for loop I had used on a previous iteration was a better option. Even still, repeating a problem with a constraint helped me understand when it’s advantageous to use one approach over another.

有时约束最终会使我的代码复杂化。 在一个可循环使用的问题中,我给自己一个使用while循环的约束,程序变得冗长而复杂。 我在之前的迭代中使用的for循环是一个更好的选择。 即便如此,重复约束问题也有助于我理解何时使用一种方法优于另一种方法。

Despite the result, repeating a problem with constraints gets me outside my comfort zone and makes me think in new and creative ways. I usually get stuck and have to do some research. In the process, I pick up details I’d overlooked and learn new ways of doing things.

尽管有结果,但是重复约束问题却使我脱离了自己的舒适范围,并使我以新颖和创新的方式思考。 我通常会卡住,必须做一些研究。 在此过程中,我将收集一些我所忽略的细节,并学习新的做事方式。

学习写作测试 (Learning to Write Tests)

I’m on my third time through the dozens of problems in Brian Hogan’s book Exercises for Programmers. I’ve had a different intent for each iteration. This time through I’m practicing writing my own tests.

我是第三次浏览Brian Hogan的《 程序员练习》一书中的许多问题。 每次迭代我都有不同的意图。 这次我正在练习编写自己的测试。

This is how it works: I pick a problem at random from Hogan’s book and solve it. I organize the program into separate files; each file is responsible for a different part of the solution. Then, I write the tests. Ultimately I want to write the tests first, then write the code, but I’m not quite there yet. Meanwhile, though, I’m getting a lot of practice writing and extracting functions and importing files.

它是这样工作的:我从Hogan的书中随机选择一个问题并加以解决。 我将程序组织成单独的文件; 每个文件负责解决方案的不同部分。 然后,我编写测试。 最终,我想先编写测试,然后再编写代码,但是我还没有。 但是,与此同时,我正在练习编写和提取函数以及导入文件。

There’s a broader point to purposeful repetition: it helps me see patterns and solidify them in my mind, so I can use them as mental models for new problems. That’s the advice George Polya gives in his book How to Solve It. When tackling a new problem, he recommends to “seek contacts with your formerly acquired knowledge.” He goes on:

有目的的重复存在更广泛的意义:它可以帮助我看到模式并在我的脑海中巩固它们,因此我可以将它们用作解决新问题的心理模型。 这就是乔治波利亚(George Polya)在他的书《 如何解决》中的建议。 解决新问题时,他建议“与您以前获得的知识联系”。 他继续说:

“Try to think of what helped you in similar situations in the past. Try to recognize something familiar in what you examine, try to perceive something useful in what you recognize.”

“试着想想过去在类似情况下对您有什么帮助。 尝试识别您所检查的事物中熟悉的事物,尝试感知您所识别的事物中有用的事物。”

He’s right. I recently completed a problem where I had to identify anagrams. Before I typed a line of code, I recalled a similar anagram problem I’d solved a few weeks prior. Although the original problem was much easier than the one at hand, it gave me a place to start.

他是对的。 我最近完成了一个必须识别字谜的问题。 在输入一行代码之前,我想起了几周前解决的一个类似的字谜问题。 尽管最初的问题比手头的问题要容易得多,但它为我提供了一个起点。

Recycling problems with a specific intent has been hugely beneficial. It’s solidifying concepts, giving me exposure to new ones, and building a strong foundation of knowledge, and that’s what I’m after as a beginner programmer.

出于特定目的回收问题非常有益。 它巩固了概念,使我接触到新概念,并建立了坚实的知识基础,这就是我作为初学者程序员所追求的。

I’m a writer, writing about technology, productivity, and art (amymhaddad.com), and a beginner programmer.

我是一名作家,写有关技术,生产力和艺术( amymhaddad.com )的文章,也是一名初学者。

翻译自: https://www.freecodecamp.org/news/why-i-recycle-programming-problems-7785e04e451d/

编程基础 垃圾回收

相关文章:

SQL Server孤立账户解决办法

选择你想要的数据库。 执行 exec sp_change_users_login UPDATE_ONE,用户名,登录名 假如你的登录名是:sd exec sp_change_users_login UPDATE_ONE,sd,sd 转载于:https://www.cnblogs.com/runliuv/p/7273675.html

vue更新data无效,页面data没刷新 vue.set

Vue中组件的data是有很多坑的&#xff0c;先普及一下常识&#xff1a; 1.想使用data&#xff0c;必须先在data中创建。&#xff08;如果不创建就会报错&#xff09;示例&#xff1a; <div class"">{{user.Age}}</div>new Vue({el: #app,data: {user:{A…

重温Thinking in java

1、高精度 BigInteger、BigDecimal 支持任意大小的数字 不能使用运算符 运算速度相对于int、float稍慢 2、对象作用域 {String s new String("aaa"); } 在}外 此时栈中的引用s已经超出了自己的作用域 便不存在了 但是new String("aaa")这个堆中的对象仍然…

2018 react 大会_React Conf 2018的经验教训

2018 react 大会by Yangshun Tay阳顺泰 React Conf 2018的经验教训 (Lessons Learned at React Conf 2018) I was fortunate to have attended React Conf 2018 thanks to my managers — it was an awesome event. I have been watching past React Conf videos online and i…

删除url中某个参数

这里的url 是指一个网站链接 例如&#xff1a; https://baidu.com?a1&b2 下面看一下封装的代码 <!DOCTYPE html> <html><head><meta charset"utf-8"><script src"https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js&q…

【转载】MSXML应用总结 开发篇(下)

原文&#xff1a;http://blog.sina.com.cn/s/blog_48f93b530100eq4b.html 三、查询XML文档节点 这部分属于“读”XML文档并做节点遍历&#xff0c;由于担心加上实例会占用过多的篇幅影响阅读&#xff0c;先在这篇做方法总结&#xff0c;以后有时间再写一篇“实战篇”专门写个实…

d010:盈数、亏数和完全数

题目: 对一个正整数N而言&#xff0c;将它除了本身以外所有的因子加起来的总和为S&#xff0c;如果S>N&#xff0c;则N为盈数&#xff0c;如果S<N&#xff0c;则N为亏数&#xff0c;而如果SN&#xff0c;则N为完全数&#xff08;Perfect Number&#xff09;。例如10的因子…

软件开发 理想_我如何在12个月内找到理想的软件工作

软件开发 理想In this talk, Matt Woods shares the 3 cornerstone habits that helped him land his dream software job in just 12 months. These habits paved the way for him to consistently grow as a software developer, balloon his professional network, and easi…

Angular4.0从入门到实战打造在线竞拍网站学习笔记之四--数据绑定管道

Angular4.0基础知识之组件Angular4.0基础知识之路由Angular4.0依赖注入Angular4.0数据绑定&管道 数据绑定 数据绑定允许你将组件控制器的属性和方法与组件的模板连接起来&#xff0c;大大降低了开发时的编码量。 常见的表现形式有&#xff1a; 插值表达式&#xff1a;<h…

给GridView增加求和行

1、在WebForm窗体中&#xff0c;设置GridView的ShowFooter"True" 2、在后台代码中 private int jhrs0,ybrs0;//定义变量 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowIndex > 0) { jhrs Convert.ToInt16(e.Ro…

phpMyAdmin 数据库添加int类型的值时默认设为唯一主键的问题解决

数据库的表中插入了一条数据&#xff0c;再插入数据就插入不进去。 这是我今天在开发数据库的时候&#xff0c;遇到一个问题&#xff0c;经过排查&#xff0c;是数据库的结构有问题&#xff0c;有字段是唯一数据&#xff0c;但是目前还不想设置它的值。 场景环境描述&#xff…

python 类中定义类_Python中的动态类定义

python 类中定义类Here’s a neat Python trick you might just find useful one day. Let’s look at how you can dynamically define classes, and create instances of them as required.这是一个整洁的Python技巧&#xff0c;有一天可能会有用。 让我们看一下如何动态定义…

用自定义方法,传入成绩数组,实现输出考试成绩的成三名

package com.imooc; import java.util.Arrays; //导入Array类包 import java.util.Scanner; //导入Scanner类包 public class Final2 { public static void main(String args[]){Scanner…

EJS 什么是EJS后缀文件 EJS怎么用

一、什么是EJS EJS是一个JavaScript模板库&#xff0c;用来从JSON数据中生成HTML字符串。 二、为什么要使用EJS 与最初的JavaScript相比较&#xff0c;一些不太了解你的代码的人可以更容易地通过EJS模板代码看得懂你的代码。 让我们放松一下&#xff0c;一起来享受下令人激动的…

一个推荐系统,实现完整的设计-在百度搜索关键词推荐案例

在之前一篇博文中&#xff0c; 有同学在评论中问了个问题&#xff1a; 怎样解决因式分解带来的推荐冷门。热门关键词的问题。 在回答这个问题的时候&#xff0c; 想到了近几年在做搜索推荐系统的过程中&#xff0c; 学术界和工业界的一些差别。 正好近期正在做技术规划&#xf…

如何充分利用JavaScript(ES6)中的解构功能

by Joanna Gaudyn乔安娜高登(Joanna Gaudyn) Destructuring was a new addition to ES6. It took inspiration from languages like Python and allows you to extract data from arrays and objects into distinct variables. It might sound like something you’ve done in…

React 开发环境搭建

先来一个 React 官方文档的链接 点击跳转 搭建 React 的前期准备&#xff1a;你的本地环境需要安装 cnpm、node。 注&#xff1a;代码块中的 $ 代表&#xff1a; $后面是在命令行输入的命令&#xff0c;举例 $ npm start 解&#xff1a;实际上是应该打开命令行输入 npm st…

c++中的友元重载

1 语法 返回值类型 operator 运算符名称(形参列表) { 重载实体 } --------->operator和运算符名称在一起构造成新的函数名 2 案例 1 #include <iostream>2 3 using namespace std;4 5 class Complex6 {7 public:8 9 Complex(float x0,float y0) 10 :_…

WPF解析TTF 字体

偶遇需要自己解析 TTF 字体并显示&#xff0c;此做。。。 using System; using System.Collections.Generic; using System.Drawing.Text; using System.IO; using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Windows; using System.W…

redux logic_Redux-Logic简介

redux logicby Sam Ollason通过萨姆奥拉森(Sam Ollason) Redux-Logic简介 (An Introduction to Redux-Logic) This article will go through a high-level overview of Redux-Logic. We will look at what is it, why it is needed, how it differs from other Redux middlewa…

[SDOI2009]HH的项链

题目背景 无 题目描述 HH 有一串由各种漂亮的贝壳组成的项链。HH 相信不同的贝壳会带来好运&#xff0c;所以每次散步完后&#xff0c;他都会随意取出一段贝壳&#xff0c;思考它们所表达的含义。HH 不断地收集新的贝壳&#xff0c;因此&#xff0c;他的项链变得越来越长。有一…

DvaJS 入门, 快速上手Dva

为什么要使用Dva? React 没有解决的问题 React 本身只是一个 DOM 的抽象层&#xff0c;使用组件构建虚拟 DOM。 如果开发大应用&#xff0c;还需要解决一个问题。 通信&#xff1a;组件之间如何通信&#xff1f;数据流&#xff1a;数据如何和视图串联起来&#xff1f;路由…

Static、DynamicResource学习笔记一

定义了资源后&#xff0c;我们可以在元素中直接使用该资源&#xff0c;但又分为StaticResource及DynamicResource两种方式。 StaticResource 静态资源在首次创建窗口时一次性的设置完毕&#xff0c;之后源资源对象本身发生的任何变化都会影响到使用该资源的元素&#xff0c;如果…

javascript迭代器_JavaScript迭代器概述

javascript迭代器by Joanna Gaudyn乔安娜高登(Joanna Gaudyn) JavaScript迭代器概述 (An overview of JavaScript iterators) for&#xff0c;for…in和for…of循环之间的区别 (The difference between for, for…in and for…of loops) Iteration might be one of the most c…

knockout学习笔记目录

关于knockout学习系列的文章已经写完&#xff0c;这里主要是做个总结&#xff0c;并且将目录罗列出来&#xff0c;方便查看。欢迎各位大神拍砖和讨论。 总结 kncokout是一个轻量级的UI类库&#xff0c;通过MVVM模式使前端的UI简单话&#xff0c;减少javascript代码的编写。通常…

ant Design Pro 登录状态管理

未登录自动跳转到登录页面&#xff0c;登录成功不跳转回登录页面的实现代码调用流程。 ant Design Pro 是一个企业中后台管理框架&#xff0c;开始做他&#xff0c;第一个肯定是要做登录&#xff0c;下面来看一下它是怎么登录的。 先看路由配置 Authorized.jsx代码&#xff1…

初级java开发学习路线_成为初级全栈Web开发人员的10分钟路线图

初级java开发学习路线So you have started your journey into the world of web development. But what do you learn first? The Internet is overloaded with a wealth of information about the millions of different technologies that a web developer can know.因此&am…

国外物联网平台初探(四):Ayla Networks

定位 Ayla企业软件解决方案为全球部署互联产品提供强大的工具 功能 Ayla的IoT平台包含3个主要组成部分&#xff1a; (1) Ayla嵌入式代理Ayla Embedded Agents (2) Ayla云服务Ayla Cloud Services (3) Ayla应用库Ayla Application Libraries 设备 开发者使用任何微控制器、操作系…

《英语语法新思维初级教程》学习笔记(一)名词短语

参考资料&#xff1a; 1. 《英语语法新思维初级教程》 ▶ 知识点 ▼ 英语是“固定词序语言&#xff08;a fixed-word-order language&#xff09;”。 ▼ 语言的构造级别分五个层次&#xff1a;1. 词&#xff08;word&#xff09;&#xff1b;2. 短语&#xff08;phase&#xf…

根据数组中对象的属性值排序倒叙

数组中对象的属性值排序倒叙demo function compare(e) {return function (a, b) {var value1 a[e];var value2 b[e];return parseInt(value1) - parseInt(value2);} } var arr[{a:2},{a:3},{a:1}];var arr2 arr.sort(compare(time)).reverse();console.log(arr2) //[{a:3}…