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

推荐订阅源

T
The Exploit Database - CXSecurity.com
F
Fortinet All Blogs
U
Unit 42
F
Full Disclosure
雷峰网
雷峰网
博客园 - 司徒正美
云风的 BLOG
云风的 BLOG
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
The Cloudflare Blog
Last Week in AI
Last Week in AI
罗磊的独立博客
D
DataBreaches.Net
C
Check Point Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
O
OpenAI News
C
CXSECURITY Database RSS Feed - CXSecurity.com
aimingoo的专栏
aimingoo的专栏
S
Security @ Cisco Blogs
大猫的无限游戏
大猫的无限游戏
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
SegmentFault 最新的问题
NISL@THU
NISL@THU
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Hacker News
The Hacker News
Webroot Blog
Webroot Blog
Security Latest
Security Latest
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Google DeepMind News
Google DeepMind News
酷 壳 – CoolShell
酷 壳 – CoolShell
N
News | PayPal Newsroom
P
Proofpoint News Feed
B
Blog RSS Feed
MongoDB | Blog
MongoDB | Blog
C
Cybersecurity and Infrastructure Security Agency CISA
N
News and Events Feed by Topic
Google Online Security Blog
Google Online Security Blog
H
Help Net Security
Spread Privacy
Spread Privacy
T
Threat Research - Cisco Blogs
GbyAI
GbyAI
I
Intezer
Application and Cybersecurity Blog
Application and Cybersecurity Blog
M
MIT News - Artificial intelligence
Vercel News
Vercel News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
IT之家
IT之家
MyScale Blog
MyScale Blog
腾讯CDC

博客园 - YQM

NUnit单元测试属性介绍 C#静态构造函数 没有使用lock的Singleton How to serialize and deserialize using C# .NET - YQM Javascript调用web service 简单的英语不简单 我们应该怎样去学习和工作--写给自己 扩展方法 使用反射-动态创建对象及调用对象方法 使用XmlWriter对象 使用XmlReader类 生活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中编写上述代码是很容易的事情了,因为你理解了要做什么而不是怎样去做。