惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - YQM

NUnit单元测试属性介绍 C#静态构造函数 没有使用lock的Singleton How to serialize and deserialize using C# .NET - YQM Javascript调用web service 简单的英语不简单 我们应该怎样去学习和工作--写给自己 扩展方法 - YQM 使用反射-动态创建对象及调用对象方法 - YQM 使用XmlWriter对象 使用XmlReader类 - YQM 生活15点,要记住! 设计模式之Command模式 使用javascript动态添加和删除table的行和列 Generate unique strings and numbers in C#(生成一个唯一的字符串和数值) Some notes Localization in ASP.NET 2.0 ASP.NET 2.0: Playing a bit with GridView "Sort Grouping" 通过TryParse来检验和转换数据类型
知道做什么而不是怎样做(摘抄)
YQM · 2008-06-11 · via 博客园 - YQM

很多初级程序员问我“我怎样做这个,或者我怎样做那个?”我总是会跟他们说“你想做什么呢?”听闻此言后,他们会死盯着我,就好像我跟他们的妈妈约会了一 样。这就是我的下一个观点,绝不要在知道你想做什么之前去学习怎样做,比如一个程序员想要搜索一个文本文件中是否存在的某个特定的词汇。下面是用C#来实 现该目的:

 string fileContent;  
 System.IO.FileStream myStream 
= new FileStream("c:\\aa.txt", FileMode.Open);  
 System.IO.StreamReader myStreamReader 
= new StreamReader(myStream);   
 fileContent 
= myStreamReader.ReadToEnd();  
  myStreamReader.Close();  
  
int idx = fileContent.  
 IndexOf(
"string");   
  
if (idx)  
 
{  
 
return true  
   }
 

现在我给他这些代码去做这件事,但是更重要的是理解自己正在试着做的是什么。在这个例子中我们想做的是:
1. 打开一个文件
2. 读其中的内容
3. 关闭文件
4. 搜索字串
5. 如果找到了则输出结果
用这个方法来解决事情产生了以下结果:
1. 它使语言无关
2. 使你的精力集中在需要做什么上
3. 使你的代码更易读和有效
知道要做什么将使你的代码更有目的性。现在在C++、PHP、VB.NET、Ruby on Rails中编写上述代码是很容易的事情了,因为你理解了要做什么而不是怎样去做。