答:
Welcome to the world of Scrum. You are right in guessing that providing technical input in the user story might be wrong. Here's why. The User Story is about the user. The user does not care about the technical information. You would not care about the technical information had you come from  a less technical background. What you, as the PO would care about is that the team delivers the value you are asking for. Any way they can (this often means that they should be encouraged to think out of the box and look for a simple solution).

If, however there are certain criteria that the solution must meet for the story to be considered successful, you will of course provide them in the acceptance criteria (often written on the back of the story card, in the GWT form). For example, perhaps you need the service to run in under 2 seconds, or due to customer requirements, such as interfacing with another system, your service must provide an XML-based result.

Other technical opinions (which might be biased, like by your skill-set) should be kept unofficial. Remember that user stories are not contracts, but rather a promise to have a conversation! During the sprint you, the PO, are considered a "chicken", therefore your advice should considered, but it should be ultimately up to the team to own the delivery of the solution.

I hope this helps, and you find the transition from command and control to agile as easy as possible. It's one heck of a ride, but well worth it.

OwnerDisplayName: Assaf Stone


问:
How to make security usable in a web application?
I'm in the planning stages of developing a web application that I want to make as secure as possible. I'm pretty clear about how to do that from a technical point of view, but there is one massive potential security hole: I want the site to have users.

As anyone who has ever been a user knows, users forget usernames, forget passwords, sometimes forget that they even had an account with your site. Users respond to phishing emails and give away their credentials. If you do anything that they find too complicated they won't use your site, it has to be simple and all happen in as few clicks as possible, but we have to balance that out by making it as hard as possible for users to accidentally give away their credentials and to keep access to the service as secure as possible.

What I'm particularly interested in are strategies that go beyond the standard username and password combination and ways of recovering or resetting passwords that make things easy for users but hard for anyone trying to steal their account. I know a lot of sites provide an extra user-set security question, but because I don't trust users not to create a stupid question like "what is 1+1" I don't see how this can guarantee security.

Are there strategies that could be useable to the most clueless user but challenging to a determined and targetted attack aiming to break into their account? If not what are the closest things we could get? As a user what are the best/worst sites for this you have encountered and why?

答:
The only way I know of to build a truly secure web site is to require a password and have a challenge/response device.

For example, TreasuryDirect.gov sends you a card with a grid of random characters. As part of the logon process, you are asked to provide the characters that are contained in specific cells of the grid. But this is expensive and time-consuming; it requires to get the cards, to track them and to send them out. Plus, if a person loses the card, they can't log in until you get them a new card. In the case of TreasuryDirect, where you could be managing millions of dollars, this hassle is worth it. Only you can determine if it will be worth it for your site.

Another option is to add a validation picture, like a lot of banks do. I believe this option only helps thwart some phishing attacks so if you think phishing will be a problem, this might be an option.

I believe the other alternatives, including what most banks use, seem to be secure but aren't really. Security questions, for example, I believe compromise sites more than they help. Others think this too.

One other thing will be to encourage users to use a "Passphrase" instead of a password as Jeff Atwood recommends. Amazon has taken this approach as well with their newish PayPhrase.

ContentLicense: CC BY-SA 2.5


问:
How can I provide guidance on technology choices through user stories?
I'm a project manager for a team of firmware engineers making the transition to adopting Scrum and I'm moving to support the team in a Product Owner role. We've just gone through Scrum training and are beginning a month of coaching which is going to be invaluable. Coming from a technical background I can already see the challenge of shifting my point of view from the solution domain to focusing on business value. For me it's very tempting to think of "how" to solve a problem. But I like the concept of user stories and defining vertical slices of functionality that give value to the customer and letting the team determine the "how".

Forgive me if this is a naive question, but as the PO how can I provide guidance on specific technical direction through user stories? My concern is that in some cases without guidance the team may head down the wrong path on key technical decisions.

As a simplistic example I might have a user story:

As a clinician I want the device to record information about the patient's treatment so that I can determine if the patient's therapy has been effective.

Now say time to market is critical and I want to fork out for an off-the-shelf file system stack to save time, what conveys that to the team? They might go off and start writing their own stack from scratch.

Is this sort of guidance provided through:

Conversations during sprint planning and backlog grooming? But if so, is it my place as the PO to even be suggesting how to solve a problem.

Acceptance criteria? I don't really like this, I have a bad feeling about making acceptance criteria so prescriptive that they specify how to solve a problem.

Constraints?

Thanks in advance. I could (and will) ask our Scrum coach but I won't be able to do that before Monday and this question has been really bugging me :)

答:
You need to let go!

Its not your job any more. You need to trust the technical guys to make the right decisions, and, concentrate on getting the Product right from the marketing business point of view.

After all you would have hated it if the product owner had questioned your judgement when you were head of the technical team. By concentrating on your "last job" you will perform poorly in your new job. Being the "Product Owner" does not sound that easy, and will require you to master a new set of skills and looks a big enough of a challenge without the distraction of doing someone else's job as well.

OwnerDisplayName: Jono

ContentLicense: CC BY-SA 3.0


问:
Why was the C syntax for arrays, pointers, and functions designed this way?
After having seen (and asked!) so many questions similar to

What does int (*f)(int (*a)[5]) mean in C?

and even seeing that they'd made a program to help people understand the C syntax, I can't help but wonder:

Why was the syntax of C designed this way?

For example, if I were designing pointers, I would translate "a pointer to a 10-element array of pointers" into

```<code>int*[10]* p;
</code>```

and not

```<code>int* (*p)[10];
</code>```

which I feel most people would agree is much less straightforward.

So I'm wondering, why the, uh, unintuitive syntax? Was there a specific problem the syntax solves (perhaps an ambiguity?) that I'm unaware of?

答:
It's pretty simple: int *p means that *p is an int; int a[5] means that a[i] is an int.

```<code>int (*f)(int (*a)[5])
</code>```

Means that *f is a function, *a is an array of five integers, so f is a function taking a pointer to an array of five integers, and returning int.  However, in C it isn't useful to pass a pointer to an array.

C declarations very rarely get this complicated.

Also, you can clarify using typedefs:

```<code>typedef int vec5[5];
int (*f)(vec5 *a);
</code>```

Body:
It's pretty simple: int *p means that *p is an int; int a[5] means that a[i] is an int.

int (*f)(int (*a)[5])

Means that *f is a function, *a is an array of five integers, so f is a function taking a pointer to an array of five integers, and returning int.  However, in C it isn't useful to pass a pointer to an array.

C declarations very rarely get this complicated.

Also, you can clarify using typedefs:

typedef int vec5[5];
int (*f)(vec5 *a);


答:
I think you have to consider * [] as operators that are attached to a variable. * is written before a variable, [] after.

Let's read the type expression

```<code>int* (*p)[10];
</code>```

The innermost element is p, a variable, therefore

```<code>p
</code>```

means: p is a variable.

Before the variable there is a *, the * operator is always put before the expression it refers to, therefore,

```<code>(*p)
</code>```

means: variable p is a pointer. Without the () the [] operator to the right would have higher precedence, i.e.

```<code>**p[]
</code>```

would be parsed as

```<code>*(*(p[]))
</code>```

Next step is []: since there is no further (), [] has higher precedence than the outer *, therefore

```<code>(*p)[]
</code>```

means: (variable p is a pointer) to an array.
Then we have the second *:

```<code>* (*p)[]
</code>```

means: ((variable p is a pointer) to an array) of pointers

Finally you have the int operator (a type name), which has the lowest precedence:

```<code>int* (*p)[]
</code>```

means: (((variable p is a pointer) to an array) of pointers) to integer.

So the whole system is based on type expressions with operators, and each operator has its own precedence rules. This allows to define very complex types.

Title: Why was the C syntax for arrays, pointers, and functions designed this way?

Body:
After having seen (and asked!) so many questions similar to

What does int (*f)(int (*a)[5]) mean in C?

and even seeing that they'd made a program to help people understand the C syntax, I can't help but wonder:

Why was the syntax of C designed this way?

For example, if I were designing pointers, I would translate "a pointer to a 10-element array of pointers" into

```<code>int*[10]* p;
</code>```

and not

```<code>int* (*p)[10];
</code>```

which I feel most people would agree is much less straightforward.

So I'm wondering, why the, uh, unintuitive syntax? Was there a specific problem the syntax solves (perhaps an ambiguity?) that I'm unaware of?

Body:
I think you have to consider * [] as operators that are attached to a variable. * is written before a variable, [] after.

Let's read the type expression

int* (*p)[10];

The innermost element is p, a variable, therefore

p

means: p is a variable.

Before the variable there is a *, the * operator is always put before the expression it refers to, therefore,

(*p)

means: variable p is a pointer. Without the () the [] operator to the right would have higher precedence, i.e.

**p[]

would be parsed as

*(*(p[]))

Next step is []: since there is no further (), [] has higher precedence than the outer *, therefore

(*p)[]

means: (variable p is a pointer) to an array.
Then we have the second *:

* (*p)[]

means: ((variable p is a pointer) to an array) of pointers

Finally you have the int operator (a type name), which has the lowest precedence:

int* (*p)[]

means: (((variable p is a pointer) to an array) of pointers) to integer.

So the whole system is based on type expressions with operators, and each operator has its own precedence rules. This allows to define very complex types.


问:
Stuff every programmer needs while working
I've been tasked with creating a fun and relaxing environment, one thing I know that I want is ergonomic mice and keyboards, others have suggested exercise balls and bands.

What is it that every programmer needs while working? What might not be necessary but would be nice to have anyway?

Note: this question was asked previously, but has been recommended to be posted here. See this link for the previous responses: https://stackoverflow.com/questions/3911911/stuff-every-programmer-needs-while-working-closed

答: A game room where he/she would not be disturb while is cleaning hes/her mind.


问:
What is the point of Java's package naming convention?
I don't understand why Java uses the reverse of a (probably hypothetical) domain name as the name of a package, while mostly there is no connection between the domain name that some people uses and the products that they have. A lot of developers don't even have any domain.

What are the reasons of this naming convention, if any?

答:
As Wikipedia says on the subject,

"The Java Language Specification establishes package naming
  conventions to avoid the possibility of two published packages having
  the same name."


答: Global uniqueness. If everyone, or at least serious developers who distribute their code beyond in-house projects, adheres to that convention, it will never happen that you get name clashes when you add another third-party library to your project. Bear in mind that Java was initially propagated as a solution for code deployment anywhere, anytime (via applets and remote classloading over the internet).</p>

Title: What is the point of Java's package naming convention?

Body:
I don't understand why Java uses the reverse of a (probably hypothetical) domain name as the name of a package, while mostly there is no connection between the domain name that some people uses and the products that they have. A lot of developers don't even have any domain.

What are the reasons of this naming convention, if any?


问:
What are questions to test a programmers knowledge of SQL?
What are questions to test a programmers knowledge of SQL? What is the answer to the question? And what would a lack of an correct answer mean in terms of time likely to understand the concept(s) related to the question?

GOOGLED: sql challenge

答:
I had a hand in developing a technical test for database programmers. The questions were what I consider quite basic: write the CREATE TABLE statements for a given table structure; do some simple queries; etc.

Most job applicants who called themselves experts at SQL flunked the test. One said that although he had been an SQL developer for many years, he had never written a CREATE TABLE statement because the GUI did it for him.

We've had similar experiences with other technical tests. For Windows support staff, the tasks are similar to "create a domain user," "add a printer," "change permissions on a file." Most people can't do those tasks, especially under pressure. We figure that if you can do even the simple stuff, you're probably pretty competent.


答:
A lot of the oddities of the C language can be explained by the way computers worked when it was designed. There were very limited amounts of storage memory, so it was very important to minimize the size of the source code files themselves. The programming practice back in the 70s and 80s was to make sure the source code contained as few characters as possible, and preferably no excessive source code comments.

This is of course ridiculous today, with pretty much unlimited storage space on hard drives. But it is part of the reason why C has such weird syntax in general.

Regarding array pointers specifically, your second example should be int (*p)[10]; (yeah the syntax is very confusing). I would perhaps read that as "int pointer to array of ten"... which makes sense somewhat. If not for the parenthesis, the compiler would interpret it as an array of ten pointers instead, which would give the declaration an entirely different meaning.

Since array pointers and function pointers both have quite obscure syntax in C, the sensible thing to do is to typedef away the weirdness. Perhaps like this:

Obscure example:

```<code>int func (int (*arr_ptr)[10])
{
  return 0;
}

int main()
{
  int array[10];
  int (*arr_ptr)[10]  = &array;
  int (*func_ptr)(int(*)[10]) = &func;

  func_ptr(arr_ptr);
}
</code>```

Non-obscure, equivalent example:

```<code>typedef int array_t[10];
typedef int (*funcptr_t)(array_t*);

int func (array_t* arr_ptr)
{
  return 0;
}

int main()
{
  int        array[10];
  array_t*   arr_ptr  = &array; /* non-obscure array pointer */
  funcptr_t  func_ptr = &func;  /* non-obscure function pointer */

  func_ptr(arr_ptr);
}
</code>```

Things can get even more obscure if you are dealing with arrays of function pointers. Or the most obscure of them all: functions returning function pointers (mildly useful). If you don't use typedefs for such things, you'll quickly go insane.

Body:
A lot of the oddities of the C language can be explained by the way computers worked when it was designed. There were very limited amounts of storage memory, so it was very important to minimize the size of the source code files themselves. The programming practice back in the 70s and 80s was to make sure the source code contained as few characters as possible, and preferably no excessive source code comments.

This is of course ridiculous today, with pretty much unlimited storage space on hard drives. But it is part of the reason why C has such weird syntax in general.

Regarding array pointers specifically, your second example should be int (*p)[10]; (yeah the syntax is very confusing). I would perhaps read that as "int pointer to array of ten"... which makes sense somewhat. If not for the parenthesis, the compiler would interpret it as an array of ten pointers instead, which would give the declaration an entirely different meaning.

Since array pointers and function pointers both have quite obscure syntax in C, the sensible thing to do is to typedef away the weirdness. Perhaps like this:

Obscure example:

int func (int (*arr_ptr)[10])
{
  return 0;
}

int main()
{
  int array[10];
  int (*arr_ptr)[10]  = &array;
  int (*func_ptr)(int(*)[10]) = &func;

  func_ptr(arr_ptr);
}

Non-obscure, equivalent example:

typedef int array_t[10];
typedef int (*funcptr_t)(array_t*);

int func (array_t* arr_ptr)
{
  return 0;
}

int main()
{
  int        array[10];
  array_t*   arr_ptr  = &array; /* non-obscure array pointer */
  funcptr_t  func_ptr = &func;  /* non-obscure function pointer */

  func_ptr(arr_ptr);
}

Things can get even more obscure if you are dealing with arrays of function pointers. Or the most obscure of them all: functions returning function pointers (mildly useful). If you don't use typedefs for such things, you'll quickly go insane.

ContentLicense: CC BY-SA 4.0


问:
is Ada really gone?

Do people still use Ada -- (it was mostly used in the Defense Department)

Are all applications written in Ada "Legacy"?

Does Ada knowledge still sell

答: The answer is: No, Ada is still being used. My company uses Ada to develop native server-side applications for companies in manufacturing, retail, healthcare and more.</p>

Title: is Ada really gone?


答:
My understanding of the history of it is that it's based on two main points...

Firstly, the language authors preferred to make the syntax variable-centric rather than type-centric. That is, they wanted a programmer to look at the declaration and think "if I write the expression *func(arg), that'll result in an int; if I write *arg[N] I'll have a float" rather than "func must be a pointer to a function taking this and returning that".

The C entry on Wikipedia claims that:

Ritchie's idea was to declare identifiers in contexts resembling their use: "declaration reflects use".

...citing p122 of K&R2 which, alas, I don't have to hand to find the extended quote for you.

Secondly it is actually really, really difficult to come up with a syntax for declaration that is consistent when you're dealing with arbitrary levels of indirection. Your example might work well for expressing the type you thought up off-the-bat there, but does it scale to a function taking a pointer to an array of those types, and returning some other hideous mess? (Maybe it does, but did you check? Can you prove it?).

Remember, part of C's success is due to the fact that compilers were written for many different platforms, and so it might have been better to ignore some degree of readability for the sake of making compilers easier to write.

Having said that, I'm not an expert in language grammar or compiler writing. But I know enough to know there's a lot to know ;)


问:
instantiate or initialize when using a new class?
my question is rather a matter of English language. For proper commenting my code I want to know when you do for example the following code, what comment you can write for it?

```<code>public class TestClass
{
    public double volt {get; set;}
    public double curr {get; set:}
}
</code>```

Somewhere else in the same namespace

```<code>public class AnotherTest
{
    TestClass test;

    public AnotherTest(TestClass test)
    {
       this.test = new TestClass(); //how to comment this?
    }
}
</code>```

答:
You don't need comments in the example given. You need better variable names.

Use the following rules to judge the value of a comment:

Comment on specific implementation of a piece of logic or business rule or program modification log, or feature change

Never comment on language syntax inside the code (as in your case) - The developer should know the syntax

Comment on a specific choice of a computing approach such as useing Instr instead of Regex that could result in performance gain

Add comments to describe specific usage of variables and methods to avoid unnecessary long names or to clarify the purpose for the reader quickly.

Too many comments are useless and harmful sometimes, especially if not maintained.

The code is not the only place for comments.

If you are working on a project, have some guidelines.


答:
It's not so hard when you start thinking and C never was very easy language.
And int*[10]* p really isn't easier than int* (*p)[10]
And what type of k would be in int*[10]* p, k;


问:
What to do with .git folder and data in Xcode?
I am using Hg for my development. Recently, I upgraded to Lion and Xcode 4.2 and I have created a Xcode project in my source tree. The Xcode by default uses Git and created .git folder in the project folder.

Being able to do versioning in Xcode is a plus but it is sort of redundant with both Git and Hg.

The problem is, should I check in the .git (folder and files) in the Xcode project folder or not? Or should I just switch off Git in Xcode and delete .git folder?

Thanks.

答:
When having projects in both git and hg repositories, clone your projects from both repositories into different work copy folder. If you preferred, use hg-git to check out git repository using hg.

In my case, I use SourceTree, a GUI client, that supports both git and hg so I don't have to deal with the complexity of setting up hg-git.

Thanks.


答:
Unless you understand all the edge cases in securely dealing with authentication and sessions, don't implement this yourself.

Broken authentication and session management is one of the top 10 OWASP security issues, and there is a reason for that. "Getting it right" is so complex you have to be a web security expert.

If possible, use a third party auth system. For example, use google accounts. Let them worry about all this stuff.

Title: How to make security usable in a web application?

Body:
I'm in the planning stages of developing a web application that I want to make as secure as possible. I'm pretty clear about how to do that from a technical point of view, but there is one massive potential security hole: I want the site to have users.

As anyone who has ever been a user knows, users forget usernames, forget passwords, sometimes forget that they even had an account with your site. Users respond to phishing emails and give away their credentials. If you do anything that they find too complicated they won't use your site, it has to be simple and all happen in as few clicks as possible, but we have to balance that out by making it as hard as possible for users to accidentally give away their credentials and to keep access to the service as secure as possible.

What I'm particularly interested in are strategies that go beyond the standard username and password combination and ways of recovering or resetting passwords that make things easy for users but hard for anyone trying to steal their account. I know a lot of sites provide an extra user-set security question, but because I don't trust users not to create a stupid question like "what is 1+1" I don't see how this can guarantee security.

Are there strategies that could be useable to the most clueless user but challenging to a determined and targetted attack aiming to break into their account? If not what are the closest things we could get? As a user what are the best/worst sites for this you have encountered and why?


问:
Is "truthiness" a legitimate programming term?
SO has quite a few questions using the word "truthiness" to mean the truth value of an expression, when evaluated as a boolean, regardless of its original type. It's very useful in dynamic languages.

So my question is, is this a real term, and if so were we using it before Stephen Colbert made it popular? Or did we just adopt it afterward? In that case, what is the correct term with the definition I gave above?

答:
There's a lot of debate over truthiness.

Merriam-Webster defines it as:

truthiness (noun)

1 : "truth that comes from the gut, not books" (Stephen Colbert, Comedy Central's "The Colbert Report," October 2005)

2 : "the quality of preferring concepts or facts one wishes to be true, rather than concepts or facts known to be true" (American Dialect Society, January 2006)

Oxford Dictionaries Online defines it as:

noun

  [mass noun] informal

  the quality of seeming or being felt to be true, even if not necessarily true.

Origin:

  early 19th century (in the sense 'truthfulness'): coined in the modern sense by the US humorist Stephen Colbert

It was used a little bit on Usenet prior to Stephen Colbert, but usually explained as soon as used, such as "the quality of stating concepts or facts one wishes or believes to be true, rather than concepts or facts known to be true".

Back to programming. Regardless of the origin, this modern sense of "truth from the gut, even if not true" is clearly incorrect most of the time when discussing Boolean logic and truth tables: this if statement is definitely true, and that while statement is false until (i > k). My gut feeling doesn't come into it.

If you're using truthiness in programming, most likely you're using the rare 19th century meaning of truthfulness, and it would be both clearer (and arguably more correct) to use truthfulness or simply truth.

Ngram:

Of course, English changes as usage changes, and some people have started to use truthiness to mean truth in programming. However, I would advise against truthiness to avoid any ambiguity of meaning ("real absolute truth" vs. "my gut feeling of truth, regardless of the facts").


答:
I regard truthy as a legitimate term in use over JavaScript evaluation.  Douglas Crockford's book on JavaScript - 'JavaScript the Good Parts' defines the terms that JavaScript 'if' evaluates as true to be 'truthy'.  Equally he defines the terms that JavaScript evaluates to false as 'falsy'.  He also uses the term to highlight the way that the '==' evaluation works in JavaScript (which is different to the way that many JavaScript users  seem to believe it works).

From Crockford's The Elements of JavaScript Style

The == operator should not be used for comparing values with true because it does type coercion. If our intent is to determine if d.w.sv.checked is the boolean value true, then we must use the === operator. If we only care that a value is truthy (and not falsy) then it is better to not use an equality operator at all.

For example, because of type coercion., 1 == true is true, but 1 === true is false. The == operator can hide type errors.

In this context the term is both legitimate and useful.

As a further illustration of true and false in this context these cases are illustrative.

```<code>'' == '0' // false
0 == '' // true
0 == '0' // true

false == 'false' // false
false == '0' // true

false == undefined // false
false == null // false
null == undefined // true

' \t\r\n ' == 0 // true
</code>```

Title: Is "truthiness" a legitimate programming term?

Body:
SO has quite a few questions using the word "truthiness" to mean the truth value of an expression, when evaluated as a boolean, regardless of its original type. It's very useful in dynamic languages.

So my question is, is this a real term, and if so were we using it before Stephen Colbert made it popular? Or did we just adopt it afterward? In that case, what is the correct term with the definition I gave above?

Body:
I regard truthy as a legitimate term in use over JavaScript evaluation.  Douglas Crockford's book on JavaScript - 'JavaScript the Good Parts' defines the terms that JavaScript 'if' evaluates as true to be 'truthy'.  Equally he defines the terms that JavaScript evaluates to false as 'falsy'.  He also uses the term to highlight the way that the '==' evaluation works in JavaScript (which is different to the way that many JavaScript users  seem to believe it works).

From Crockford's The Elements of JavaScript Style

The == operator should not be used for comparing values with true because it does type coercion. If our intent is to determine if d.w.sv.checked is the boolean value true, then we must use the === operator. If we only care that a value is truthy (and not falsy) then it is better to not use an equality operator at all.

For example, because of type coercion., 1 == true is true, but 1 === true is false. The == operator can hide type errors.

In this context the term is both legitimate and useful.

As a further illustration of true and false in this context these cases are illustrative.

'' == '0' // false
0 == '' // true
0 == '0' // true

false == 'false' // false
false == '0' // true

false == undefined // false
false == null // false
null == undefined // true

' \t\r\n ' == 0 // true


问:
"Release Early Release Often" for Android and iPhone Apps
I wanted to know the experiences others have about doing the Agile way of "Release Early, Release Often" with iPhone and Android Apps. Its not a problem with webapps as the update happens at the server and user does not have to do anything specific for updates

It may not be a big problem with Android, as the approval process is smooth compared to iPhone app store.

Can someone share the experiences/suggestions/examples they've for releasing early and often to Android and iPhone markets?

答:
There are two differences between releasing on your own or releasing through Apples App Store:

It takes 1-3 weeks to get approved for updates. Often one week, sometimes two, occasionally three.

You run the risk of having your update rejected for one reason or another, thus having to redo the release again. Approving rejections is quick (1-5 days)

So all this makes it impossible to make controlled releases quicker than three weeks. You are forced to plan your releases and deadlines much more thorough.

OwnerDisplayName: leenasn


答:
I found two Oracle-published documents that discuss the naming of packages. There is the Naming a Package page in the Java Tutorials and the Packages section of the Java Language Specification.

The primary purpose of this convention is to try to minimize conflicts between packages published by different organizations.


答: I've written a system that would determine the (mathematical) chance of a boolean statement being true, given partial data. I.e. we could determine that there was a 73% chance of X being true, if we didn't have sufficient data yet to establish firmly that X was true. "Truthiness" would be a perfectly valid way to describe such a percentage belief in X.


问:
Why aren't VM languages compiled just once?
(First of all, I should make clear that compilers and virtual machines (aka) are a completely unknown field for me)

As I understand it, every time a Java/C#/... application is run, a VM is invoked and translates intermediate code (bytecode, CIL, etc) to machine instructions.

But why can't this operation done only once - at install time?

答:
To rephrase the question in accordance with the clarification:

Why can't the bytecode be compiled down to native code the first time the program is run?

I see the following problems:

Where would the results be stored? You can't assume that the file containing the bytecode is writable; you don't want to bloat a developer's machine by dumping a new .exe to permanent storage each time he runs a test; and if you store the file in temporary storage then it will be lost the next time you reboot, so you haven't gained much.

You're trading away a slightly slow startup every time for a very slow startup the first time. Not going to leave a great impression with the client.

You're going to have significant trouble with dynamic classloading.


答:
"Truthiness" is something I make sure I understand when I'm picking up a new language, as they all deal with it differently. In my home-base first language of Perl, the string "0" is false. In many languages, that is a string that has content and is therefore true. In some languages the empty string "" is false, and in some it's true.

Understanding the choices that the language designers made about truthiness tells you a lot about their thinking, and starts to dip you into the conceptual universe of the language.

Whether we spelled it "truthiness" or used some other term (I think the header for that chapter in the Camel Book is "What Is Truth?"), programmers had a grip on varying values of the absolute thing called "true and false" long before Colbert came along and pointed out the bending of "true" in the public discourse.


问:
Does having pagination lessens server load? (theory)
I was wondering what is the reason behind pagination? Is it used because it lessens the burden on the servers since we would technically limit the amount of rows returned per page?

I wanted to do something without pagination but given that I am new to this (I am an amateur) started wondering if its OK technically or not.

答:
There are a number of reasons for having pagination, reducing server load is just one. However, Stephen Orr raises a valid point - you still need to find the amount of data first. You have to make sure that that query is quick and doesn't unduly load your server.

Other reasons include:

Reducing the amount of data returned to the client in one go. If you have a lot of data this could take some considerable amount of time and take up a lot of memory.

The user often isn't interested in all the data, but only the most recent (say). By returning only a couple of pages of data you aren't getting data the user is never going to see.

In both of these cases you don't want to make the user wait - either for data they aren't going to view, or for all the data when they could be getting one with processing some of it.


答:
I'd like to debunk this "Apple's approval process is like running a gauntlet" business.

No app I've ever submitted has taken more than seven days to be approved.

In my experience, if you're careful and aware, you'll have no problem getting approved. Half a million apps or so have been approved, and my experience is, you really have to try to not get approved. And of course, whining on a blog about it is a good attention-getter and leaves people afraid and concerned, rather than just being professional about the requirements of the platform.

My policy with iPhone apps IS to release early and often. The only exception is if there's some big, game-changing feature the app has that you don't want to show your hand about. If the marketing plan calls for something splashy on release, you don't want to have put out a crippled early version of it first. That's probably true on all platforms.

Title: "Release Early Release Often" for Android and iPhone Apps

Body:
I wanted to know the experiences others have about doing the Agile way of "Release Early, Release Often" with iPhone and Android Apps. Its not a problem with webapps as the update happens at the server and user does not have to do anything specific for updates

It may not be a big problem with Android, as the approval process is smooth compared to iPhone app store.

Can someone share the experiences/suggestions/examples they've for releasing early and often to Android and iPhone markets?


答:
It varies depending on implementation.

It will speed up rendering of a page, but it won't necessarily reduce the load on the server. Most naive pagination algorithms need to perform a query first to decide how many pages there should be, then query again to get the "paged" result set.

Title: Does having pagination lessens server load? (theory)

Body:
I was wondering what is the reason behind pagination? Is it used because it lessens the burden on the servers since we would technically limit the amount of rows returned per page?

I wanted to do something without pagination but given that I am new to this (I am an amateur) started wondering if its OK technically or not.


问:
iPad app architecture with very large files
I am working on an iPad app.  It needs to contain some very large files.  I could put them into the app, but they would push it well over 20MB, which means that it would not be downloadable over the air -- only via iTunes.

Is there a way around this without too much pain for me?  I don't have a server or anything like that.

答: I'm for embedding, as long as your app provides sufficient value to justify the download. If so, people will be fine waiting for it. If not... why are you making it?</p>


答:
Pagination, to my mind, is the mother of all premature optimisations. It is absolutely ok to write your site without pagination.

If you find, after release, that you are loading too much data in one call, or that your users are having to wait for information that they do want because it's busy loading data they don't want, go ahead and write an Ajax solution which only loads the page as people scroll down (see: Twitter, Tumblr, Google image search).

Edit: The second paragraph above was written with the assumption that a common response would be "but if you know you are going to paginate at some point, you may as well do it early, rather than waste time developing something you are going to throw away."

As well as being the mother of all premature optimisations, I think that pagination is a UX nightmare and that there are better solutions which wouldn't require much extra development on top of the complete page.

Despite the number of downvotes, I am leaving this answer here because I stand by the sentiment, even though it may not have been my best writing.


问:
How to handle "X" data sets as input
I participated in a coding competition today, and I found that almost all of the command line input our programs needed to receive would start with an integer representing the amount of data sets to follow.  There were 6 different problems, and they all started this way.

For example, one sample problem had:
"Input to this problem will begin with a line containing a single integer N (1 <= N <= 100) indicating the number of data sets.  Each data set consists of the following components:

A line containing a single integer W that specifies the number of wormholes

A series of W lines containing....

etc.
"

Pretty much all the competition problems had this format, with the first integer representing the amount of data sets to follow.

My initial reaction (and the way I tried to solve the problem) was just using a vector of size N, where each element represented a data set.  Trouble is, there are a whole bunch of things in these data sets.  Using this approach often left me with a vector of vector of vectors (maybe an exaggeration but you get the idea) which was very hard to manage.

Another idea was looping through the entire program N times, but this doesn't always seem that applicable.

I realize this is a vague question, but that's because I'm looking for a general solution to this type of problem.  What is the best approach to handling this type of input?

答:
The common solution that I've used was to write a function that would read 1 data set from an input file, and solve that. Then, in the main loop, I'd read the first line, extract how many data sets there were, and call for(1..N) {Solve(inputfile);}

I didn't put all problems in a single data structure, because each data set was a standalone input. The fact that they're all in the same file is just a convenience.

Title: How to handle "X" data sets as input


问:
What is the actual problem with a prototype based design?
I feel like anything that can be developed using OO/functional languages can be generally made 'better' using a prototype based language, because they appaer to have the best of them all: high order functions, flexibility to simulate any OO structure, productivity (low verbosity) and scalability because of concurrency. But it seems like they are avoided for the creation of executable applications and of bigger projects in general. Why that?</p>

答:
OK, let's put aside the debate of native vs JIT, and static vs dynamic. Suppose we take as a given that someone wants to use a dynamic JIT-ed language, like java, python or javascript. Why do they choose a language with classical inheritance instead of one with prototypal inheritance?

The dominant reason is because javascript is not very suited to large systems programming and javascript is the only prototypal language popular enough to get "C-level" approval for a new project. Javascript is bad for large systems programming because it lacks a strict typing mechanism. In large systems you rely on API's to abstract implementation details. Strict typing moves the responsibility of correctly addressing API's from the developer to the compiler. You want the compiler to do that job.

A second reason is because classical inheritance is what most programmers know and have been trained on, and prototypal inheritance is too weird for them. Never underestimate how much "popularity" factors into technical decisions.

Performance does not factor into the decision. Large systems are programmed in java every day, and javascript V8 is roughly in the same performance order-of-magnitude as java (3 times slower in synthetic benchmarks).


问:
Should I choose Doctrine 2 or Propel 1.5/1.6, and why?
I'd like to hear from those who have used Doctrine 2 (or later) and Propel 1.5 (or later). Most comparisons between these two object relational mappers are based on old versions -- Doctrine 1 versus Propel 1.3/1.4, and both ORMs went through significant redesigns in their recent revisions. For example, most of the criticism of Propel seems to center around the "ModelName Peer" classes, which are deprecated in 1.5 in any case.

Here's what I've accumulated so far (And I've tried to make this list as balanced as possible...):

Propel

Pros

Extremely IDE friendly, because actual code is generated, instead of relying on PHP magic methods. This means IDE features like code completion are actually helpful.

Fast (In terms of database usage -- no runtime introspection is done on the database)

Clean migration between schema versions (at least in the 1.6 beta)

Can generate PHP 5.3 models (i.e. namespaces)

Easy to chain a lot of things into a single database query with things like useXxx methods. (See the "code completion" video above)

Cons

Requires an extra build step, namely building the model classes.

Generated code needs rebuilt whenever Propel version is changed, a setting is changed, or the schema changes. <s>This might be unintuitive to some and custom methods applied to the model are lost. (I think?)</s> -- Not true; custom methods aren't lost because the generated class is a base class; Propel provides an entity class specifically for extension.

Some useful features (i.e. version behavior, schema migrations) are in beta status.

Doctrine

Pros

More popular

Doctrine Query Language can express potentially more complicated relationships between data than easily possible with Propel's ActiveRecord strategy.

Easier to add reusable behaviors when compared with Propel.

DocBlock based commenting for building the schema is embedded in the actual PHP instead of a separate XML file.

Uses PHP 5.3 Namespaces everywhere

Cons

Requires learning an entirely new programming language (Doctrine Query Language)

Implemented in terms of "magic methods" in several places, making IDE autocomplete worthless.

Requires database introspection and thus is slightly slower than Propel by default; caching can remove this but the caching adds considerable complexity.

Fewer behaviors are included in the core codebase. Several features Propel provides out of the box (such as Nested Set) are available only through extensions.

Freakin' HUGE :)

This I have gleaned though only through reading the documentation available for both tools -- I've not actually built anything yet.

I'd like to hear from those who have used both tools though, to share their experience on pros/cons of each library, and what their recommendation is at this point :)

答:
I recommend you Propel because it's well integrated, fast, and powerful.
To generate code is better than to load classes on runtime, it eases debug steps and shows you what you've created. So the build step is not à problem.

Doctrine2 has no official behaviors, and the DataMapper design pattern is cool but hard to use in real life. Oh and DQL is a pain, yet aborder language to learn...

If you want to think with objects (no DQL/SQL/whatever), choose Propel.

Doctrine2 is part of Symfony2 de facto but things will move very soon, look at the last Fabien Potencier article.

Cheers,
William


答:
Ada is still heavily used in defense, mission critical, safety critical, real time, embedded systems.

Therefore: Trains, Railways, Planes, Air traffic Control, Satellites, Medical Systems, Nuclear Power Plants etc

for a recent use of ada see : this

Title: is Ada really gone?

Body:
Do people still use Ada -- (it was mostly used in the Defense Department)

Are all applications written in Ada "Legacy"?

Does Ada knowledge still sell


问:
What license is applicable for an app based on CodeIgniter?
I am trying to fork an application that is based on CodeIgniter. According to the GoogleCode page, the license is GPLv3. However, examining the license.txt file inside the root directory of the application is very clearly not GPL (it does not include the preamble etc.) and looks like a slightly modified version of the BSD License specifying that a copy of the license and all copyrights must be included with a changelog, as well as some indemnity clauses.

The confusing part is that within several of the actual php files they include another license in the comments. This license is a verbatim copy of the 2-clause BSD license, but below this BSD license there is a series of @tags, and the @license one has a link to the GPL 2.0 so it is unclear to me what license applies to this application. Finally, I have found no mention anywhere that the project is dual/multi-licensed. Also, the project has not been under active development for over 2 years. Can anyone shed any light on this (or point me in the direction of resources that could)? Thanks.

答:
2 tools to consider to help with complying with open source software licenses:

http://www.sonatype.com/Products/Sonatype-Insight

http://www.blackducksoftware.com/

(I don't work for either of them).


问:
Why did memory-managed languages like Java, Javascript, and C# retain the `new` keyword?
The new keyword in languages like Java, Javascript, and C# creates a new instance of a class.

This syntax seems to have been inherited from C++, where new is used specifically to allocate a new instance of a class on the heap, and return a pointer to the new instance.  In C++, this is not the only way to construct an object. You can also construct an object on the stack, without using new - and in fact, this way of constructing objects is much more common in C++.

So, coming from a C++ background, the new keyword in languages like Java, Javascript, and C# seemed natural and obvious to me.  Then I started to learn Python, which doesn't have the new keyword.  In Python, an instance is constructed simply by calling the constructor, like:

```<code>f = Foo()
</code>```

At first, this seemed a bit off to me, until it occurred to me that there's no reason for Python to have new, because everything is an object so there's no need to disambiguate between various constructor syntaxes.

But then I thought - what's really the point of new in Java?  Why should we say Object o = new Object();?  Why not just Object o = Object();?  In C++ there's definitely a need for new, since we need to distinguish between allocating on the heap and allocating on the stack, but in Java all objects are constructed on the heap, so why even have the new keyword?  The same question could be asked for Javascript.  In C#, which I'm much less familiar with, I think new may have some purpose in terms of distinguishing between object types and value types, but I'm not sure.

Regardless, it seems to me that many languages which came after C++ simply "inherited" the new keyword - without really needing it.  It's almost like a vestigial keyword.  We don't seem to need it for any reason, and yet it's there.

Question: Am I correct about this?  Or is there some compelling reason that new needs to be in C++-inspired memory-managed languages like Java, Javascript and C# but not Python?

答:
I'm not sure whether Java designers had this in mind but when you think of objects as recursive records, then you could imagine that Foo(123) doesn't returns an object but a function whose fixpoint is the object being created (ie. function that would return the object if it's given as argument the object being constructed). And the purpose of new is to "tie the knot" and return that fixpoint. In other words new would make the "object-to-be" aware of its self.

This kind of approach could help formalizing inheritance for example: you could extend an object-function with another object-function and finally provide them with common self by using new:

```<code>cp = new (Colored("Blue") & Line(0, 0, 100, 100))
</code>```

Here & combines two object-functions.

In this case new could be defined as:

```<code>def new(objectFunction) {
    actualObject = objectFunction(actualObject)
    return actualObject
}
</code>```

Body:
I'm not sure whether Java designers had this in mind but when you think of objects as recursive records, then you could imagine that Foo(123) doesn't returns an object but a function whose fixpoint is the object being created (ie. function that would return the object if it's given as argument the object being constructed). And the purpose of new is to "tie the knot" and return that fixpoint. In other words new would make the "object-to-be" aware of its self.

This kind of approach could help formalizing inheritance for example: you could extend an object-function with another object-function and finally provide them with common self by using new:

cp = new (Colored("Blue") & Line(0, 0, 100, 100))

Here & combines two object-functions.

In this case new could be defined as:

def new(objectFunction) {
    actualObject = objectFunction(actualObject)
    return actualObject
}


问:
Ideas for Offline & Sync Across Multiple Platforms
I'm looking for some implementation ideas to be able to have offline apps sync data to a central server.  The server will be Sql Server 2008. The clients will download data from the server when internet access is available and will need to allow the user to make changes offline and then sync the changes back to the server when it becomes available again. The clients will come in multiple flavors ranging from Windows to Android, so whatever I use needs to be easily translated into multiple OSes.

I have been looking at using Microsoft's Odata (odata.org) on the server. It looks to have some pretty neat features and appears to even partially support what I want (by means of a concurrency token) -- though I'm not sure how the logic would revolve around the use of this token yet, that's what I hope to get from this.

So - my question is this:  Is there a 3rd party tool or app that I can use on multiple platforms which can handle offline & sync scenarios? If not, can anyone provide me with ideas on how to implement logic for syncing data back to a server and handle things like conflicts, etc.?

答:
You would be able to achieve this using the entity framework with disconnected entities. The entities can dan be published via a data service (e.g WCF using the HTTP api) to create a RESTfull service interface that can be consumed from the various platforms you're describing. The format in which you deliver these obejects is up to you, JSON would be a good one.

Upon posting back an entity you can then re-attach those to the ObjectContext which in turn will sort out the state of the object(new,changed,deleted, etc.) and can persist the changes.

Using sync framework is out of scope since it's not supported on non microsoft platforms. See FAQ  http://msdn.microsoft.com/en-us/sync/bb906054


问:
What's The Difference Between Imperative, Procedural and Structured Programming?
By researching around (books, Wikipedia, similar questions on SE, etc) I came to understand that Imperative programming is one of the major programming paradigms, where you describe a series of commands (or statements) for the computer to execute (so you pretty much order it to take specific actions, hence the name "imperative"). So far so good.

Procedural programming, on the other hand, is a specific type (or subset) of Imperative programming, where you use procedures (i.e., functions) to describe the commands the computer should perform.

First question: Is there an Imperative programming language which is not procedural? In other words, can you have Imperative programming without procedures?

Update: This first question seems to be answered. A language CAN be imperative without being procedural or structured. An example is pure Assembly language.

Then you also have Structured programming, which seems to be another type (or subset) of Imperative programming, which emerged to remove the reliance on the GOTO statement.

Second question: What is the difference between procedural and structured programming? Can you have one without the other, and vice-versa? Can we say procedural programming is a subset of structured programming, as in the image?

答:
First question: Yes, many pure object-oriented languages qualify. While they have methods, which are very close to functions, they view these methods in terms of messages and do not give them enough weight to call the language procedural.

Second question: The difference is often in a different scope. You can have a function with goto statements all over the place, which will be in procedural style, but not structured programming. On the other hand, most OO languages support and encouraged structured programming, but not procedural programming.

Procedural programming describes the global ordering of the program. Procedural programs are those that are most effectively understood by looking at their call graphs. Structural programming is a local property, it applies to the use of if and while as opposed to goto.

As such, these two properties are disjunct, you can have either one without the other.


答:
Many of the terms can be reused (often misused) about programming languages, especially those other than object oriented ones.

Here are some small descriptions of the terms.

Imperative programming -
In good old days, when programming was broadly in assembly, code would have tons of GOTOs. Even higher level languages like FORTRAN and BASIC began using the same primitives. In this programming paradigm, the entire program is a single algorithm or complete functionality written linearly - step-by-step. This is imperative style. Understand that one can really write totally bad imperative work even in modern C language as well but it is quite easy to organize code in higher level languages.

Structured and Modular programming -
Most often we should be able to use the term interchangeably but with subtle differences. When higher level languages begun to get richer, one realized that all units of work should be broken into smaller tractable parts - that is when functions came into existence and programming became a hierarchy of functions and many at lower level could be re-used.

Structured programming is any programming when functionality is divided into units like for loop, while loop, if... then etc block structure.

Also, here the a piece of code (function) can be re-used.

In modular programming, one can create a physical form of package - i.e. a chunk of code that can be shipped; which are fairly general purpose and re-usable. This is called modules of elements compiled together.

So one can hardly see modular programs which are not structured and vice versa; the technical definition is subtly different but mostly structured code can be made modular and other way.

Then came "object oriented programming" which is well defined in literature. Understand that object oriented programming is a form of structured programming by definition. The new name for all those function based code which is structured code but NOT object oriented is often called as Procedural programming.

So basically structured code where functions (or procedures) dominate over data is called procedural whereas class and object based representation is called object oriented. Both by definition are also modular.

Many people think - all of structured programming (maybe skipping Object based) as imperative programming; I guess this is only due to lack of clear definition of imperative programming - but it is wrong. You are doing structured programming when you are not doing much imperative ones! But I can still write a lot of functions as well as a lot of goto statements inside C or FORTRAN program to mixup.

To be specific to your questions:

First Question :
Pure assembly language is imperative language which is NOT structured or procedural. (Having step by step interpretive control flow doesn't mean procedural - but division of functionality into functions is what makes a language procedural).

correction * Most modern forms of assembly DO support the use of functions. In fact, everything that's possible in high level code HAS to exist low level to work. Although it's a far better practice to create procedural code, it's possible to write both procedural and imperative code. Unlike the latter, it's more maintainable and easier to understand (avoiding horrible spaghetti code). I think there are shell/bash scripts that better fit the accolade of being purely imperative, but even then, most have functions, developers definitely understand how much value they have.

Second Question :
Procedural programming is a FORM of structured programming.

BONUS

According to some taxonomy the primary classification is Declarative (or functional language) vs. Imperative. Declarative languages allow computation without describing its control flow whereas imperative is where explicit control flow (step-by-step) is defined. Based on this classification, Imperative programing, for some can be a super-set of structured, modular and OO programming.  See this: Functional Programming vs. OOP

After Object oriented, there have been other programming paradigms invented:
See here for more details: What are the differences between aspect-oriented, subject-oriented, and role-oriented programming?

Title: What's The Difference Between Imperative, Procedural and Structured Programming?

Body:
By researching around (books, Wikipedia, similar questions on SE, etc) I came to understand that Imperative programming is one of the major programming paradigms, where you describe a series of commands (or statements) for the computer to execute (so you pretty much order it to take specific actions, hence the name "imperative"). So far so good.

Procedural programming, on the other hand, is a specific type (or subset) of Imperative programming, where you use procedures (i.e., functions) to describe the commands the computer should perform.

First question: Is there an Imperative programming language which is not procedural? In other words, can you have Imperative programming without procedures?

Update: This first question seems to be answered. A language CAN be imperative without being procedural or structured. An example is pure Assembly language.

Then you also have Structured programming, which seems to be another type (or subset) of Imperative programming, which emerged to remove the reliance on the GOTO statement.

Second question: What is the difference between procedural and structured programming? Can you have one without the other, and vice-versa? Can we say procedural programming is a subset of structured programming, as in the image?


问:
Stuff every programmer needs while working
I've been tasked with creating a fun and relaxing environment, one thing I know that I want is ergonomic mice and keyboards, others have suggested exercise balls and bands.

What is it that every programmer needs while working? What might not be necessary but would be nice to have anyway?

Note: this question was asked previously, but has been recommended to be posted here. See this link for the previous responses: https://stackoverflow.com/questions/3911911/stuff-every-programmer-needs-while-working-closed

答:
Quiet.

Low light.

A steady and never-ending supply of soda, or other caffeinated beverage of choice, never more than an arms-length away.

A computer fast enough that you don't leave the zone while waiting for a compiler or debugger to finish. Obviously for larger projects this becomes difficult, but ideally I never ever wait on the computer.


问:
Can code be the documentation in open source developer tools? How frequently is it?
It's understandable that after a big development effort, some OSS authors deem reasonable that the project users should make an effort too in order to get started.

Can the source code effectively be the project's documentation? Does it need to be structured in a particular way in order to achieve this? And how often is this approach taken?

Of course this only would be feasible if the project is aimed to developers, and written in the same targeted language of the application (e.g. you can't understand the V8 engine only knowing JavaScript).

答:
NHibernate is OSS. You can download the source code for free, make your own changes, recompile it, push that source code back to the VCS, etc etc. Does Ayende require you to dig through the code, and that of Castle's DynamicProxy, in order to effectively use his library to implement your persistence layer? Of course not. The NHibernate community provides a pretty good set of documentation and best practices for using the NHibernate library. Similarly, the Fluent NH add-on has decent documentation; you don't have to dig through the library's code to figure out what it does and how to use it.

In short, even OSS should conform to the "black box principle" from the perspective of the end user.

Coders expect their libraries to be packaged much like their electronic equipment: they expect to receive an instruction manual along with this "black box", that tells them how to hook it up and how to communicate with it. If they don't receive a manual, the smarter among them will look at what does come in the package, will expect to see very clear labels for where things plug in to it, and will assume no specialized knowledge is required for operation once it is set up properly. If neither of these is true, the coder will likely be calling the library's developers for help, much like you'd be calling tech support if you didn't have all the info you needed to set up your TiVo. The last thing you would do is crack the seal on a brand-new, warrantied piece of equipment and try to trace through it yourself, much like the last thing the coder would do is pull up and trace through the library's source code for a clue as to its inner workings.

Similarly, OSS projects that aren't effectively documented in some other way than code fall into one of three categories:

infant projects - the documentation is simply not yet well-developed because the focus is on proof-of-concept and thus working code. Users of the code at this stage are "beta" testers, and understand its "as-is" nature on all fronts including documentation.

extremely simple - the stated purpose of the library, the names and signatures of the classes and class members as viewed from some object browser or by JavaDocing the JAR, plus maybe a simple demo, tell the user all they need to know.

dead or dying - nobody wants to take the time to figure out how to use the library by trial and error, or by inspection, so nobody's using it.


答:
Source code is not a documentation.

I have seen too many (excellent) projects with no documentation, only source code and some tutorials. My latest example is Lutece (a French CMS : I spent a lot of time to understand how to use it, and what I can do with it. It was horrible).

Ideally, documentation would be written when you are developing your application. Unfortunately, a lot of people don't write any documentation (not Javadoc for Java projects, ...), and think contributors will write tutorials, wikis, documentations. If there is no initial documentation, nobody will try to help you, nor discover your work.

If you can make a good documentation, and if you have enough time, please, make it ;)

Title: Can code be the documentation in open source developer tools? How frequently is it?

Body:
It's understandable that after a big development effort, some OSS authors deem reasonable that the project users should make an effort too in order to get started.

Can the source code effectively be the project's documentation? Does it need to be structured in a particular way in order to achieve this? And how often is this approach taken?

Of course this only would be feasible if the project is aimed to developers, and written in the same targeted language of the application (e.g. you can't understand the V8 engine only knowing JavaScript).


问:
What are some useful resources for learning tuple calculus?
I've been trying to go over my tuple calculus over and over again. What's worse is that my professor and tutors are not much help during their hours.

Does anyone know a good place to learn about tuple calculus? I'm having a hard time understanding how to "speak" the language in terms of what I want to get from a database.

答:
May I recommend Tutorial D?  Rel, an implementation thereof is an abstract set of operations for your tuples or record-level structures.

I know you want a LOT of detail on this, but I'm glad to hear questions, I am writing a school-aged text on relational algebra, hopefully to get some folks interested earlier...


问:
Which DVCS (git or hg) is easier for programming students?
A bit of context: I'm in 3rd year of college. students are divided into teams of 4. Almost everyone will be working under windows (except a few like me who are on linux). As part of the school curriculum, we will soon start working on a project for a real client, but me and another team are wondering which way would be best for sharing our code with each other.

I've been working part-time for 3 years and have had plenty of experience using both git and mercurial on different projects, so I don't have any problems using one system or the other.  However, none of my teammates have ever used a version control system before. There's also another team who've tried using SVN but have had major problems and would prefer trying out something else, so they've asked for my opinion.

My thoughts : I've heard that mercurial + TortoiseHg has a better integration under windows, but I'm wondering if the concept of anonymous heads might confuse them even If I explain them. On the other hand, I find that git branches are easier for a beginner to understand (clear seperation of work for each programmer) but doesn't work as well under windows.

答:
As many people have suggested, Mercurial via TortoiseHg has a very low barrier to entry.

For those on Windows it's a single installer rather than two installers (and a whole load of stuff they might not want to learn about) and the THg user interface is much more polished than TortoiseGit+Msysgit.

Anonymous heads

If you think they would be confused by anonymous heads, then don't encourage their use. Most hg books take a balanced approach and teach both topological and named branches, and let the reader determine which is most appropriate for their use.

Named branches

One thing I really miss in git is hg's named branches, so that's one option. git branches are fine while you are working on them, but once you've merged that work into another branch, you lose much of the context for those changes.

In hg you could create a branch called Jira#1234 and always be able to find all of the revisions associated with that fix. In git, once your branch is merged in and the ref deleted, you have to infer which revisions were part of the fix from the topology of the revision tree. Even if you don't delete the ref, you still only know the last commit on that branch, not which of it's ancestors were part of that chain of commits.

Bookmarks

Alternatively, if you don't want to use named branches, but want a git style workflow with your anonymous branches, then you can use bookmarks instead.

This could be the best of both worlds - they get to learn a git workflow, but get to use the simpler hg commands.

Index/Cache/Staging area

Personally, I think students are far more likely to be confused by the git's index/cache/staging area than by hg's anonymous heads. I much prefer hg making this advanced functionality optional on the command line, over the way git assumes you always want/need to use it.

I also think that the staging area encourages commits which haven't been tested or even compiled. Since many of the places I've worked have had a don't commit if it doesn't compile rule, I would much rather shelve/stash changes I don't want right now, re-run unit tests and commit a version that I know compiles.

When you later come to track down a bug using hg bisect or git bisect, you will thank yourself that you can test all of the revisions, not just the ones that compile.


答:
To those that complain about speed and scalability ask these questions:

How fast does it need to be.  I'm talking requirements here, not generalities (full page must respond in 1s kind of detail)

How many users are going to use this sytstem now, how many in 5 years.

Will it interface with other systems and if so how.

The answers to the above questions will greatly influence your decision.  You don't need C++ speeds for probably 95% of applications out there, maybe more.  As for scalability.  Less than 1/10000 of 1% of applications will ever scale to google/ebay/amazon levels.  Most, probably less than 1% will scale to the point that you have more than 100 requests per second, even in enterprise.

Now if you work for say AOL or Google, then by all means speed and scalability likely matter, for the rest of us, not so much so, it's a lot more important to get it done and get it done fast at the lowest possible cost.

Title: What is the actual problem with a prototype based design?

Body: I feel like anything that can be developed using OO/functional languages can be generally made 'better' using a prototype based language, because they appaer to have the best of them all: high order functions, flexibility to simulate any OO structure, productivity (low verbosity) and scalability because of concurrency. But it seems like they are avoided for the creation of executable applications and of bigger projects in general. Why that?</p>


答:
No, I don't think code should be documentation. And I don't think it matters that much whether or not it's an open-source project.

A lack of documentation (other than the code itself) will be a turn-off to many potential users and contributors. I've ditched or avoided using some libraries for other open-source libraries simply because the very scant tutorials were far too simplistic (real business uses were more complex and needed featuers that were never clearly explained or documented) and the API documentation amounted to little more than function: SetParamX() - This sets param X. Code alone also does not easily capture higher-level business requirements or specifications, such as param X must be a valid subnet mask, unless param Y is set to "foo". To infer this requirement, you might have to read through 100 lines of code and jump through 3 or 4 layers of method calls to find out exactly what this requirement is.

How eager would you be to work on a project that you have decipher yourself from only the code? I know I wouldn't, whether it's an open source project, or some internal corporate project. At least with internal projects (at least here), this is rarely but not never) a problem - and if it did happen with an internal project, I could probably find the person who wrote the code and ask them questions.


答:
The word documentation means many things - and for most open source projects that's a problem.

While leaving aside many details, i would primarily classify it in three parts -

End user documentation - where people are likely to only use the end product. By far the most common and minimum you find in OSS projects is 'man page'.

API documentation - here you assume that people are looking at the internals of your modules but only as a black box - mostly by linking the libraries. (e.g. use a video codec library to build your own media player).
One of the excellent examples is GNOME, GTK documentation for application developers.

Developer documentation - here is where you assume that people are actually going to contribute towards the core internal logic to enhance it or scale it.

The need and method to create all three types of documentation is different.

The end-user level documentation certainly cannot be done inside the code. Typically these are external documents like user manual; they cannot be inside the code (even if they are carried inside the tar.gz of the source codes).

The API documentation can often be done (and usually best done) using doxygen kind of framework - where comments above the functions can be translated into fully formatted pages. This way, efforts of formatting is saved and consistency is achieved - while documentation's core details are still handwritten. Also, we can see that when API evolves or become un-compatible, modifying comments can help make new version documentation easier.
Another such thing i have seen is to write a small - "api_example.c" file that explains how to use it. For most medium size projects this is enough.

Last but most important is the design documentation that explains the inner workings of the code. Hard to say but this is rare even in professionally paid companies. Many a companies prefer to make "design documents" somewhere outside the code but unfortunately as code evolves these remains disconnected from the docs. In such scenario, having lot of comments - and comments on top of comments actually help much better. It is usually NOT complete - but most often, if the developer is intelligent enough, what really matters is to comments all the non-obvious parts in plenty. This approach always works much better.

In fact keeping this in mind - one should care fully draft higher level documents only to explain terminology and broader business logic and leave the details explained inside the code (and let it evolve along with code). External documents almost always never evolve as fast as code - so they should be limited on dependencies and details.

Dipan.


答:
If you want the OSS project to be a success you really should provide ample documentation for the users.  Most OSS projects have a relatively small user base that cares to delve into the code.

If I am not directly contributing to the project in some way then the only time I look at the source code is when I feel that I have discovered a bug and wish to either fix it myself or notify the project of the bug I had found and where in the code I feel the problem is.

I can't say how many times I have evaluated a complex OSS project to find no substaintial documentation whatsoever.  Many times if I have another more transparent choice I will go in that direction partly because I don't wish to spend days of trial and error figuring out how to use it, or because I feel the project is too "green" or too "amateurish" to commit to.


问:
How to spend less time on debugging?
Following the Pareto rule, a programmer spends only 20% of his time for really useful things.

I spend 80% of my time debugging, fixing small things to get everything working.

Is there a way to spend less time debugging?

答: The best way to decrease debugging, IMO, is by concentrating and slowing down when coding. This forces you to see mistakes you may have made!</p>

Title: How to spend less time on debugging?


答:
Unit testing.

After I started applying unit testing I found that the code I wrote became better structured. It was then easier to avoid and spot bugs. I spent less time debugging, but more time with writing unit test.

I also think that the time invested in unit tests has a better return of investment then debugging. After a debugging session I just fixed the code. The same bug can appear weeks later and I have to debug again. If I write a unit test the bug is documented as a unit test and later acts as a regression test. If the bug appears again the unit tests reveals this to me.

Title: How to spend less time on debugging?

Body:
Following the Pareto rule, a programmer spends only 20% of his time for really useful things.

I spend 80% of my time debugging, fixing small things to get everything working.

Is there a way to spend less time debugging?


答:
My 80% is debug. I am fixing simple bugs and trying to make all
  working.

Start by writing unit tests, and try to have as high coverage as possible. Someone mentioned TDD, but I would go with BDD.

At the end, you'll most likely spend 80% on debuging complex bugs.

Title: How to spend less time on debugging?


问:
Learning Each Type of Programming Language
I have heard several times that every programmer should learn one of each type of language. Now, this is not necessarily true, but I believe it is a good idea.

I've learned a Procedural Language (Perl), but what are the other types?

What are the differences between them and what are some examples of each?

答:
There are several different programming paradigms that are currently in vogue:

Object Oriented - VB.NET, C#, Java fall into this category. Code is arranged around objects that have behavior and related data and that communicate with each other by passing messages.

Functional - Haskel, Scheme, Lisp and F# fall into this category. Pure functions that do not have side-effects. Think functions like in maths. Often one can extend the language itself through its constructs.


问:
Why are parser generators used?
I saw some projects require BISON to generate C++ code. What is the advantage of having BISON/Yacc etc. generate C/C++ code instead of writing it yourself?</p>

答:
If you know the grammar you need to parse, it's much faster to get working code by simply feeding that grammar to a parser generator and use suitable call-outs from that than to hand-code a parser.

If, however, you have a poorly-described file format you need to parse, it may be about as much work to hand-roll a parser as it would be to figure out the grammar, describe it to the parser generator and then get a parser.

Hopefully, you're closer to the first paragraph than the second.

Title: Why are parser generators used?


答:
Prolog is a logic programming language and is relatively easy to get started with. It requires a completely different thinking than procedural programming therefore it is good to explore when you are trying to stretch your brain.

If you go to college, you should take a course on Programming Languages as it is geared towards introducing the different types of programming languages and what they are best used for.

Title: Learning Each Type of Programming Language

Body:
I have heard several times that every programmer should learn one of each type of language. Now, this is not necessarily true, but I believe it is a good idea.

I've learned a Procedural Language (Perl), but what are the other types?

What are the differences between them and what are some examples of each?


答:
Even though terminology is far from standardized, a common way to is categorize major programming paradigms into

Procedural

Functional

Logical

Object-Oriented

Generic

You seem to already know what procedural programming is like.

In functional languages functions are treated as first-class objects.  In other words, you can pass a function as an argument to another function, or a function may return another function.  Functional paradigm is based on lambda calculus, and examples of functional languages are LISP, Scheme, and Haskel.  Interestingly, JavaScript also supports functional programming.

In logical programming you define predicates which describe relationships between entities, such as president(Obama, USA) or president(Medvedev, Russia).  These predicates can get very complicated and involve variables, not just literal values.  Once you have specified all your predicates, you can ask questions of your system, and get logically consistent answers.

The big idea in logical programming is that instead of telling the computer how to calculate things, you tell it what things are.  Example: PROLOG.

Object-oriented paradigm is in some ways an extension of procedural programming.  In procedural programming you have your data, which can be primitive types, like integers and floats, compound types, like arrays or lists, and user-defined types, like structures.  You also have your procedures, that operate on the data.  In contrast, in OO you have objects, which include both data and procedures.  This lets you have nice things like encapsulation, inheritance, and polymorphism.  Examples: Smalltalk, C++, Java, C#.

Generic programming was first introduced in Ada in 1983, and became widespread after the introduction of templates in C++.  This is the idea that you can write code without specifying actual data types that it operates on, and have the compiler figure it out.  For example instead of writing

```<code>void swap(int, int);
void swap(float, float);
....
</code>```

you would write

```<code>void swap(T, T);
</code>```

once, and have the compiler generate specific code for whatever T might be, when swap() is actually used in the code.

Generic programming is supported to varying degrees by C++, Java, and C#.

It is important to note that many languages, such as C++, support multiple paradigms.  It is also true that even when a language is said to support a particular paradigm, it may not support all the paradigm's features.  Not to mention that there is a lot of disagreement as to which features are required for a particular paradigm.

Body:
Even though terminology is far from standardized, a common way to is categorize major programming paradigms into

Procedural

Functional

Logical

Object-Oriented

Generic

You seem to already know what procedural programming is like.

In functional languages functions are treated as first-class objects.  In other words, you can pass a function as an argument to another function, or a function may return another function.  Functional paradigm is based on lambda calculus, and examples of functional languages are LISP, Scheme, and Haskel.  Interestingly, JavaScript also supports functional programming.

In logical programming you define predicates which describe relationships between entities, such as president(Obama, USA) or president(Medvedev, Russia).  These predicates can get very complicated and involve variables, not just literal values.  Once you have specified all your predicates, you can ask questions of your system, and get logically consistent answers.

The big idea in logical programming is that instead of telling the computer how to calculate things, you tell it what things are.  Example: PROLOG.

Object-oriented paradigm is in some ways an extension of procedural programming.  In procedural programming you have your data, which can be primitive types, like integers and floats, compound types, like arrays or lists, and user-defined types, like structures.  You also have your procedures, that operate on the data.  In contrast, in OO you have objects, which include both data and procedures.  This lets you have nice things like encapsulation, inheritance, and polymorphism.  Examples: Smalltalk, C++, Java, C#.

Generic programming was first introduced in Ada in 1983, and became widespread after the introduction of templates in C++.  This is the idea that you can write code without specifying actual data types that it operates on, and have the compiler figure it out.  For example instead of writing

void swap(int, int);
void swap(float, float);
....

you would write

void swap(T, T);

once, and have the compiler generate specific code for whatever T might be, when swap() is actually used in the code.

Generic programming is supported to varying degrees by C++, Java, and C#.

It is important to note that many languages, such as C++, support multiple paradigms.  It is also true that even when a language is said to support a particular paradigm, it may not support all the paradigm's features.  Not to mention that there is a lot of disagreement as to which features are required for a particular paradigm.


问:
What to do when allowing application to run in an invalid state?
We currently have a 'global catch all exceptions' section in our application.  When an uncaught exception is thrown, the stack trace is displayed and the application continues running.

More often than not, this leaves the state of the application invalid going forward.  Especially with NullReferenceExceptions, and threading exceptions being the cause.

I decided to have the application log the exception in the 'global' section and shutdown and restart.  This was met with criticism from management - who asserted that the user should choose to select whether or not to restart under these conditions, since it never shut down before.  (Though I tried my best to explain that the issue was allowing the app to continue running in the first place).

I am looking for things to watch out for now, and specific approaches I can take to handle code that is now allowed to continue to run while in an invalid state.

答:
I can understand the point that your application managers are trying to make, that simply shutting down or restarting immediately upon encountering an unexpected error can confuse a user.  You always want to give the user information about what happened and if possible give them a choice on how they would like to handle it.

You may also want to try and localize the problem to a particular component that may perhaps be reloaded or re-synced so as to prevent other working areas of the application from needing to be brought down?

On the other hand, if by them continuing to work and possibly corrupting persisted data which could cause future problems for themselves or others, OR if this bad or corrupted data needs manual intervention to clean up in some way then you have a case for shutting the application down as soon as possible.  Just make sure that it is informative and graceful (... as graceful as an application crash could possibly be :)

Perhaps your efforts are better focused on stabilizing the application to where unexpected exceptions occur far less, and expected exceptions occur far greater.


答:
Unit testing, so that you know whether your code works in the first place.

At least some amount of upfront design, so that you know what you are coding.

Code reviews, because two heads are better than one, and four eyes are better than two.  Not to mention that even trying to explain your code to someone else reveals many problems.

Version control, so that you can quickly isolate which changes may have caused the bug.

Refactoring, so that you code does not turn into a horrible incomprehensible mess.

Read "Clean Code" by Robert C. Martin, and do what he tells you.  You will be amazed by the results.

Title: How to spend less time on debugging?


答: Understand the what and the why before you start writing code.  Then use a methodology consistently.  Which methodology you choose is not nearly as important as consistent repeated use of the methodology.  If you want consistently good results, you need to do consistently good work and having a "method to your madness" is the first step to getting these results.  As you identify issues you can adjust your methodology as needed and over time you will improve your development process, and hopefully fewer bugs and more new, meaningful development.</p>

Title: How to spend less time on debugging?


问:
Work Item Traceability in TFS 2010
I have created a Windows Form project (VS solution) under a TFS 2010 project. I may eventually add more solutions to the TFS project.

My question: Can we create a Use Case WIT for a specific solution within a TFS project? Furthermore, is it possible to create a "traceability matrix" that starts at the Use Case level and goes down to the the code level (at least the namespace level) of that particular VS solution?

答:
Additionally, TFS 2010 allows for several different kinds of links between Work Items. Very common is the Parent / Child. Using TFS Out of the Box with the Agile Process Template you can link User Stories to Tasks, and Tasks to Change Sets. Once you find a Bug, you can Link that back to a User Story and once you resolve the Bug, you can associate with a specific change set.

Reporting on this is a little more difficult because I'm not aware of a "traceability matrix" report, but since all the data is in a SQL server, you can query it from SQL Enterprise Manager.

Title: Work Item Traceability in TFS 2010


问:
What keywords are important to speedup the code in C++?
I'm porting to C++ and adding a lot of functionality to a numerical application written in Fortran 77. While I hate F77, I have to admit that the thing goes very fast. Now, I'm implementing practically the same structure and algorithm, but nevertheless the difference in the execution time is noticeable. Not big, but it's there. And I'm wondering, could it be that I need to pass extra information to the compiler? The only related information that I've been able to find is a recommendation to use the restrict key word which is supported by g++, but that's all. Hence, my question: Are there anymore keywords important to speedup code in C++ in numerical applications? or maybe compiler directives?

Thanks!

答:
The first thing you should do is profile, to see which specific piece of code is responsible for the slowdown.

As far as the keywords, inline might be a good one to use.


问:
Using a SetProperty method to prevent accidental changes to a property
Is it good/bad practice to do the following:

```<code>public class MyClass {
  public MyType MyProperty { get; private set; }

  public void SetMyProperty(MyType myProperty) {
    MyProperty = myProperty;
  }
}
</code>```

My intention is to prevent MyProperty from being accidentally changed outside the class. However, it can be changed if needed.

Also, if MyType is a reference type, then will the private set prevent, for example:

```<code>instanceOfMyClass.MyProperty.SomeField = 2;
</code>```

In other words, will it make MyProperty and all its members readonly, or just the reference to MyProperty?

Sorry if this seems an unintelligent question; I'm afraid I'm a beginner.

答:
Having a private setter is a perfectly valid practice and I do this often myself. This is part of encapsulation, which is one of the foundations of OOP.

However, providing a public method for setting is rather pointless - if you want to be able to set the value, use a public setter.

As you asked, having a private setter will not allow the value of the underlying field to change outside of the class (the compiler generates one for you - there is still an underlying field). This is unless you provide public functions that will cause changes to this value.


答:
My intention is to prevent MyProperty from being accidentally changed outside the class. However, it can be changed if needed.

I'm not seeing the point of doing this, to be honest. Calling

```<code>myClass.MyProperty = new MyType();
</code>```

is not any less intentional than calling

```<code>myClass.SetMyProperty(new MyType());
</code>```

In terms of readability, I think you're far better off going with the more intuitive setter approach instead of a separate method. And if you don't want to allow anyone to change the value of MyProperty, then don't allow it either via a setter or a method.

In other words, will it make MyProperty and all its fields readonly, or just the reference to MyProperty?

Just the reference to MyProperty. MyType has to be an immutable type if you want to prevent people from changing its properties.

Title: Using a SetProperty method to prevent accidental changes to a property

Body:
Is it good/bad practice to do the following:

```<code>public class MyClass {
  public MyType MyProperty { get; private set; }

  public void SetMyProperty(MyType myProperty) {
    MyProperty = myProperty;
  }
}
</code>```

My intention is to prevent MyProperty from being accidentally changed outside the class. However, it can be changed if needed.

Also, if MyType is a reference type, then will the private set prevent, for example:

```<code>instanceOfMyClass.MyProperty.SomeField = 2;
</code>```

In other words, will it make MyProperty and all its members readonly, or just the reference to MyProperty?

Sorry if this seems an unintelligent question; I'm afraid I'm a beginner.

Body:
My intention is to prevent MyProperty from being accidentally changed outside the class. However, it can be changed if needed.

I'm not seeing the point of doing this, to be honest. Calling

myClass.MyProperty = new MyType();

is not any less intentional than calling

myClass.SetMyProperty(new MyType());

In terms of readability, I think you're far better off going with the more intuitive setter approach instead of a separate method. And if you don't want to allow anyone to change the value of MyProperty, then don't allow it either via a setter or a method.

In other words, will it make MyProperty and all its fields readonly, or just the reference to MyProperty?

Just the reference to MyProperty. MyType has to be an immutable type if you want to prevent people from changing its properties.


答:
If I wanted to use "SetProperty" methods all day, I'd program in java.

Additionally, if you have a public get property, even if that property has a private set, the property's value's members can be changed. Some classes provide "read only" wrappers to solve this concern, such as the many of the array class: http://msdn.microsoft.com/en-us/library/53kysx7b.aspx


答:
If you had to narrow it down to one keyword, it would probably be template. Unfortunately, applying that (at all well) will require some study. Applying it as well as possible (e.g., using expression templates) will require quite a lot of study.

For some ideas of how to write competitive numerical code in C++, you might want to look at some existing libraries such as blitz++ and Boost uBLAS.

Title: What keywords are important to speedup the code in C++?

Body:
I'm porting to C++ and adding a lot of functionality to a numerical application written in Fortran 77. While I hate F77, I have to admit that the thing goes very fast. Now, I'm implementing practically the same structure and algorithm, but nevertheless the difference in the execution time is noticeable. Not big, but it's there. And I'm wondering, could it be that I need to pass extra information to the compiler? The only related information that I've been able to find is a recommendation to use the restrict key word which is supported by g++, but that's all. Hence, my question: Are there anymore keywords important to speedup code in C++ in numerical applications? or maybe compiler directives?

Thanks!