问题标签 [implementation]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
131 浏览

language-agnostic - What are some authoritative/respected "best known implementation" websites/resources?

EDIT:

Wow, the initial response to this question was quite negative. I think I might have triggered some pretty strong emotions by using the word "best"; it seems like a few people latched onto that word and decided to dismiss my question right away.

Obviously, there are many, many situations in which no single approach is "best", or at least, what ends up being the best solution to one problem will often not be the best solution for other, even similar, problems. I get that. But now let me try to elaborate on the reasoning behind what I'm actually asking.

I tend to find it easiest to explain myself using analogies, so here goes. In my current job I work almost exclusively in .NET. .NET has a lot of functionality built into the framework. A prime example is the System.Collections.Generic namespace, which has a bunch of collection classes that (almost) no .NET developer in his/her right mind would bother re-developing from scratch, because very good implementations are already there. If I am working on a problem that requires a doubly linked list, I'm not going to decide, "Okay, time to write a doubly linked list class"; I'm just going to use the LinkedList<T> that's already there, or, at most, extend it or wrap it with my own class that adds some extra functionality.

Am I saying the "best" version of a doubly linked list is LinkedList<T> from .NET? Of course not. That would be absurd. But I highly doubt .NET's implementation of LinkedList<T> is drastically different from most other established libraries' implementations of collections that are intended to serve the same purpose (that of a doubly linked list). On the other hand, I am relatively confident that if I were to write my own implementation from scratch, there'd be a considerable number of issues with it, in terms of robustness, performance, flexibility, etc. for one simple reason: not that I'm stupid, or lazy, or don't care about good code--simply that I'm one person, and I'm not an expert on linked lists, and I haven't thought of everything that needs to be taken into consideration when designing one.

But I happen to be a developer who does take an interest in how things are implemented internally. And so it would be nice if I could check out a page where some variant of a well thought-out design for a linked list--or for any fairly established concept for which robust, efficient implementations have been written--were available to view. (By the way, yes I am aware that the source code for .NET's LinkedList<T> is available. I'm just using that as an example; really I am talking about all problems with solutions for which good, working implementations exist.)

Now, I talked about this being something that is open; let me elaborate on that. I am not talking about sites like SourceForge.net, or CodePlex, or Google Code. These are all sites for hosting projects, i.e., applications or libraries tailored for some specific industry or field or otherwise categorizable purpose. What I'm talking about is something like this:

http://en.wikibooks.org/wiki/Category:Algorithms_and_data_structures

Maybe I should have just provided that link in the first place, as it probably illustrates what I'm getting at better than anything I've written so far. But I think the main point that differentiates what I'm asking about from any other site I've seen is that I was specifically wondering if there could be some way to work on a new problem--so, something for which there aren't necessarily any well-known, established implementations, again as in my linked list example--collaboratively, in a wiki-esque fashion, but not tied to any specific open-source project.

So, as a conclusion of sorts, I was kind of envisioning a situation like the following: I find myself faced with a new problem. Maybe it isn't common enough to be something that is addressed in a framework like .NET. But it's common enough that some developers here and there are independently working on it. If a website exists like what I'm imagining, maybe at some point one of those developers working on the problem could post an idea on that website, and over time others might discover it and suggest improvements/modifications, and given enough time and participation, a pretty darn good implementation might result from all this collaboration. And from there, eventually, something like this implementation might be considered fairly "standard", just like a linked list implementation, or a quicksort implementation, or, I don't know, some well-known pseudo-random number generator.

Does this make any more sense to anyone now? I feel quite confident that what I'm talking about is not absurd, but hey, if that's what people think, then maybe it is.


Open source projects are very popular. Some of these are libraries suited for specific purposes, the best of which include some very well-written code.

However, if you're interested in contributing to an open source project, finding a project that is well-suited to your skills can be quite a task. At the same time, if you're interesting in using an open source project in your own work, finding a project that is well-suited to your needs can also be difficult, especially when, for example, open-source library X has a lot of functionality you could use, as does library Y, and these two libraries' capabilities overlap so that integrating both into your code could be messy.

We've all seen questions, here on Stack Overflow and elsewhere on the web, posted by one developer: "How would I implement this idea?" and answered by others, often accompanied by a plethora of example code. Sometimes these answers link to an open source project/library that provides functionality similar to what the poster is asking about.

My question is: are there any well-known websites or other sources that are open in nature and provide "best-known implementations" for common (or even not-so-common) programming problems, but not associated with any particular open source project?

As a generic example, suppose I have a need for some algorithm that does X. I post a question on SO or some other site requesting ideas, asking for suggestions on how best to implement it. One person points me to project P1, which contains some code that performs something very similar to this algorithm. Another person points me to project P2. Someone else writes some sample code and says, "maybe you could do it like this."

It seems to me, if there are all these different versions of this idea floating around out in the world, it would make sense for there to be a site, somewhat in the vein of Wikipedia, where a quasi-"official" implementation ("official" is not the right word; I'm just having trouble thinking of a better one right now) could be published and modified as improvements are developed/discovered.

I feel like I have stumbled across a few different sites like this in the past, but I'm interested to know if anyone else has found any resources like what I'm describing.

0 投票
2 回答
1061 浏览

vb.net - 为什么?重新声明实现接口的东西?!在 VB.NET 中

我在 VB.NET v2 中工作

我有一个接口IMyInterface,这个接口实现了一个方法MyMethod

我有一个对象MyObjectBase。该对象包含一个(相同的)方法MyMethod

1)如果现在我确实MyObject Inherits MyObjectBase Implements IMyInterface 需要重新定义?(阴影,覆盖)MyMethodMyObject课堂上?

2)如果MyMethod我有一个MyEvent 事件的方法,现在怎么办?

谢谢。

0 投票
3 回答
616 浏览

php - 为什么MD5碰撞失败?

这两个数据块来自该站点,但未能产生冲突:

哪个输出a bool(false),我做错了什么吗?

编辑 最好的演示?

0 投票
2 回答
2105 浏览

javascript - Javascript CPS(延续传递风格)实现

由于IBM Developer Works 中有一篇关于 CPS (continuation pass style) 的文章,我试图不使用“return”。

没有 CPS

过渡

函数的其余部分

带 CPS

问题

循环在函数的其余部分结束。

解决办法是什么?

0 投票
8 回答
1596 浏览

c++ - C++:使方法虚拟化的含义

应该是新手问题...

我在现有类 A 中有现有代码,我想扩展它以覆盖现有方法 A::f()。

所以现在我想创建类 B 来覆盖 f(),因为我不想只更改 A::f(),因为其他代码依赖于它。

为此,我相信我需要将 A::f() 更改为虚拟方法。

我的问题是除了允许动态调用方法(使用 B 的实现而不是 A 的实现)之外,使方法虚拟化还有其他含义吗?我是否打破了某种良好的编程习惯?这会影响任何其他尝试使用 A::f() 的代码吗?

请告诉我。

谢谢,jbu

编辑:我的问题更多的是让别人的方法虚拟化有什么问题吗?即使您没有更改其他人的实现,您仍然必须进入某人的现有代码并更改声明。

0 投票
9 回答
7545 浏览

php - 如何从头开发 MVC 框架?

View容易与MC分离,

但是如何区分 M 和 C?区别对我来说似乎有点模糊。

我正在使用 PHP。

0 投票
5 回答
144 浏览

enums - 枚举的表示

枚举如何在编程语言的“幕后”工作?我猜每种语言都有不同的方式来表示这些数据类型。

在 java 中,您可以使用 == 运算符,例如:

枚举类型是否在 == 期间转换为原始类型?还是枚举值是单例?C# 是否以与 java 相同的方式利用枚举?与编程语言相比,数据库枚举类型的处理方式是否不同?

0 投票
2 回答
534 浏览

unix - 写入套接字是 sendfile() 系统调用的任意限制吗?

序幕

sendfile()是一个非常有用的系统调用,原因有两个:

首先,它比/ (或者/如果你更喜欢那个 jive)循环的代码更少。 其次,它比上述方法更快(更少的系统调用,实现可以在没有缓冲区的设备之间复制等......)。read()write()recv()send()

更少的代码。更高效。惊人的。

在 UNIX 中,一切(大部分)都是一个文件。这是柏拉图理论与现实世界实践碰撞的丑陋领域。我知道套接字与驻留在某些设备上的文件根本不同。我还没有深入研究 Linux/*BSD/Darwin/任何操作系统实现的源代码,sendfile()以了解为什么这个特定的系统调用仅限于写入套接字(特别是流式套接字)。

我只是想知道...

问题

sendfile()允许目标文件描述符成为套接字以外的东西(如磁盘文件或管道)有什么限制?

0 投票
7 回答
5261 浏览

seo - Google 如何知道您在伪装?

我似乎找不到任何关于谷歌如何确定你是否隐藏你的内容的信息。从技术角度来看,您认为他们是如何确定这一点的?他们是否发送了 googlebot 以外的内容并将其与 googlebot 结果进行比较?他们有一群人比较吗?或者他们能以某种方式告诉您已经检查了用户代理并执行了不同的代码路径,因为您在名称中看到了“googlebot”?

这与关于 seo 的合法 url cloaking 的问题有关。如果文本内容完全一样,但渲染不同(1995 年风格的 html vs. ajax vs. flash),真的有隐藏的问题吗?

谢谢你穿上这个。

0 投票
2 回答
197 浏览

java - 面向对象的执行

考虑以下源代码片段:

片段#1

片段#2

片段#3

问:哪个片段最面向对象,为什么?

问:每个片段的优缺点是什么?