问:
Given a set of VLSI chips, how do I determine which are good?
I have the following problem:

Given n chips [note: these are VLSI chips] out of which majority of chips are good, we need to find one good chip. The only test that we can apply is on a pair of chips that answers if both chips are good or both are bad.
  The second part is to find a good chip if some tests might produce a wrong result. Also, the results are systematic meaning that if a pair gives wrong result, it will always give the wrong result.

I have solved the first problem using divide and conquer approach where I reduce the problem set to at least half every time. This can be done by simply performing tests on n/2 distinct pairs every time and keeping those pairs that answer a YES (i.e. both good or bad). I am unable to solve the second part of the problem.

A wrong result means that even if two chips are good or bad, the test might answer a NO. Also note that the percentage of wrong tests is very low.

How can I go about solving this problem?

答:
For the first problem I don't think divide and conquer is the best approach.  You would just want to walk the list until you found a good pair.  An explanation may help here:

```<code>Starting size = 100
First split = 50/50
Second split = 25,25 / 25,25
Third split = 12,13,12,13/ 12,13,12,13
Fourth split = 6,6,6,7,6,6,6,7/ 6,6,6,7,6,6,6,7
Fifth split = 3,3,3,3,3,3,3,4,3,3,3,3,3,3,3,4/3,3,3,3,3,3,3,4,3,3,3,3,3,3,3,4
etc.
</code>```

Then we start working on each of those pairs until we find a good one.  This is far less efficient than just walking a list for a good pair.

In terms of the second problem this is a general manufacturing problem so solving it is not as straight forward as one would think.  The reason why it is hard is that it means that the testing program is inheritently incorrect.  It is why when you buy a new laptop it can pass system test and fail to function when you get it home and turn it on. There is not yet a practical answer for this in the real world, so solving it makes you rich (essentially).  The following page provides some analysis on the chip problem: chips

OwnerDisplayName: Anna

Body:
For the first problem I don't think divide and conquer is the best approach.  You would just want to walk the list until you found a good pair.  An explanation may help here:

Starting size = 100
First split = 50/50
Second split = 25,25 / 25,25
Third split = 12,13,12,13/ 12,13,12,13
Fourth split = 6,6,6,7,6,6,6,7/ 6,6,6,7,6,6,6,7
Fifth split = 3,3,3,3,3,3,3,4,3,3,3,3,3,3,3,4/3,3,3,3,3,3,3,4,3,3,3,3,3,3,3,4
etc.

Then we start working on each of those pairs until we find a good one.  This is far less efficient than just walking a list for a good pair.

In terms of the second problem this is a general manufacturing problem so solving it is not as straight forward as one would think.  The reason why it is hard is that it means that the testing program is inheritently incorrect.  It is why when you buy a new laptop it can pass system test and fail to function when you get it home and turn it on. There is not yet a practical answer for this in the real world, so solving it makes you rich (essentially).  The following page provides some analysis on the chip problem: chips


答:
To find the wrong results, I would compare each chip to multiple other chips. If chips 1 and 2 give a wrong result, the likelihood that comparing 1 to 3, 4, 5, and 6 all also giving wrong results in those four comparisons is greatly diminished. Since you know the percentage of wrong results, it's probably possible to do some math to calculate how many comparisons you need to do to completely eliminate the wrong results, or at least reduce it to an acceptable rate. In the real world you'd sure want to do that, and then some -- perhaps balancing the cost of each comparison, the cost of using/shipping bad chips, and needlessly tossing good chips.

You also don't clearly say what happens when you compare good vs. bad (good test and wrong result). A wrong result with bad vs. bad would be YES, wouldn't it? Make sure you cover all scenarios.

ContentLicense: CC BY-SA 3.0

Title: Given a set of VLSI chips, how do I determine which are good?

Body:
I have the following problem:

Given n chips [note: these are VLSI chips] out of which majority of chips are good, we need to find one good chip. The only test that we can apply is on a pair of chips that answers if both chips are good or both are bad.
  The second part is to find a good chip if some tests might produce a wrong result. Also, the results are systematic meaning that if a pair gives wrong result, it will always give the wrong result.

I have solved the first problem using divide and conquer approach where I reduce the problem set to at least half every time. This can be done by simply performing tests on n/2 distinct pairs every time and keeping those pairs that answer a YES (i.e. both good or bad). I am unable to solve the second part of the problem.

A wrong result means that even if two chips are good or bad, the test might answer a NO. Also note that the percentage of wrong tests is very low.

How can I go about solving this problem?

OwnerDisplayName: minnow


答:
I think this is a clustering problem: you have two clusters - the good chips and the bad chips. Your test tells you if two chips belong in the same cluster or not - at least under my interpetation of the question you have asked. The reference provided in the answer by Woot4Moo suggests a different question to this.

For the first part of the test, pick one chip and test every other chip against it. You get two clusters of chips - those that are of the same kind as the first chip, and those that are different. The good chips are in the larger cluster, so pick one at random.

For the second part, use n chips for testing, so that for each chip you have an n-bit pattern, saying whether it was in the same cluster as each of the n test chips. Expect to see mostly two sorts of patterns, each the inverse of the other. You can use this to sort the chips into two clusters as before, and hope that the larger cluster is composed of good chips.


问:
Using C++ but not using the language's specific features, should switch to C?
I'm developing a NES emulator as a hobby, in my free time.  I use C++ because is the language I use mostly, know mostly and like mostly.

But now that I made some advance into the project I realize I'm not using almost any specific features of C++, and could have done it in plain C and getting the same result. I don't use templates, operator overloading, polymorphism, inheritance. So what would you say? should I stay in C++ or rewrite it in C?

I won't do this to gain in performance, it could come as a side effect, but the idea is why should I use C++ if I don't need it?

The only features of C++ I'm using is classes to encapsulate data and methods, but that can be done as well with structs and functions, I'm using new and delete, but could as well use malloc and free, and I'm using inheritance just for callbacks, which could be achieved with pointers to functions.

Remember, it's a hobby project, I have no deadlines, so the overhead time and work that would require a re-write are not a problem, might be fun as well. So, the question is C or C++?

答:
You aren't using it now, but the next time you leak memory or get a double delete, you'll be begging to come back to std::vector<T>, std::unique_ptr<T, Del> and std::shared_ptr<T>, which can solve those problems easily- almost trivially. That's what happens to everyone who uses C over C++, eventually, and the smarter ones just don't wait for the bugs to pop up before moving over.

Code that uses new and delete directly doesn't really belong in C++, it belongs in that kind of half house that we refer to as "C with Classes". That's where the language was circa 1985. It's not particularly similar to C++, circa 2011. In all likelihood, wherever you learned C++ simply didn't teach it very well- something that is unfortunately rather common- and with a better education, you would find use of these features.

Specifically, as I listed above, C++'s generic data structures and the resource-managing classes simply are fundamentally massively superior to anything C has to offer. If you want a dynamically allocated array, then use std::vector<T>. That's a pretty common use case. If you aren't using them, then your code is at huge risk of error unnecessarily- especially resource management related. C++ can guarantee safety and re-use code in a way that C can never touch.

However, I think that you also might be expecting too much. Writing templates and operator overloads is not common for library consumers. If your code uses std::vector<T>, you don't need to write a template to make that happen. If your code uses std::string, nobody is forcing you to overload your operators. You only have to do those things to write std::vector<T> and std::string- but you can still take full advantage of them.

Polymorphism/inheritance also only has a specific use case. If your code happens to not require you to write any templates or use virtual functions, then it doesn't, and there are programs or segments of programs where you don't need to write your own templates.

Also, there's no gain in performance in C over C++.


问:
How to get a programmer to apply nice design touches?
We have a small webdesign firm, and count with one designer. We can currently not afford too much expansion in the design area, so that means that the designer creates the main design of a website (which often means: the homepage), and the programmers then work with this to make it into a website. In general, this works for us. However, I have noticed a big difference between the abilities of different programmers to apply 'nice design touches' to a website. Given that we only have the homepage design, we often need to structure internal sections ourselves. Nothing major, no design program needed, but CSS skills come into play. So let's say we need to show a list of different sections in the website. I will have the content and assign this to two programmers. One will come up with this:

And another will do very much his best - and has the same CSS knowledge - but can only come up with something like this:

NOTE: sample image taken from MailChimp website.

The second programmer is aware that his 'design' lacks style and that it needs improvement, but he is just not able to create something nice without having it all drawn up by somebody else. He wants to work on this, but I do not know what a good approach would be. Any tips? Anybody with similar experiences?

答:
It's very rare to find a programmer who can design to a good standard. Design can be very hard for some programmers while programming can be very hard for some designers. If it was easy for programmers you wouldn't need designers.

Let the programmer create the initial layouts from the home page then let the designer review each (and perhaps tweak) before it goes live. Also, why doesn't the designer create a design brief on how elements should look that the programmers can follow? You would still need the designer to review it all though.


问:
Designing a plugin-based architecture - what is a protocol service supposed to provide to a plugin?
I'm starting a hobby project and I'm in the middle of designing its architecture. I would like to make my program plugin-based (never done anything like that before), to make it extensible. Now I'm trying to grasp how such an architecture is created conceptually.

Now, this wikipedia article about Plugins says that the host application is supposed to provide a protocol service (among other things) to establish how data is exchanged with the plugin.

I don't really understand this tidbit, what does that mean? What kind of data actually needs to be exchanged?

EDIT: Just to be clear, I'm not looking for implementation specifics, but for a clear explanation of the mechanism, that the wikipedia article presents. As it stands now, I have no idea what the purpose of a protocol in a plugin-based application is.

I figured, the plugin could just fetch relevant data from outside the application on its own and present it to the user, without directly involving the application. What would be the purpose of establishing a protocol for data exchange?

It's a desktop application, which will be written mainly in Java, thus object-oriented. The application at its core mainly provides an interface for plugins to register itself in the application and a plugin-manager, which interacts with the plugin.

答:
In my view, plugins are sharing the same address space (& process) as the receiving application and involve dynamic linking.

In Linux parlance, I think that a plugin is a dynamically loaded shared object which is dlopen-ed by the application.

Then the application has to define what dlsym-ed symbols are expected by the application in the plugin, and how they interact with (i.e. how they are called by) the application.

A concrete exemple is given by Gcc plugins (I'm working on MELT, a high-level domain specific language to extend GCC, implemented as a [meta-] plugin); as the document explains, it define some set of conventions that you would call a "protocol service"

Added:

So the plugin protocol is the set of conventions (and associated API and names) defining how the plugin is installed, and which plugin's functions (and names) are expected, in what order and conditions they are invoked by the application, and which application data and API the plugin can access (and modify).


答:
However, I have noticed a big difference between the abilities of different programmers to apply 'nice design touches' to a website.

And you will notice big differences between the abilities of different programmers to play guitar. nice design touches are outside the job description for a developer. You should hire developers with design experience (or more designers) and not try to squeeze skills out of people.

And of course you could invest in formal design training for your developers. We always like learning new things. But it should be formal training, on the company's time and dime.

Half measures will lead to failure, sooner than later.

Title: How to get a programmer to apply nice design touches?

Body:
We have a small webdesign firm, and count with one designer. We can currently not afford too much expansion in the design area, so that means that the designer creates the main design of a website (which often means: the homepage), and the programmers then work with this to make it into a website. In general, this works for us. However, I have noticed a big difference between the abilities of different programmers to apply 'nice design touches' to a website. Given that we only have the homepage design, we often need to structure internal sections ourselves. Nothing major, no design program needed, but CSS skills come into play. So let's say we need to show a list of different sections in the website. I will have the content and assign this to two programmers. One will come up with this:

And another will do very much his best - and has the same CSS knowledge - but can only come up with something like this:

NOTE: sample image taken from MailChimp website.

The second programmer is aware that his 'design' lacks style and that it needs improvement, but he is just not able to create something nice without having it all drawn up by somebody else. He wants to work on this, but I do not know what a good approach would be. Any tips? Anybody with similar experiences?


问:
Is it necessary to read every single byte to check if a copied file is identical to the original?
I recently learned of a program called Total Commander. It's a Windows Explorer replacement and has its own stuff to copy files. To check whether the files are identical, instead of calculation a CRC, it literally checks every single byte, one at a time, on both the original and the copy.

My question is: Is this necessary? Can CRC or any other such technique go wrong? Should you, as a programmer, try and implement this perfect but slow system, or is it too extreme?

答:
I think that you should use the supplied file compare utility with your operating system or use a file compare tool (see: wiki-file compare tools ) to compare contents AFTER you have checked the file properties outlined by @Glenn Nelson.

I don't think that CRC is 100% accurate and I think that its accuracy decreases with file length. Also, I don't suggest you write it from scratch since it may require lots of testing.


答:
This is what stuck out to me:

and has the same CSS knowledge

Having the same knowledge of CSS doesn't mean they have the same skill or experience to manipulate it, or fully understand how different styles can interact.

In addition, it's difficult to say anyone has the same knowledge in something like CSS, where every attribute and possible values are pure memorization.

For example, I'd been using CSS on and off for years, and near-continuously at work for perhaps 7 months, before I found out what absolute positioning does when inside a relative-positioned DIV.  And that's just one simple thing that I'd overlooked for so long.


答:
Calculating CRCs (or, better, sha1sums) on both files requires reading every byte anyway. If you do a byte-by-byte comparison, you can quit as soon as you see a mismatch -- and you don't have to worry about two different files that happen to have the same checksum (though that's vanishingly unlikely for sha1sum in the absence of deliberate collisions, which became feasible after I originally wrote this answer).  So if you're doing the comparison locally, a byte-by-byte comparison will be at least as fast as a checksum comparison (unless you've already computed the checksums anyway).

On the other hand, checksum comparisons are useful when you're comparing files that aren't on the same machine; the checksums can be computed locally, and you don't have to transfer the entire content over the network.

Hybrid approaches are also possible. For example, you might compute and compare checksums for the two files a chunk at a time, which can avoid reading the whole files (if they differ) while also avoiding transmitting the whole file across the network. The rsync protocol does something like this.

Note that using a simple CRC gives you a fair chance of a collision, as Dave Rager mentioned in his answer.  Use at least sha1sum, or even something more recent.  (Don't try to invent your own hashing algorithm; the folks who developed sha1sum know far more about this stuff than either of us.)

As for the likelihood of collision, if you use a decent hash like sha1sum you pretty much don't have to worry about it, unless someone is deliberately and expensively constructing files whose sha1sums collide (generating such collisions was not feasible when I first wrote this, but progress is being made).  Quoting Scott Chacon's "Pro Git", section 6.1:

Here’s an example to give you an idea of what it would take to get a
SHA-1 collision. If all 6.5 billion humans on Earth were programming,
and every second, each one was producing code that was the equivalent
of the entire Linux kernel history (1 million Git objects) and pushing
it into one enormous Git repository, it would take 5 years until that
repository contained enough objects to have a 50% probability of a
single SHA-1 object collision. A higher probability exists that every
member of your programming team will be attacked and killed by wolves
in unrelated incidents on the same night.

Summary :

Byte-by-byte comparison is good for local comparisons.  sha1sum is good for remote comparison, and presents no significant chance of accidental false positives.

And there are newer checksum checksum algorithms that are (so far) less vulnerable to deliberate collisions than SHA1 is. I won't be too specific to avoid having this answer become obsolete yet again in a few years.

Title: Is it necessary to read every single byte to check if a copied file is identical to the original?

Body:
I recently learned of a program called Total Commander. It's a Windows Explorer replacement and has its own stuff to copy files. To check whether the files are identical, instead of calculation a CRC, it literally checks every single byte, one at a time, on both the original and the copy.

My question is: Is this necessary? Can CRC or any other such technique go wrong? Should you, as a programmer, try and implement this perfect but slow system, or is it too extreme?

ContentLicense: CC BY-SA 4.0


问:
What Are The Specific Meanings Of The Terms: Functions, Methods, Procedures, and Subroutines?
I'm wondering what are the specific differences in the terminology we use for grouping related parts of code. I've sometimes seen the terms used interchangeably: many OO languages even use the keyword "function" to define a method. (Why?)

If you wanted to be precise, what are the specific meanings of each? Or is it just whatever each language chooses to call it?

答:
It depends on the languages, what you can do with them

do you need a distinction

is there a distinction in the syntax, or is it just convenience, when talking about code

AFAIK, in Basic, if you call something, which does not return anything, but performs a job with side effects, like printing, write to file or change a global variable, it was called a procedure.

If it returns something, it was called a function.

In an OOP-Language like Java I rarely met the term 'function', but 'method', and it was teached that functions are things which are global and can be called by everyone.

In the functional and OOP-language scala, a method isn't called function, but you can pass such a thing to another method, and then it becomes a function.

A subroutine is a routine, which is called by another routine, to my understanding.

In summary, I don't think there is a concise definition over all languages and more so paradigms. You have to consider the specific culture, you're in, if you use these terms - maybe you should introduce your definition first.


问:
Protecting an Application with Logins
I am a beginner Java programmer, and have tried searching for a way to set up a login system with my Java application.  The application is a game and I do not want people to just upload it to a website so others can down load and play. I want to use something like MySQL to make the user authenticate in order to use the application. Does anyone have a suggestion?</p>

答:
One approach to this problem would be the use of a web service which would authenticate the user's credentials before allowing further use of the application or game.  This would mean that the game would have to have internet access, and that you have a server on which you could host the authentication service.

There's a lot to learn to make this work.  First, you'll need to know how to build a web service and how to call one. Presumably, the service would have to send a token back to the game if the credentials are valid--you'd need to use encryption to make sure that the token itself is valid and not a spoof.  That means you probably need to learn something about encryption with public and private keys.  You'll also need to integrate the security checks throughout your application.

In the end, you're still not guaranteed a 100% protected application, but you can limit abuse to the real die-hard hackers.

Title: Protecting an Application with Logins


答: Even if you don't use C++ specific features, a C++ compiler will catch more problems than a C one due to the stricter type system of C++.</p>

Title: Using C++ but not using the language's specific features, should switch to C?

Body:
I'm developing a NES emulator as a hobby, in my free time.  I use C++ because is the language I use mostly, know mostly and like mostly.

But now that I made some advance into the project I realize I'm not using almost any specific features of C++, and could have done it in plain C and getting the same result. I don't use templates, operator overloading, polymorphism, inheritance. So what would you say? should I stay in C++ or rewrite it in C?

I won't do this to gain in performance, it could come as a side effect, but the idea is why should I use C++ if I don't need it?

The only features of C++ I'm using is classes to encapsulate data and methods, but that can be done as well with structs and functions, I'm using new and delete, but could as well use malloc and free, and I'm using inheritance just for callbacks, which could be achieved with pointers to functions.

Remember, it's a hobby project, I have no deadlines, so the overhead time and work that would require a re-write are not a problem, might be fun as well. So, the question is C or C++?


问:
Is it a bad idea to list every function/method argument on a new line and why?
I work with someone who, every time they call a function they put the arguments on a new line e.g.

```<code>aFunction(
    byte1,
    short1,
    int1,
    int2,
    int3,
    int4,
    int5
) ;
</code>```

I find this very annoying as it means the code isn't very compact, so I have to scan up and down more to actually make any sense of the logic. I'm interested to know whether this is actually bad practice and if so, how can I persuade them not to do it?

答:
Why are you wasting cycles on such a trivial concern? Just fire up your trusty IDE, open the file, and reformat. Voila! It will be in whatever form you want.

Now let's move on to the really important issue--vi or emacs, LOL.


答:
subprogram, subroutine

"subroutine" probably comes from assembly language. Some processors include instructions to support subroutines as a way of organizing code and reusing common sections of code. For example, the 6502 processor had JSR (jump to subroutine) and RTS (return from subroutine) instructions. I remember it also being used a lot in structured programming, in which a program is a hierarchy of units of code which were sometimes called subroutines or subprograms. IMO, these are the most generic terms for some unit of code to which control is temporarily transferred for the purpose of completing a given task.

function, procedure

These are often used interchangeably, but in some languages there's a distinction. In Pascal, a function is a subprogram that returns a value, while a procedure is a subprogram that doesn't. In C and related languages, every subprogram has a return type (even if it's void), so there's no distinction.

method, member function

These are two names for the same thing -- essentially a function that's associated with a given class or object.

operator

Every language has a set of built-in operators. In some languages, such as C++, operators are functions that can be overridden (i.e. replaced) and/or overloaded (i.e. defined for new types).

anonymous function

This refers to a function without a name. Anonymous functions are essentially blocks of code that can be assigned to variables or passed as parameters for subsequent use, for example as a completion routine.

closure, lambda expression, block

A closure is a chunk of code that's bound to a set of variables. I think of closures as anonymous functions plus context.

Title: What Are The Specific Meanings Of The Terms: Functions, Methods, Procedures, and Subroutines?

Body:
I'm wondering what are the specific differences in the terminology we use for grouping related parts of code. I've sometimes seen the terms used interchangeably: many OO languages even use the keyword "function" to define a method. (Why?)

If you wanted to be precise, what are the specific meanings of each? Or is it just whatever each language chooses to call it?


问:
When is a version control commit too large?
I've heard in several places "Don't make large commits" but I've never actually understood whats a "large" commit. Is it large if you work on a bunch of files even if there related? How many parts of a project should you be working on at once?

To me, I have trouble trying to make "small commits" since I forget or create something that creates something else that creates something else. You then end up with stuff like this:

```
Made custom outgoing queue

Bot
-New field msgQueue which is nothing more than a SingleThreadExecutor
-sendMsg blocks until message is sent, and adds wait between when messages get
sent
-adminExist calls updated (see controller)
-Removed calles to sendMessage

Controller
-New field msgWait denotes time to wait between messages
-Starting of service plugins moved to reloadPlugins
-adminExists moved from Server because of Global admins. Checks at the channel,
server, and global level

Admin
-New methods getServer and getChannel that get the appropiate object Admin
belongs to

BotEvent
-toString() also show's extra and extra1

Channel
-channel field renamed to name
-Fixed typo in channel(int)

Server
-Moved adminExists to Controller

PluginExecutor
-Minor testing added, will be removed later

JS Plugins
-Updated to framework changes
-Replaced InstanceTracker.getController() with Controller.instance
-VLC talk now in own file

Various NB project updates and changes

---

Affected files
Modify  /trunk/Quackbot-Core/dist/Quackbot-Core.jar
Modify  /trunk/Quackbot-Core/dist/README.TXT
Modify  /trunk/Quackbot-Core/nbproject/private/private.properties
Modify  /trunk/Quackbot-Core/nbproject/private/private.xml
Modify  /trunk/Quackbot-Core/src/Quackbot/Bot.java
Modify  /trunk/Quackbot-Core/src/Quackbot/Controller.java
Modify  /trunk/Quackbot-Core/src/Quackbot/PluginExecutor.java
Modify  /trunk/Quackbot-Core/src/Quackbot/info/Admin.java
Modify  /trunk/Quackbot-Core/src/Quackbot/info/BotEvent.java
Modify  /trunk/Quackbot-Core/src/Quackbot/info/Channel.java
Modify  /trunk/Quackbot-Core/src/Quackbot/info/Server.java
Modify  /trunk/Quackbot-GUI/dist/Quackbot-GUI.jar
Modify  /trunk/Quackbot-GUI/dist/README.TXT
Modify  /trunk/Quackbot-GUI/dist/lib/Quackbot-Core.jar
Modify  /trunk/Quackbot-GUI/nbproject/private/private.properties
Modify  /trunk/Quackbot-GUI/nbproject/private/private.xml
Modify  /trunk/Quackbot-GUI/src/Quackbot/GUI.java
Modify  /trunk/Quackbot-GUI/src/Quackbot/log/ControlAppender.java
Delete  /trunk/Quackbot-GUI/src/Quackbot/log/WriteOutput.java
Modify  /trunk/Quackbot-Impl/dist/Quackbot-Impl.jar
Modify  /trunk/Quackbot-Impl/dist/README.TXT
Modify  /trunk/Quackbot-Impl/dist/lib/Quackbot-Core.jar
Modify  /trunk/Quackbot-Impl/dist/lib/Quackbot-GUI.jar
Modify  /trunk/Quackbot-Impl/dist/lib/Quackbot-Plugins.jar
Modify  /trunk/Quackbot-Impl/lib/javarebel.stats
Add /trunk/Quackbot-Impl/lib/jrebel.info
Modify  /trunk/Quackbot-Impl/nbproject/private/private.properties
Modify  /trunk/Quackbot-Impl/nbproject/private/private.xml
Modify  /trunk/Quackbot-Impl/nbproject/project.properties
Modify  /trunk/Quackbot-Impl/plugins/CMDs/Admin/reload.js
Add /trunk/Quackbot-Impl/plugins/CMDs/Operator/hostBan
Modify  /trunk/Quackbot-Impl/plugins/CMDs/Operator/mute.js
Modify  /trunk/Quackbot-Impl/plugins/CMDs/lyokofreak/curPlaying.js
Modify  /trunk/Quackbot-Impl/plugins/CMDs/lyokofreak/lfautomode.js
Modify  /trunk/Quackbot-Impl/plugins/listeners/onJoin.js
Modify  /trunk/Quackbot-Impl/plugins/listeners/onQuit.js
Modify  /trunk/Quackbot-Impl/plugins/testCase.js
Add /trunk/Quackbot-Impl/plugins/utils/whatsPlaying.js
Modify  /trunk/Quackbot-Impl/src/Quackbot/impl/SandBox.java
Add /trunk/Quackbot-Impl/vlc_http
Add /trunk/Quackbot-Impl/vlc_http/current.html
Modify  /trunk/Quackbot-Plugins/dist/Quackbot-Plugins.jar
Modify  /trunk/Quackbot-Plugins/dist/README.TXT
Modify  /trunk/Quackbot-Plugins/dist/lib/Quackbot-Core.jar
Modify  /trunk/Quackbot-Plugins/nbproject/private/private.properties
Modify  /trunk/Quackbot-Plugins/nbproject/private/private.xml
Modify  /trunk/Quackbot-Plugins/src/Quackbot/plugins/JSPlugin.java
Add /trunk/Quackbot-Plugins/vlc_http
Add /trunk/global-lib/jrebel.jar
```

Yea....

So for questions:

What are some factors for when a commit becomes too large (non-obvious stuff)?

How can you prevent such commits? Please give specifics

What about when your in semi-early stages of development when things are moving quickly? Are huge commits still okay?

答:
In my field (physics modeling), I discover a bug in the output today that wasn't in the repository as of 6 months ago.  When this happens, I will do a binary search on revisions:

Run model from 3 months ago

If bug is still in output, run the model from 4.5 months ago

... repeat until I find the commit that yields in bad output

When the bug was introduced in a monstrous commit, I have to sit with a fine-toothed comb to find the source of the problem.  If the commit touched a small number of files, it's less painful to track down the line(s) of code that introduced the problem.

I would recommend breaking down your problem into a series of smaller tasks (ideally put each task in a bug tracker).  Make a commit as you complete each task (and close that bug/feature in your bug tracker).

ContentLicense: CC BY-SA 2.5


问:
A good analogy for computer memory?
So, I'm a computer science major and I'm also a huge fan of the no-longer-on-TV show, Numb3rs.

Now, whenever I talk with my friends they also ask me quite a few questions about programming and computers (and how they work). Now, on Numb3rs, they (Charlie, and occasionally Amita or Larry) often went on short, but well explained and well spoken summaries of the mathematical topic. While they had the benefits of graphics, often their voices alone were plenty to explain. Basically, they took complex concepts and presented them in laymens terms. It was short, concise, easy to understand, and very interesting.

Basically, I'm looking for something like that. Just a really great, short, interesting analogy for computer memory. So, thanks to whoever can come up with a brief, interesting, engaging, enjoyable, but educational and correct analogy/summary for computer memory!

答: Computer memory works just like writing on paper in pencil- you go back and read it later, or erase it and write something new. There's just an awful lot of paper, read and written in obscene times.</p>

Title: A good analogy for computer memory?


答:
Computer memory reminds me of Post Office Boxes a lot:

Each box can store an item.

Every box can be identified and accessed discretely using its unique address.

One can place an item into the box or remove an item from the box, or just simply peek inside to see what is stored there.

All boxes are standard size, they're interchangeable, the only unique thing about them is the address. Adding extra capacity means adding more shelving units.

In some cases an owner can access the box directly, but sometimes only via a member of staff (managed memory).

Where the metaphor breaks down:

P.O.B. can contain more than one item.

When memory is read the stored value is not consumed, whereas taking a letter out of the P.O.B leaves it empty.

Memory at an address neither full nor empty, it always contains a value.

Storing a larger parcel would mean splitting it across multiple adjoining boxes. Perhaps this could be explained using the analogy of removing partitions between adjoining P.O. boxes with the parcel taking up multiple addresses.

Title: A good analogy for computer memory?

Body:
So, I'm a computer science major and I'm also a huge fan of the no-longer-on-TV show, Numb3rs.

Now, whenever I talk with my friends they also ask me quite a few questions about programming and computers (and how they work). Now, on Numb3rs, they (Charlie, and occasionally Amita or Larry) often went on short, but well explained and well spoken summaries of the mathematical topic. While they had the benefits of graphics, often their voices alone were plenty to explain. Basically, they took complex concepts and presented them in laymens terms. It was short, concise, easy to understand, and very interesting.

Basically, I'm looking for something like that. Just a really great, short, interesting analogy for computer memory. So, thanks to whoever can come up with a brief, interesting, engaging, enjoyable, but educational and correct analogy/summary for computer memory!


答:
I like to think of it as a giant wall of numbered Safe Deposit Boxes like at a Bank and every Box contains a piece of paper with a number on it.

It works to describe lots of circumstances. How do you explain what the ASCII characters 'A' and 'B' are? Everybody just agrees that a piece of paper with the number 65 means 'A' and 66 means 'B'. The same thing goes for encoding pictures/movies anything.

How do we store bigger things like the String "AB". We need 2 boxes. One to store 65 and one to store 66. It would make sense for these boxes to be next to eachother. Maybe the 'A' gets stored in box number 1000 and then 'B' gets stored in box 1001. How do we know that the String only has 2 characters in it? Maybe we store the number 0 in box 1002 to signal that that's the end of the String and it turns out that this way actually needs 3 boxes to store 2 characters.

Are there other ways I could store the String? How do I know how long the String [65, 66, 0] is? I have to start at box 1000 and keep opening boxes until I get to one with 0 in it. Is there another way I could store my String? What if the first box held the length of my String? I could store [2 65 66] and then if I need to know the length of my String I only need to open the first box. As long as me and everybody else knows what system I'm using it doesn't really matter which way I choose.

How do we know where our String is? We somehow need to know it starts in spot 1000. Either we wrote it in our code or we somehow have access to another box (a pointer) and inside that box on its piece of paper we write 1000 so that we know our String starts at location 1000.

Maybe you think it's stupid that 65 means 'A'. You could say 1 = 'A' and 2 = 'B' etc.
That system is perfectly fine too as long as when you share them with other people those people know what your system is.

We could keep going deeper and deeper but eventually we will have to come to the realization that the significance of what is written on the pieces of paper are whatever we as humans decide is the significance. We the programers decide whether a number in a box is an Integer, Fraction, Character, Pointer to another box, Instruction for the Machine, Pixel color for an Image.
Only the people who wrote the numbers on the paper can figure out whether 65 means 65, 'A', -99, Red, Infinity or an Orange Bucket.

It is like writing. What is the significance of a vertical line? Is it a lower case L? Is it the number 1? Is it part of some sort of drawing? Does it stand for a word in another language? Is it that thing above \ on my keyboard? The only way you can know the meaning of the line is if the person who drew it tells you.

Title: A good analogy for computer memory?


问:
Is there any technology similar to LINQPad for compiling C# that runs in a browser?
Think JSFiddle.  LINQPad is pretty sweet for fast C# with similar options.  Is there anything like LINQPad that runs in a browser?</p>

答:
I don't know of anything like that, but the reason JSFiddle is practical is because the code is run natively on the browser, not the server. In order to do something similar for C# code, you would most likely need to do so on the server or use a browser plugin.

A plugin solution would defeat the purpose of even being browser-based because it would require an installation and limit the platforms it can run on. A server-based solution would have many inherent risks unless it were heavily sandboxed.


答:
You could try www.compilr.com.  According to their website, Compilr is an online IDE, allowing you to write and compile code for a variety of platforms from any major web browser.

I've tried it out, it works fairly well. It supports C#, Ruby, C, Java and others.

Title: Is there any technology similar to LINQPad for compiling C# that runs in a browser?

Body: Think JSFiddle.  LINQPad is pretty sweet for fast C# with similar options.  Is there anything like LINQPad that runs in a browser?</p>


问:
How did you pick up the art of solving real life problems? Can you shortcut the process?
I have been coding on and off on C and to a certain extent on C++ since my college days(2003), but I never had the opportunity to work with a hard core programming responsibility, which could have taught me "industrial grade coding" better and what is needed really for solving real life problems. To me it looks like I had been coding naive codes, like linked lists, binary trees, and Dijkstra and Kruskal's Algos all these years.

Additionally I feel my academic experience just taught me the language not how to solve real life problems.

So my question is:

So how did you pick up the art of solving real life problems?

Any way to shortcut the process?

Is it only my education or in general everyone coding education sucked big time?

How often do you have to learn "new things" to solve a problem in a better way.

For example, though I have used delegates and events for simple windows programming, but my current problem will require a much more in depth knowledge of it, plus I have forgotten most of it. So its as good as new for me. I will have to learn threaded programming and multicore programming. So it gives me an impression-"heck then what did I learn really all these years?"

答:
What you are feeling is pretty common and there are several questions like this around with good answers if you want to search, but to answer your questions:

So how did you pick up the art of solving real life problems?

Experience - What you have learned is not useless, you already know how to write a program to solve a specific problem.  When coming from an educational environment you often have the basics of the problem taught to you right before you apply that knowledge.  You now have to start researching and teaching yourself about the problem before you try to solve it.  This becomes easier as you build your knowledge and can become second nature if you are solving problems in a similar domain all the time.

Any way to shortcut the process?

YES! A mentor of some kind can really cut down on the learning curve, a really good one can teach you not only good ways to solve the current types of problems you are facing, but also good habits and resources to solve any type of problem you are facing.

Is it only my education or in general everyone coding education sucked big time?

I think most employers expect to do extra training for people getting their first full-time programming job, I think most programmers getting their first programming job question their competency and wonder what the heck they spent all that money learning. :-)  You'll come to realize how valuable it was in time.

How often do you have to learn "new things" to solve a problem in a
  better way.

You'll learn tools and tricks that will stick with you and serve you well, but you should always keep an eye and ear out for a better way to do something - read other people's code and other people's answers on the Stack Exchange sites.  The programmers I respect most keep growing and keep looking for better ways to do things.

What did you learn all those years?  You learned how to learn, how to think, how to tackle a problem, and some good foundation skills.


问:
Proxied calls not working as expected
I have been modifying an application to have a cleaner client/server split to allow for load splitting and resource sharing etc. Everything is written to an interface so it was easy to add a remoting layer to the interface using a proxy. Everything worked fine. The next phase was to add a caching layer to the interface and again this worked fine and speed was improved but not as much as I would have expected. On inspection it became very clear what was going on.

I feel sure that this behavior has been seen many times before and there is probably a design pattern to solve the problem but it eludes me and I'm not even sure how to describe it.

It is easiest explained with an example. Let's imagine the interface is

```<code>interface IMyCode {
    List<IThing> getLots( List<String> );
    IThing getOne( String id );
}
</code>```

The getLots() method calls getOne() and fills up the list before returning.

The interface is implemented at the client which is proxied to a remoting client which then calls the remoting server which in turn calls the implementation at the server. At the client and the server layers there is also a cache.

So we have :-

```<code>Client interface
      |
 Client cache
      |
 Remote client
      |
 Remote server
      |
  Server cache
      |
Server interface
</code>```

If we call getOne("A") at the client interface, the call is passed to the client cache which faults. This then calls the remote client which passes the call to the remote server. This then calls the server cache which also faults and so the call is eventually passed to the server interface which actually gets the IThing. In turn the server cache is filled and finally the client cache also.

If getOne("A") is again called at the client interface the client cache has the data and it gets returned immediately. If a second client called getOne("B") it would fill the server cache with "B" as well as it's own client cache. Then, when the first client calls getOne("B") the client cache faults but the server cache has the data.

This is all as one would expect and works well.

Now lets call getLots( [ "C", "D" ] ). This works as you would expect by calling getOne() twice but there is a subtlety here. The call to getLots() cannot directly make use of the cache. Therefore the sequence is to call the client interface which in turn calls the remote client, then the remote server and eventually the server interface. This then calls getOne() to fill the list before returning.

The problem is that the getOne() calls are being satisfied at the server when ideally they should be satisfied at the client. If you imagine that the client/server link is really slow then it becomes clear why the client call is more efficient than the server call once the client cache has the data.

This example is contrived to illustrate the point. The more general problem is that you cannot just keep adding proxied layers to an interface and expect it to work as you would imagine. As soon as the call goes 'through' the proxy any subsequent calls are on the proxied side rather than 'self' side.

Have I failed to learn or not learned something correctly?

All this is implemented in Java and I haven't used EJBs.

It seems that the example may be confusing. The problem is nothing to do with cache efficiencies. It is more to do with an illusion created by the use of proxies or AOP techniques in general.

When you have an object whose class implements an interface there is an assumption that a call on that object might make further calls on that same object. For example,

```<code>public String getInternalString() {
    return InetAddress.getLocalHost().toString();
}

public String getString() {
    return getInternalString();
}
</code>```

If you get an object and call getString() the result depends where the code is running. If you add a remoting proxy to the class then the result could be different for calls to getString() and getInternalString() on the same object. This is because the initial call gets 'deproxied' before the actual method is called.

I find this not only confusing but I wonder how I can control this behavior especially as the use of the proxy may be by a third party.

The concept is fine but the practice is certainly not what I expected.

Have I missed the point somewhere?

答:
Relation between any two methods is unknown to a proxying library.

So the method

```<code>public String getString() {
  return getInternalString();
}
</code>```

once proxied and implemented on server side is equivalent to any method

```<code>public String getString() {
  //some executable statements along with a return.
}
</code>```

But if you want to preserve the relation between the methods then you may want to not proxy the higher methods

```<code>public String getString() {
</code>```

or

```<code>List<IThing> getLots( List<String> );
</code>```

each client of the proxying library would code for this separately i.e. it is no more part of the interface IMyCode which is expected to be supported by the proxying library.

Title: Proxied calls not working as expected

Body:
Relation between any two methods is unknown to a proxying library.

So the method

public String getString() {
  return getInternalString();
}

once proxied and implemented on server side is equivalent to any method

public String getString() {
  //some executable statements along with a return.
}

But if you want to preserve the relation between the methods then you may want to not proxy the higher methods

public String getString() {

or

List<IThing> getLots( List<String> );

each client of the proxying library would code for this separately i.e. it is no more part of the interface IMyCode which is expected to be supported by the proxying library.


问:
How should I organize my source tree?
I am an individual developer working, largely, on web-projects (W/LAMP) and, at times, on C/C++ (non-GUI) projects of about average scale.

I often struggle with structuring my source-code tree. In fact, usually, I don't complete a project without dumping the entire tree and rearranging the pieces three-four times which really takes up a lot of effort and moreover the end result does seem like a compromise.

Sometimes, I end up with over classification of source - very long tree of folders and sub-folders. At other times, I simply end up concentrating all files in a particular folder based on the larger purpose they serve and thereby leading to 'chaotic' folders in the source.

I would want to ask:

Are there any principles/logic/best-practices that can help me better at structuring my source tree?

Are there any graphical/diagrammatic techniques (for eg.: DFD in case of dataflow) that can help me visualize my source tree beforehand based on the analysis of the project?

What strategy to adopt to structure multi-media files-tree associated with the project?

About the bounty: I appreciate existing answers with the members sharing their own practices, however, I'd like to encourage more general and instructive answers (or resources) and more responses from the members.

答:
Ideally, the organisation has a single repository, the structure of which is intended to increase engagement between engineering & business and promote reuse.

```<code>...\products\
...\products\productName\
...\products\productName\doc\

...\systems\
...\systems\systemName\
...\systems\systemName\doc\
...\systems\systemName\res\
...\systems\systemName\build\
...\systems\systemName\test\

...\library\
...\library\libraryName\
...\library\libraryName\doc\
...\library\libraryName\build\
...\library\libraryName\test\

...\devops\
</code>```

products

One folder per product; helps communicate how the software supports the business.

Ideally, each "product" is little more than a configuration file indicating which systems to invoke and how they are to be configured.
   The doc subfolder could contain the top-level brief\spec & any promotional materiel etc...

By separating products and systems we communicate the potential of reuse to the customer-facing side of the business, and break down per-product silos.
   (This contrasts with the "product line" approach to the same problem)

systems

One folder per system; helps communicate the primary capabilities & opportunity/value of the contents of the repository.

"Configuration management" files specifying build & deployment environments.

System-level testing configuration (could be significant quantity).

Top level logic & functionality; most heavy lifting being done by library functions.

library

Reusable components invoked by various systems.
   Most development activities are organised around the production of libraries, rather than systems, so reuse is "baked in" to the development process.

devops

Build, Continuous Integration & other Development Automation functionality.

Conclusion

The source tree is a key piece of documentation, and shapes the approach, structure and psychology of the business' relationship with its proprietary technology.

The drivers for this approach are explained in a bit more depth in my answer to this question: https://softwareengineering.stackexchange.com/questions/43733/who-organizes-your-matlab-code/59637#59637

Title: How should I organize my source tree?

Body:
Ideally, the organisation has a single repository, the structure of which is intended to increase engagement between engineering & business and promote reuse.

...\products\
...\products\productName\
...\products\productName\doc\

...\systems\
...\systems\systemName\
...\systems\systemName\doc\
...\systems\systemName\res\
...\systems\systemName\build\
...\systems\systemName\test\

...\library\
...\library\libraryName\
...\library\libraryName\doc\
...\library\libraryName\build\
...\library\libraryName\test\

...\devops\

products

One folder per product; helps communicate how the software supports the business.

Ideally, each "product" is little more than a configuration file indicating which systems to invoke and how they are to be configured.
   The doc subfolder could contain the top-level brief\spec & any promotional materiel etc...

By separating products and systems we communicate the potential of reuse to the customer-facing side of the business, and break down per-product silos.
   (This contrasts with the "product line" approach to the same problem)

systems

One folder per system; helps communicate the primary capabilities & opportunity/value of the contents of the repository.

"Configuration management" files specifying build & deployment environments.

System-level testing configuration (could be significant quantity).

Top level logic & functionality; most heavy lifting being done by library functions.

library

Reusable components invoked by various systems.
   Most development activities are organised around the production of libraries, rather than systems, so reuse is "baked in" to the development process.

devops

Build, Continuous Integration & other Development Automation functionality.

Conclusion

The source tree is a key piece of documentation, and shapes the approach, structure and psychology of the business' relationship with its proprietary technology.

The drivers for this approach are explained in a bit more depth in my answer to this question: https://softwareengineering.stackexchange.com/questions/43733/who-organizes-your-matlab-code/59637#59637


问:
Why isn't rich code formatting more common?
I was reading Code Complete and in the chapter on layout and style, he was predicting that code editors would use some sort of rich text formatting. That means, instead of code looking like this

```<code>Procedure ResolveCollisions
{ Performs a posteriori collision resolution through spatial partitioning algoritm }
(
  CurrentMap : SpriteContext,
  PotentialColliders: SpriteList
)
var Collider  : Sprite,
    Collidee  : Sprite,
    Collision : SpriteCollision
begin
  DoStuff();
end.
</code>```

it could look something like this:

Procedure ResolveCollisions

Performs a posteriori collision resolution through spatial partitioning algorithm

Parameters

CurrentMap : SpriteContext

PotentialColliders : SpriteList

Local Variables

Collider  : Sprite

Collidee  : Sprite

Collision : SpriteCollision

```<code>    DoStuff();
</code>```

I've seen syntax coloring and highlighting and even parentheses coloring, but nothing that looked like this in actual code. I was wondering if this sort of thing actually ever existed, or perhaps if it was decided that it didn't have enough benefit or that it was an entirely bad idea.

Have any of you seen richly-formatted code like this before, or know if the idea was ever considered and eventually rejected?

答:
Some time ago, I asked this question on code formatting, asking whether programmers would want their code formatted as they typed.

My question only addressed the indentation aspect of formatting, but some answers may well apply to code formatting in general. The overall sentiment in the answers suggest that programmers are opposed to losing absolute control of the way their code is represented.

My personal experience has been quite different. Though I normally use publicly available tools, sometimes I need to write XSLT in my own bespoke editor. This editor formats code as I type by indenting the left-margin so I have no issues with unwanted whitespace (significant in XSLT) and allows my code to word-wrap and yet still maintain formatting. I find the experience quite natural, formatting style is controlled by the context and position of line-feeds alone (the experience is especially rewarding when using touch-sensitive input devices).

If the XSLT is not well-balanced, the formatting actually helps show where the problem lies. It took a while to adjust to code shifting horizontally as you type but it isn't a distraction for me any more. I did however find that formatting features that affected the vertical spacing of my XSLT rendered the editor just about unusable, so I've disabled these.

To go back to your question, I think the reason why rich code formatting is not more common is just that it takes a long time for perceptions to change in the programming world. Its time will come, possibly coinciding with the time when code editing is done predominantly without a keyboard.


答:
I think that rich formatting of source code is not very popular because it is intended for information input, where structure and meaning is far more important (and easier to type as well). Fontification, extra special symbols and white spaces just add unnecessary visual noise. It might be appropriate for generated documentation though.

There are never ending flame war about the same topic in typesetting world between those who prefer WYSIWYG editors (like MS Word) and systems like TeX (LaTeX).

In general, there is no definitive answer. It all depends on tools, use cases and personal preferences.

Title: Why isn't rich code formatting more common?

Body:
I was reading Code Complete and in the chapter on layout and style, he was predicting that code editors would use some sort of rich text formatting. That means, instead of code looking like this

```<code>Procedure ResolveCollisions
{ Performs a posteriori collision resolution through spatial partitioning algoritm }
(
  CurrentMap : SpriteContext,
  PotentialColliders: SpriteList
)
var Collider  : Sprite,
    Collidee  : Sprite,
    Collision : SpriteCollision
begin
  DoStuff();
end.
</code>```

it could look something like this:

Procedure ResolveCollisions

Performs a posteriori collision resolution through spatial partitioning algorithm

Parameters

CurrentMap : SpriteContext

PotentialColliders : SpriteList

Local Variables

Collider  : Sprite

Collidee  : Sprite

Collision : SpriteCollision

```<code>    DoStuff();
</code>```

I've seen syntax coloring and highlighting and even parentheses coloring, but nothing that looked like this in actual code. I was wondering if this sort of thing actually ever existed, or perhaps if it was decided that it didn't have enough benefit or that it was an entirely bad idea.

Have any of you seen richly-formatted code like this before, or know if the idea was ever considered and eventually rejected?


答:
Also in more than a few languages (Haskell, Ruby, Python, Erlang, CoffeeScript a few others) indentation is important. So if you are changing font sizes it could get very hard to figure out.

Mostly its tradition. I have been programming professionally for almost 20 years and I suspect it would drive me nuts. I write books in Emacs or VI with docbook, so I am not a WYSIWIG fan


答: Knuth’s CWEB does this, but it only works for C/C++ and Pascal. — You should take a look at it though… it’s quite neat. There are two programs: ctangle and cweave which combine/separate CWEB files into TeX and C respectively.


问:
What's the most effective way to perform code reviews?
I've never found the ideal way to perform code reviews and yet often my customers require them. Each customer seems to do them in a different way and I've never felt satisfied in any of them.

What has been the most effective way for you to perform code reviews?

For example:

Is one person regarded as the gatekeeper for quality and reviews the code, or do the team own the standard?

Do you do review code as a team exercise using a projector?

Is it done in person, via email or using a tool?

Do you eschew reviews and use things like pair programming and collective code ownership to ensure code quality?

答:
At my company each task is assigned a tester to test the task, and also a code reviewer to review the code.

If your product is already released and you want to make sure you aren't doing anything wrong (such as a handle leak, or memory leak) code reviews are a great thing.   I think during the initial development before releasing your product, code reviews may be too much work.

If your team has all senior developers, then peer review is still useful.  Everyone makes mistakes sometimes.  If your team has some seniors and some juniors, then let the senior developers do the code reviews, but still have code reviews for the senior's code as well.

One important thing about code review is that it can catch errors that we make, but it is not a replacement for testing.


问:
Design Patterns for Javascript
A lot of web frameworks have a MVC-style layout to code and approaching problems. What are some good similar paradigms for JavaScript? I'm already using a framework (jQuery) and unobtrusive js, but that still doesn't address the problem I run into when I have more complex web apps that require a lot of javascript, I tend to just end up with a bunch of functions in a single, or possibly a few files. What's a better way to approach this?</p>

答:
This link describes, better than I could, a sane way to architecture a medium-to-large Javascript application. Among other things, this involves:

Splitting code into modules, using the module pattern

Letting the modules declare their dependencies and load them asynchronously via a tool like RequireJS

Namespacing the global objects you define

Abstracting away the DOM manipulation library (this only makes sense for large enough projects)

Following (some variation of) the MVC pattern, leaving to models the role of data persistence and AJAX calls, to controller the role of managing events and to views the role of DOM and style manipulations

Minimizing the communication through independent modules, by means of some core that dispatches messages

Designing a mechanism that restarts module as soon as they throw an exception. As a consequence, designing modules so that their restart does not have unexpected consequences (like drawing some UI element twice)

Combine reusable parts of the UI into widgets

Title: Design Patterns for Javascript


问:
How can I deal with the cargo-cult programming attitude?
I have some computer science students in a compulsory introductory programming course who see a programming language as a set of magic spells, which must be cast in order to achieve some effect (instead of seeing it as a flexible medium for expressing their idea of solution).

They tend to copy-paste code from previous, similar-looking assignments without considering the essence of the problem.

Are there some exercises or analogies to make these students more confident that they can, and should, understand the structure and meaning of each piece of code they write?

答:
1) Teach them the history of computers, programming.
2) Teach how different programming languages work.
3) Teach what a good programming and programming practices are.
4) Teach them how to analyze a problem, find a solution and then start coding.</p>


问:
Using C++ but not using the language's specific features, should switch to C?
I'm developing a NES emulator as a hobby, in my free time.  I use C++ because is the language I use mostly, know mostly and like mostly.

But now that I made some advance into the project I realize I'm not using almost any specific features of C++, and could have done it in plain C and getting the same result. I don't use templates, operator overloading, polymorphism, inheritance. So what would you say? should I stay in C++ or rewrite it in C?

I won't do this to gain in performance, it could come as a side effect, but the idea is why should I use C++ if I don't need it?

The only features of C++ I'm using is classes to encapsulate data and methods, but that can be done as well with structs and functions, I'm using new and delete, but could as well use malloc and free, and I'm using inheritance just for callbacks, which could be achieved with pointers to functions.

Remember, it's a hobby project, I have no deadlines, so the overhead time and work that would require a re-write are not a problem, might be fun as well. So, the question is C or C++?

答:
It's not easy to answer your questions, since we don't know if you are working on the project to improve your language specific skills (C vs C++) or to improve other programming skills (design, problem-solving, etc.).

"The only features of C++ I'm using is classes to encapsulate data and methods, but that can be done as well with structs and functions,". This is not true. structs in C do not support encapsulation and cannot contain functions (methods) - at least not without using techniques like pointers to functions. Also, functions in C are weaker because they cannot be overloaded.

"I'm using new and delete, but could as well use malloc and free, and I'm using inheritance just for callbacks, which could be achieved with pointers to functions.". As deadmg mentioned, using directly new and delete in C++ is not encouraged. Also, IMHO (and the GoF) inheritance in OOP should be preferred over composition only when polymorphism is required. And I don't think that it is trivial to achieve polymorphism (late binding) in C using pointers to functions.

Other than that, I'll not try to convince you that C++ is "better" than C because it's a matter of preference and it always depends on the problem that you are trying to solve (using OOP features for developing your NES emulator might be a good idea).


问:
Sharing buffer between multiple threads
I had a job process that was executing a lot of IO to read and write  temporary files.

Now I want to (need to) reduce the quantity of IO executions.

So I want to create  a sort of circular buffer that is going to be filled up with a data from a text file within first thread.

The consumer (reading) thread will fetch data from this buffer.

The problem is that there could be multiple consumers that need to read from same one buffer.

For buffer implementation I prefer not to use any existing wrappers (simple  array, where i just "play"  with indices is enough).

I also don't want to create a separate buffer for every reader.
And ofcourse I want to avoid any deadlocks and unnecessary  blockings.

UPDATE

Right now I am using circular buffer (an array and 2 indices)

The question is how to implement such buffer that can be accessed by  multiple consumers where each consumer can read from it interdependently from other consumers (one costumer may read faster than the other one).

IMPORTANT UPDATE

The first thread don't know (and should not know) about it's consumers!!!
It should write data to a buffer, when data ends it should raise a flag.

答:
Using a bare array is forcing you to do more work than you need to. People have spent a lot of time coming up with data structures to make your life easier, so use them.

It sounds like you are trying to implement a Queue. This is a data structure that allows you to add things to the collection and then remove them later. This is done in a first in first out order. Java even has a Thread-Safe Queue built in. You can simply make an instance of that class and give each of your threads a reference to it. The producer will add items to the queue and the consumer(s) will remove items from the queue or perform another action if the queue is empty.

If you really have your heart set on implementing everything yourself, you will need to synchronize all access to your array so that two threads can't access the buffer at the same time.

EDIT:

It wasn't clear before that you wanted every consumer to read every bit of data. You can extend the Queue implementation so it keeps track of the count of items (making size() constant time) and then throw an exception if the queue is full.

To solve the popping issue is a little trickier. You need to keep track of the index that each consumer is at, a map would do this. Then when all of the consumers have moved passed an item, it can be popped and update all the indexes in the map. When a consumer calls pop() and the item needs to be retained you can re-route it to a peek().

Title: Sharing buffer between multiple threads


问:
Given a set of VLSI chips, how do I determine which are good?
I have the following problem:

Given n chips [note: these are VLSI chips] out of which majority of chips are good, we need to find one good chip. The only test that we can apply is on a pair of chips that answers if both chips are good or both are bad.
  The second part is to find a good chip if some tests might produce a wrong result. Also, the results are systematic meaning that if a pair gives wrong result, it will always give the wrong result.

I have solved the first problem using divide and conquer approach where I reduce the problem set to at least half every time. This can be done by simply performing tests on n/2 distinct pairs every time and keeping those pairs that answer a YES (i.e. both good or bad). I am unable to solve the second part of the problem.

A wrong result means that even if two chips are good or bad, the test might answer a NO. Also note that the percentage of wrong tests is very low.

How can I go about solving this problem?

答:
The test for sameness lets you divide the chips into two piles. Select any chip and test all the others against it, putting the chips into 'same' and 'different' piles (the selected chip goes into the 'same' pile). It doesn't matter whether the selected chip is good or bad -- you have no way to know that until the testing is done. Then use your knowledge about the distribution of good and bad chips to figure out which pile is which.

For part two, realize that your confidence in a given chip increases as it tests 'same' against other chips thought to be good.


答:
I have created such a class as you describe in C++, but not Java.  I used a singleton pattern, combined with templates so that if you knew the buffer type and size you will get the correct instance.  So you can have different buffers of different types at the same time.  I'm not sure you'll be able to do this exactly in Java or not.  But regardless of this, what I say below still holds.

Implementation wise you'll need some semaphores and mutexes.  I used two semaphores, one to count the number of items in the buffer and one to count the amount of space left.  You can then use these in your put() and get() methods to determine if there is space left or anything to take.  One you've done that you can grab the mutex that protects access to the buffer, copy out your object and change your index pointers.

Using the semaphores avoids deadlocking on the mutex in the scenario where the getter thread acquires it before the putter thread has placed anything in the buffer.  You can use the index pointers to implement a numItems() function and you'll need them to workout the array indies to use for the get and put.

Title: Sharing buffer between multiple threads

Body:
I had a job process that was executing a lot of IO to read and write  temporary files.

Now I want to (need to) reduce the quantity of IO executions.

So I want to create  a sort of circular buffer that is going to be filled up with a data from a text file within first thread.

The consumer (reading) thread will fetch data from this buffer.

The problem is that there could be multiple consumers that need to read from same one buffer.

For buffer implementation I prefer not to use any existing wrappers (simple  array, where i just "play"  with indices is enough).

I also don't want to create a separate buffer for every reader.
And ofcourse I want to avoid any deadlocks and unnecessary  blockings.

UPDATE

Right now I am using circular buffer (an array and 2 indices)

The question is how to implement such buffer that can be accessed by  multiple consumers where each consumer can read from it interdependently from other consumers (one costumer may read faster than the other one).

IMPORTANT UPDATE

The first thread don't know (and should not know) about it's consumers!!!
It should write data to a buffer, when data ends it should raise a flag.


问:
Is having your own website important?
How necessary or important is it? I try to keep a running list of blogs or sites to follow, but a lot of the time I pull up someone's profile and notice there isn't anything there. Is it really important?

I understand are different levels of programming (from C/C++ system programmers to Rails and even Haskell and J) and not everyone works in a language easily worked with for web based applications. Not everything is web-centric, however with the advent of many popular and sometimes free services I don't think it's unreasonable to expect a majority of programmers to have a personal site.

答:
I think having one is a great idea, both for yourself, and to increase the knowledgebase all around for everyone. Every problem has many different solutions, and it is unlikely that many of the specific solutions you find would be completely unoriginal.

That being said... if your site has your name on it and is something that clients/employers have access to and know that its yours, be sure to keep it up to date, especially aesthetically. I know as programmers we know that graphic design is a whole different field, but clients do not know that and could see your site as a poor reflection of your work. People who sell life-sized Han Solo figurines can use all of the BLINK tags they want (with black background and yellow text), but the same cannot be said for a developer.

Title: Is having your own website important?


答: On the Java side look at the disruptor which is a non-blocking, high Performance Inter-Thread Messaging Library. This is in contrast to the 'traditional' lock based concurrency that most folks still use with Java/JVM programming. The style that you want to avoid in your use case (why deal with shared state when you don't have to).</p>

Title: Sharing buffer between multiple threads


答:
The question is how to implement such buffer that can be accessed by
  multiple costumers where each costumer can read from it
  interdependently from other costumers (one costumer may read faster
  than the other one).

In order to do this safely, you'll need to ensure that only one thread can access the buffer at a given time. This can be a complex problem, but Java's synchronized methods simplifies things for you. In a nutshell, if one thread is executing a synchronized method of an object, no other synchronized method on that object may be executed in any thread until that method completes.

So, your job is to create a class for your buffer with synchronized read and write methods. Instantiate that class early in your program and share the resulting object with all producers and consumers. Java's method synchronization will ensure that only one thread accesses the object at a time.

Title: Sharing buffer between multiple threads


问:
F# performance vs Erlang performance, is there proof the Erlang's VM is faster?
I've been putting time into learning functional programming and I've come to the part where I want to start writing a project instead of just dabbling in tutorials/examples.

While doing my research, I've found that Erlang seems to be a pretty powerful when it comes to writing concurrent software (which is my goal), but resources and tools for development aren't as mature as Microsoft development products.

F# can run on linux (Mono) so that requirement is met, but while looking around on the internet I cannot find any comparisons of F# vs Erlang.  Right now, I am leaning towards Erlang just because it seems to have the most press, but I am curious if there is really any performance difference between the two systems.

Since I am used to developing in .NET, I can probably get up to speed with F# a lot faster than Erlang, but I cannot find any resource to convince me that F# is just as scalable as Erlang.

I am most interested in simulation, which is going to be firing a lot of quickly processed messages to persistent nodes.

If I have not done a good job with what I am trying to ask, please ask for more verification.

答:
What do you mean by "viable?"  "Having the most press" is not necessarily the best way to choose a language.

Erlang's claim to fame is its capability of massive parallelization.  That's why it's commonly used in Ericsson phone switches.  Erlang is soft-realtime, so you can make certain performance guarantees about it.

F# benefits from the optimization capabilities of the .NET Jitter.  In addition, the language itself is designed to be a high-performing functional language (it being a variant of OCaml, widely used in the financial industry because of its speed).

Ultimately, unless you plan on running millions of tiny agents at the same time (which is what Erlang is optimized for), F# should be up to the task.

This page explains the appropriate use cases for Erlang.


答:
Have any of you seen richly-formatted code like this before, or know
  if the idea was ever considered and eventually rejected?

Sure. Xcode supports styles beyond simple coloring for different syntax:

It's been a long time since I used it, but I think Metrowerks CodeWarrior supported styled text too, and that was 10+ years ago.

You don't want to go overboard with the styles, though -- any text, source code or otherwise, can be harder to read when the styles vary too much. In particular, I think mixing sizes is distracting, and anything that causes columns not to line up is annoying. There's a reason most programmers still use monospaced fonts.

A different question is whether styled text should be used as part of the language syntax itself. For example, should the compiler use the fact that some text is styled a certain way to determine that the text is a function declaration? That might sound crazy at first, but languages like Python and Fortran already use indentation as syntax. Nevertheless, I think it's more likely that we'll continue to see style driven by syntax rather than the other way around. There are a lot of benefits that come from being able to use plain text (simpler compilers, platform independence, programmer preferences), and other traditions have evolved to make code readable in the absence of styles (indentation, blank lines, marker characters, and editor features like code folding and navigation menus).


问:
Decoupling Threads
It's not uncommon to hear of decoupling the UI from program logic, or database design/access from program logic...or even program logic from itself.

However, I've never heard of an approach to generalizing or abstracting away the details of threading tasks to the logic (aside from Tymeac, an Android-specific package). Honestly, with all of the details going into managing threads, I don't expect many solutions to work well anytime soon, so...

My question is, how do you write threads that aren't joined at the hip to the processes that use those threads? What do you normally do when requirements change in an already complicated multi-threaded application? Is there a design approach to this that I should read?

I ask this because we are the dawn of the "bagillion"-core era in computing. Eventually, a good methodology will have to exist to manage 1k+ cores and even more threads here in the next couple of decades.

答:
Despite wikipedia not listing threading specifically as a cross cutting concern I would almost say it is one. Finding a way to partition your data so that the resulting chunks are independent enough to be calculated in a thread is hard and highly dependent on your specific problem.

There are approaches to separate out threading, mostly patterns. Master-Worker, Thread Pool, you name it. They often rely on defining tasks, executing them and writing the results back into some data structure.

Unfortunately these patterns have only limited use when you want to have your word processor take advantage of your new 64-core machine.

Another approach are functional programming languages, the fact that they are inherently parallel, takes away some of the complexity with multi-threading. But they are only one puzzle piece in solving this problem and I am afraid you have to know a large list of techniques. In multithreading there is no "one size fits all".

Title: Decoupling Threads


答:
Why does it not exist? There isn't the demand/need for it.

Current editors are able to satisfy the needs of programmers with syntax highlighting and some other minor stylistic options. Is that not "rich text" already?


问:
Is it a bad idea to list every function/method argument on a new line and why?
I work with someone who, every time they call a function they put the arguments on a new line e.g.

```<code>aFunction(
    byte1,
    short1,
    int1,
    int2,
    int3,
    int4,
    int5
) ;
</code>```

I find this very annoying as it means the code isn't very compact, so I have to scan up and down more to actually make any sense of the logic. I'm interested to know whether this is actually bad practice and if so, how can I persuade them not to do it?

答:
"I'm interested to know whether this is actually bad practice..."

Yes, it's bad practice, except when the list of variables is abnormally long. But in that case, the problem is likely due to the function's design. Why not pass an object that encapsulates many of the parameters?

"...and if so, how can I persuade them not to do it?"

Tie them down and keep tickling them until they agree to stop that crap.


答:
Well, here's some downvote-bait.
I've never been accused of doing the popular thing.
Clearly, if things fit on one line, then fine, fit them on one line.

But my main concern is not whether the code is "ugly" or "pretty".
My main concern is how easy it is to understand and make changes to without making mistakes.

If the arguments are long and there are a lot of them, why not put them on separate lines?
To my mind that makes it easier to see what they are, and easier to change them if necessary.
It also gives me room to attach a comment to each argument if I want to.

I also want to minimize the chance of making a mistake if I add or remove an argument to a function, which is more likely to happen at the end of an argument list than at the beginning.
For that reason, I prefer to put the comma (,) at the beginning of a line, than at the end.
Then, if for example, I want to remove or add an argument at the end of the list, it's a one-line edit.
I don't have to go fiddle with the comma that needs to go at the end of all lines but the last, where the last has to end with a parenthesis.

So (boy, I'm gonna get flamed for this) I write it like this:

```<code>nameOfFunction(firstArgument
    , secondArgument // optional comment
       ...
    , lastArgument   // optional comment
    );
</code>```

When there's a function with from five to twenty arguments, the function didn't get that way all at once.
It grew over time, meaning there were lots of edits.
Any edit not completed is a syntax error or a bug.
So I don't claim this is pretty.
I claim it helps in getting the edits right.

(And for those who say I should pass a structure instead, all that does is displace the issue, because you need a bunch of lines of code to fill in the structure, not to mention the extra code to declare and allocate it.)

Title: Is it a bad idea to list every function/method argument on a new line and why?

Body:
I work with someone who, every time they call a function they put the arguments on a new line e.g.

```<code>aFunction(
    byte1,
    short1,
    int1,
    int2,
    int3,
    int4,
    int5
) ;
</code>```

I find this very annoying as it means the code isn't very compact, so I have to scan up and down more to actually make any sense of the logic. I'm interested to know whether this is actually bad practice and if so, how can I persuade them not to do it?

Body:
Well, here's some downvote-bait.
I've never been accused of doing the popular thing.
Clearly, if things fit on one line, then fine, fit them on one line.

But my main concern is not whether the code is "ugly" or "pretty".
My main concern is how easy it is to understand and make changes to without making mistakes.

If the arguments are long and there are a lot of them, why not put them on separate lines?
To my mind that makes it easier to see what they are, and easier to change them if necessary.
It also gives me room to attach a comment to each argument if I want to.

I also want to minimize the chance of making a mistake if I add or remove an argument to a function, which is more likely to happen at the end of an argument list than at the beginning.
For that reason, I prefer to put the comma (,) at the beginning of a line, than at the end.
Then, if for example, I want to remove or add an argument at the end of the list, it's a one-line edit.
I don't have to go fiddle with the comma that needs to go at the end of all lines but the last, where the last has to end with a parenthesis.

So (boy, I'm gonna get flamed for this) I write it like this:

nameOfFunction(firstArgument
    , secondArgument // optional comment
       ...
    , lastArgument   // optional comment
    );

When there's a function with from five to twenty arguments, the function didn't get that way all at once.
It grew over time, meaning there were lots of edits.
Any edit not completed is a syntax error or a bug.
So I don't claim this is pretty.
I claim it helps in getting the edits right.

(And for those who say I should pass a structure instead, all that does is displace the issue, because you need a bunch of lines of code to fill in the structure, not to mention the extra code to declare and allocate it.)


答:
Here's pros and cons of C++ vs. C:

Moving to C would make it easier to stay within the chosen C++ subset, because compiler would then give error when you go outside of it. If the main problem is with staying within decided subset, this alternative should be chosen. (why don't we have compiler support for this?)

Once you can stay within chosen c++ feature subset, then next thing is to try to change the subset to get rid of bad conventions which break the code. This requires use of whole c++.

Once you have both "staying inside subset" and "it's a good subset", then move outside of c++ features, and start thinking about requirements.


问:
Why can people expect hardware/software requirements on software applications, but it's not for web applications?
Questions revolving around ways of getting customers to embrace new web technology / browsers so one can deliver better web software to the end user.

It's hard to manage expectations of customers. Expectations such as:

Websites should work on older browsers. (ambiguous).

Websites should not require specific hardware.

Giving system / computer specs for running a website is unacceptable.

Web development isn't as easy as many think. There's a lot that goes into creating a properly run web application (not just a website). Take a look at Google Docs or Microsoft Office online. These are more than just regular websites, and they force users to use newer browsers.

MS Office Online will not work with IE6, and they are trying very hard to push people to use IE8 (soon IE9). Google pushes as well, same with many other strong web entities.

You can do a lot on the internet, from playing games, watching movies, doing work, even coding and have the server you're connected to compile your code.

With everything the web can do, I find it amazing that people still want to put unrealistic expectations on web applications just because it will require someone to use a browser that is only... 2-3 years old.

I understand people don't like change. And we all know that many corporations will provide days/weeks of training to help their employees understand new internet browsers. There are also cases where people are forced to use old browsers because the archaic system they use for internal work only runs on that browser (ActiveX+IE6).

My Questions

How can you tell your end users that they will need to upgrade their browser to use the latest version of your website without a huge outcry?

Why does the expectation exist that it's ok for software to require people to upgrade Windows/Mac versions, but a website cannot require a new browser version?

答:
The expectation that a website shouldn't need a new browser is simple. The browser works fine with other sites. Why is yours broken?

To overcome this resistance, you should take a page from Adobe's playbook and keep as much of your site's functionality compatible with older browsers as possible. For that which requires a more modern browser, have some graphic indicate that additional functionality requires X feature of newer browsers.

If you're dumping support for some outdated browser feature, try to have some corresponding indication on your site as well.


答:
As a more general answer:

Do not switch to C++ just because you are using some of it's more unique features. One day you may need those features, and will just pound your head because you are using C.


答:
For hobbyist development, I would consider switching back to plain C.  C and C-like languages are more likely to be supported on tiny hobby development modules.

Many of the answers here might be from professional software types.  As a hobbyist, you won't be coding continuously or full time.  So consider which language you are more likely to remember or forget the quirks within, if you table your project for a year and then come back and try to read your code after you have gotten rusty in coding.  C++, having a richer feature set, may take more or less time to re-acquire, depending on your coding style.


答:
This already exists for LaTeX in AucTeX mode for Emacs. Section titles are larger in size, sub and superscripts are resized appropriately and you can even have little previews of math (and possibly other environments like Algorithmic).

This is fine for LaTeX because the mapping from the code to the output is usually much more straightforward than in other programs; I think I would not like that at all for more general-purpose languages.

Another thing Emacs can do is replace symbols like -> and forall with → and ∀ respectively in Haskell. There is little reason this sort of thing can't be extended to doing formatting like you're suggesting except that it isn't necessary at all in Haskell.


答: The primary point in favor of using a web site is that people can use it without worrying about the hassles of installing and maintaining up to date software. If they have to do that anyway, desktop applications generally have substantial advantages in responsiveness, performance, features, etc.</p>

Title: Why can people expect hardware/software requirements on software applications, but it's not for web applications?

Body:
Questions revolving around ways of getting customers to embrace new web technology / browsers so one can deliver better web software to the end user.

It's hard to manage expectations of customers. Expectations such as:

Websites should work on older browsers. (ambiguous).

Websites should not require specific hardware.

Giving system / computer specs for running a website is unacceptable.

Web development isn't as easy as many think. There's a lot that goes into creating a properly run web application (not just a website). Take a look at Google Docs or Microsoft Office online. These are more than just regular websites, and they force users to use newer browsers.

MS Office Online will not work with IE6, and they are trying very hard to push people to use IE8 (soon IE9). Google pushes as well, same with many other strong web entities.

You can do a lot on the internet, from playing games, watching movies, doing work, even coding and have the server you're connected to compile your code.

With everything the web can do, I find it amazing that people still want to put unrealistic expectations on web applications just because it will require someone to use a browser that is only... 2-3 years old.

I understand people don't like change. And we all know that many corporations will provide days/weeks of training to help their employees understand new internet browsers. There are also cases where people are forced to use old browsers because the archaic system they use for internal work only runs on that browser (ActiveX+IE6).

My Questions

How can you tell your end users that they will need to upgrade their browser to use the latest version of your website without a huge outcry?

Why does the expectation exist that it's ok for software to require people to upgrade Windows/Mac versions, but a website cannot require a new browser version?


问:
Should controls on a form be prepared in a separate class?
I have a form with several controls on it. Every control has to be declared in the class, formatted in the constructor (-size, location, event subscription etc), and its event-handlers declared, again, in the class.

This is getting a bit unorganized, so I was thinking of refactoring this. For every control: Preparing a class which derives from that control-type (which will include location, event-subscription and event-handlers, etc.), and then using an instance of it.

Am I going to run into any trouble doing this?

答: If you need to have the same control, with the same formatting, etc. in a whole bunch of places, then this isn't a bad idea.  However, if each class you create would only be used once, then you're not really removing any complexity, only moving it around.  I'd prefer linear, conceptually simple straight-line code to a bunch of classes that are only instantiated once.</p>


答: Ideally speaking you should be having a separate class to initialize all your controls that are commonly needed in your application. Then override them in accordance with your specific requirements in your main program. This will make life much easier for you.</p>

Title: Should controls on a form be prepared in a separate class?

Body:
I have a form with several controls on it. Every control has to be declared in the class, formatted in the constructor (-size, location, event subscription etc), and its event-handlers declared, again, in the class.

This is getting a bit unorganized, so I was thinking of refactoring this. For every control: Preparing a class which derives from that control-type (which will include location, event-subscription and event-handlers, etc.), and then using an instance of it.

Am I going to run into any trouble doing this?


问:
Using bug-tracking / issue-tracking software to discuss design questions, new tools etc
Does anybody have experience with using a bug-tracking / issue-tracking software like bugzilla, mantis or JIRA not only for bugs or tasks, but to initiate and maintain discussions that in the end lead to a decision?

For example, a developer thinks that all protected fields should be abolished and changed to private fields with protected methods that access them. It is not his call, and he would like to discuss it. Normally he brings up the point in the next developer meeting at the end of which a decision is made. Instead, my idea was for him to open an issue of a certain type "decision" and describe his intent like normally one would describe a bug or task.

Other developers can make their comments if they feel like it, and in the end, the issue is closed as "accepted" or "denied".

The advantages I see in this:

Asynchronous communication: no one is forced to voice his opinion in a meeting when they didn't have time yet to oversee all ramifications of said decision.

Written log of considerations that lead to a decision. If one later raises that question again he can be referred to it.

Relations to other issues can be made, e.g. a task can be followed back to a decision.

Integration with version control software, e.g. a commit can be traced back to a decision.

Disadvantages:

Heavy smell of a golden hammer: issue tracking software normally is used to track actionable items

Organizational overhead may be disproportionate: instead of a small informal talk one has to communicate his ideas in written form

答:
The way we work, issue tracking should track all issues. We don't know what issues are actionable until it has been analyzed. If the tracking system only has actionable issues in it, it is likely they are being triaged too soon, meaning any discussions and decision is lost. We take the approach every thing should go in (In our workflow anyway), as otherwise issues can be repeatably raised with no visibility.

We have a category in our Jira implementation for "Risk", so we are using Jira to track items that are not actionable, but have the ability to jeopardize the software in some way. Discussion on the item is tracked and once the risk is gone (or mitigated) the issue is closed. The example you have given could easily go into the Risk category.

It is important that things such as this are discussed and tracked, and the decision recorded. When the developer re-raises the issue in a few months time, the "Asked and answered" response has a justification to it.


答:
It makes it easier to:

Reorder arguments.

Comment out or disable arguments.

See exactly which argument has changed when you view diffs in your version control system

Avoid re-indenting and word-wrapping everything when you add or remove an argument, or change the function name. (Even if your editor automatically indents, you are still creating lots of unhelpful whitespace changes which make it harder to follow changes in your version control system.)