问:
Why is it so hard to get employees to update the issue tracker?
I've always had this struggle to get folks to update their issues, both at my company and at work. I've had a few cases when people actually do it from the goodness of their heart, but ~70% of the time I have to be chasing people down.

Being the one that generally does some or other form of management (I am firstmost a developer), the main reason I try to give is that I don't want to be chasing people down and interrupting to query on progress, but I don't think in the end people mind that much being asked. In some rare and extreme cases I end up updating their tickets (when I need to create reports).

So, have you ran into this problem?, how have you encouraged developers to update the issue tracker frequently?, what degree of success have you had?

答:
As pointed out by some other answers, the right question here is probably: why do you have an issue tracker. A good answer to this question (not just from a management perspective but also from a developer perspective) is imperative if you want an issue tracking system to really work and be regularly updated.

In many companies the issue tracking system is mainly used as a management reporting tool. Getting programmers to update issues just so that management can run a report does not work well. And forcing programmers to update issues does not work either - you may have updated issues but you should question the data.

In my experience, the only way to really have developers (and testers, management, etc.) effectively use an issue tracking system is to integrate it into the development process. This means that the output of one part of the process becomes the input to the next part of the process.

To give the bug tracking system authority I would suggest the following:

Developers only work on bugs/features logged in the issue tracker and no work is done outside of it. All ideas, refactoring projects, new features, custom tools to be developed, etc. should be logged as well.

Issues are worked on in order of priority. The priority should partly be determined by management, but developers should definitely have a say in determining priorities as well. This is especially true when it comes to maintenance and refactoring issues.

As to process, you could use something like the following:

status 'new' indicates that an issue has not yet been picked up by a developer and is still in the queue of prioritized issues

status 'assigned' indicates that it has been assigned to a developer. This could be done by the developer or someone else such as the team lead. I find it works well to have a few issues assigned to each developer, and usually a mix of 'heavy lifting' such as new features and easy pickings such as simple bugs or some simple maintenance work. This allows developers to choose work depending on their mood.

status 'in progress' means that a developer is working on an issue. Only one or two issues per developer should be 'in progress' at any point in time.

once an issue has been resolved the developer can change the status of the issue to 'needs testing' and change the owner to the tester. This is an important step, as this is also the work queue of the testers.

testers can change the status either to 'failed testing' and change ownership back to the developer which means that it goes to the top of the queue for the developer, or they can change the status to 'ready for deploy'.

issues with the status of 'ready to deploy' can then be merged and released according to the release cycle by whoever is responsible for the releases.

In short: make the issue tracking system an essential part of the development process and you won't have to worry about issues not being updated.


问:
I don't know C. And why should I learn it?
My first programming language was PHP (gasp).  After that I started working with JavaScript.  I've recently done work in C#.

I've never once looked at low or mid level languages like C.

The general consensus in the programming-community-at-large is that "a programmer who hasn't learned something like C, frankly, just can't handle programming concepts like pointers, data types, passing values by reference, etc."

I do not agree. I argue that:

Because high level languages are easily accessible, more "non-programmers" dive in and make a mess

In order to really get anything done in a high level language, one needs to understand the same similar concepts that most proponents of "learn-low-level-first" evangelize about.

Some people need to know C; those people have jobs that require them to write low to mid-level code. I'm sure C is awesome, and I'm sure there are a few bad programmers who know C.

Why the bias?  As a good, honest, hungry programmer, if I had to learn C (for some unforeseen reason), I would learn C.  Considering the multitude of languages out there, shouldn't good programmers focus on learning what advances us? Shouldn't we learn what interests us?  Should we not utilize our finite time moving forward?  Why do some programmers disagree with this?

I believe that striving for excellence in what you do is the fundamental deterministic trait between good programmers and bad ones.

Does anyone have any real world examples of how something written in a high level language—say Java, Pascal, PHP, or JavaScript—truly benefited from a prior knowledge of C? Examples would be most appreciated.

答:
Much as I hate to post the obligatory Joel blog post, I agree with him here.  C is the lingua franca of programming.  I can't think of any high-level language that can't interface with it somehow.  Because of that, C is still a popular choice for systems programming type stuff.  You simply can't interface with some OS-level things without C.

Besides that, what do you plan to do when your high-level language isn't fast enough?  Knowing how to write C is especially important when you're using a high-level, dynamically typed language like Ruby, Python, or PHP.  But even Java and C# programmers need to drop down to C from time to time.

ContentLicense: CC BY-SA 3.0

ContentLicense: CC BY-SA 2.5


问:
Boolean-Integer Typecasting to Replace Conditional
When choosing a value based off of 2 boolean values in this format

```<code>var foo:int;

if (X){
    foo = 50;
} else if (Y){
    foo = -50;
} else {
    foo = 0;
}
</code>```

I discovered that I can condense this down by typecasting the boolean operations to integers,  and mathing it up a bit like so:

```<code>var foo:int;

foo = ( int (X) - int(!X && Y) ) * 50;
// int() typecasts a boolean argument to an int of 1 if true, 0 if false.
</code>```

Here are my questions:

Is this approach less resource intensive?

Is this approach readable to you?

Is assigning values in this way common?

If 1 is true then in your opinion, does the performance increase justify the less readable nature of this approach?

This situation arose in ActionScript 3.0, but I am interested in answers from all languages, and from a best practice perspective.

答:
This is to some extent a matter of style, but I really believe your single-line option is much, much less readable, and is not a common approach.

The first classic if is very easy to read and check. There's no complex nesting, just a plain, "boring", chain of conditions that is well understood in all languages that have an if/else if/else construct.

The second is very tricky:

Two conditionals, one of them a composite for which you need to know operator precedence

(is !X && Y interpreted as (!X) && Y or !(X && Y))

Two casts for which you need to know that true is converted to 1 and false to 0 (or are those function calls?). This might be common, but it's something people aren't always aware of, or aware that the language guarantees that. (That is if you're indeed using a built-in cast in this example - if it's a custom function call, then that needs to be known too)

Then you have to figure out what the result of that - operation will be in what circumstances. Pretty basic maths, but needs a few brain cycles more than the trivial if/else cascade.

As for the second version could somehow be more efficient? I don't think so. In fact, it might be not only less efficient, but not behave the same way as the first. X is evaluated twice (so potentially more expensive). If the evaluation of X has side-effects, the two versions aren't equivalent.

(And let's not mention C-type macros that could break the second version while the first works, or the issues with un-sequenced operations your second version could entail in C and C++ because of that double evaluation in a single statement - I don't think that's the point of your question here.)

tl;dr: less lines of code does not mean more efficient. Your code should be written so that it can be efficiently maintained. Your compiler/runtime/interpreter will take care of the dirty work of optimizing as long as you've chosen the right algorithms and data structures and expressed them clearly in your language.


问:
Stroustrup and the C++ complexity admission
I heard from a friend that Bjarne Stroustroup admitted that he doesn't know entirely the C++ programming language due to its vast complexity

Is it true and there's some referrable sources or is it just an exaggeration?

This affirmation should be present on his website, he told it in an interview/conference some time ago

答:
In a comment to your original question, I mentioned that I'd seen something similar, but I couldn't find it.  Well, I found what I was thinking about.

From Stroupstrup's "interviews" page, there is a link to a PDF ("Interview by Ryou Ezoe")

Page 9 of the PDF has the quote I'd remembered.  It reads as follows (Stroustrup speaking):

Even I can’t answer every question about C++ without reference to
  supporting material (e.g. my own books, online documentation, or the
  standard). I’m sure that if I tried to keep all of that information in
  my head, I’d become a worse programmer. What I do have is a far less
  detailed – arguably higher level – model of C++ in my head.

So, if nothing else, I found what I'd been looking for.  Your question forced me to do it.  Thank you.


问:
Why some consider static analysis a testing and some do not?
Preparing myself also to ISTQB certification, I found they call static analysis actually as a static testing, while some engineering book distinct between static analysis and testing, which is the dynamic activity. I tent to think that static analysis is not a testing in the true sense as it does not test, it checks/verifies. But sure I would love to hear opinion of the true experts here.
Thank you</p>

答:
One of the traditional definitions of software testing is execution of the program with the intent of finding bugs. This was Glen Myers definition, for example. We pretty much followed that definition in Testing Computer Software. I still see this--Wikipedia, for example, says "Test techniques include, but are not limited to, the process of executing a program or application with the intent of finding software bugs (errors or other defects)."

Under that definition, static analysis cannot be testing because it analyzes the code without executing it.

The definition that I currently use is that testing is an empirical investigation of a software product or service in order to learn quality-related information about it. (See for example, the BBST courses (my free course videos for BBST are at http://www.testingeducation.org).

Under this definition, static analysis might be testing. If you think that SCA is an empirical activity (in other words, something like running an experiment), then you should think that SCA would be testing under my definition. In contrast, if you think that SCA is more like theoretical analysis than like running experiments, then you should think that SCA is not testing.

I don't personally have an opinion. I use SCA while I am writing code and it feels to me that it is part of what I do when programming. It doesn't much feel like testing. But I also do a lot of unit testing and monitor code coverage of the unit tests and when I do it, that also feels like part of an integrated programming activity, not like testing either. Mainly, I don't care whether people call SCA (or unit testing) testing or not. The more important question to me is whether they do it, and if they do, whether they are any good at it.

There are several other widely used definitions of software testing. Some people (and some organizations) insist that they have the One True Definition. And I suppose it is the One True One for them. But there are enough different One True Definitions that I find it more useful to accept the diversity as a fact of life and work with people by asking them what they mean when they say things.

So, depending on your favorite definition of testing, SCA is or is not testing (or is ambiguous), but under someone else's favorite definition, the answer might be different. If you're studying for the ISTQB exam, the relevant definition is the ISTQB definition. I don't remember it, but you can look it up in your study materials.

By the way, static analysis is a broad term. A program that analyzes code to check for certain specific coding errors (or even nonconformities with a specified coding style) is doing static analysis. So is a person or program that analyzes code to determine whether an algorithm is theoretically correct (and whether the implementation conforms logically to the algorithm). This latter case is called a proof of correctness. This is an instance of static analysis, not the entirety of it.

By the way, proofs of correctness cannot prove that the program as run will be correct. They can prove that certain types of errors cannot be present. However, if you analyze the source code (e.g. code written in Java), you have not analyzed what actually gets run, because the Java gets translated into other code by a compiler. Additionally, you don't know how this Java code will interact with the memory manager, the printer driver, the video display, etc. Those interactions might cause a program failure but the static analysis will be blind to them. Another class of increasingly common risk involves multithreaded execution. What looks to you like one linear sequence of commands can be executed partially in parallel. Sometimes, things get done in an unexpected order of execution (the wrong thing gets done first, so perhaps a memory location has outdated information or information that shouldn't have been put there yet) The result is a failure, even if it wouldn't have been a failure on a different computer. Finally, I have never seen an error-free specification, so the idea that a proof that some code matches the specification perfectly doesn't assure me that the program is error-free.

So.... formal analysis is useful, but it cannot replace all of (the other types of) testing.


答:
I'm a developer and struggle to use the issue tracker we have at work. This is unfortunate because I am all for them to keep things organized. My solution for the moment is to use a personal tracking tool and reference it to talk about progress at our daily scrums.

Here's what would make me use the tracker all the time:

Seamless integration with the IDE and source control. We use some clunky webapp because licenses were already purchased for it. It takes forever to create/update tasks, and has some confusing UI features. Unfortunately using this is beyond our team's control.

Simplicity. By this I mean not taking 10 manually populated fields just to add a task. Hourly estimates vs. completion time, manually entering the project/component/etc. in several fields, etc. just increase the amount of time.

Only one. Not sure how common this is, but project management uses one tool, support uses another, and development uses a third. If one doesn't get updated, three certainly aren't and synchronizing between them is unlikely to be automated.

Title: Why is it so hard to get employees to update the issue tracker?

Body:
I've always had this struggle to get folks to update their issues, both at my company and at work. I've had a few cases when people actually do it from the goodness of their heart, but ~70% of the time I have to be chasing people down.

Being the one that generally does some or other form of management (I am firstmost a developer), the main reason I try to give is that I don't want to be chasing people down and interrupting to query on progress, but I don't think in the end people mind that much being asked. In some rare and extreme cases I end up updating their tickets (when I need to create reports).

So, have you ran into this problem?, how have you encouraged developers to update the issue tracker frequently?, what degree of success have you had?


问:
Why did Alan Kay say, "The Internet was so well done, but the web was by amateurs"?
OK, so I paraphrased. The full quote:

The Internet was done so well that most people think of it as a natural resource like the Pacific Ocean, rather than something that was man-made. When was the last time a technology with a scale like that was so error-free? The Web, in comparison, is a joke. The Web was done by amateurs. -- Alan Kay.

I am trying to understand the history of the Internet and the web, and this statement is hard to understand. I have read elsewhere that the Internet is now used for very different things than it was designed for, and so perhaps that factors in.

What makes the Internet so well done, and what makes the web so amateurish?

(Of course, Alan Kay is fallible, and no one here is Alan Kay, so we can't know precisely why he said that, but what are some possible explanations?)

*See also the original interview*.

答:
In a sense he was right.  The original (pre-spec) versions of HTML, HTTP and URL were designed by amateurs (not standards people).  And there are aspects of the respective designs ... and the subsequent (original) specs ... that are (to put it politely) not as good as they could have been.  For example:

HTML did not separate structure/content from presentation, and it has required a series of revisions ... and extra specs (CSS) ... to remedy this.

HTTP 1.0 was very inefficient, requiring a fresh TCP connection for each "document" fetched.

The URL spec was actually an attempt to reverse engineer a specification for a something that was essentially ad hoc and inconsistent.  There are still holes in the area of definition of schemes, and the syntax rules for URLs (e.g. what needs to be escaped where) are baroque.

And if there had been more "professional" standards people involved earlier on, many of these "miss-steps" might not have been made.  (Of course, we will never know.)

However, the web has succeeded magnificently despite these things.  And all credit should go to the people who made it happen.  Whether or not they were "amateurs" at the time, they are definitely not amateurs now.


问:
Why should I use the function migration in codeigniter?
What is wrong with using database tables with phpmyadmin or mysql? What are the benefits, if I'll use 'migration'?</p>

答:
I don't use CodeIgniter, but as a Rails developer who used to just use phpMyAdmin and now uses migrations I'd say the primary benefits are:

It's an easy way to port the code to a different workstation. Instead of having to dump the SQL file and import it into the other workstation, you just run the migrations.

It allows you to keep your database schema in sync with your co-workers. When a table is modified, everyone can just run the migration and you're good to go.

It allows you to easily roll back database changes if they cause problems.

It documents the changes made to the database structure.


答:
You cannot really say that the Internet or the Web was invented by amateurs or professionals because those fields are absolutely new ones; all people were amateur in Internet protocols before they were invented so from a point of view the inventors of the Internet were amateurs too.

If we were to be really judgmental the Internet was not so great after all: IPv6 is needed. And it is not only about the address space; IPv6 has a new header with fewer and different fields.

Another big difference from the Internet and the Web is how they are perceived by the programmer; a programmer rarely interacts with the Internet. From his point of view in IP you have addresses and in TCP you have a port in addition and you are assured that the packages are sent. That's about it... While with Web the programmer has a more intense interaction: HTTP methods, headers, HTML, URLs etc. It is normal to see the limits of something with many more possibilities than in something with almost no possibilities at all. With this I don't want to say that the Internet is simple: underneath it is kind of complex but this complexity is handled by network and telecommunications engineers and is about configuring something in a limited amounts of possibilities while in the web you basically have unlimited possibilities but the task of building complex applications relying only on packet sending.

Regarding the greatness of these two technologies, the Internet is so appreciated because it is a very scalable technology and the idea of layering was very good one; basically at the lower levels you can use any technology you want (WLAN, Ethernet, Token Ring etc.) and have IP as a standard intermediate protocol upon which TCP and UDP are placed and above which you can basically add what application protocol you want.

The greatness of the Web is strictly related to the greatness of the Internet because the Web strongly relies on the Internet, having the TCP/IP stack underneath. But I would say the Internet is dependent on the Web too; the Internet existed 20 years before the Web and was kind of anonymous but 20 years after the Web, the Internet is ubiquitous and all of this thanks to the Web.

Title: Why did Alan Kay say, "The Internet was so well done, but the web was by amateurs"?

Body:
OK, so I paraphrased. The full quote:

The Internet was done so well that most people think of it as a natural resource like the Pacific Ocean, rather than something that was man-made. When was the last time a technology with a scale like that was so error-free? The Web, in comparison, is a joke. The Web was done by amateurs. -- Alan Kay.

I am trying to understand the history of the Internet and the web, and this statement is hard to understand. I have read elsewhere that the Internet is now used for very different things than it was designed for, and so perhaps that factors in.

What makes the Internet so well done, and what makes the web so amateurish?

(Of course, Alan Kay is fallible, and no one here is Alan Kay, so we can't know precisely why he said that, but what are some possible explanations?)

*See also the original interview*.


答:
He actually elaborates on that very topic on the second page of the interview.  It's not the technical shortcomings of the protocol he's lamenting, it's the vision of web browser designers.  As he put it:

You want it to be a mini-operating system, and the people who did the
  browser mistook it as an application.

He gives some specific examples, like the Wikipedia page on a programming language being unable to execute any example programs in that language, and the lack of WYSIWYG editing, even though it was available in desktop applications long before the web existed.  23 years later, and we're just barely managing to start to work around the limitations imposed by the original web browser design decisions.


问:
Can a developer perform testing efficiently?
I don't know yet how it feels to be a part of dev/testing teams. If in an organization (mostly single-product company), can a developer handle testing efficiently?

From what I have read:

Developers do not like testing and hence effectiveness of testing suffers, Testing requires special tools and skills.

So in a work place, if a member from dev has to perform a testing part, wouldn't he do it efficiently? If not, why not? And why don't developers like testing?

I am not getting the actual concept.

Source: Automated Software Testing: Introduction, Management, and Performance by Elfriede Dustin, Jeff Rashka, John Paul

答:
If a developer has extensive knowledge in the company or in the field per se, then it may be possible for a developer to test efficiently.

One problem is that developers like to code, and you don't code much in testing. Another problem is that the developer would likely be focusing on doing the task at hand (whether creating a new screen or fixing existing bugs) that he/she will not be able to test other parts of the code because the developer expects that since he/she did not change the logic of the other parts of the program, then the program should behave exactly as it used to. I'm guilty in both of those problems. :)


答:
So in a work place, if a member from dev has to perform a testing
  part, wouldn’t he’ll do it efficiently?

Obviously that is a bit of genralisation but yes, most often developers wont be effective testers. Testing is quite a hard skill, you have to get into the mind of the users also be able to effectively find all the ways in which the software can be used and abused. Lots of tests (ie load tests) require knowledge and licences to specialised tools.

And why developers don't like testing?

Again a genralisation (some people do). The people that dont like it tend not to like it because its hard, they don't know what they are doing and it takes time away from development.

Title: Can a developer perform testing efficiently?

Body:
I don't know yet how it feels to be a part of dev/testing teams. If in an organization (mostly single-product company), can a developer handle testing efficiently?

From what I have read:

Developers do not like testing and hence effectiveness of testing suffers, Testing requires special tools and skills.

So in a work place, if a member from dev has to perform a testing part, wouldn't he do it efficiently? If not, why not? And why don't developers like testing?

I am not getting the actual concept.

Source: Automated Software Testing: Introduction, Management, and Performance by Elfriede Dustin, Jeff Rashka, John Paul


答:
I would say the problem is less that developers don't like testing than that developers know the flow that they pictured the user taking through their product, so they'll tend to unconsciously stay within that happy path. Testers, on the other hand, don't know what steps the developer is expecting the user to take, so they'll wander off the path and find out what breaks when you do that.

In addition, there are certain things you stop seeing or never looked at to begin with. For example, if I copied and pasted text that is shown on screen from a document that came directly from the client, I often don't look at it for typos or grammatical errors.

What you get from a tester who is not a developer is a set of fresh eyes. Try as she might, a developer can't look at her product the same as someone who has never seen it. So she may wind up running through it many times and not seeing as many things. This is not the best use of her time, since she will never be able to give you what a pair of fresh eyes would. Plus, she's likely to be relatively expensive for that task.


答:
Well it depends on what type of testing are you talking about. If you refer to unit testing or integration testing I believe it should be done only by developers since their code is going to heavily rely on it.

If manual testing or automatic testing for example I believe is a job for tester; developers will most likely not cover all the flows only the major one(s).


问:
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 case I am trying to commit files of a server to the repository system (SVN). This is the initial commit and don't want to download it as it is a really large project (a few GB) and I want to do the initial commit off the clients server.

The issue is that the client is on a shared server, the svn client is killed (or any other software) if it runs more then a minute.

One alternative would be to download the project on my computer and do the initial commit from there but I am interested to know if there is a option in SVN to break the large commit into more, something similar to transactions methods.

The developer before me never used a version control system.


问:
What kind of JavaScript design pattern is this?
In our workplace we use simple ajax library for getting page data and submitting changes to the server. Sometimes we need to change the form’s field values. We know that fields can be of any type (dropdown, textbox, radio buttons, etc.) and one of the most annoying and tedious tasks was remembering each field’s ID so could do the manipulation. (The task can exceed a few days, so I had to keep the IDs in a text document). So I made this design pattern for easily working with the fields.

```<code> function FormFieldsManager() {
            var FormMgr = {
                txtGradeName: function (txt) {
                    if (txt) {
                        $('#txtGradeName').val(txt);
                    }
                    else {
                        return $('#txtGradeName').val();
                    }
                },
                txtGradeDesc: function (txt) {
                    if (txt) {
                        $('#txtGradeDesc').text(txt);
                    }
                    else {
                        return $('#txtGradeDesc').text();
                    }
                },
                ddStatus: function (txt) {
                    if (txt) {
                        if (isNaN(txt)) {
                            $("#ddStatus").val(txt);
                        }
                        else {
                            $("#ddStatus")[0].selectedIndex = txt;
                        }
                    }
                    else {
                        return $('#ddStatus :selected').val();//selected value: A
                    }
                }
            };
        return FormMgr;
        };
</code>```

To use this function, I just call the method and I could navigate the form fields and get full JavaScript intellisense.

```<code>var form = FormFieldsManager();
form.txtGradeName('Software Developer');//to set the field value
form.txtGradeName();//to get the field value
</code>```

So my questions are,

What specific design pattern is this?

What suggestions for improvement can you give?

P.S.: I like to call it jsPageObject.

答:
This is superfluous since you will only need a once instance of that object ever because it has no state. You can simply do

```<code>var FormFieldsManager = {
    txtGradeName: function (txt) {
        ...
    },
    txtGradeDesc: function (txt) {
        ...
    },
    ddStatus: function (txt) {
        ...
    }
};
</code>```

You can simply refer to that, no need to create it. This is simply namespacing static functions somewhere, dunno if that even has a name.

If it was an actual object with state, I guess an improvement would be to use prototype so it's not as cast in concrete as it is now. You also
won't create the function objects from scratch everytime but that only really matters when you create
100+ instances of something.

```<code>//This causes an error when you forgot to specify `new` as in `new FormFieldsManager()`
"use strict";

var method = FormFieldsManager.prototype;

function FormFieldsManager() {
    this.state = "something";
}

method.txtGradeName = function (txt) {
    ...
};

method.txtGradeDesc = function (txt) {
    ...
};

method.ddStatus = function (txt) {
    ...
};
</code>```

Body:
This is superfluous since you will only need a once instance of that object ever because it has no state. You can simply do

var FormFieldsManager = {
    txtGradeName: function (txt) {
        ...
    },
    txtGradeDesc: function (txt) {
        ...
    },
    ddStatus: function (txt) {
        ...
    }
};

You can simply refer to that, no need to create it. This is simply namespacing static functions somewhere, dunno if that even has a name.

If it was an actual object with state, I guess an improvement would be to use prototype so it's not as cast in concrete as it is now. You also
won't create the function objects from scratch everytime but that only really matters when you create
100+ instances of something.

//This causes an error when you forgot to specify `new` as in `new FormFieldsManager()`
"use strict";

var method = FormFieldsManager.prototype;

function FormFieldsManager() {
    this.state = "something";
}

method.txtGradeName = function (txt) {
    ...
};

method.txtGradeDesc = function (txt) {
    ...
};

method.ddStatus = function (txt) {
    ...
};


答:
I consider myself a great tester among developers. I'm very strict about the way automated tests are written, including test names that are meaningful to the business or domain, not allowing tests to get tangled up in implementation details, etc. In my company I helped (along with a tester) introduce BDD techniques and acceptance testing using the Gherkin language, for the first time.

In other words, I care a lot about software testing, for a developer. I've spent a lot of time reading James Bach, Google Testing, Adam Goucher, Ben Simo, etc. - probably more than a lot of actual testers read. And I don't mind telling you that my team (one among several) has consistently put out releases with the lowest bug counts and least serious bugs.

But I am not a tester. I would be horrified if the project manager came up to me one day and informed me that I was going to be taking over all testing duties. Here are just the most severe problems with that approach:

I don't like testing. Most developers don't like testing. And when people keep having to do something that they don't want to do, they burn out. I commonly cite the lack of an actual QA team as one of the main reasons I left my previous company.

Exploratory testing (as opposed to writing the automated test code, which developers should be doing or at least reviewing) is a very manual activity. It's inefficient simply on the grounds that programming at an experienced/expert level has a far greater ROI than testing on any level. We have a cross-functional team with a 2:3 tester:developer ratio and still the testers often can barely keep up because they have other duties (release management, regressions, etc.). It simply doesn't make economic sense for developers to test.

Developers and testers have a completely different mind-set. It's hard to explain unless/until you've had a chance to work alongside them. Good testers will attempt to do things that are not described anywhere in the spec, things that developers would never in a million years have thought to try, typically on the basis that it seems stupid to developers. But testers are testing for the user, not the developer, which means they need to intentionally try to do stupid things, to test everything as opposed to a well-known set of happy and sad paths. It's very interesting to get a developer, tester, and BA/product manager in the same room and talk about a controversial bug; you'll get a totally different perspective from each.

Developers know too much. Because they built (or helped to build) a particular feature, they know exactly what initial conditions are supposed to be in place in order to make it work, and will almost always take shortcuts in their testing such as directly modifying databases or temporarily changing configuration files. Even if they don't do any of these things, they still know exactly what steps to take and in which order. Testers - or really, anyone who is not a developer - will lack this knowledge and/or the ability to take those shortcuts and must literally test the system from end to end, and the "integration" is precisely where the highest number of bugs usually tend to materialize.

The best way I can think of to summarize it in fewer words is:

Developers are focused on the design

Testers are focused on tasks

Project managers are focused on features

The rest of the business cares about the product

If you don't have proper feedback from all of these different groups, your product quality and overall team effectiveness is going to suffer. Greatly.

Developers should not actually be responsible for testing. If you're being asked to handle all the testing duties, run for the hills. It's a full-time job that requires a very different skill set from programming.

P.S. If I had to guess why developers almost universally loathe testing, I would say that it is probably because it does not produce anything in the sense that coding does. Creating test scenarios is more of an analytical discipline than a truly creative one, and the creative sandbox is an important reason why developers like programming. It's not coding that I like, per se; it's seeing the fruits of my labours.

The end goal of a tester is to produce exactly what the developers don't want to know about: a list of reasons why they have to stop working on that cool new feature and go back to fixing something that they thought was already done. It's not a fun activity, for a developer.


答:
There are several aspects that make it difficult for a developer to be a tester.  It is not an impossible task, but finding a developer who is proficient at being a tester too is not a common thing.

The developer is the advocate of the system is working right.  Every thing that they have written and done prior is leading up to correctly working code.  Every edge case has already been tested as part of writing the code.  Every use case has already been coded.  Every code path has been thought through.  When the application is being delivered to a testing phase, the developer believes it is working correctly.

The tester is the advocate for the system is broken in strange and subtle ways - and they will figure out how.  Sometimes this just involves the iteration of going through a number of testing scripts.  Other times this is trying to abuse the system in ways the developer never thought of (what happens if I triple click here instead of double clicking? what happens if I enter the network broadcast address into the spot where I am supposed to enter the IP address of the router?).  These are often things that exist just outside of the business specification.

Note the phrase above "abuse the system in ways the developer never thought of."  The developer of the code has a very difficult imagining new ways to break it that he or she hasn't already coded for.  This reduces the efficiency of the developer as a tester.

Testing is sometimes seen as boring to a developer. It isn't seen as a creative process - there isn't anything being built.  This is often the mindset of the developer.  Many developers get antsy and demotivated if they aren't writing code for too long.  Taking a developer and moving them from coding (where they could be writing the next round of features, or the next application) to a spot where all you are doing is running the same thing over and over is down right boring. And thus developers don't often do it well.

A bug has been found and now the developer is back to code - finding the bug and fixing it.  There is the switch from one mindset (testing) to another (developing) - Human Task Switches Considered Harmful.  These switches don't take place quickly.  There are the practical sides of switching where you are physically working (you aren't having the developer test the product on their own development work station that is customized far beyond what the product will be run on... right?).

All in all, while developers can be testers, developers are rarely efficient testers when compared to someone who wants to do testing and can maintain the mindset of the system is not working right.


问:
Difference between Dependency Injection (DI) and Inversion of Control (IOC)
I've been seeing a lot of references of Dependency Injection (DI) & Inversion Of Control (IOC), but I don't really know if there is a difference between them or not.

I would like to start using one or both of them, but I'm a little confused as to how they are different.

答:
Good article to understand IOC and DI http://martinfowler.com/articles/injection.html

IOC (Inversion of Control)

IOC means

coding to interface (one component should dependent on other component’s interface and not on impl), and
e.g

```<code>interface iComp_2 {...}

class Comp_1 {
    iComp_2 c2 = ….;
}
</code>```

removing the component implementation specific code
e.g

```<code>Comp_1 {
    iComp_2 c2 = getComp_2_Impl(); // not new Comp_2_Impl();
}
</code>```

IOC can be achieved by either of the following:

1. DI (Dependency Injection)

```<code>3 types of DI

1.1 Constructor Injection

1.2 Setter Injection

1.3 Interface Injection
</code>```

2. Service Locator

DI (Dependency Injection) container

Runtime impl determination and not compile time: determines at runtime which concrete implementation of an interface to be used based on some config file (so at compile time we don’t know which impl is going to be used and thus increases configurability of the application). It is an implementation where the concrete relation between different modules is decided at "run time".

Instantiation of impl after dependency injection: after determining the impl, it instantiates that impl by first creating all of its dependencies (specified in config file) and then injecting those dependencies into that impl

Instance Life-cycle management: DI containers usually only keep a reference to objects it needs to manage life cycles for, or that are reused for future injections, like singletons or flyweights. When configured to create new instances of some components for each call to the container, the container usually just forgets about the created object. Otherwise the garbage collector would have a hard time collecting all these objects when no longer used.

OwnerDisplayName: Elijah Manor

Body:
Good article to understand IOC and DI http://martinfowler.com/articles/injection.html

IOC (Inversion of Control)

IOC means

coding to interface (one component should dependent on other component’s interface and not on impl), and
e.g

interface iComp_2 {...}

class Comp_1 {
    iComp_2 c2 = ….;
}

removing the component implementation specific code
e.g

Comp_1 {
    iComp_2 c2 = getComp_2_Impl(); // not new Comp_2_Impl();
}

IOC can be achieved by either of the following:

1. DI (Dependency Injection)

3 types of DI

1.1 Constructor Injection

1.2 Setter Injection

1.3 Interface Injection

2. Service Locator

DI (Dependency Injection) container

Runtime impl determination and not compile time: determines at runtime which concrete implementation of an interface to be used based on some config file (so at compile time we don’t know which impl is going to be used and thus increases configurability of the application). It is an implementation where the concrete relation between different modules is decided at "run time".

Instantiation of impl after dependency injection: after determining the impl, it instantiates that impl by first creating all of its dependencies (specified in config file) and then injecting those dependencies into that impl

Instance Life-cycle management: DI containers usually only keep a reference to objects it needs to manage life cycles for, or that are reused for future injections, like singletons or flyweights. When configured to create new instances of some components for each call to the container, the container usually just forgets about the created object. Otherwise the garbage collector would have a hard time collecting all these objects when no longer used.


问:
Algorithm for dividing a range into ranges and then finding which range a number belongs to
Having

a minimum

a maximum

number of ranges

a value between minimum and maximum

I'm trying to come up with a method, or two, which would calculate which range the provided value belongs to.

For min=1, max = 10, number of ranges=5 the ranges would be
[1,2],[3,4],[5,6],[7,8],[9-10]

The other method would behave like shown below:

method(1)->[1-2]

method(2)->[1-2]

method(3)->[3-4]

method(4)->[3-4]

method(5)->[5-6]

method(6)->[5-6]

method(7)->[7-8]

method(8)->[7-8]

method(9)->[9-10]

method(10)->[9-10]

This would be used for generating a legend for a map where the size of the marker depends on the range a value belongs to.

I wonder if there is a nice algorithmic solution for this.

The numbers I work with are integers.

Edit:

Another example:

For min=1, max = 3, number of ranges=2 the ranges would be

a) [1-2],[3-3]

or

b) [1-1],[2-3]

The other method would behave like shown below:

a)

method(1)->[1-2]

method(2)->[1-2]

method(3)->[3-3]

or
b)

method(1)->[1-1]

method(2)->[2-3]

method(3)->[2-3]

I don't have a preference for a) or b).

答:
Here's what I would do:

First start with an array the size of number of ranges to keep track of the length of each range. Let's call this bucket_sizes[number_of_ranges]

Initialize the size of each bucket with the highest evenly possible length: (max-min+1)/number_of_ranges (integer division)

Then, find the surplus that couldn't fit evenly in each bucket, (max-min+1) % number_of_ranges (remainder from integer division)

Distribute the surplus as evenly as possible between each bucket (start at index 0, add 1 to each bucket while subtracting 1 from surplus. If index wraps to end of bucket_size array, start from index 0 again and continue until surplus is 0).

Now that we know the size of each bucket, we can generate the ranges:

```<code>for (i=0, k=min; i<number_of_ranges; i++) {
  ranges[i].lo = k;
  ranges[i].hi = k+bucket_sizes[i]-1;
  k += bucket_sizes[i];
}
</code>```

To find the range of a specific number, simply iterate the ranges array and match the range where ranges[i].lo <= number <= ranges[i].hi.

Here is the full source code that I used to test this out (it's written in C):

```<code>#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

struct range
{
    int lo;
    int hi;
};

int generate_ranges(int min, int max, int number_of_ranges, struct range ranges[])
{
    int i;
    int bucket_sizes[number_of_ranges];

    int even_length = (max-min+1)/number_of_ranges;
    for(i=0; i<number_of_ranges; ++i)
        bucket_sizes[i] = even_length;

    /* distribute surplus as evenly as possible across buckets */
    int surplus = (max-min+1)%number_of_ranges;
    for(i=0; surplus>0; --surplus, i=(i+1)%number_of_ranges)
        bucket_sizes[i] += 1;

    int n=0, k=min;
    for(i=0; i<number_of_ranges && k<=max; ++i, ++n){
        ranges[i].lo=k;
        ranges[i].hi=k+bucket_sizes[i]-1;
        k += bucket_sizes[i];
    }
    return n;
}

int number_range_index(int number, int number_of_ranges, const struct range ranges[]) {
    int i;
    for(i=0; i<number_of_ranges; ++i)
        if(number >= ranges[i].lo && number <= ranges[i].hi)
            return i;
    return number_of_ranges;
}

#define MAX_RANGES 50

int main(int argc, char *argv[]) {
    int i;
    struct range ranges[MAX_RANGES];

    if(argc != 5) {
        printf("usage: %s <min> <max> <number_of_ranges> <number>\n", argv[0]);
        return EXIT_FAILURE;
    }

    int min = atoi(argv[1]);
    int max = atoi(argv[2]);
    int number_of_ranges = atoi(argv[3]);
    int number = atoi(argv[4]);

    assert(max > min);
    assert(number >= min && number <= max);
    assert(number_of_ranges > 0);
    assert(number_of_ranges <= MAX_RANGES);

    printf("min=%d max=%d number_of_ranges=%d number=%d\n\n", min, max, number_of_ranges, number);

    int n = generate_ranges(min, max, number_of_ranges, ranges);
    for(i=0; i<number_of_ranges; i++) {
        if(i<n)
            printf("%s[%d-%d]", i>0?",":"", ranges[i].lo, ranges[i].hi);
        else
            printf("%s[]", i>0?",":"");
    }
    printf("\n\n");

    int number_idx = number_range_index(number, n, ranges);
    printf("method(%d)->[%d,%d]\n", number, ranges[number_idx].lo, ranges[number_idx].hi);

    return EXIT_SUCCESS;
}
</code>```

Body:
Here's what I would do:

First start with an array the size of number of ranges to keep track of the length of each range. Let's call this bucket_sizes[number_of_ranges]

Initialize the size of each bucket with the highest evenly possible length: (max-min+1)/number_of_ranges (integer division)

Then, find the surplus that couldn't fit evenly in each bucket, (max-min+1) % number_of_ranges (remainder from integer division)

Distribute the surplus as evenly as possible between each bucket (start at index 0, add 1 to each bucket while subtracting 1 from surplus. If index wraps to end of bucket_size array, start from index 0 again and continue until surplus is 0).

Now that we know the size of each bucket, we can generate the ranges:

for (i=0, k=min; i<number_of_ranges; i++) {
  ranges[i].lo = k;
  ranges[i].hi = k+bucket_sizes[i]-1;
  k += bucket_sizes[i];
}

To find the range of a specific number, simply iterate the ranges array and match the range where ranges[i].lo <= number <= ranges[i].hi.

Here is the full source code that I used to test this out (it's written in C):

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

struct range
{
    int lo;
    int hi;
};

int generate_ranges(int min, int max, int number_of_ranges, struct range ranges[])
{
    int i;
    int bucket_sizes[number_of_ranges];

    int even_length = (max-min+1)/number_of_ranges;
    for(i=0; i<number_of_ranges; ++i)
        bucket_sizes[i] = even_length;

    /* distribute surplus as evenly as possible across buckets */
    int surplus = (max-min+1)%number_of_ranges;
    for(i=0; surplus>0; --surplus, i=(i+1)%number_of_ranges)
        bucket_sizes[i] += 1;

    int n=0, k=min;
    for(i=0; i<number_of_ranges && k<=max; ++i, ++n){
        ranges[i].lo=k;
        ranges[i].hi=k+bucket_sizes[i]-1;
        k += bucket_sizes[i];
    }
    return n;
}

int number_range_index(int number, int number_of_ranges, const struct range ranges[]) {
    int i;
    for(i=0; i<number_of_ranges; ++i)
        if(number >= ranges[i].lo && number <= ranges[i].hi)
            return i;
    return number_of_ranges;
}

#define MAX_RANGES 50

int main(int argc, char *argv[]) {
    int i;
    struct range ranges[MAX_RANGES];

    if(argc != 5) {
        printf("usage: %s <min> <max> <number_of_ranges> <number>\n", argv[0]);
        return EXIT_FAILURE;
    }

    int min = atoi(argv[1]);
    int max = atoi(argv[2]);
    int number_of_ranges = atoi(argv[3]);
    int number = atoi(argv[4]);

    assert(max > min);
    assert(number >= min && number <= max);
    assert(number_of_ranges > 0);
    assert(number_of_ranges <= MAX_RANGES);

    printf("min=%d max=%d number_of_ranges=%d number=%d\n\n", min, max, number_of_ranges, number);

    int n = generate_ranges(min, max, number_of_ranges, ranges);
    for(i=0; i<number_of_ranges; i++) {
        if(i<n)
            printf("%s[%d-%d]", i>0?",":"", ranges[i].lo, ranges[i].hi);
        else
            printf("%s[]", i>0?",":"");
    }
    printf("\n\n");

    int number_idx = number_range_index(number, n, ranges);
    printf("method(%d)->[%d,%d]\n", number, ranges[number_idx].lo, ranges[number_idx].hi);

    return EXIT_SUCCESS;
}


问:
Why many programming languages have only 2 data-structures: arrays and hashes?
Many programming languages have only those 2 structures, and even some languages that have more structures still only provide special syntax for those 2; usually, [] and {}. Why is this? Is there anything special about those datatypes that is necessary for the completeness of the language?

答:
My comment received a lot of up votes, so I am expanding it as an answer.

This question's premise takes a narrow view of what programming languages actually have. Plenty of languages in the ML family have lists rather than arrays (head/tail semantics instead of random access). And C doesn't have built-in hashes at all. Also, q/kdb+ has a table container that mimics an in-memory SQL-like database.

Having said that, all practical programming languages have loops and/or recursion. This kind of control flow requires that data can be addressed indirectly.

For example, I can't give a unique name to all of my data. That is, I can't call my variables alpha, bravo, charlie, etc.; not only will I run out of names, I'll also be unable to generically reference one variable in relation to another.

So instead I must have indirect addressing, like x1, x2, x3, etc. This is very nature of arrays! Alternatively, I can take a recursive view and investigate first-of-xs and remainder-of-xs. As long as I have indirect addressing, I can use loops or recursion.

As @DonalFellows mentions in the comments, there are models of computation that are Turing complete and yet don't have indirect addressing. Nobody actually writes code that way though.

So from a practical standpoint, I believe that arrays or lists are required for completeness in a programming language since they support the traditional control-flow mechanisms. All other containers like hashes and tables are more for convenience.


答:
Thanks for the quote from our book Automated Software Testing - a book we wrote 14 years ago.

Interestingly enough, from the responses here we can see that some developers agree they still don't really like testing, because instead - from my experience - they like to focus on feature development.

Some do a really good job unit testing, but larger integration testing and/or systems of systems testing are not really part of their job description. Hence there is the need for a separate testing role that can focus on "other" testing from that of the developer/unit and component testing tasks.


答:
There's nothing that particularly forces a language to have arrays and hashes as fundamental datatypes. Indeed, many don't (especially older languages). However, there are a few fundamental concepts involved which indicate that these sorts of mappings make for good data structures.

Firstly, the ordered collection where you perform lookups by index number. These are a very common structure that is very useful for the case where you've got a bunch of things and you want to be able to walk through them one by one or look the up by some index. The key reason why this is so popular is that the variation where the collection is compact and mapped onto a contiguous region of memory — the array — is very efficient and fast with modern hardware. It is this efficiency which is why arrays are very common (though not universal). The major alternative to the array is the linked list, which are also quite common; linked lists have linear time lookup (whereas arrays have constant-time lookup) but super-cheap insertion and deletion from the middle of the sequence.

The second major category of collection is a mapping from values of one type (that supports an equality test) to another type. This is a way of realizing a whole class of very simple functions in a memory-based data structure, and it is superb for implementing all sorts of other basic datatypes. The name of these things does vary though (e.g., “dictionary”, “associative array”) as does the implementation strategy; the most common three implementation strategies are the record/struct, the mapping tree, and the hash table. Structs are very common (and are in fact a partial hybrid between dictionaries and arrays, where the key is mapped to an offset into an array/memory block). Trees used to be very common, but have become less so as it turns out they tend to have surprisingly poor performance (their memory access pattern turns out to work poorly with the way CPU memory cache predictors work, which is unfortunate). Hash tables, which were relatively uncommon a few decades ago, work pretty well: they've got reasonable memory access patterns and are easy to implement well (which is definitely not true of trees!). Their major down-side is that they don't guarantee the order of iteration (though that is fixable with some extra complexity in the data structure design).

So, the real thing that languages are providing is ℤ⁺→α and α⁼→β maps. These are both generally very useful! One is done with arrays normally, because they are easy to implement and highly efficient for lookup (typically the most common operation), and the other is done with hash tables (or structures) normally, again because they are easy to implement and usually efficient for lookup. The reason why these two particular maps? They turn out to be sufficient for creating a great many other structures with minimal extra code (which in turn means minimal extra mistakes).

Title: Why many programming languages have only 2 data-structures: arrays and hashes?

Body: Many programming languages have only those 2 structures, and even some languages that have more structures still only provide special syntax for those 2; usually, [] and {}. Why is this? Is there anything special about those datatypes that is necessary for the completeness of the language?


答:
I think he was pointing to something less obscure-- TBL knew nothing about the hypertext work that had gone on from the 60s, so this work didn't inform the design of the web.
He often talks of computing as a pop culture, where practitioners don't know their history, and continually "reinvent the flat tire". </p>


问:
Is the 'C' in MVC really necessary?
I understand the role of the model and view in the Model-View-Controller pattern, but I have a hard time understanding why a controller is necessary.

Let's assume we're creating a chess program using an MVC approach; the game state should be the model, and the GUI should be the view. What exactly is the controller in this case?

Is it just a separate class that has all the functions that will be called when you, say, click on a tile? Why not just perform all the logic on the model in the view itself?

答:
Think of a browser that displays a static web page. The Model is the HTML. The View is the actual result on the screen.

Now add some JavaScript. That is the Controller. When the user clicks on a button or drags something the Event is sent to the JavaScript, it decides on what to do and alters the underlying HTML (Model) and the browser/renderer displays those changes on the screen (View).

Perhaps another button is clicked, the event is sent to some handler (Controller), and it may cause a request for further data to be sent to a webservice. The result is then added to the HTML (Model).

The Controller responds to events and controls what is in the Model and hence what is on the screen/View.

Stepping back a bit, you can think of the whole browser as the View and the server as the Controller and the data as the Model. When the user clicks a button in the browser the event it sent to the server (Controller), it gathers together resources as an HTML page (Model) and sends that back to the browser to be displayed (View)

Down in the server whether it is asp, php, or java the 'code' (Controller) receives the click event and queries a database or document repository (Model) and creates HTML. From the server point of view the result of all its actions are a View (HTML) of its underlying datastore (Model). But from the client point of view the result of its request to the server is its Model (HTML)

Even if you jumble up your JavaScript in your HTML or your PHP in your HTML the Model, View, Controller still exists. Even if you think of your request to a server and the response back from the server as a simple two way street, there is still a Model, a View, and a Controller.

Title: Is the 'C' in MVC really necessary?


问:
Pros/Cons for getter and setters of collections
I'm creating a model where one element can contain other elements. I'm currently writing the interface to the model, and I'm not sure which is the best of the two options:

Option 1

```<code>interface Container {
  List<Element> getElements(); // returns an unmodifiable list.
  void addElement(Element e);
  void removeElement(Element e);
}
</code>```

Option 2

```<code>interface Container {
  List<Element> getElements(); // returns an unmodifiable list.
  void setElements(List<Element> elements);
}
</code>```

What are the pros/cons of each option? Furthermore, are there "accepted" naming conventions in these cases, like using children instead of elements?

答:
I generally prefer Option 3:

```<code>interface Container {
  MutableList<Element> getElements();
}
</code>```

This is the pattern used by most API's that are written in the .NET framework. It keeps the API as simple as possible -- particularly in .NET where you have property getters as in myContainer.Elements.Add(new Element()).

Body:
I generally prefer Option 3:

interface Container {
  MutableList<Element> getElements();
}

This is the pattern used by most API's that are written in the .NET framework. It keeps the API as simple as possible -- particularly in .NET where you have property getters as in myContainer.Elements.Add(new Element()).


答:
It's actually a question of "Who manages the list".

In Option 1, you provide the container with the elements, and keep it its responsibility to manage them: The order, maybe reject some elements, etc.

With Option 2, the container is a dumb container. It gets the list from someone else, and has no say as to what's in it or what order it's in.

Option 1 would allow you (If you drop getElements()) to hide the container's content (Or part of the content) from other workflows in your code. It can even allow some sort of multi-threading, by providing thread-safety handling inside the container code (Although this sounds excessive).

As far as naming goes - to me, "elements" kinda means "I don't care what's in there" - so a generic Container would hold Elements. "Children" implies a dependency relation: to handle a Parent, you must handle all its Children (Tree-like fashion).

Title: Pros/Cons for getter and setters of collections

Body:
I'm creating a model where one element can contain other elements. I'm currently writing the interface to the model, and I'm not sure which is the best of the two options:

Option 1

```<code>interface Container {
  List<Element> getElements(); // returns an unmodifiable list.
  void addElement(Element e);
  void removeElement(Element e);
}
</code>```

Option 2

```<code>interface Container {
  List<Element> getElements(); // returns an unmodifiable list.
  void setElements(List<Element> elements);
}
</code>```

What are the pros/cons of each option? Furthermore, are there "accepted" naming conventions in these cases, like using children instead of elements?


答:
In my experience, in a traditional desktop mvc gui program, the controller ends up spaghettied into the view. Most people do not take the time to factor out a controller class.

the gang-of-four book says:

Design Patterns in Smalltalk MVC

The Model/View/Controller (MVC) triad of classes [KP88] is used to
  build user interfaces in Smalltalk-80. Looking at the design patterns
  inside MVC should help you see what we mean by the term "pattern."

MVC consists of three kinds of objects. The Model is the application
  object, the View is its screen presentation, and the Controller
  defines the way the user interface reacts to user input. Before MVC,
  user interface designs tended to lump these objects together. MVC
  decouples them to increase flexibility and reuse.

MVC decouples views and models by establishing a subscribe/notify
  protocol between them. A view must ensure that its appearance reflects
  the state of the model. Whenever the model's data changes, the model
  notifies views that depend on it. In response, each view gets an
  opportunity to update itself. This approach lets you attach multiple
  views to a model to provide different presentations. You can also
  create new views for a model without rewriting it.

The following diagram shows a model and three views. (We've left out
  the controllers for simplicity.) The model contains some data values,
  and the views defining a spreadsheet, histogram, and pie chart display
  these data in various ways. The model communicates with its views when
  its values change, and the views communicate with the model to access
  these values.

Taken at face value, this example reflects a design that decouples
  views from models. But the design is applicable to a more general
  problem: decoupling objects so that changes to one can affect any
  number of others without requiring the changed object to know details
  of the others. This more general design is described by the Observer
  (page 293) design pattern.

Another feature of MVC is that views can be nested. For example, a
  control panel of buttons might be implemented as a complex view
  containing nested button views. The user interface for an object
  inspector can consist of nested views that may be reused in a
  debugger. MVC supports nested views with the CompositeView class, a
  subclass of View. CompositeView objects act just like View objects; a
  composite view can be used wherever a view can be used, but it also
  contains and manages nested views.

Again, we could think of this as a design that lets us treat a
  composite view just like we treat one of its components. But the
  design is applicable to a more general problem, which occurs whenever
  we want to group objects and treat the group like an individual
  object. This more general design is described by the Composite (163)
  design pattern. It lets you create a class hierarchy in which some
  subclasses define primitive objects (e.g., Button) and other classes
  define composite objects (CompositeView) that assemble the primitives
  into more complex objects.

MVC also lets you change the way a view responds to user input without
  changing its visual presentation. You might want to change the way it
  responds to the keyboard, for example, or have it use a pop-up menu
  instead of command keys. MVC encapsulates the response mechanism in a
  Controller object. There is a class hierarchy of controllers, making
  it easy to create a new controller as a variation on an existing one.

A view uses an instance of a Controller subclass to implement a
  particular response strategy; to implement a different strategy,
  simply replace the instance with a different kind of controller. It's
  even possible to change a view's controller at run-time to let the
  view change the way it responds to user input. For example, a view can
  be disabled so that it doesn't accept input simply by giving it a
  controller that ignores input events.

The View-Controller relationship is an example of the Strategy (315)
  design pattern. A Strategy is an object that represents an algorithm.
  It's useful when you want to replace the algorithm either statically
  or dynamically, when you have a lot of variants of the algorithm, or
  when the algorithm has complex data structures that you want to
  encapsulate.

MVC uses other design patterns, such as Factory Method (107) to
  specify the default controller class for a view and Decorator (175) to
  add scrolling to a view. But the main relationships in MVC are given
  by the Observer, Composite, and Strategy design patterns.

Title: Is the 'C' in MVC really necessary?

Body:
I understand the role of the model and view in the Model-View-Controller pattern, but I have a hard time understanding why a controller is necessary.

Let's assume we're creating a chess program using an MVC approach; the game state should be the model, and the GUI should be the view. What exactly is the controller in this case?

Is it just a separate class that has all the functions that will be called when you, say, click on a tile? Why not just perform all the logic on the model in the view itself?


问:
Why should form inheritance be avoided?
I remember learning VB4 and dragging a button onto a form, double-clicking on that button, and typing code into that event handler I had just been magically blessed with. Coming from QBASIC I was thrilled with the "V" in "VB", the visual designer was literally the best thing since sliced bread.

Of course you could do all that programmatically but the magic of the "V" was so appealing you just couldn't help but drag that button. We were encouraged to take that route.

But then a few years ago I started learning about C# and the .net framework and was fascinated by the way everything I thought I knew had just gone out the window. There's a lot of magic going on in VB6 that's completely unveiled in .net: take constructors and the InitializeComponents method for example. In the latter you'd find all the control instances you've dragged from the toolbox, all the events you've registered and the properties you've set in the designer.

And that's fine... I guess. It's just, I feel like I don't "own" what's going on, this code that I can only modify via the designer annoys the heck out of me. Every time you copy a button that says "Ok" from one form to another (sometimes along with its brother "Cancel"), you are actually duplicating code, and that's a sin isn't it? DRY, don't repeat yourself, says the Pope.

Religions and schools of thought aside, in all objectivity, shouldn't we derive forms from base forms instead, and have the "Ok" button (and all of its friends) live on the base form? Something like a FormBase from which derives a DialogFormBase; all classes created in no time... by typing code. The buttons are created depending on how the class is instanciated (i.e. a constructor enum argument determines which buttons are to be created), controls are laid out inside an arrangement of split panels and flow layout panels, injected into the form as Content that fits into the main content panel. Isn't this what ASP.net does with master pages and content placeholders? I'd derive a form when I need a new "master page", but this new "master page" still derives from a base form class so the visuals are consistent across the entire application.

To me that's much more code reuse than anything else I've ever done with the designer in WinForms, and it wasn't even hard, and code isn't cluttered with a 200-lines method that I have no control over, I can put comments where I like, they won't get overwritten by a designer. I guess it's just a matter of patterns and architecture, which is what brought me to this link: Best design for Windows forms that will share common functionality, where I realized I was spot on, except the answer there, suggests exactly what I'm doing, but it's advising against form inheritance because of designer considerations. That's the part I don't get. I would rather advise against using the designer because of code structure considerations, especially in regards with form and control inheritance, which I see no reason to avoid other than well it breaks the designer.

We can't all be just lazy, so what part am I missing?

答:
You can use inheritance providing you correctly encapsulate your fields and populate accordingly. If you were keen to use inheritance my suggestion would be to have the base form and a corresponding Model for that form, and for each derivation derive both the form and the Model.

A far better alternative would be to group related controls into one or more UserControl controls. You just need a little bit of logic to put the relevant data into it.

Title: Why should form inheritance be avoided?


问:
What's a good developer workflow for teams? (VM based)
I normally work by myself as a freelancer, and the setup I use has worked pretty well for me so far. I'm not sure if it's the optimal setup for a team though.

I develop on Windows, and I setup a Linux VM on my local machine, running the same OS/stack as our production machines (CentOS, Nginx, PHP-FPM). I setup Samba, and map my webroot to a drive in Windows. Locally, I setup host shortcuts such as http://someproject.local/. To share with the team, I use my IP address or an internal DNS name such as http://brandon/someproject.

I was thinking a possible change to this workflow would be to move the VMs onto one of our internal virtualization servers. One of the sysadmins could spin up a new one based on a VM image and that way all devs are using the same setup. Also means everything is backed up properly.

Another one I've read about would be a single dev VM, where each dev gets a folder full of projects they map to their local drive, and any other dev could see the project by going to http://thedevbox/developer_name/project_name. I dislike this approach though, as I would not be able to play around with the server stack if I wanted/needed too.

What setups to you use at your job?

答:
For me, the reason for developing against a linux VM is that it will be exactly the same as your production environment. This is definitely what you want. Giving all developers full access to their dev VM to be able to mess with the server stack isn't probably what you want. You don't want someone to change something that you later depend on - then you have to worry about keeping in sync all the server changes across all of the dev VM's. It also means that all of your developers will need to learn the idiosyncrasies of your virtual machine software. This can actually chew up a lot of time. I used Sun's virtualbox and there were quite a few little gotchas that made setup take quite a few days. We started giving everyone their own virtualbox VM's and it was a pain making sure that everybody understood how it worked, how to set it up etc. At another place where I worked we all used the same dev linux box and it worked great :)

One downside that I can see in having one large VM is that is needs to be much larger than  individual VM's running locally, and it needs to be maintained by someone, and it needs to be running on a server that is up most of the time. But this is probably a good thing - it should save everyone time in the long term, if you appoint your best sysadmin as the sysadmin of that box.


答:
A single big VM would differ from the production server in that that it will have many instances of your application running in it; Production has only one. As you've mentioned, it also prevents you from playing with the server stack, and if something does break, it's broken for everybody.

With individual VMs that are cheap (=easy) to create, you can try things, break things, and restart easily. You can start a new VM for each change you're working on. You can have test the same code with n different configurations at the same time.

Anyway, if your VMs are on a server somewhere, you might want to use a NAS for all /home/ folders, to save some effort with back-ups and syncs.

Facebook uses the same approach, except they use physical machines instead of VMs; Provisioning and re-imaging a machine is easy to do and self-serve, which is the important part.

Title: What's a good developer workflow for teams? (VM based)

Body:
I normally work by myself as a freelancer, and the setup I use has worked pretty well for me so far. I'm not sure if it's the optimal setup for a team though.

I develop on Windows, and I setup a Linux VM on my local machine, running the same OS/stack as our production machines (CentOS, Nginx, PHP-FPM). I setup Samba, and map my webroot to a drive in Windows. Locally, I setup host shortcuts such as http://someproject.local/. To share with the team, I use my IP address or an internal DNS name such as http://brandon/someproject.

I was thinking a possible change to this workflow would be to move the VMs onto one of our internal virtualization servers. One of the sysadmins could spin up a new one based on a VM image and that way all devs are using the same setup. Also means everything is backed up properly.

Another one I've read about would be a single dev VM, where each dev gets a folder full of projects they map to their local drive, and any other dev could see the project by going to http://thedevbox/developer_name/project_name. I dislike this approach though, as I would not be able to play around with the server stack if I wanted/needed too.

What setups to you use at your job?


问:
How do you name your private variables in C#?
What is the best practice, most commonly accepted naming conventions for private variables in C#?

private int myInteger;

private int MyInteger;

private int mMyInteger;

private int _myInteger;

private int _MyInteger;

Mysterious other option

Which do you use and why?  (My company is fairly new to C# and I would like to pick the most "industry accepted" method to try and get into our coding standard.)

答:
In C++ I tend to use _ as I switch editors a lot which doesn't allow me to see if it's private.

For C# I tend to to leave the _ away as Visual Studio allows me to see if it's private.

I tend to use the Camel Case way to do this.


答: This is what Vagrant was designed to manage for you.  You set up a base box, all the developers can install the same virtual image by running a single command.  You can configure it to expose a port on the virtual image on the host machine so other machines can see it with a single line of code.</p>


问:
How do these technologies go together?

Ruby on Rails

Twitter Bootstrap

Html5Boilerplate

Backbone.JS or Knockout.JS

I sort of understand what each one is individually, but my understanding isn't strong enough to understand whether some of them sort of overlap in functionality and whether any subset of that list contains items you wouldn't use together because they play similar roles. I'm fairly clear on RoR-- it's mainly the latter three that I'm not sure how they play together.

答:
If I understand your question well, you are asking for the contact points between these technologies.

any answer trying to thoroughly answer that question might fill a book.
So, in order to get you going I have made a somewhat simple illustration, it shows a high-level overview:

you see that I have changed Html5Boilerplate to simple HTML because Html5Boilerplate has a quite some overlap with backbone/knockout and bootstrap (contains its own javascript and css) and does not play particularly well with rails either.

therefore, it does not seem a fortunate fit in this combination.

However, with some effort you can use Html5Boilerplate or any other library or framework that produces Html in that position (see this guide for using html5boilerplate with rails).

Title: How do these technologies go together?


问:
Should I use a formal grammar for my interpreted scripting language
I have a scripting engine I just published as an open source project. It's been sitting on my harddrive waiting for about a year. My engine of course isn't complete in any way, but it does work for simple scripts. It has a javascript-ish feel to it, but I don't wish to abide by the ECMA spec or anything.

Now, the big thing I'm working on is improving code quality while leaving the language working as it is(which I have a few regression tests to "prove"). It doesn't have a formal grammar at all and works like so:

Preprocess/Tokenize. At this point it removes whitespace and cuts everything into "tokens", which is basically just a structure containing a string and a rough "hint" as to what the token is (Number, Identifier, Operation, etc) and some debugging info such as line number

A ScriptingEngine class which takes the list of tokens and actually parses them and executes them

An "ExpressionEvaluator" class which will take a subset of the tokens list and build a specific tree of operations, values, and then execute operations and such and collapse the tree down into a single value

My engine has the goals of being portable(works everywhere .Net does) and self-contained. So far, this "works", but the code is terrible and I'm pretty sure that I'm going about it the wrong way.

I'm wondering if a formal grammar and everything that goes with it might help

Some benefits I've heard of being more formal with grammar

Unambiguous specification of the language

Easier to maintain/change

More traditional/Bigger community support?

And some of the disadvantages

Some languages can be very difficult to reduce to a formal grammar, ie Perl.

A learning curve for someone not in the know(ie, me)

Generally rely on tools such as yacc and ANTLR, which introduce another step in your workflow and/or add dependencies(which I'd like to avoid)

Although this project is in .Net, it could equally apply to any other implementing language. Should I use a formal grammar? Can someone expand on the pros/cons of both sides?

答:
First of all, a formal grammar doesn't imply you have to use a parser generator. You can write a recursive descent parser or whatever floats your boat.

Formal grammars are good as documentation. They help programmers decide what foreign code means and tells you what is allowed / mandatory in the language.

For example, in javascript, do I always have to wrap a function literal in parens if I want to call it right away? That is, is this allowed:

```<code>function(a1,a2) { ... }(42, "bacon").
</code>```

Formal grammars are also very helpful when you want to

Make another implementation of the language,

Do code generation targeting the language,

Or for doing static analysis of the language.

Of course, if it's a quick and dirty scripting language these points are less important.

Body:
First of all, a formal grammar doesn't imply you have to use a parser generator. You can write a recursive descent parser or whatever floats your boat.

Formal grammars are good as documentation. They help programmers decide what foreign code means and tells you what is allowed / mandatory in the language.

For example, in javascript, do I always have to wrap a function literal in parens if I want to call it right away? That is, is this allowed:

function(a1,a2) { ... }(42, "bacon").

Formal grammars are also very helpful when you want to

Make another implementation of the language,

Do code generation targeting the language,

Or for doing static analysis of the language.

Of course, if it's a quick and dirty scripting language these points are less important.


问:
Is it good practice for Azure applications to self-administrate?
In a lot of examples for the Azure platform I'm seeing a lot of self-administration happening: an application will test for the presence of an external system such as a queue or database and create the necessary structures it needs to function.

This behaviour seems contrary to a more traditional application's environment being configured by an administrator or a separate setup application acting on behalf of the administrator.

So far, the biggest drawback I can observe to this is that the application would need to have some level of administrative rights over the services it is configuring and that could lead to increased vulnerability.

However, the Code-First approach in Entity Framework would also seem to suggest a practise of allowing an application to work at an administrator-level on the resources it needs to function.

Is this a paradigm I should be expecting to see more of, and are there compelling reasons to consider it as "good practice"?

答:
Whether this is "good practice" or not probably depends on how your organisation and application are structured as much as any "accepted standards".

As Azure isn't very dynamic in terms of infrastructure  (i.e. it's long-winded to add new stuff while other stuff is running), I'd say it's appropriate for you to have pre-deploy setup tasks for your database or queue, since you're unlikely to be working with arbitrary numbers of databases or queues, or adding more infrastructure during runtime.

However, if your organisation relies on the ability to quickly (and automatically) deploy a new version of your app at short notice then you may be well placed to have your application ensure the state of its own database. I'd say this is quite a rare scenario, and if you're in that position perhaps the Azure platform (with its huge spool-up times) isn't the ideal choice for you anyway. To be honest, I'd say the big downside of the self-configuring approach is not so much the security risk (this can be managed) as the amount of extra time you'll need to implement it.

For most Azure applications, I'd suggest simply looking into some form of SQL version control (Red Gate make an excellent solution), and perhaps an automated script you can run after deployment to configure your other infrastructure. This will allow for deployment agility without going over the top making an all-singing self-configuring application when you may be better off spending that time implementing some cool features.


答:
The Internet has worked remarkably well as a prototype of the packet switching concept discovered by Baran, Pouzin and contemporaries. Contrary to popular opinion, this does not mean that IPv4 as handed down is the perfect protocol architecture, or that IPv6 is the way to go. John Day, who was deeply involved in the development of ARPANET and IP, explains this in his 2008 book Patterns of Network Architecture.

As for the Web, in the words of Richard Gabriel, "Worse is Better". Tim Berners-Lee's account, Weaving The Web, is decent. How The Web Was Born by Gillies & Cailliau is denser and less readable but has lots of detail and some fascinating links with other events in personal computing at the time. I don't think Kay gives it enough credit.


答:
I read this as Kay being unfamiliar enough with the lower level protocols to assume they're significantly cleaner than the higher level web. The “designed by professionals” era he's talking about still had major problems with security (spoofing is still too easy), reliability and performance which is why there's still new work being done tuning everything for high speed or high packet loss links. Go back just a little further and hostnames were resolved by searching a text file which people had to distribute!

Both systems are complex heterogenous systems and have significant backwards compatibility challenges any time you want to fix a wart. It's easy to spot problems, hard to fix them, and as the array of failed competitors to either shows it's surprisingly hard to design something equivalent without going through the same learning curve.

As a biologist might tell an intelligent design proponent, if you look at either one and see genius design you're not looking closely enough.


问:
Is Project Titan (Facebook email app) going to be a game changer from a programmers perspective?
Is Project Titan (Facebook email app) going to be a game changer from a programmers perspective?

Although some details are still scarce, the internet is slowly learning more about this new software. From the perspective of a programmer, what if any functionality do you think this will bring to the mass communications sector of internet use? Will it in anyway be a "game changer" from the existing layer of highly successful web based email clients (such as hotmail, gmail, yahoo mail, etc)

I'm interested if anyone thinks email fundamentally needs to change other than to add more "connectedness" to other sources of data such as social media profiles.

答: More integration inside of Facebook may make Facebook users stay inside the Facebook site more (and more page views means more advertising dollars in Facebook's pockets).  People who are e-mailed from Facebook but who don't already have an account may be encouraged to get one by their peers.  However, there are many many people who use email but do not use Facebook and are not interested in social networking.  I don't see there being much of a change.  Google Wave attempted to extend email but failed (it looked like a great concept but was confusing for users, and ultimately abandoned by Google); Microsoft Lync and Google Buzz attempt to integrate social networking and email, but I only see that as being useful for people who really want to use it for social networking.</p>


问:
ASP.NET MVC Web Site & WCF Web Service - Sharing functionalities
I have the following situation: I have to create a website and a web service that will share a part of the functionalities.

This is why I do not want to write code twice.

I have thought of the following architecture:

MyApp.BusinessLogic --> here we save the DataModels to the database

MyApp.DataAccess -> DataModels & Entity & mapping

MyApp.UI.Models -> ViewModels

MyApp.UI.ServiceLayer -> Acceses the Business Logic, creates the UI ViewModels for the website, and transforms the ViewModels back into DataModels for saving with the help of the BusinessLogic Layer

MyApp.WebSite

MyApp.WS.Models - >Ws Models, these will be the objects passed between the client and the WS

MyApp.WS.ServiceLayer -> Accesses the business Logic, creates the WS Models for the web service, and transfoms the WS.Models back into DataModels for saving with the help of the  BusinessLogic Layer

MyApp.WebService

Is the architecture overkill ?

What problems will I encounter ?

Will I have problems with the controllers in the ASP.NET MVC website ?

答:
I think the models being in separate projects I think is overkill. You should have your models and controllers, along with View Models in their relevant projects.

Depending on your architecture, it may make more sense to have the service with the web site. I'd do this if it were only one or two services, for several services or if you need it to run independently of the web site then I'd have it as a separate service.

With regards to the sharing of functionality, look into data transfer objects to transfer lightweight implementations of your objects and object graphs between layers, particularly with the service layer as you won't necessarily want to transport deep graphs. Look into the adapter pattern.


问:
Search on multiple values
I have a database having around 15 tables.Currently I am working on a report generation page, which is having 16 criteria.The values are distributed among multiple tables.User can select any number of search criteria. The problem is, if the user is entering 2-3 values, it is better to filter first by certain value and then apply the next level of filtration on remaining values and this order of filtration depends on the user input always. That means, I have to check all the possible ways of input permutation and give execution path for each, which will be horrible.Is there any way by which I can reduce the execution paths. I am not able to come up with an efficient algorithm.

Suppose I have 3 parameters: name, skill, programExp

If name is given, then I should filter based on name first.
If skill is given, then I should filter using skill, programExp and then name.

答: As already suggested in a comment, a search index is a better solution that database queries. I can second the Thorsten's suggestion of apache Solr. You could probably get a working index up in an hour.</p>

Title: Search on multiple values


问:
Might starting variables/members with an underscore puzzle the compiler?
I've been taught since high school that defining variables like this:

```<code>int _a;
</code>```

or

```<code>int __a;
</code>```

should be consider bad practice because this would eventually puzzle compilers that use variables starting with an underscore to name temporary variables.

As far as I know this is the reason why some people like to move the underscore at the end of the name, like:

```<code>int a_;
</code>```

However, I see a lot of code all around that makes use of underscore-starting variables. And that code builds fairly well with both Visual Studio 2010 and g++ 4.x.

So I wonder: is this a non-issue nowadays? Are modern compilers smarter about naming conventions?

答:
You are apparently misunderstanding the reason prefix underscores are bad practice.
To make it short, it is because the C and C++ standard reserve these prefix for implementation details, for example for standard library implementation. (note that _ and __ are not reserved for the same things, see comments)

Even if the names are under scope (namespace, class, etc.), there can be some global names, in particular macros, which use these prefix and might silently break your code if you use them too.

So, basically, most of the time it is safe to use these prefix BUT if you don't use them you have a 100% guarantee that your naming will never conflict with the implementation names.

Which is why, in doubt, don't use these prefix.

ContentLicense: CC BY-SA 4.0


问:
How to create a dynamic online Windows Installer with a key?
I'm creating an application which needs to have a key file based product activation.

If a user purchases the application, the key file may have to be attached to the application EXE file dynamically (may be online) and package it to an MSI installer. The user downloads the application from a server or repository.

How can I do this?

答:
You can embed custom data in the Binary table in an MSI file. When a customer downloads your installer you could perform a custom action and copy the base MSI, insert their license and provide the file to download.

I think that you're over complicating this. I think you would be far better off shipping an unregistered installer and providing the user the facility to input their license data.


答:
You should not be coding an “Sql execution Path\Plan decision tree”

You need to optimize your Query (singular) to perform as best it can with NO criteria. Then add a Dynamic where clause encompassing all the selected search criteria.

Title: Search on multiple values

Body:
I have a database having around 15 tables.Currently I am working on a report generation page, which is having 16 criteria.The values are distributed among multiple tables.User can select any number of search criteria. The problem is, if the user is entering 2-3 values, it is better to filter first by certain value and then apply the next level of filtration on remaining values and this order of filtration depends on the user input always. That means, I have to check all the possible ways of input permutation and give execution path for each, which will be horrible.Is there any way by which I can reduce the execution paths. I am not able to come up with an efficient algorithm.

Suppose I have 3 parameters: name, skill, programExp

If name is given, then I should filter based on name first.
If skill is given, then I should filter using skill, programExp and then name.