知乎周源微信

I really advocate folks reading as much source as they can because you become a better writer by reading as much as writing. That's the whole point of the Weekly Source Code - reading code to be a better developer.

我真的提倡人们阅读尽可能多的资料,因为您会通过阅读和写作而成为更好的作家。 这就是每周源代码的重点-阅读代码以成为一名更好的开发人员。

Reading code in Open Source projects is a good way to learn, especially if the project has been around a while and been successful, or if you already respect the team of people working on it. Less reliably, you can find snippets of code by searching and sharing code.

在开放源代码项目中阅读代码是一种学习的好方法,特别是如果该项目已经进行了一段时间并且取得了成功,或者您已经尊重从事该项目的团队的话。 不太可靠的是,您可以通过搜索和共享代码来查找代码片段。

搜索代码 (Searching Code)

There's basically three players in the "Code Search Engine" space. These are the ones I bump into all the time. There could be others.

“代码搜索引擎”空间中基本上有三个参与者。 这些都是我一直碰到的。 可能还有其他。

  • Koders.com (where Phil Haack used to work)

    Koders.com (Phil Haack曾在哪里工作)

  • Krugle - MSDN is using Krugle to power the MSDN Code Search Preview that searches MSDN Library, MSDN Code Gallery, and CodePlex.

    克鲁格 -MSDN使用Krugle来驱动MSDN代码搜索预览,该搜索可搜索MSDN库,MSDN代码库和CodePlex。

    • (Note, the Krugle MSDN Code Search is going up and down, as it's in preview and they are actively developing it. If you get a login dialog, that's why. Wait a while.)

      (请注意,由于处于预览状态,Krugle MSDN代码搜索正在上升和下降,并且他们正在积极地开发它。如果出现登录对话框,这就是为什么。请稍等。)

    Krugle - MSDN is using Krugle to power the MSDN Code Search Preview that searches MSDN Library, MSDN Code Gallery, and CodePlex.

    克鲁格 -MSDN使用Krugle来驱动MSDN代码搜索预览,该搜索可搜索MSDN库,MSDN代码库和CodePlex。

  • Google Code Search - If you have lots of code on your site you can make its existence explicit to Google by extending your Sitemap to include the CodeSearch extensions. You can also point them to your Subversion repo if it's publically available.

    谷歌代码搜索 -如果您的网站上有很多代码,则可以通过扩展Sitemap使其包含CodeSearch扩展名,使其对Google明确。 您还可以将他们指向您的Subversion仓库(如果它是公开的)。

  • Codase - Been around forever, and still up and running, but nothing new on their homepage for 4 years? What's up? Weird. I don't count them as a player, but they were first, as far as I can see.

    Codase-一直存在并且仍在运行中,但是四年来首页上没有新内容吗? 这是怎么回事? 奇怪的。 我不认为他们是一名球员,但据我所知,他们是第一名。

Searching the web is 99% free text search, as you know. Every once in a while, I'll use an advanced technique like searching with "filetype:ppt" or with a numeric range like "$1500..$3000" but seriously, that's like once in a 100 searches or less. I challenge you if you say you use it more. Free text searching almost always gets it right, unless you're searching for homonyms or something general.

众所周知,网上搜索是99%的免费文本搜索。 每隔一段时间,我将使用一种高级技术,例如使用“ filetype:ppt”搜索或使用数字范围(例如“ $ 1500 .. $ 3000”)进行搜索,但实际上,这就像每100次搜索或更少一次。 如果您说更多使用它,我会挑战您。 自由文本搜索几乎总能正确解决,除非您要搜索同音异义词或一般名称。

Because free text is so good, while I like the idea of a code search engine and I do use them, I'm not sure if I need anything more than a "code-specific free text search." I personally believe that being really specific in your search query is a really good way to filter your way out of the ONE result you need.

因为自由文本非常好,所以虽然我喜欢代码搜索引擎的想法并且确实使用它们,但是我不确定是否需要除“特定于代码的自由文本搜索”之外的任何东西。 我个人认为,在搜索查询中非常具体是一种从所需的一个结果中过滤出自己的方式的好方法。

Sometimes, however, when searching code you will occasionally want the advanced techniques.

但是,有时在搜索代码时,您偶尔会需要高级技术。

Here's some examples:

这里有一些例子:

  • Google Code Search:

    Google代码搜索:

    • BTree lang:C#

      BTree语言:C#

    • license:bsd xdocument lang:c#

      许可:bsd xdocument lang:c#

    Google Code Search:

    Google代码搜索:

  • MSDN Code Search via Krugle

    通过Krugle的MSDN代码搜索

    • btree filename:"*.h"

      btree文件名:“ *。h”

    • Poop findin:comment

      便便查找:评论

    MSDN Code Search via Krugle

    通过Krugle的MSDN代码搜索

  • Koders

    科德斯

    • cdef:md5 (a class called MD5)

      cdef:md5 (称为MD5的类)

    Koders

    科德斯

If you're looking for a specific implementation of something, like an MD5 hash or a BTree, these search engines can be really useful. They can't tell you anything about quality though.

如果您正在寻找某种特定的实现,例如MD5哈希或BTree,则这些搜索引擎会非常有用。 他们无法告诉您有关质量的任何信息。

共享码 (Sharing Code)

在您的博客上...(On your blog...)

I started using SyntaxHighlighter on my blog for all my code snippets and I'm bummed I didn't start earlier. The best aspect of it is that all my snippets are inside of <pre> tags. That means they're easily indexed and not littered with markup. The syntax highlighting is added on the client side by JavaScript. I use the PreCode plugin in Windows Live Writer and wrote up on I do it on my blog. It's fast becoming THE way to post code inline. I even convinced ScottGu (by doing it for him without asking) to use SyntaxHighlighter when I converted the Nerddinner PDF to HTML.

我开始在自己的博客上使用SyntaxHighlighter编写所有代码段,但我感到很沮丧,因为我没有更早开始。 最好的方面是我所有的代码片段都在<pre>标记内。 这意味着它们很容易被索引并且不会乱成一团。 语法高亮显示是通过JavaScript在客户端添加的。 我在Windows Live Writer中使用PreCode插件,并在我的博客上写了关于它的内容。 它正Swift成为内联发布代码的方式。 当我将Nerddinner PDF转换为HTML时,我什至说服了ScottGu(无需询问即可为他完成此操作)使用SyntaxHighlighter 。

在网络上或通过IM ... (On the web or via IM...)

You know by know that pasting code in an IM window is a recipe for pain, and misplaced emoticons. I use code-pasting services for this instead.

您知道,在IM窗口中粘贴代码是痛苦和表情符号放置不当的秘诀。 我为此使用代码粘贴服务。

I really like using Josh Goebel's Pastie for sharing code, although he doesn't formally support C# or VB. I'm slowly moving to Gist.Github.com though.

我非常喜欢使用Josh Goebel的Pastie共享代码,尽管他并不正式支持C#或VB。 不过,我正在慢慢迁移到Gist.Github.com 。

The best social-code-sharing snippet sites are:

最好的社交代码共享代码段站点是:

  • Pastie.org - Favorite of Rubyists and the "original." Couldn't be simpler.

    Pastie.org-Ruby主义者和“原始人”的最爱。 再简单不过了。

  • Pastebin.com - Favorite of IRC users and supports C# and dozens of other languages. Also nice because it supports "expiration" of your code in a day or a month. Nice for email or IM.

    Pastebin.com -IRC用户的最爱,并支持C#和许多其他语言。 也很不错,因为它支持您的代码在一天或一个月内“到期”。 非常适合用于电子邮件或IM。

  • Gist.GitHub.com - Winner for best name, as "Gist" (pronounced "Jist") meaning "Essense" is a great way to express what you're trying to, ahem, express. Just the gist. Supports virtually all languages as well as a "private" option. It also supports versioning, which is unique. This makes sense since Github is a "social source control system." Here's a screencast explaining how this concept can by taking to the next level.

    Gist.GitHub.com-最佳名称的获胜者,“ Gist ”(发音为“ Jist”)意思是“ Essense”,是表达您想要表达的一种好方法。 只是要点。 支持几乎所有语言以及“专用”选项。 它还支持唯一的版本控制。 这是有道理的,因为Github是“社交资源控制系统”。 这是一个截屏视频,解释了如何将这个概念带入新的高度。

I've had an interesting conversation or two about making sharing code easier with Jeff. We'll see where that goes.

关于让Jeff更轻松地共享代码,我进行了一两个有趣的谈话。 我们将看到结果。

代码注释 (Code Comments)

Kind of unrelated, but still fun...I think that every developer should have a blog, or at least an outlet for writing. Those that don't, often use Code Comments to express themselves.

有点无关,但仍然很有趣...我认为每个开发人员都应该有一个博客,或者至少要有一个写作的渠道。 那些没有的人通常使用代码注释来表达自己。

There was a great post at StackOverflow asking for the "best comment in source code you have ever encountered." This, of course, turned into a list of the worst comments ever found in source code, because that's how programmers work, right? Best == Worst. ;) A lot like the Daily WTF.

StackOverflow上有一篇很棒的帖子,要求“您遇到过的源代码中的最佳注释”。 当然,这变成了源代码中发现的最糟糕的注释的列表,因为这就是程序员的工作方式,对吗? 最好==最差。 ;)非常类似于Daily WTF 。

You can find some interesting stuff if you use the code search engines to search for stuff that shouldn't ordinarily be in code. This guy searched the Linux Source Code for swear words and graphed them over time.

如果您使用代码搜索引擎搜索通常不应该包含在代码中的内容,则可以找到一些有趣的内容。 这个家伙在Linux源代码中搜索了脏话,并随着时间的流逝对它们进行了图示。

Some other non-explicit examples...

其他一些非显式的示例...

  • Found on Koder's searching for Poop

    在Koder搜索船尾时发现

    Found on Koder's searching for Poop ; Poor-man's Object-Oriented Programming
    ;                   or
    ;                  POOP
    (module POOP
       (import Utility)

    在Koder的船尾搜寻中发现; 穷人的面向对象程序设计; 要么; 船尾(模块POOP (导入实用程序)

  • Found on Krugle searching for Mind-Numbing

    发现在克鲁格搜索精神

    // mind numbing: let caller use sane calling convention (as per javadoc, 3 params),
    439 // OR the 2.0 calling convention (no ptions) - we really love backward compat, don't we?

    //头脑麻木:让调用者使用理智的调用约定(按照javadoc,3个参数), 439 //或2.0调用约定(无配置)-我们真的很喜欢向后兼容,不是吗?

  • Found on Google Search searching for Hate

    在Google搜索中搜索“仇恨”

     # God, I hate DTDs.  I really do.  Why this idiot standard still# plagues us is beyond me.
  • Found on Google Search searching for Horrible

    在Google搜索上找到了可怕的内容

     case 'H':horrible++;break;
  • Found on Koders searching for "God Himself"...not really a comment, but interesting.

    在寻找“上帝自己”的科德斯上发现的……不是真正的评论,而是有趣的。

     (c.query_gender().equals("male") ? "He" : (c.query_gender().equals("female") ? "She" : "It"))+ " is " +((c.query_level() == client.WIZ_GOD) ?"the Almighty God himself\n\rBeware of his wrath if you don't follow his laws!" :((c.query_level() > client.MORTAL) ? "a powerful immortal" : "a puny mortal")))+ "\n\r"
  • Found on Google Search searching for "profoundly bad"

    在Google搜索中找到了“严重错误”

    if isinstance(real_child, SilentMock):raise TypeError("Replacing a mock with another mock is a profoundly bad idea.\n" +"Try re-using mock \"%s\" instead" % (name,))
  • Found on Google Search looking for "Pure Evil"

    在Google搜索中找到“纯罪恶”

     my $db = delete $access->{db};# This is pure evil.$db->DESTROY;
  • Found on Google Search searching for Poop, but only in Ruby files.

    在Google搜索中搜索Poop,但仅在Ruby文件中找到。

    "Stimpy-drool",
    "poopy",
    "poop",
    "craptacular carpet droppings",

I'm sure if you search, you'll find lots of great stuff in comments, much more colorful than this. For example, the Greatest Code Comment Ever (Line 107) hit tip to Cam Soper:

我敢肯定,如果您进行搜索,您会在评论中找到很多很棒的东西,比这更丰富多彩。 例如,有史以来最伟大的代码注释(第107行)提示了Cam Soper :

uint32 sign=[fh readUInt32BE];uint32 marker=[fh readUInt32BE];uint32 chunklen=[fh readUInt32BE];off_t nextchunk=[fh offsetInFile]+((chunklen+3)&~3);// At this point, I'd like to take a moment to speak to you about the Adobe PSD format.// PSD is not a good format. PSD is not even a bad format. Calling it such would be an// insult to other bad formats, such as PCX or JPEG. No, PSD is an abysmal format. Having// worked on this code for several weeks now, my hate for PSD has grown to a raging fire// that burns with the fierce passion of a million suns.// If there are two different ways of doing something, PSD will do both, in different// places. It will then make up three more ways no sane human would think of, and do those// too. PSD makes inconsistency an art form. Why, for instance, did it suddenly decide// that *these* particular chunks should be aligned to four bytes, and that this alignement// should *not* be included in the size? Other chunks in other places are either unaligned,// or aligned with the alignment included in the size. Here, though, it is not included.// Either one of these three behaviours would be fine. A sane format would pick one. PSD,// of course, uses all three, and more.// Trying to get data out of a PSD file is like trying to find something in the attic of// your eccentric old uncle who died in a freak freshwater shark attack on his 58th// birthday. That last detail may not be important for the purposes of the simile, but// at this point I am spending a lot of time imagining amusing fates for the people// responsible for this Rube Goldberg of a file format.// Earlier, I tried to get a hold of the latest specs for the PSD file format. To do this,// I had to apply to them for permission to apply to them to have them consider sending// me this sacred tome. This would have involved faxing them a copy of some document or// other, probably signed in blood. I can only imagine that they make this process so// difficult because they are intensely ashamed of having created this abomination. I// was naturally not gullible enough to go through with this procedure, but if I had done// so, I would have printed out every single page of the spec, and set them all on fire.// Were it within my power, I would gather every single copy of those specs, and launch// them on a spaceship directly into the sun.//// PSD is not my favourite file format.

Enjoy your search and read more code!

享受您的搜索并代码!

翻译自: https://www.hanselman.com/blog/the-weekly-source-code-41-searching-code-sharing-code-and-reading-code-and-comments

知乎周源微信

知乎周源微信_每周源代码41-搜索代码,共享代码和阅读代码(和注释)相关推荐

  1. 知乎周源微信_每周源代码7

    知乎周源微信 In my new ongoing quest to read source code to be a better developer, I now present the seven ...

  2. 知乎周源微信_每周源代码36-PDC,BabySmash和Silverlight图表

    知乎周源微信 First, let me remind you that in my new ongoing quest to read source code to be a better deve ...

  3. 知乎周源微信_每周源代码33-Google Chrome中的Microsoft Open Source

    知乎周源微信 First, let me remind you that in my new ongoing quest to read source code to be a better deve ...

  4. 知乎周源微信_每周源代码42-树修剪,插件和MEF

    知乎周源微信 I really advocate folks reading as much source as they can because you become a better writer ...

  5. 知乎周源微信_每周源代码56-Visual Studio 2010和.NET Framework 4培训套件-代码合同,并行框架和COM互操作...

    知乎周源微信 Do you like a big pile of source code? Well, there is an imperial buttload of source in the V ...

  6. 知乎周源微信_每周源代码39-Silverlight 3中的Commodore 64仿真器

    知乎周源微信 I had the pleasure of interviewing Pete Brown this last week and talking about the Silverligh ...

  7. 知乎周源微信_每周源代码24-可扩展性版本-.NET中的插件,提供程序,属性,插件和模块...

    知乎周源微信 I've been getting more and more interested in how folks extend their applications using plugi ...

  8. 知乎周源微信_每周源代码18-深度缩放(Seadragon)Silverlight 2 MultiScaleImage鼠标滚轮缩放和平移版...

    知乎周源微信 Dear Reader, I present to you eighteenth in a infinite number of posts of "The Weekly So ...

  9. 知乎周源微信_每周源代码30-具有XML文字的VB.NET作为ASP.NET MVC的视图引擎

    知乎周源微信 I was literally in the middle of writing the post when I saw a message from Andrew Davey abou ...

  10. 知乎周源微信_每周源代码59-开源宝藏:具有讽刺意味的.NET语言实现工具包

    知乎周源微信 One of the best, if not the best way to sharpen the saw and keep your software development sk ...

最新文章

  1. hdu1695(莫比乌斯)或欧拉函数+容斥
  2. MFC的exe启动时提示应用程序配置不正确,应用程序未能启动错误
  3. java jre 中导入导出证书
  4. php进度条插件,分享8款优秀的 jQuery 加载动画和进度条插件_jquery
  5. 使用密钥登录CentOS系统(基于密钥的认证)
  6. 实体服务与虚拟服务迎来数字化发展新契机 中关村助力首都全球数字经济标杆城市建设
  7. 【wpf】在win10系统上弹出toast和notification
  8. JIRA 饼图中文乱码
  9. tiledmap 图块属性_cocos2dx[3.4](25)——瓦片地图TiledMap
  10. 操作系统SPF算法Java实现
  11. python推箱子代码详细讲解_python实现推箱子游戏
  12. arduino学习笔记十四--Arduino 环境光线传感器实验
  13. 宏基因组组装神器-MEGAHIT使用及常见问题
  14. 人工势场算法 Matlab版源码
  15. java 数字补零_java数字位数不足在前后补0
  16. 华为OD机试 - 模拟商场优惠打折
  17. MATLAB 画五星红旗
  18. 【无标题】el-table隐藏横纵滚动条并滚动
  19. 图像语义分割实践(二)数据增强与读取
  20. 入坑量化投资(一): qlib的使用

热门文章

  1. html怎么设置整体右对齐,如何在html中右对齐按钮
  2. 值对象 Value Object
  3. 网页设计配色应用实例剖析——蓝色系
  4. Qt编写可视化大屏电子看板系统2-配色方案
  5. python实现一种相似图片搜索算法
  6. cookie基础知识
  7. 阿里云服务器上传下载速度测试(Speedtest带宽测试工具)
  8. 华硕Armoury crate 奥创控制中心 卡在安装安装已连接设备中,安装失败,请重新启动,网络连接失败(-101)
  9. 电脑自动跳转加QQ好友html,自动添加QQ好友.html
  10. explicit 为什么禁止隐式类型转换