答:
Merely asking search spiders to please not index your site is a very weak defense, if any.

The usual way to go about this is as follows:

While in development, you run the code on a development machine that isn't accessible from outside your LAN, or possibly not even from anywhere except the same machine (localhost). This is usually done with a firewall, either at the network level (an actual LAN firewall; if your company is worth anything at all, you have one) or locally (a 'personal' firewall). In addition, you can configure your local apache server to only accept connections from localhost (127.0.0.1).

The acceptance version (i.e., a sandboxed version for the customer to try out and test) runs on a machine that is identical to the production environment (as much as possible - some configuration details will have to be different); you limit access similar to how you did with the development environment, except you also grant access to the customer's network. If this isn't possible (e.g., because the customer doesn't have their own dedicated IP, or because they can't be bothered figuring out what it is), you may consider adding HTTP authentication and giving the customer a password; this can be done at the web server level (i.e., Apache), with one caveats: HTTP authentication goes over the wire unencrypted, so if the acceptance version contains anything remotely confidential, serving the site over HTTPS exclusively is an absolute must.

As to how you'd set these things up: If you run a decent *nix distribution, it comes with a package manager (apt, port-install, rpm, etc.); use this to install the components you need, and read the documentation. Ask a sysadmin for help if you can't figure it out yourself.


问:
How to prevent piracy on software which is sold online?
When selling software online what's the most suitable/secure way to provide activation in order to get rid of pirates copies of the software? Is there any well-known software for this purpose?</p>

答:
If there is an online service that is an integral part of your software, then that can be sufficiently secured.

However don't be tempted to add some "token online service" just for the sake of using it as copy-protection: that will be worked around.

In fact, the online service would be the real product, with the actual software being just a way to access it (so you might as well give the software itself away).

Of course this approach has all the usual constraints of requiring a permanent internet connection (don't be fooled, even in our modern world, that's still a deal-breaker sometimes).

ContentLicense: CC BY-SA 3.0


答:
Anyone sufficiently motivated will be able to break you anti-piracy measures. No matter what encryption validation scheme you use at the end of the day you must have a clean executable in memory. And this can be used as the basis for defeating your scheme.

You are liable to lose more sales through honest customers disliking whatever hoops your anti-piracy scheme makes them jump through, than, you will through illegal copying.

Title: How to prevent piracy on software which is sold online?

Body: When selling software online what's the most suitable/secure way to provide activation in order to get rid of pirates copies of the software? Is there any well-known software for this purpose?</p>


问:
Implementing Bulk Update feature and its trade offs
The feature to implement is to allow a user to select items and apply data update in bulk. It is very similar to JIRA's ability to bulk update a list of selected issues. In my case:

I iterate over the items,

and for each item, I simply call the existing method used for individually updating an item.

Take note, I cannot do this in sql level (ie. sql batch update) as business logic is in java.

Evidently, for performance, it will be slower given that a user decides to update multiple items, hence you can expect speed = # of items * rate of transaction. So in effect, updating an item individually should be same speed as bulk updating a list where the list contains a single item. That is fine, as it's a trade-off.

My other concern however is this: the method used to update individually, will remain unchanged, and will simply be called by bulk update multiple times according to the number of selected items; this method acquires locks to involved tables until it finishes its transaction. This in effect, would cause locking for long time if there were multiple items to be updated; hence a user would not be able to use the view and search page that retrieves from the locked tables. It's a trade-off that may not be as acceptable as the first point I discussed above.

I am conflicted, given that the nature of the existing method for individually updating an item is really to acquire locks, and I am not suppose to touch that code. I am supposed to only reuse that method, calling it multiple times to implement the bulk update. Is this 2nd trade-off something we cannot bypass, is it a valid trade-off?

Please note also, I am not an expert in transactions and locks.

答:
You certainly can use SQL and bulk updates is one of those areas in which it can be a superior solution (in terms of performance) than an ORM layer or firing of multiple small updates (with an overriding Transaction).

It's the cost of lots of networks calls vs a larger update statement.

You need to measure the performance difference, but I'm guessing that your I/O across the network is the larger bottleneck.

In terms of locks/txns etc. I'd carefully draw out where the boundaries of these are.  You might find you're able to reduce the Txn overhead. Using AOP style Txns helps here, i.e.  Injecting the start and end of a txn at exactly the points you need them and no more.


问:
Is it safe to use CamelCased file names?
I'm developing a simple CMS which I'd like to make it open source.

For the file structure, do you think it's safe to use names like:

```<code>AppData
FileUploads
</code>```

instead of

```<code>app-data
file-uploads
</code>```

?

Because I heard some servers have problems with the camelCase.

答:
Short answer, yes with an if.

More specifically, some filesystems are case-sensitive (foo.php and FOO.PHP would be different files), whilst others aren't (foo.php and FOO.PHP would be the same file).

If you're developing on a system with a case-sensitive filesystem (most Linux filesystems, HFS+ in Case Sensitive mode, etc) then you shouldn't have any problems.

If, however, you're working on a system with a case-insensitive filesystem (NTFS, HFS+ in its default configuration, etc) then you need to keep a careful eye on the filenames.  You can run into problems where a file loads on one machine but causes a file not found error on another.  Depending on the criticality of the file, this can cause problems that range from annoyances to show-stopping failures, but it will cause problems.

If you're developing on Linux, you can probably don't have to worry about it.  If not, then you probably do, but there's nothing stopping you from using camel cased filenames.

EDIT:  If you're using an autoloader then it's generally a good idea for your class filename casing to match the PHP class name casing.  The autoloader automatically gets the class name as an argument and has to figure out what file to open to find it.  Of course you can do anything you like an an autoloader to resolve the class name, but most autoloaders just map the class name onto a filename.  Unless you explicitly change the case of the class name in the autoloader that means that a request for a new FooClass will probably attempt to open a FooClass.php file.

The best advice I can offer is use whatever casing convention you want, but be sure to test it on both case sensitive and case insensitive filesystems if at all possible.


答:
As already stated, there is no way to fully protect desktop software. </p>

<p>However, not all is lost. The only real way to protect your software is to have significant part of the software working in SaaS model, with the desktop being just a client, useless without the back-end. This of course means, that users have to be on-line to use it, but nowadays, that's not a huge issue. </p>

Body:
As already stated, there is no way to fully protect desktop software.

However, not all is lost. The only real way to protect your software is to have significant part of the software working in SaaS model, with the desktop being just a client, useless without the back-end. This of course means, that users have to be on-line to use it, but nowadays, that's not a huge issue.


问:
How do professional software development teams deal with design complexity in non-trivial projects?
First, I realize this question may by somewhat long and vague and I apologize for this. This is probably a basic problem with a short name to anybody who's "got it", but as I find myself lacking in this regard, please bear with me in describing the problem.

I've been doing programming in this way or the other since I was about 11 years old. This means that I've been mostly teaching myself everything from the start. I received a technical education, but not strictly in Computer Science (I graduated with a degree in Photonic Engineering). We had programming courses of course, but this was mostly basic stuff for me and I didn't learn much new things. I've kept educating myself along the way for the joy of it and always knew I would pursue a career in programming, but all my projects were quite small at that time. I had no trouble keeping them in my mind and maintaining them.

Now, I find myself the lead on a team, but not in a corporate environment - I work for the university developing scientific software (in C++) for engineering applications. Suddenly the project is growing (relatively) big and I've trouble wrapping my mind around it most of the time. I'm losing a lot of time and effort on two things mostly:

When I have to  return to a section of code I've not worked on for a while, I have difficulty remembering how it worked. I spend a lot of time reviewing the header files for the relevant classes and reading the comments I placed along the way in the source files. I wish there was some form of "schematic" I could glimpse at and regain the picture more easily;

When I introduce changes, sometimes I realize half-way that what I'm trying to do will break things somewhere else (or worse, it shows up only at runtime as a surprise). I revert and start doing it differently, only to find out I neglected the influence on some other component. I wish there was some "architecture diagram" where I could see how things get done, how what I'm trying to do will influence other components and a way for me to plan in detail before I start implementing changes.

Most of the people I work with have similar stories as my own - strong technical orientation and sometimes great skills, but with no way of organizing their work. However, their projects are usually much smaller than mine so they cope somehow. Anyway, what that means for me is that I'm on my own and I have nobody to learn the good practices from.

I took up a postgraduate course in managing IT and while I find it quite satisfying, it's mostly targeted at non-programmers, teaching about project management methodologies, budget/schedule estimations, enterprise architecture etc. - not software design and planning as such. That's OK, I'm trying to learn that stuff too. Of course, some tools (like UML) and the types of sofware development processes (cascade, iterative, agile...) were introduced, but obviously not in great detail and I've a hard time deciding what I should pick and use (and to what extent).

I've been reading many questions and answers about software design on SO - there are many about doing it using this or that particular tool or methodology, and if I was convinced that UML documentation would solve my problems - I'd pick it up and start using it. But some people swear by it, others say it's useless. I'm looking for an answer on a higher level of abstraction - are there ways to solve the two problems I'm having, and how do you personally do it? What should I learn to be able to do it, possibly without being bound to one particular tool? These come and go out of style from time to time, and I expect their applicability varies depending on the type of the project.

Thanks a lot for reading, I was unable to say what I mean more briefly (lacking in software design experience and vocabulary).

答:
Like your question, any answer that is useful to you will be very long and vague - but the short answer is "Software Engineering" </p>

<p>I suggest you clear some free time, as much as possible if you are serious about a software development career, and start by visting Steve McConnells site. Programming is easy and can be taught in a semester, Software Engineering is an order of magnitude more complex and needs a lot longer to learn. </p>

Body:
Like your question, any answer that is useful to you will be very long and vague - but the short answer is "Software Engineering"

I suggest you clear some free time, as much as possible if you are serious about a software development career, and start by visting Steve McConnells site. Programming is easy and can be taught in a semester, Software Engineering is an order of magnitude more complex and needs a lot longer to learn.


答:
If you're really dead set on preventing piracy there's one hardware-dongle based system that has never been fully cracked as far as I have been able to ascertain:  WIBU CodeMeter.  That they haven't been cracked is of course out of their own press releases (Hacker Contest - WIBU still uncracked) so take the claim with a grain of salt, but at least they are confident enough to hold these contests!

This system is based around hardware encryption on the key itself and all kinds of tamper-proofing in the hardware and software.  They regularly update their system as well.

Logistically shipping hardware keys can be a pretty big overhead, and the keys and licenses are not free.  You pay for the hardware, and you pay a (small) fee per license activation.

They do offer a software-only version (CodeMeterACT) but this is less secure, by their own admission.


问:
What do you think of this new if-then syntax
I was just thinking of something that would be really cool to have in my if-elif-else controls.

```<code>
if condition:
    stuff()
elif condition:
    otherstuff()
then:
    stuff_that_applies_to_both()
else:
    stuff_that_doesnt_aply_to_either()
</code>```

So basically a then will be run when any of the conditions are run EXCEPT the else condition. Do you think this is useful? It's similar to the try-except-else of python.

I think some of you are nitpicking a very preliminary implementation. The then block would be just like the else block in a try-except block in python. The real reason I suggest this is for situations like this.

```<code>
m = {}
if condition == '1':
    m['condition'] = condition
elif condition2 == '3':
    m['condition2'] = condition2
elif condition3 == 'False':
    m['condition3'] = True
then:
    run_test_that_relies_on_one_of_the_conditions_being_true()

return m
</code>```

The then block is scoped to the first if just like the else is. So nesting works fine. And if you need to run a method before the if statements, that really has nothing to do with this use case.

答:
It seems like a cool idea. However the only problem i imagine is you are more prone to bugs. Like writing an if/else if and calling blah() in then. Writing an extra else if that doesnt want blah, removing blah from then and adding it to your ifs/elseifs. Then when you or another programmer add another statement you may expect blah to be called but not.

Or you can have several ifs, write a blah and forget all ifs but one require this which would break something. Also chances are if you need them to follow every if you'll put it under the if block. Possibly setting a bool in else (NoUpdate=true) and just write a if(!NoUpdate) {} directly under which is clearer and can be set by an if

I am just saying it seems more prone to bugs, not that i dont like the idea. I wouldnt mind seeing it in a language but i cant imagine any situtaion where i would use it if my language does support it.

ContentLicense: CC BY-SA 2.5


问:
Should devs, testers and business users have one unified test script?
In development, I would normally have my own test scripts that would document the data, scenarios and execution steps that I plan to test; this is my dev test plan. When the functionality has been deployed to Test, testers test it using their own test script that they wrote. In UAT, the business user then tests using their own test plan.

In retrospect, it looks like this provides a better coverage, with dev tests having a mix of black and white box testing, while testers and business users focus on black box testing. But on the other hand, this brings up distinct test cases that only are executed per stage (ie. some cases which testers thought of are only executed on Test stage) and it would like the dev missed it, which makes it a finding/bug.

Is it worth consolidating the test scripts from the start? Thus using one unified test script, or is it abit difficult to do this upfront?

答:
I agree, that having a unified test script for devs, testers and business users would be nice to have but i belive it is not possible without a lot of effort where the cost outrageas the benefit.

The reason for the difficulty is that the database content in every system is different and tests usually heavily depend on database content. our approach to "unified tests" was that every system also gets an additional test-database and there are scripts to create that db from the scratch. the test scripts run against the testdb where the content is standartised.


问:
Who created the idea(s) of the first loop constructs?
```<code>while (1) {
      if (1+1==2) {
             print "Yes, you paid attention in Preschool!";
      } else {
             print "Wait... I thought 1+1=2";
      }
 }
</code>```

As a developer, we all have to use loops very frequently. We know that. What I was wondering was, who thought of the idea to have loops? What language introduced loops? What was the first loop construct? Was it a while loop? A for loop? etc?

答: Loops predate computing. You can find them in musical notation as early as Gregorian chant:


问:
Why is there no Fortran standard library?
To be a language focused on mathematics and scientific computing, I am always baffled by the total lack of useful mathematical routines in the Fortran standard library. One would expect it to be shipped at least with a routine to compute standard deviation and mean, but this is not the case. In particular with the introduction of Fortran 90 and the addition of modules (thus reducing namespace pollution), I don't see any reason why of this critical lack of services.

I would like to hear your knowledge about why this is the case.

答: BLAS and LAPACK are de-facto standard Fortran libraries.</p>

ContentLicense: CC BY-SA 4.0


问:
What's the difference between Entry Level/Jr/Sr developers?
Other than title and pay, what is the difference?

What different responsibilities do they have.

How knowledgeable/experienced are they?

What is the basic measure to determine where a developer fits into this basic structure?

答:
I'm going to go with the really simple answer here: senior developers (in general) are people that can see the forest for the trees. They think beyond just the immediate issue in front of their faces and have an understanding of what architectural changes could or should happen as a result of fixing the problem they are faced with.

Most software companies I've seen have the entry level people doing the day to day coding while the senior devs are overseeing what the new people are doing and tackling the really ugly, thorny issues.

Obviously this is just my opinion, and not a hard-and-fast rule. YMMV.


问:
Difference between planning a project vs. planning a product
I have read in numerous places that when developing a product you need to take a different approach to when you are developing a project (think "contract" work).

Some differences are:

1) There is no definitive user, but a "user-base".

2) You need to develop the minimal marketable feature set.

3) Scheduling needs to be watched, as there is not often a fixed deadline it is possible for the product to run overtime (or for scope creep).

I was wondering if there are people out there with experience in both, and if they could offer some input into any differences that they know of. Also if anybody could provide any tips/good references for how to deal with the differences I would be most appreciative.

答:
Some significant differences:

A project is generally time-limited. A product has a lifespan is usually not known at the time of development - your assumption should be that if it succeeds you have an ongoing business.

A project needs to deliver against a specified deliverables. A product needs to offer a viable ongoing business. Guess which is harder :-)

It's realatively easy to outsource a project. Outsourcing product development is usually a very bad idea (hint: you shouldn't outsource your core competency!)

Since products are (usually) externally focused and intended to scale, quality tends to become more important as a success factor.

I think the differences listed in the question actually aren't intrinsic differences between products and projects. You could imagine launching a product with a full feature set for example. A project may well have a broad and loosely defined "user base". And both products and projects are likely to have issues with scheduling / scope creep :-)


问:
Was classical BASIC ever used for commercial software development, and if so, how were limitations overcome?
Many of us, including me, started their programming life with programs written on home computers, something like

```<code>10 PRINT "ENTER RADIUS"
20 INPUT R
30 PRINT "CIRCUMFERENCE="; 2 * R * PI
40 PRINT "AGAIN?"
50 INPUT A$
60 IF A$="Y" THEN GOTO 10
70 END
</code>```

Of course, the line-number based BASIC was prone for creating spagetti code, also because most BASIC dialects missed structural statements like WHILE, doing everything but the FOR-loop with IF, GOTO and GOSUB. I'm talking about BASIC dialects before 1991, when QBASIC and Visual Basic appeared.

While BASIC dialects may have promoted bad style amongst aspiring programmers, were there larger commercial projects created in such a BASIC dialect? If so, how did they manage to live with and workaround the obvious shortcomings?

By "serious", I mean:

Not a game (I know some commercial games were written in BASIC, for example, Pimania)

Not freeware

Not trivial, that is, reasonably large (say: at least 1500 LOC)

Sold to several customers (not an in-house development)

"Mission critical" is a plus

答:
My first 100% programming job, back in the 1980s, was working on a vertical market accounting package that was originally written in GW-BASIC. It had been ported to QuickBASIC 3.0, but it retained almost all of the faults associated with early BASIC dialects. There were tons of GOTOs and a lot of poor structure. There were about a dozen modules (inventory, ledger, etc.) and the program sold for about US$1000 - US$2500 per module plus annual support contracts. Company revenue was in the US$15 - US$25 million a year range.

As for how to live with shortcomings, a lot of limitations were gotten around by using machine language or MASM. It was common to use PEEK and POKE commands to insert machine language into BASIC programs. I wrote MASM (and later C) programs to extend the program to add things like rudimentary database support, communications and text "graphics".


答:
This is apples and oranges.  There is no comparison as if one is exclusive of the other.  One can and should be working on projects for the benefit of the product.

Qualities of building a product definitely focus on 1 and 2, however 3 is not quite correct.  Simply because it is a product does not mean that scope creep is any more acceptable or any less dangerous.  When determining product work, one must fit workable feature development into one or more projects, as it is important to meet schedule needs and keep costs under control.

The fact of the matter is that the "software product" is partly a marketing term.  If I have working software of reasonable quality then I can brand it, advertise it, and attempt to sell it to a number of customers.

Where software design comes into play is the clever amalgamation of customizable feature sets for a disparate variety of customers makes a software product such that the need for custom development to gain a single customer is kept to a minimum if at all possible.  This can be extraordinarily hard to do.

If your organization is using the excuse that product work makes scope creep and floating deadlines as acceptable then they are merely making excuses.

Title: Difference between planning a project vs. planning a product

Body:
I have read in numerous places that when developing a product you need to take a different approach to when you are developing a project (think "contract" work).

Some differences are:

1) There is no definitive user, but a "user-base".

2) You need to develop the minimal marketable feature set.

3) Scheduling needs to be watched, as there is not often a fixed deadline it is possible for the product to run overtime (or for scope creep).

I was wondering if there are people out there with experience in both, and if they could offer some input into any differences that they know of. Also if anybody could provide any tips/good references for how to deal with the differences I would be most appreciative.


问:
Is there a clear leader amongst JVM-based languages?
What is the current status of these projects, and has any one (or two) emerged as a clear leader?

To demonstrate my motives for asking this question, cast your mind back several years.  Prototype and jQuery were going head-to-head with other players like MooTools fighting to survive as well.  Fast forward to today, and the general consensus is that jQuery is the best general purpose JavaScript library.

Has something similar happened in the last several years with these JVM-based languages?  Have certain languages fallen into disrepair and abandonment?  From what I've read, it seems that Scala is certainly well-prepped to become the favorite, but then again, nearly everything I've read is several years old.

I've done a bit more research - I had the idea to check out search volume through the years by using Google Trends. It seems that Jython and JRuby have relatively little interest while Groovy's volume is decreasing and Scala's volume is constant (at worst) or increasing slightly (at best).  Is this an accurate assessment?

And yes, I'm referring to non-Java languages on the JVM such as Jython, JRuby, Groovy, Scala, Clojure, etc.

答:
There's no clear leader - Scala, Clojure and Groovy all seem to be very strong at present (mid 2012).

Some survey data:

http://thecodegeneral.wordpress.com/2012/03/04/the-big-three-jvm-languages/

It's hard to measure though - I think job postings and indexes like TIOBE are essentially useless for new language adoption since they depend primarily on very lagging indicators (your average pointy-haired-boss isn't going to hire a Clojure developer until at least a couple of years after your current Clojure hackers have built an amazing awesome product and you have finally decided that you need to grow the team).


答:
The concept of "do it again" is somehow "primitive" to human perception. You can tell this to a child that has just elaborated a minimal comprehension of the natural language.

In discrete systems loops are found in all the finite state machines when you admit you can reach a state you alredy have been before.

The simplest loop is the cycle between two states (a clock). Given that any higher number of states can result from a count from it, every more complex machine is contructed upon a "counter" incremented by a clock that can made "jump" upon certain flags representing certain combinatory operations. This is the core of a Von Neumann machine every microprocessor based computer is based on.

In machine code, a jump is coded JP-Z-nnnn (where Z is whatefer flag ypu base your condition on). In higher level language this translate almost immediately into

```<code>if(z) goto x;
</code>```

A loop is nothing more than a goto where the x label precedes the goto instruction itself.

Every other formulation (for, do, while, etc.) is just "syntactic sugar" to better domesticate the wild goto in the very common cases of repeating until something happens

Title: Who created the idea(s) of the first loop constructs?

Body:
```<code>while (1) {
      if (1+1==2) {
             print "Yes, you paid attention in Preschool!";
      } else {
             print "Wait... I thought 1+1=2";
      }
 }
</code>```

As a developer, we all have to use loops very frequently. We know that. What I was wondering was, who thought of the idea to have loops? What language introduced loops? What was the first loop construct? Was it a while loop? A for loop? etc?

Body:
The concept of "do it again" is somehow "primitive" to human perception. You can tell this to a child that has just elaborated a minimal comprehension of the natural language.

In discrete systems loops are found in all the finite state machines when you admit you can reach a state you alredy have been before.

The simplest loop is the cycle between two states (a clock). Given that any higher number of states can result from a count from it, every more complex machine is contructed upon a "counter" incremented by a clock that can made "jump" upon certain flags representing certain combinatory operations. This is the core of a Von Neumann machine every microprocessor based computer is based on.

In machine code, a jump is coded JP-Z-nnnn (where Z is whatefer flag ypu base your condition on). In higher level language this translate almost immediately into

if(z) goto x;

A loop is nothing more than a goto where the x label precedes the goto instruction itself.

Every other formulation (for, do, while, etc.) is just "syntactic sugar" to better domesticate the wild goto in the very common cases of repeating until something happens


答:
The first software I ever worked on was an 8k line GW-BASIC program that the company wrote back in the 80's to use heat transfer calculus for sizing and pricing boiler equipment.  While the code was completely incomprehensible, it managed to work so well that they had used it for over 20 years.

This was the strength of BASIC that a mechanical engineer with a reference manual could actually write quality usable software (at the time).  Before BASIC and the prevalence of the PC, such a thing would have been unheard of.  You would need to hire a team of computer engineers and possibly computer operators to program and work off of a shared mainframe.  All of this would have been far too complex for the typical mechanical engineer to pick up in a short amount of time.

So certainly BASIC was highly useful beyond home computer enthusiasts, this was many businesses first introduction into the realm of writing custom software inhouse for an affordable price without teams of experts.

Title: Was classical BASIC ever used for commercial software development, and if so, how were limitations overcome?

Body:
Many of us, including me, started their programming life with programs written on home computers, something like

```<code>10 PRINT "ENTER RADIUS"
20 INPUT R
30 PRINT "CIRCUMFERENCE="; 2 * R * PI
40 PRINT "AGAIN?"
50 INPUT A$
60 IF A$="Y" THEN GOTO 10
70 END
</code>```

Of course, the line-number based BASIC was prone for creating spagetti code, also because most BASIC dialects missed structural statements like WHILE, doing everything but the FOR-loop with IF, GOTO and GOSUB. I'm talking about BASIC dialects before 1991, when QBASIC and Visual Basic appeared.

While BASIC dialects may have promoted bad style amongst aspiring programmers, were there larger commercial projects created in such a BASIC dialect? If so, how did they manage to live with and workaround the obvious shortcomings?

By "serious", I mean:

Not a game (I know some commercial games were written in BASIC, for example, Pimania)

Not freeware

Not trivial, that is, reasonably large (say: at least 1500 LOC)

Sold to several customers (not an in-house development)

"Mission critical" is a plus


答:
Were larger commercial projects created in such a BASIC dialect?

On older home computers like the C64 or its predecessors, there existed a lot of BASIC programs, and also some commercial ones. But "large" was seldom possible, since with <64kB of RAM writing "large" BASIC programs is not really easy. If you wanted to come around the limitations of the machine, you typically had to leave the ground of BASIC, the "high level language",  and use assembler.

So the answer to your question is "probably not many", but not because of the reasons you have in mind (like "too error prone / unstructured" etc).

By the way: AFAIK the famous PETSpeed BASIC compiler was written in BASIC (compiled with itself, of course).


答:
The concept of looping is one of the things that distinguish a full-blown computer from a simple calculating machine.  If a system doesn't support looping then it's not turing-complete and therefore not a computer.

The first Turing-complete design was Babbage's Analytical Engine, so it must have had a concept of looping.  However, there are systems that do have looping but aren't Turing complete (because they omit something else).  Babbage's work is probably a good starting point, though.


答:
All three of your points can apply to a project too.  It may help to visualize a real example: developing an internal billing system for a large company (project) versus writing a billing system to be sold broadly (product).

Some differences:

1) You can settle for "just good enough" on the project.  The product has higher quality expectations.

2) You have to accompdate many more hardware and software configurations with a product.

3) The users are more likely to be remote on a product.  It is harder, but not impossible, to get usage data.

4) With a product you are more likely to leave the integration to someone else.


问:
Including Module Source files into War file using Maven
My goal is to include modules sources files into War file.

I read this explanation on the maven official site:

http://maven.apache.org/plugins/maven-assembly-plugin/examples/multimodule/module-source-inclusion-simple.html

I wonder if it's the only way to include all sources files contained within all modules.

Can't the simple maven-plugin-war do the same ?

答: The Maven plugins for packaging can be confusing to work with. You could write a small ANT script and call it from a plugin execution. I sometimes do this if I have complex packaging requirements. It's not elegant, but it gives you full control of the packaging process.</p>


答:
As mouviciel and Emilio Garavaglia noted, the concept predates computing. However, the first instance of a software loop was the loop Ada Lovelace used to calculate Bernoulli numbers, as described in Note G of her translation of the Sketch of the Analytical Engine Invented by Charles Babbage, by L. F. Menabrea. The Analytical Engine's ability to loop is noted early on by Menabrea:

This being understood, let us, at the beginning of the series of operations we wish to execute, place the needle C on the division 2, the needle B on the division 5, and the needle A on the division 9. Let us allow the hammer of the dial C to strike; it will strike twice, and at the same time the needle B will pass over two divisions. The latter will then indicate the number 7, which succeeds the number 5 in the column of first differences. If we now permit the hammer of the dial B to strike in its turn, it will strike seven times, during which the needle A will advance seven divisions; these added to the nine already marked by it will give the number 16, which is the square number consecutive to 9. If we now recommence these operations, beginning with the needle C, which is always to be left on the division 2, we shall perceive that by repeating them indefinitely, we may successively reproduce the series of whole square numbers by means of a very simple mechanism.

The Analytical Engine's looping mechanism is directly inherited from Joseph Marie Jacquard's mechanical loom (1801), as noted in the memoir by Menabrea:

It will now be inquired how the machine can of itself, and without having recourse to the hand of man, assume the successive dispositions suited to the operations. The solution of this problem has been taken from Jacquard's apparatus, used for the manufacture of brocaded stuffs, in the following manner:—

Two species of threads are usually distinguished in woven stuffs; one is the warp or longitudinal thread, the other the woof or transverse thread, which is conveyed by the instrument called the shuttle, and which crosses the longitudinal thread or warp. When a brocaded stuff is required, it is necessary in turn to prevent certain threads from crossing the woof, and this according to a succession which is determined by the nature of the design that is to be reproduced. Formerly this process was lengthy and difficult, and it was requisite that the workman, by attending to the design which he was to copy, should himself regulate the movements the threads were to take. Thence arose the high price of this description of stuffs, especially if threads of various colours entered into the fabric. To simplify this manufacture, Jacquard devised the plan of connecting each group of threads that were to act together, with a distinct lever belonging exclusively to that group. All these levers terminate in rods, which are united together in one bundle, having usually the form of a parallelopiped with a rectangular base. The rods are cylindrical, and are separated from each other by small intervals. The process of raising the threads is thus resolved into that of moving these various lever-arms in the requisite order. To effect this, a rectangular sheet of pasteboard is taken, somewhat larger in size than a section of the bundle of lever-arms. If this sheet be applied to the base of the bundle, and an advancing motion be then communicated to the pasteboard, this latter will move with it all the rods of the bundle, and consequently the threads that are connected with each of them. But if the pasteboard, instead of being plain, were pierced with holes corresponding to the extremities of the levers which meet it, then, since each of the levers would pass through the pasteboard during the motion of the latter, they would all remain in their places. We thus see that it is easy so to determine the position of the holes in the pasteboard, that, at any given moment, there shall be a certain number of levers, and consequently of parcels of threads, raised, while the rest remain where they were. Supposing this process is successively repeated according to a law indicated by the pattern to be executed, we perceive that this pattern may be reproduced on the stuff. For this purpose we need merely compose a series of cards according to the law required, and arrange them in suitable order one after the other; then, by causing them to pass over a polygonal beam which is so connected as to turn a new face for every stroke of the shuttle, which face shall then be impelled parallelly to itself against the bundle of lever-arms, the operation of raising the threads will be regularly performed. Thus we see that brocaded tissues may be manufactured with a precision and rapidity formerly difficult to obtain.

Jacquard's loom is a very early application of a loop in the context of ordering a machine to produce a repeated output:

The idea behind the Jacquard-loom was a system of punch cards and hooks.  The cards were made very thick and had rectangular holes punched in them.  The hooks and needles used in weaving were guided by these holes in the cardboard.  When the hooks came into contact with the card they were held stationary unless it encountered one of the punched holes.  Then the hook was able to pass through the hole with a needle inserting another thread, thus forming the desired pattern.  Intricate patterns were achieved by having many cards arranged one after the other and/or used repeatedly.

Jacquard's loom is also recognized as a very early form of a stored program:

If the impetus behind much of the development of calculating machines discussed so far had arisen from numerical computation, the motivation that led to the earliest form of `stored program' was to come from a very different source: the textile industry. We have seen earlier that one of the fundamental aspects of computational systems is the concept of representing information and, although we have not done so explicitly, the application of this idea can be discerned in all of the artefacts that we have examined up to now: in the development of written representations for numeric values and the mechanical parallels that sprung from these. Thus, the alignment of pebbles on an abacus frame, the juxtaposition of moving scales on a slide-rule, and the configuration of cogged gears on the devices of Schickard, Pascal and Leibniz, are all examples of representational techniques that seek to simplify the complex processes underlying arithmetic tasks. There are, however, categories of information, and representations thereof, other than number upon which computational processes can be performed. The weaving technology developed by Joseph-Marie Jacquard in 1801 illustrates one example of such a category.

Charles Babbage also adapted Jacquard's storing procedure into the Analytical Engine, the presence or absence of a hole communicated a simple on-off command to the machine:

The Analytical Engine has many essential features found in the modern digital computer. It was programmable using punched cards, an idea borrowed from the Jacquard loom used for weaving complex patterns in textiles. The Engine had a 'Store' where numbers and intermediate results could be held, and a separate 'Mill' where the arithmetic processing was performed. It had an internal repertoire of the four arithmetical functions and could perform direct multiplication and division. It was also capable of functions for which we have modern names: conditional branching, looping (iteration), microprogramming, parallel processing, iteration, latching, polling, and pulse-shaping, amongst others, though Babbage nowhere used these terms. It had a variety of outputs including hardcopy printout, punched cards, graph plotting and the automatic production of stereotypes - trays of soft material into which results were impressed that could be used as molds for making printing plates.

The Analytical Engine's conditional branches combined with the Jacquard inspired mechanical loops and storing procedure are dauntingly similar (conceptually) to your example, especially if we add Babbage's printer to the mix, for the print "..."; parts.

Obviously mechanical loops predate Jacquard's loom, the first known device to work in a loop fashion being the Antikythera mechanism (100 BCE), and if we look even further into history (and venture horribly off topic), sundials are probably the oldest man made mechanisms where an understanding of loops is evident, following of course the repeating pattern of the sun's and other stellar bodies' orbits.

However I think that in context of computing (and not calculating or anything else), the Analytical Engine and Ada's Bernoulli numbers calculating algorithm can be credited for introducing loops, sharing at least some of the credit with Jacquard's loom, having directly adapted the concept from it.


问:
Reorganizing code based on dependencies
I'm wondering if there is a tool that can generate a dependency graph between C language object files and then analyze how to turn that graph into a DAG by modifying code that creates cycles, moving it to other source files.

I've drawn a dependency graph by hand and I could probably make one by using makedepend or something similar, but the moving of functions also has to be done by hand.

Sorry if that's vague, but that's about the best I can describe it right now.

答: There is a the Makefile.GraphViz perl module uses GraphViz to generate dependency graphs from Makefile rules. The documentation has an example of how to use it.

Title: Reorganizing code based on dependencies


答:
Yes, there were numerous commercial products and other "serious" development done in BASIC.  To understand why, you have to understand the context of the 1970s and 1980s, when BASIC grew on mini- and microcomputers.

Back then, the machinery was positively scrawny by today's standards.  CPUs were clocked at a few MHz (often much less for microcomputers) and had less memory than would be occupied by the HTML it takes to render this page.  If you were going to deploy a product, you had to use the tools that were available, which was either bare-naked assembly or, on microcomputers, the BASIC interpreter that shipped in ROM (often 16K in a 64K address space) with the system.  There were other languages available, but many didn't have all of the structured features we take for granted.  This had a lot to do with the fact that memory was scarce,* none of it was virtual except on very-high-end systems and there usually wasn't enough of it to hold a compiler for a more-sophisticated language.  With such limited resources, "serious" was a relative term, and we simply weren't throwing the kinds of jobs at computers that we do now with plentiful processing, memory and storage.

Your argument that the makers of early home computers should have known better and provided a structured language just doesn't work in that context.  It simply wasn't going to happen with the available technology at a price people could stomach.

How we got around the language shortcomings was simple: we didn't see them that way and got the job done with what was available.  ANSI Minimal BASIC is structured a lot like assembly language in that you get most of the same flavors of simple branching and subroutine calls, but it's up to you to make sure the stars are properly aligned.  The sole exception is the FOR..NEXT construct used to provide looping.  Essentially, if you wanted to develop something in BASIC and do a good job of it, you had to plan out and understand the structure of your programs just as carefully as if you were writing them in assembly.  The available debugging tools were very primitive, so, in essence, you had to have your act together if you wanted your programs to work and be maintainable.

Yes, there was a lot of spaghetti back then, but I have yet to see a language where it's impossible to write bad code.

*Memory ran about US$750-1,000 per MB in the early 1980s.  Adjusted for inflation, that's US$1,600-2,200 in 2010 dollars.  That same year, the cost per megabyte was about US$0.03.


答:
While planning a project, you need to consider the following:

Scope

Stakeholders

Resources

Constraints

Quality level

Cost

Whereas, planning a product would require you to cosider the following:

1. Generic Features: Essential component of the product, the traits without which the product does not exist.

2. Expected Features: Features that are generally assumed or expected by the target customer

3. Additional Features: Features that add more strength and value to the product

4. Potential Features: Features that are meant to make the product unique and distinct and hence contributes to customer retention.


问:
Learning to program on punchcards
I'd like to try programming with punch cards once in my life. How can I do this?

I'm in my 30s, and grew up entirely in the PC era, programming on computers with screens and keyboards. I want to experience the way my father and grandfather used to work. I imagine the hardware (and probably the cards themselves) are no longer manufactured. Are there any universities or museums with functioning punch card readers anymore? I'm in Boston, but I'm willing to travel to do this.

I asked MetaFilter, and I got some mixed answers (along with a lot of "no, don't do this" nay-saying). I did get a pointer to the Retro-Computing Society Of Rhode Island, but I haven't received a response to my email to them yet.

答: if you have a scanner you can DIY it with some image recognizing software, an emulator, a few dead trees and a felttip pen</p>

Title: Learning to program on punchcards


问:
What's the difference between a marshaller and a serializer?
...and unmarshalling/deserializing? Wikipedia's explanation leaves me none-the-wiser! I'm a Java programmer, in case the terminology is used differently in different languages.</p>

答:
This question has been asked before, but on StackOverflow. Here is the link.

Quotation of the answer given by Jeffrey Hantin:

Marshaling and serialization are loosely synonymous in the context of
  remote procedure call, but semantically different as a matter of
  intent.

In particular, marshaling is about getting parameters from here to
  there, while serialization is about copying structured data to or from
  a primitive form such as a byte stream. In this sense, serialization
  is one means to perform marshaling, usually implementing pass-by-value
  semantics.

It is also possible for an object to be marshaled by reference, in
  which case the data "on the wire" is simply location information for
  the original object. However, such an object may still be amenable to
  value serialization.

As @Bill mentions, there may be additional metadata such as code base
  location or even object implementation code.


答:
Semantics are important here:

Marshalling implies moving the data, it does not imply transforming the data from its native representation or storage. Java Objects can be Marshalled over the wire in their native representation.

Serializing implies transforming the data to some non-native intermediate representation. For example: transforming a Java Object to JSON or XML.

Of course, most systems that Marshal data, Serialize it to some non-native format before they transport it.

Title: What's the difference between a marshaller and a serializer?

Body: ...and unmarshalling/deserializing? Wikipedia's explanation leaves me none-the-wiser! I'm a Java programmer, in case the terminology is used differently in different languages.</p>


答:
This question is based on completely misplaced assumption, that JVM languages are alternatives to each other. You're drawing analogy to JS toolkits, which all are using same language, all have same audience, all have same use. In case of JVM languages, the only thing in common all of them have, is that they are implemented using JVM. Apart of that it's as wide spectrum of languages, as you can get: static, dynamic, functional, objective...

For example it's wrong to assume that Jython is an alternative to Scala or JRuby; it's much more an alternative to CPython, IronPython or PyPy.

As for current top voted answer, it also makes false assumption that job description will talk about implementation details. Actually, even if a company uses Jython or JRuby, the job description will still call for Python or Ruby experience. Jython conforms to language specification, hence Jython is Python, similary for JRuby is Ruby.

Title: Is there a clear leader amongst JVM-based languages?

Body:
What is the current status of these projects, and has any one (or two) emerged as a clear leader?

To demonstrate my motives for asking this question, cast your mind back several years.  Prototype and jQuery were going head-to-head with other players like MooTools fighting to survive as well.  Fast forward to today, and the general consensus is that jQuery is the best general purpose JavaScript library.

Has something similar happened in the last several years with these JVM-based languages?  Have certain languages fallen into disrepair and abandonment?  From what I've read, it seems that Scala is certainly well-prepped to become the favorite, but then again, nearly everything I've read is several years old.

I've done a bit more research - I had the idea to check out search volume through the years by using Google Trends. It seems that Jython and JRuby have relatively little interest while Groovy's volume is decreasing and Scala's volume is constant (at worst) or increasing slightly (at best).  Is this an accurate assessment?

And yes, I'm referring to non-Java languages on the JVM such as Jython, JRuby, Groovy, Scala, Clojure, etc.


问:
What exactly comprises 'Documentation'?
When we say 'documentation' for a software product, what does that include and what shouldn't that include?

For example, a recent question asked if comments are considered documentation?

But there are many other areas that this is a valid question for as well, some more obvious than others:

Manuals (obviously)

Release notes?

Tutorials

Comments

Any others?

Where is the line drawn. For example, if 'tutorial' is documentation, is 'video tutorial' documentation, or is it something else?

Generally, something in software isn't 'done' until it is implemented, tested and documented. Hence this question, what things should we consider as part of documention to consider something 'done'.

Question inspire from recent customer feedback at our conference indicating that our doc needed more 'samples', which we previously hadn't been as good at considering as we should have been.

Audience: Software developers using our database(s), programming languages and associated tooling (such as admin clients to said DB)

答:
Anything that answers a "how do I..." question is documentation.

For developers, that means requirements specifications ("how do I know what to write"), design documents ("how do I address my requirements"), traceability matrices ("how do I know that my designed addresses all my requirements"), test plans ("how do I know my code works"), unit tests ("how do I know I've safisfied requirement X"), inline comments ("how do I make sure the next poor schlub understands why I wrote it this way"), deployment instructions ("how do I package this product for installation"), etc.

For users, that means user manuals ("how do I use the software"), tutorials ("how do I use this specific feature"), release notes ("how do I know what bugs have been fixed/new bugs features have been added"), etc.

Title: What exactly comprises 'Documentation'?


问:
Why is Invariance, Covariance and Contravariance necessary in typed languages
Ok not really sure if I'm right.

I only recently learned that I needed to have contravariant interface to be able to pass that interface as a parameter in C# and this feature was only added in .NET 4.0.

So obviously there is some reason you can't do this Covariant or Invariant interfaces and it probably has something to do with passing in, getting out the generic class.

I'm not really sure what the limitation here is, and know that I've seen where Contravariant interface can be used where the others can't where can I use Covariant (when is that neccesary?).

This is all out of curiosity (I'm very interested in programming concepts surrounding some languages). I would love to see (link would be fine) some examples of why it is necessary to use these features, what would break if you would allow covariant/invariant into contravariant scene and vice versa and where each one shines.

答:
I only recently learned that I needed to have contravariant interface to be able to pass that interface as a parameter in C# and this feature was only added in .NET 4.0.

.NET 4 added co/contra-variance for generics. The variance concept though exists in any language with subtyping.

When doing type checking, a parameter type is acceptable if it is the same type as what is expected or more specific. Or simply, the types are covariant. This is straight-forward. If your method is working on Person then passing in a Student or a Teacher is irrelevant.

The gotcha for this feature is generic parameters. In some cases, it is safe to use generic types covariantly: eg Action<Base> can be assigned to a variable of type Action<Derived>; Who cares if a Derived is passed in, Action<Base> can work with it.

Likewise there are cases where generic types can be used contravariantly: Func<Derived> can be assigned to a variable of type Func<Base>. Who cares if a Derived is always returned, anything that calls Func<Base> can deal with the result.

And there are cases where the generic types cannot be used co- or contra- variantly. List<T> is a good example. You can't assign List<Derived> to a List<Base> (or vice versa) because then some functions would not be of the correct type.

The basic idea is that the type system is correct. Allowing user specified generic variance allows the user to tell the type system where it is possible for generic types to be co/contra-variant. The concepts though exist in any type system with sub-typing regardless of explicit notation.


问:
Why did the Haskell committee choose monads to represent I/O?
The Clean language uses uniqueness types to handle I/O in a purely functional setting. Why did the Haskell committee go with monads instead? Were there other proposals for handling state that the committee investigated but decided against?

Note: I'm not looking for a holy war between monads and other forms of computing. Let's keep the topic to just the committee's choices regarding I/O.

答:
The best explanation I've seen is Simon Peyton-Jones' "Tackling the Awkward Squad."

From what I remember from the paper, issues around laziness played a big part in the decision. (I'm not sure if Clean is lazy by default the same way Haskell is.)


问:
Why is prefixing column names considered bad practice?
According to a popular SO post is it considered a bad practice to prefix table names. At my company every column is prefixed by a table name.  This is difficult for me to read.  I'm not sure the reason, but this naming is actually the company standard.  I can't stand the naming convention, but I have no documentation to back up my reasoning.

All I know is that reading AdventureWorks is much simpler.  In this our company DB you will see a table, Person and it might have column name:

Person_First_Name

or maybe even

Person_Person_First_Name (don't ask me why you see person 2x)

Why is it considered a bad practice to pre-fix column names?  Are underscores considered evil in SQL as well?

Note:  I own Pro SQL Server 2008 - Relation Database design and implementation.  References to that book are welcome.

答: I once worked on a system where we decided to use short codes to prefix the columns. The PK fields used the "full table name" as a prefix, and all other columns used 2-4 characters consistently as their prefix. Each column also used a data domain as its suffix. If done consistently, it can be very nice and clean. It's nonsense that a naming standard of one type or another implicates sloppy coding. The presence of a consistent standard is what's important. I've seen a number of databases that are inconsistent because there is no clear standard, and that more than anything else would indicate to me that there may be trouble in the data structures. If the designer of a database can't even consistently name objects and their children, why would that lead me to believe there is anything consistent or thoughtful about the underlying data model, relationships, constraints, integrity, etc?</p>


答:
Just program like you usually do, except that:

You can only have one source file.

Whenever you want to modify code, retype the entire line.

Whenever you want to run the program, turn over a ten-minute timer and turn off the screen.  When the timer runs out, turn on the screen and run the program.

Title: Learning to program on punchcards

Body:
I'd like to try programming with punch cards once in my life. How can I do this?

I'm in my 30s, and grew up entirely in the PC era, programming on computers with screens and keyboards. I want to experience the way my father and grandfather used to work. I imagine the hardware (and probably the cards themselves) are no longer manufactured. Are there any universities or museums with functioning punch card readers anymore? I'm in Boston, but I'm willing to travel to do this.

I asked MetaFilter, and I got some mixed answers (along with a lot of "no, don't do this" nay-saying). I did get a pointer to the Retro-Computing Society Of Rhode Island, but I haven't received a response to my email to them yet.


问:
Why is the folder name "bin" used in some frameworks and languages?
I have been learning Java. And still after a prolonged time I don't know why the name of the folder is "bin" where one find all the tools for java?

Is there is any logical reason behind that?

I have also noticed the same in .Net framework also.

答: As you know every language finally converted into machine code, I mean the code which a machine can understand and machine only understand either 0 or 1 (you also can say either on or off).this 0 and 1 form of data representation is called binary data representation. Hence every language create binary code so that machine can understand and process it.so the folder where all these machine code reside is called as bin(binary).</p>


问:
Given an idea for an application, how should I decide which web technologies to use?
Background:  I'm an experienced Java developer, know basic Javascript, HTML, and CSS (and find it easy to figure out how to do something), and have a little experience in Python.  I've seen Ruby before and edited a few lines of existing scripts.

I'm curious not so much about any given technology, but mainly about what my thought process should be when deciding which technologies to use.  Let's take a simple application - maybe an online address book where I can enter contact information, and create groups of contacts.  How should I go about evaluating the options that are out there?

The number of frameworks out there  is daunting to say the least.  This should be a learning experience for me, but also I want the knowledge that I gain to be relevant, and I'm afraid of using something that I'll never use again.

答:
What are you and your developer team already familiar with?  Are you comfortable using it?

How mature is the technology?  Is it a widely recognized and used technology, or is it at the fringes?

How productive are you in the technology?  Does it take days to implement the simplest of things?

Does the technology meet your customer requirements?

If this is just a personal project, the decision will most likely hinge on whether or not you want to learn something new.


问:
Distributed Development Tools -- (Version control and Project Management)
I've recently become responsible for choosing which source control and project management software to use for a company that employs me.

Currently it uses Jira (project management) and Subversion (version control).

I know there are many other options out there -- the ones I know about are all in this article http://mashable.com/2010/07/14/distributed-developer-teams/ .

I'm leaning towards recommending they just stay with what they have as it seems workable and any change would have to be worth the cost of switching to say github/basecamp or some other solution.

Some details on the team:

It's a distributed development shop. Meetings of the whole team in one
room are rare.

It's currently a very small development team (three developers).

The project management
software is used by developers and a
product manager or two.

What are you experiences with version control and project management web applications?  Are there any you would recommend and you think are worth the switching cost of time to learn new services / implementing the change?

Edit:  After educating myself further on the options it appears DVCS offer powerful benefits that may be worth investing in now as opposed to later in the company's lifetime when the switching cost is higher: I'm a Subversion geek, why should I consider or not consider Mercurial or Git or any other DVCS?

答:
I switched a few projects over to Assembla a few years ago. The first few months were a bit slow as everyone adjusted to the transition, but in the end it was worth it. My team was resistant at first, but once everyone got into the habit, we were much more productive.

Granted, this took a few months, but I think it's been worth it. Assembla has a lot of useful tools; their bug tracking tool is by far the simplest yet effective one to use that I've seen.


问:
How do companies keep websites hidden when in development?
I am new to this and also a new 19 year old PHP developer that just got hired so I am  unsure as to how this works.  Many companies when developing their websites keep their sites hidden from being indexed.  What are some ways html5/css and then php/mysql work is hidden from search engines? If I am not wrong, these are the techniques:

Offline development: using local storage to render html/css; not sure how PHP/mysql would work with that.

Using .htaccess to prevent access

Using VPN to prevent access.

答:
In the spirit of "going in with more knowledge":

Html/Css can be hidden with robots.txt, but be sure to change those files when you push the site to production.  robots.txt does not prevent some random person guessing the development website (if it is visible to the whole world).

.htaccess could be used to add a username/password combo to any site being developed.

Here is an example of how you could use a VPN:

All requests on the VPN go through a firewall. That firewall (running some software like pfSense) examines website requests and does some redirection based on url. For example, the url http://example.com.staging will direct to the version of example.com on your staging server, and the url of http://example.com.development will direction to the version of example.com on your development server.

Since all of this is on a private VPN, none of these websites are accessible from the outside world.

Also, to clarify some things with your original question. The php/mysql work is being done server side, so web crawlers, browsers, etc. never see the code--they only see the output of the code (that is, if you've configured your server correctly and aren't rendering .php files as text).

I'm sure I've misread your question, but I found your use of the phrase "local storage" ambiguous. LocalStorage can also refer to an HTML5 technology for storing assets locally on a client's machine. It is not used for rendering html/css, it is only a datastore (the browser renders the html/css). Local storage typically has nothing to do with how companies keep websites hidden in development.

PHP files can be viewed locally if you are running a web server on your machine and the files are in the appropriate directories (usually the htdocs directory if running Apache).


问:
How to implement a system to hide spammed user content?
I'm trying to work out a good way to manage user submitted content and create a method to determine when spammed/poor content should be hidden.

The aim is to create comment voting similar to youtubes like/dislike comments and if the score is good show the comments, else they're invisible.

Approach

My thought is to do this via the comments table, you could create two columns rateup, ratedown.

For each rate up the comment gets the rateup colulmn is: rateup = rateup + 1

and the same for the ratedown: ratedown = ratedown + 1

You can then put a clause into your database query to only select comments if their rateup ratio is greater than a number, say -5:

```<code>WHERE (rateup - ratedown) > -5
</code>```

but this would need a lot of voting up and down if a user posts many spam/poor content posts over the site?

To strengthen the approach I could add the same two columns to the user table and also update these columns to give an overlal view of the users combined content submission ratio and then display comments like so:

```<code>WHERE ((comment.rateup - comment.ratedown) > -5 ) && ((user.rateup - user.ratedown) > -5 )
</code>```

Issues

Would this approach lead to instances of users creating mass fake accounts to attack good users and ruin their reputation?

What other methods could I use to help hide spammed/poor content without moderators having to manually go through everything?

答:
Have a separate "spam" flag that any user can use.

When the number of spam flags hits 5 (as in Stack Exchange say), automatically delete/hide the post and put a "spammer" flag against the user. When the user gets "N" spammer flags (where this could be as low as 1 or as high as you like) then stop the user posting anything.

This is independent of the like/dislike flags and this can carry a higher weight.

Have the spam flags listed for moderators to review so that they can spot someone abusing the flags.


答:
My immediate guess is "probably no" to a fair number of your questions. While there are undoubtedly at least a few card punches and readers left in the world, my immediate guess would be that it's been long enough since anybody's tried to use them that there's little certainty that they'd work even if somebody tried.

At least based on my recollection, card punches were sufficiently reliable that many of them probably still work. They're not really a lot different from typewriters, except that when the the "thing" swings forward to hit the paper, it doesn't just hit hard enough to push a ribbon against the paper -- it swings enough harder to punch a hole through.

I'm going from distant memories, but my recollection of card readers is quite different -- that they needed servicing quite frequently. In fact, when I was working on a mainframe, I seem to recall our having three card readers -- but rarely being able to use more than two at any given time. At least if memory serves, the card sorter was actually even a bit worse. In both cases, I'm pretty sure most of the problems stemmed from the mechanical parts to feed the cards into the reader proper.

I have to say, however, that in this case I see little (if anything) to gain from "doing things the old-fashioned way." I'm hard put to think of any benefit from Hollerith cards that can't be achieved much more quickly, easily, and dependably by more modern methods. I suppose (in theory) they did encourage some discipline in programming, and actually looking carefully at code before committing to running it (which, at least in my experience, was more often "overnight" than the "10 minutes" @Kevin Cline mentions).

Truthfully, however, a decent screen is a much better way to do that than Hollerith cards. When we had to do it back then, we usually got a print-out on 132-column fan-fold paper. I can't imagine trying to proof-read even a trivial program directly on the cards.

Bottom line: good luck -- but don't get your hopes too high about really learning much from this, even in the rather unlikely even that you manage to do it.

Title: Learning to program on punchcards


答:
The need for covariance and contravariance can be best understood with an example.

Let's say you have a function that accepts a parameter of type List<Base>, where Base is a base class that other classes inherit from.  You would intuitively think that it would be just fine to pass a List<Derived1> to this routine, if Derived1 inherits from Base, and you would be mostly right.  It would be fine if the function treated the list as read-only, but otherwise you'd have a problem.

Since all the function sees is a List<Base>, it could theoretically call the Add method and add a Derived2 instance to the list, which is a different, incompatible class derived from Base.  And then the function returns, and you've got a Derived2 in your list of Derived1 objects, and you've violated type-safety.  Then you try to iterate over the list and call some method on each object that doesn't exist on Derived2, and the whole thing blows up in your face.

Covariance and contravariance requirements exist to prevent this sort of scenario by enforcing extra constraints on the parameters.  For example, in this example, the function could be made type-safe by ensuring that no methods that add new objects to the list can be called.  If the compiler can use variance requirements to prove that, then it's safe to create a function like this.  Otherwise, it isn't.

Title: Why is Invariance, Covariance and Contravariance necessary in typed languages

Body:
Ok not really sure if I'm right.

I only recently learned that I needed to have contravariant interface to be able to pass that interface as a parameter in C# and this feature was only added in .NET 4.0.

So obviously there is some reason you can't do this Covariant or Invariant interfaces and it probably has something to do with passing in, getting out the generic class.

I'm not really sure what the limitation here is, and know that I've seen where Contravariant interface can be used where the others can't where can I use Covariant (when is that neccesary?).

This is all out of curiosity (I'm very interested in programming concepts surrounding some languages). I would love to see (link would be fine) some examples of why it is necessary to use these features, what would break if you would allow covariant/invariant into contravariant scene and vice versa and where each one shines.


答:
I'd recommend using a multi-step process to reduce the ability to spam.

First, require registration to submit content. In the registration process use CAPTCHA or another similar (but less intrusive) process to block auto-spam scripts along with email response verification. This will prevent most automated attempts and slow down a lot of manual or semi-manual spamming.

Also, record IP addresses. You can use this to compare against known spamming proxies and to catch multiple account creation. I wouldn't flag or ban on this basis alone but put such accounts on a moderator monitoring list.

Next, use a content grader algorithm to watch for common spammer techniques ("Great Post!!!"), certain keywords related to certain products, common curse words and for the insertion of links from sites other than recognized ones that you want to white list (Wikipedia, CNN, etc.). Flag offending content for further examination.

You can also use a participation scoring system like Stack Exchange uses. Add features as users participate. Spammers generally won't participate in a site but will move on to easier targets.

After that, use a user spam scoring system to allow users to flag inappropriate content. Don't act on this alone but put flagged content on a moderator list for further action.

Title: How to implement a system to hide spammed user content?

Body:
I'm trying to work out a good way to manage user submitted content and create a method to determine when spammed/poor content should be hidden.

The aim is to create comment voting similar to youtubes like/dislike comments and if the score is good show the comments, else they're invisible.

Approach

My thought is to do this via the comments table, you could create two columns rateup, ratedown.

For each rate up the comment gets the rateup colulmn is: rateup = rateup + 1

and the same for the ratedown: ratedown = ratedown + 1

You can then put a clause into your database query to only select comments if their rateup ratio is greater than a number, say -5:

```<code>WHERE (rateup - ratedown) > -5
</code>```

but this would need a lot of voting up and down if a user posts many spam/poor content posts over the site?

To strengthen the approach I could add the same two columns to the user table and also update these columns to give an overlal view of the users combined content submission ratio and then display comments like so:

```<code>WHERE ((comment.rateup - comment.ratedown) > -5 ) && ((user.rateup - user.ratedown) > -5 )
</code>```

Issues

Would this approach lead to instances of users creating mass fake accounts to attack good users and ruin their reputation?

What other methods could I use to help hide spammed/poor content without moderators having to manually go through everything?


答:
I worked for a small software company during the time where they released new versions to handle Y2K. To me the biggest differences involve the control and consistency of the users and their environments.

User computer setups will be more consitent.

The users are usually better trained (Except if your market is IT professionals.) or have an IT department.

Contract jobs give you more access to the user's systems in case you have to tweak an install.

User buy-in can be tricky in contract situations if there is internal fighting and politics going on. Many users don't want change. Hopefully,  a customer buying commercial software really wants to use it.

I don't think the time demands are that different because someone is still paying for your time and may be losing business or productivity because they don't have your app (Isn't that why they're buying it in the first place?). If you're building some free social app and using borrowed money, investors want to see a product sooner rather than later.


问:
Is there a more modern program than lex or yacc, which does not require JVM?
Is there a "modern" bison and flex equivalent which does not require the JVM or .NET or similar "heavy" runtimes?

By modern, I mean for example Antlr and another one in Java I saw but forgot the name of. (I know that for instance Antlr has a C target, but I am toying with the idea of embedding the compiler generator inside my own program and Java would be very impractical for me.)

答:
A very different but quite capable (and easily embeddable) answer is LPEG.

At first glance is just a pattern matching library, like a more capable RegEx; but it allows you to define not only patterns but whole language grammars, attaching custom behaviour to any step.

On that page there's a sample that matches an arithmetic expression, and produces the final value.  It could instead produce a parse graph, or directly emit code.

The LPEG Recipes page includes samples for whole Lua lexer and parsers, and also an ANSI C lexer.


答:
This is mostly a rewording of this excellent blog by Eric Lippert:

C# sub types have always been assignment compatible with their base types e.g. given that Teacher is derived from Person Person p = new Teacher(); is valid i.e. there is a relation isAssignable(x,y) which is true IFF x= y is allowed.

before C# 4 generic collections of sub types were not assignment compatible with generic collections of base types (i.e. IEnumerable<Teacher> does not derive from IEnumerable<Person> so you could not assign IEnumerable<Teacher> to a IEnumerable<Person>) i.e. isAssignable(IEnumerable<x>,IEnumerable<y>) was always false regardless of the value of isAssignable(x,y)

C# 4 adds variance for generic types, this allows a generic type to be *variant over a projection from T -> A<T>. which means that for covariant parameters, relations which hold for T,U hold for A<T>,A, and for contra-variant the relation is reversed. i.e. for the relationship isAssignable(x,y) a types that are covariant over the projection like IEnumerable<>s has the same relations as their generic parameters so isAssignable(x,y) == isAssignable(IEnumerable<x>,IEnumerable<y>)

Body:
This is mostly a rewording of this excellent blog by Eric Lippert:

C# sub types have always been assignment compatible with their base types e.g. given that Teacher is derived from Person Person p = new Teacher(); is valid i.e. there is a relation isAssignable(x,y) which is true IFF x= y is allowed.

before C# 4 generic collections of sub types were not assignment compatible with generic collections of base types (i.e. IEnumerable<Teacher> does not derive from IEnumerable<Person> so you could not assign IEnumerable<Teacher> to a IEnumerable<Person>) i.e. isAssignable(IEnumerable<x>,IEnumerable<y>) was always false regardless of the value of isAssignable(x,y)

C# 4 adds variance for generic types, this allows a generic type to be *variant over a projection from T -> A<T>. which means that for covariant parameters, relations which hold for T,U hold for A<T>,A<U>, and for contra-variant the relation is reversed. i.e. for the relationship isAssignable(x,y) a types that are covariant over the projection like IEnumerable<>s has the same relations as their generic parameters so isAssignable(x,y) == isAssignable(IEnumerable<x>,IEnumerable<y>)


问:
Is JSF really ready to deliver high performance web applications?
I have heard a lot of good about JSF but as far as I know people also had lots of serious complains with this technology in the past, not aware of how much the situation has improved. We are considering JSF as a probable technology for a social network project. But we are not aware of the performance scores of JSF neither we could really come across any existing high performance website that had been using JSF. People complain about its performance scalability issues.

We are still not very sure if we are doing the right thing by choosing jsf, and thus would like to hear from you all about this and take your inputs into consideration.

Is it possible to configure JSF to satisfy the high performance needs of social networking service ? Also till what extent is it possible to survive with the current problems in JSF. What exactly are its problems ?

I am not  worried about the development complexities with JSF what others usually complain about because as per my personal experience I believe that's not at all true, but I am more concerned about what performance and scalability issues. And please don't just abuse it on its old issues linked to previous versions. I just care about the present state whatever had been its past.

答:
If you want to understand more clearly how JSF performs (both Mojarra 2.1.7 and MyFaces 2.1.7) and compare it against a similar framework like Apache Wicket(both 1.4.20 and 1.5.5), take a look to this in-deep comparison (MAY 2012):

Understanding JSF 2 and Wicket: Performance Comparison

The good part is everything is available (code, experimental data, instructions about how to reproduce the test, a detailed exhaustive report). It will solve all your questions about JSF performance, and you'll see what Apache MyFaces is able to do.


问:
JSF for an internet facing, high traffic web application
I, perhaps, made a wrong choice of going with a Component-based Framework like JSF for an internet facing, high traffic web application.
Development with JSF has although been easier but what I fear now is whether JSF would allow me that scalability & performance with all it fundamental problems & issues. State saving in a high traffic web app, does that make sense at all!?

How do I tune up my JSF app now to make it perform better under heavy load? I am already trying to reduce the state / component tree by reducing the no of components on page. What are other things I can tune up to make JSF app perform better ?

答:
A good start to understand how JSF performance works is take a look at this blog:

Understanding JSF 2 and Wicket: Performance Comparison

There is a test application with everything you need to tune JSF properly. It is quite simple because you usually only need to set javax.faces.PROJECT_STAGE web config param to Production and JSF will configure for you, but there are some additional config parameters that helps just a little.


问:
Good workflow for software development with scrum and continuous integration
I'm studying an approach to understand better how the continuous integration workflow fits better in a software development company with the scrum method.

I'm thinking something like this:

Would that be a nice workflow?

答:
I use the term "Development Automation" to encompass all automated build, documentation generation, test, performance measurement and deployment activities.

A "development automation server" therefore has a similar, but somewhat broader remit than a continuous integration server.

I prefer to use development automation scripts driven by post-commit hooks that allow both private branches and the central development trunk to be automated, without requiring additional configuration on the CI server. (This precludes the use of most of the off-the-shelf CI server GUIs that I am aware of).

The post-commit script determines which automation activities to run based on the content of the branch itself; either by reading a post-commit configuration file in a fixed location in the branch, or by detecting a particular word (I use /auto/) as a component of the path to the branch in the repository (with Svn)).

(This is easier to set up with Svn than Hg).

This approach enables the development team to be more flexible about how they organise their workflow, allowing CI to support development on branches with minimal (close to zero) administrative overhead.


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

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

For example:

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

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

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

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

答:
At my work we have a very simple rule: changes must be reviewed by at least one other developer before a merge or a commit to the trunk.  In our case this means the other person physically sits with you at your computer and goes through the change list.  This is not a perfect system, but it has noticeably improved code quality nonetheless.

If you know that your code is going to be reviewed that forces you to look it over first.  Many problems become apparent then.  Under our system, you have to explain what you did to the reviewer, which again causes you to notice problems you may have missed before.  Also, if something in your code is not immediately clear to the reviewer, that is a good indication that a better name, a comment, or a refactoring is required.  And, of course, the reviewer may find problems too.  Furthermore, in addition to looking at the change, the reviewer may also notice problems in the nearby code.

There are two main drawbacks to this system.  When the change is trivial, it makes little sense to have it reviewed.  However, we absolutely have to stick to the rules, to avoid the slippery slope of declaring changes to be "trivial" when they are not.  On the other hand, this is not a very good way to review significant changes to the system or addition of large new components.

We have tried more formal reviews before, when one developer would email code to be reviewed to the rest of the team, and then the whole team would get together and discuss it.  This took a lot of everyone's time, and as a result these reviews were few and far between, and only a small percentage of the code base got reviewed.  The "one other person reviews changes before commit" has worked much better for us.


问:
Agile estimation with tech-debt
When estimating (story points) a story that consists on extending a current functionality with a known tech-debt, should we consider the effort that will be spent to refactor the current code or should we estimate independently of this tech-debt?</p>

答:
Let's try both:

Without Tech Debt: When work commences and you KNOW you'll have to refactor the code to make it work you'll probably decrease your velocity - since the overall complexity was underestimated

With Tech Debt: You'll increase the 'story point' score since it'll link to the tech debt and "make that explicit" to everyone and could be factored into existing velocity calculations, so to speak.

So, what should you choose? I'd go for #2 since that makes explicit what the story entails, is more realistic a picture and exposes the 'hidden' jobs that may be lurking below (devils in the details, perhaps).

If you do go with #1 the team may be questioned for decreasing velocity and 'not bringing up the tech-debt fix' in the meeting. Just keep it clear - estimate with tech debt and your team will be happy (and so will the PM - a debt would be paid off since something valuable is preceded by it :)

Title: Agile estimation with tech-debt


答:
Your estimates should certainly take into account the technical debt. The point of estimating stories is to get an indication of how much effort it will take to accomplish something, and technical debt definitely contributes to that. In fact, you should take everything that might effect the time/effort it takes to implement a story in your estimates (for example, learning the business domain).

Sometimes, when there is a lot of refactoring work to be done, I've added a separate sub-task under a story, and estimated that accordingly. Otherwise, refactoring and dealing with technical debt is going to be a natural part of every story. It should be estimated accordingly.

Title: Agile estimation with tech-debt

Body: When estimating (story points) a story that consists on extending a current functionality with a known tech-debt, should we consider the effort that will be spent to refactor the current code or should we estimate independently of this tech-debt?</p>


问:
I want to sell an app but also share the source code
I'm sorry if the title isn't clear, I have no idea about licences...

The thing is that I have created a little app for android targeted at developers. I want to get paid for the app, but I also want to share the code so others can modify it to improve it or to suit their needs.

I think this is somewhat close to minecraft way (sell and expect that everybody pays, but have no problem with people modifing the source, build mods, etc) and is pretty close to http://livereload.com/ way of distributing and licensing.

Maybe I should sell the app and give access to a private repo from the app itself (so, once you bought it, you get access to the source). Am I right? is this my best option?

答: You could do it that way, or simply distribute the source with the app, with a notice at the top of each source file that this is proprietary source code that is not to be redistributed.  There are plenty of good libraries that do that.  We use several of them where I work. (We have a policy not to use any library that we can't get the source to.)</p>


答:
The different forms of variance are only needed because you have two independent axes of polymorphism going on:

Subtype polymorphism: A function that is defined to operate on values of type Base can also operate on values of type Derived, if Derived is a subtype of Base.  Within the function, only the operations exposed by type Base may be used (unless reflection or run-time type inspection are used).

Parametric polymorphism: A generic function that is parameterized over a type T (e.g. void Foo<T>()) can operate on values of type A, B, etc., if those types match the where clause restrictions (if any) on the type of T.  Within the function, only operations which are valid for the entire bounds of the type parameter can be used.  (So if there are no bounds on T, then only operations that are guaranteed to be valid for all objects may be used.)

Each axis makes sense on its own.  But you run into problems when you try to act polymorphically in both axes at once.

For example, given classes Base, Derived, and SomethingElse:

A method void Foo(Base b) can accept a value of type Derived as a parameter, by subtype polymorphism.

The method void Add(T item) on the type List<T> can accept values of any of Base or SomethingElse, etc, provided the type has been instantiated as List<Base>, List<SomethingElse>, etc.

The method void Add(T item) on the type List<T>, when the type has been instantiated as List<Base>, is treated as if it were declared as void Add(Base item), and thus can accept a value of type Base.

Additionally, the method void Add(T item) on the type List<T>, when the type has been instantiated as List<Base>, can accept a value of type Derived, due to the combination of both parametric polymorphism (the parameterized type of Base) and subtype polymorphism (the is-a relationship between Derived and Base).

However, given a function void Foo(List<Base> list), and a value of type List<Derived>, the method void Add(T item) on the type List<Derived> is treated as if it were declared as void Add(Derived item), which is incompatible with the method void Add(T item) on the type List<Base> (which is treated as if were declared as void Add(Base item)).

This is because the value which is required for the formal parameter list of void Foo(List<Base> list) must be an object that has an Add() method that is able to accept values of type Base, but the value which is being supplied (a value of type List<Derived>) does not accept values of type Base in its Add() method!

Now, if you are only dealing with one axis of polymorphism at a time, then this isn't a problem:

If all you have is subtype polymorphism, then we're just like the type system of C# 1.0: there are no generics, and thus no way for problems of covariance and contravariance to come up.  (Actually, the problems can come up, it's just that they appear at run time, not compile time.  For example, see ArrayTypeMismatchException.)

Conversely, if all you have is parametric polymorphism (a.k.a. generics), then it is never allowed to pass a type Derived to a function that expects a value of type Base, since functions cannot act polymorphically with respect to a subtype relationship.

(While this restriction seems hopelessly restrictive to someone coming from an OO background, it's actually quite common in some functional programming languages.  It does change how you go about structuring your code, however.)

Now, the problems of covariance and contravariance can occur just as easily in a dynamically typed language as in a statically typed one.  The only difference is that dynamic language code is necessarily more resilient to unexpected types.

For example, in a Python program, you might have a class that represents a list of strings, and an add(item) method that adds an item to the list.  However, the type system does not enforce the invariant of the class -- any caller can pass a value of any type they like to the add() method.  Therefore, the code must either defend against illegal values somehow (e.g. by doing a check in the add() method to ensure that a non-string doesn't get added), or cope gracefully with finding a non-string in its internal storage.

These kinds of problems are exactly what covariance and contravariance are about: cases where code can be "surprised" by the type of values.  In a statically type-checked language, the type checker is responsible for proving that code can never be surprised by the type of a value: if you have a local variable that was declared with type string, it will never contain a value of type double, no matter what.  If, due to the way you're using different forms of polymorphism together, the type checker can no longer prove that, it will reject your program with a type error.

Basically, this is the trade-off of static versus dynamic type checking: a static type checker can prove that certain kinds of undesirable behavior are not present in your program (in this case, "surprising" types of values), but only at the cost of rejecting some interesting programs.  That is, a type checker is by necessity conservative.

In order to make type checkers more flexible (and thus allow more interesting programs to be checked by them), modern languages like C# have introduced new language constructs (like the in and out keywords to identify covariant and contravariant type parameters), which allow more fine-grained control over the type checker's proof.  Generally, this is considered a good thing: it allows us to have the advantage of a type checker proving useful things about our program, while still allowing the maximum number of interesting programs through.


问:
How can I convince management to deal with technical debt?
This is a question that I often ask myself when working with developers. I've worked at four companies so far and I've become aware of a lack of attention to keeping code clean and dealing with technical debt that hinders future progress in a software app. For example, the first company I worked for had written a database from scratch rather than use something like MySQL and that created hell for the team when refactoring or extending the application. I've always tried to be honest and clear with my manager when he discusses projections, but management doesn't seem interested in fixing what's already there and it's horrible to see the impact it has on team morale.

What are your thoughts on the best way to tackle this problem?
What I've seen is people packing up and leaving. The company then becomes a revolving door with developers coming in and out and making the code worse. How do you communicate this to management to get them interested in sorting out technical debt?

答:
It has to be a very convincing argument, in terms of the original product and business case, that I couldn't use that money now to do something more important to me. Like it or not, your management or your customers are paying for this and you need to be able to sell to aka convince them.

Let's rephrase this to position yourself as a customer. Good old role play.

Suppose you were buying a refrigerator. And you could buy a fridge for
  $1000 that worked OK from Acme Corp. Or a fridge for $2000 from Acme
  Deluxe Fridges that looked the same on the outside and had the same
  technical specs, but had lower maintenance costs due to a cleaner
  internal architecture.

As a customer, which would you yourself buy?

And what do Acme Deluxe's engineers think is the better answer?