答:
I can understand not being allowed to talk about the specific technology or work that you're doing (NDAs are a part of the game when you're dealing with IP). However, to not be allowed to tell anyone that you're even working for him? That's just bad business (almost sounds like the guy's outsourcing you for his own job).

You're being used. Cut your ties now.

You might be getting a few extra bucks here and there with these projects but in the long run, they are going to do absolutely nothing for your career.

Title: How do I decide whether to take a job I can't add to my portfolio?

Body:
I am a programmer, but since I've barely been in the professional market my portfolio is rather bare right now. Still, I started to try and get my website up and running to help a little bit, but what I really need right now is to be able to expand my portfolio.

I have a guy who wants me to do a lot of work for him, and I'm willing to do it for a while at least until I can get better jobs. The real problem, though, is that he does not want me to tell anyone that I have been doing work for him. Naturally, since I'm both trying to earn money and expand my portfolio, this poses a problem.

Part of the reason for doing an app was to prove I can develop one, but if I can't tell anyone I wrote it, then developing the app seems pointless; I may be better off creating my own app and eating the loss in profit because I can get more work out of it, but of course, at the same time, I'm in desperate need of cash. I do have jobs lined up elsewhere, but I'll likely get paid faster through doing this specific job.

What factors should I be looking at when making a decision on whether or not I should take a job for money that I can't talk about?


问:
How do I decide whether to take a job I can't add to my portfolio?
I am a programmer, but since I've barely been in the professional market my portfolio is rather bare right now. Still, I started to try and get my website up and running to help a little bit, but what I really need right now is to be able to expand my portfolio.

I have a guy who wants me to do a lot of work for him, and I'm willing to do it for a while at least until I can get better jobs. The real problem, though, is that he does not want me to tell anyone that I have been doing work for him. Naturally, since I'm both trying to earn money and expand my portfolio, this poses a problem.

Part of the reason for doing an app was to prove I can develop one, but if I can't tell anyone I wrote it, then developing the app seems pointless; I may be better off creating my own app and eating the loss in profit because I can get more work out of it, but of course, at the same time, I'm in desperate need of cash. I do have jobs lined up elsewhere, but I'll likely get paid faster through doing this specific job.

What factors should I be looking at when making a decision on whether or not I should take a job for money that I can't talk about?

答:
This guy already sounds like trouble. Get out early, before you end up doing a lot of work you might not get paid for.

The real question is, how easy was it to get work in the first place? It doesn't sound like you're hurting for other work too much, so don't feel like this is the only job you're going to get off of oDesk and accept contracts with more reasonable conditions. Don't be blinded by the money, and in future jobs, mention your portfolio site upfront and negotiate a more reasonable way to be able to list your previous work.

You mentioned rates like $15/hr. That's not a lot of money in programming, and keep in mind that once you've built up a portfolio site comprised of several individual jobs, you'll not only have more experience under your belt, but have the outward facing prior work to justify being able to charge higher rates.

ContentLicense: CC BY-SA 3.0


问:
emacs - project explorer and auto complete features - is it available?
I know that Emacs is a very powerful editor out there. I try to use it occasionally and want to learn it better. But to learn it better i have to use it more frequently than I am using now.

But one big obstacle is that I could not find the basic properties like a project auto completion. Maybe I am lazy but I dont want to write again and again the same long method names.
Another one is go to definition stuff, I want to see the real declaration of any class or method or even a variable.

Also I know that it can handle the make files but an actual representation of a project alongside the editor would be very good.
So, what I am asking is, is there a way to provide these options in Emacs? Or is there an extended version of Emacs that supports these features?

答:
There is CEDET which provides all of that sort of stuff, I should add that I havent used it myself.

I personally find dabbrev-expand (M-/ by default) as useful, if not more, than language aware auto-completes, being able to complete in comments or from comments or code which currently won't compile is very useful.


答:
You need money, and if the conditions for this job are the you can't tell others, then don't. Whether it's in the contract or not, it's clear the work will end if you discuss it. You could take him to court, but that probably won't help much.

It is extremely common for subcontractors to work under non-disclosure agreements that mean you can't tell others about the actual work or customer, but you can usually talk about the type of work or project in more general terms.

If he's subcontracting you to someone else, well it's up to those two what they charge and pay for.

I suggest you look for other work. Ask them upfront for permission to include it in your portfolio, and say why; some will be happy for a bit of extra publicity. Others will say no, and that's fine. If you're really short of cash, stay with this guy but start looking now. In any case you're gaining a lot of useful experience.


答:
I'd been doing work for him quite a bit before I mentioned that I was
  going to set up my portfolio website soon (this was about two weeks
  ago) at which point he told me (for the first time ever) that he does
  not let anyone know who works for him. He even managed to get me a job
  with someone else who used his system, but the catch was that I had to
  work THROUGH him. I couldn't go directly to the other guy. It should
  be noted that he got me this job BEFORE telling me that he didn't let
  anyone know who worked for him.

If he didn't mention it before you started, and it's not in the relevant contract, then it's tough bananas for him. You can't just add terms into an agreement in the middle.

Secondly, it's extremely fishy. I'd be very suspect of anyone who wants to maintain secrecy about who they employ.


问:
Using Paypal (or similar) to log into my site?
I have a web site and I want to offer a few levels of service - one free, one for a one-off payment, and one for a subscription.  My first inclination is to use Paypal for the payment options.  I understand that I can make some login page on my site where you create an account or login to an existing account, and then I can make an API call to Paypal to see what they've paid for and give them the appropriate level of access, and redirect to Paypal for them to pay for the access they want.  I'm not sure yet if the free service will require a login or not.

But having read Joel Spolsky's and Bruce Schnier's blogs, I'm conscious of how hard it is to do authentication right, and what a pain it is for users to have to create an account or login to my site, and then create an account or login to Paypal.  Is there a way to use Paypal's login system directly, so they login to Paypal and Paypal sends me back a token saying who they are and what they've paid for?  That kind of sounds like almost an OpenID, or something similar?

答:
It's possible that not all user's have PayPal so if you want to use them for authentication it's best to have some other options such as FaceBook or OpenID. That way the users using the free option will be more comfortable than having to use PayPal up front where they might think they could be charged and may opt out.

But there is an option (Paypal Account Authentication) to do what you're suggesting, but it looks like it is a new thing and not widely used or accepted yet for application authentication.  They also state that it's not intended as a federated identity or single sign-on as is OpenID.


问:
When should I start learning a PHP Framework
I'm a beginner programmer

I have been learning PHP for a while, though not consistently. But for the past few months (say 3 months) I have been a bit consistent in my learning, largely because of a project a friend ask me to do for him since he knew I was into web design. Though I struggled to complete the tiny project for him after about 3 weeks, because I got stuck some times and I have to look up tutorials/references relating to the problem I was trying to solve, but I feel fulfilled been able to accomplish a project and along the way grab most of PHP basics.

My interest in Web development has grew higher since completing that project and I have been trying to learn PHP/MySQL as fast as I could, because the same friend want me to do something else for him, which to me is way beyond the basics I know. Though I don't charge him anything, but it gives me a sense of fulfillment.

I want to learn a framework, because I heard it can make you accomplish more as a web developer and makes life much easier.

Can I learn a framework without having OOP knowledge?
I know how to create and use functions, though I don't use it much

I know my question is not straight forward, but I know you will understand were I'm coming from and advice me appropriately. I wish to become a professional Web Developer.

I really need your professional advice.

答: Yes, I think one should learn a framework in whichever web language they are using, even if it's just for open source or hobby work.  I think the amount of OOP needed depends on the framework itself, but that is also good knowledge to have. Probably best is to learn a popular framework as it helps when you collaborate with others on projects. The frameworks also help to avoid the trap of writing hard-to-maintain "spaghetti" code. Even on your own projects you will become the maintainer of legacy code.</p>


答:
In PHP, most frameworks use both OOP and MVC pattern. It means that you have to know both. Maybe not know them very well, but at least have a basic idea of what are those things, what are their strong points and weaknesses and how to use them.

As for when you should start learning a framework, for PHP, I would say use PHP framework as soon as possible, for several reasons:

PHP by itself is a language which does everything to encourage you to write bad quality code. Different PHP frameworks try, on the other hand, to, not force, but encourage you to write a better code.

A framework provides an abstraction. It means that:

You'll write less code most of the time,

You'll see some minor performance issues.

This means that:

It is a good idea to use a PHP framework most of the time, unless you're really sure that it doesn't worth it and you will be faster writing a native PHP code with no framework at all,

The PHP framework may not be a solution for very large websites requiring high performance. Chances are you will not work on those projects very often, and if you do, you will first have to profile your code to determine that the bottleneck is the framework itself.

Title: When should I start learning a PHP Framework

Body:
I'm a beginner programmer

I have been learning PHP for a while, though not consistently. But for the past few months (say 3 months) I have been a bit consistent in my learning, largely because of a project a friend ask me to do for him since he knew I was into web design. Though I struggled to complete the tiny project for him after about 3 weeks, because I got stuck some times and I have to look up tutorials/references relating to the problem I was trying to solve, but I feel fulfilled been able to accomplish a project and along the way grab most of PHP basics.

My interest in Web development has grew higher since completing that project and I have been trying to learn PHP/MySQL as fast as I could, because the same friend want me to do something else for him, which to me is way beyond the basics I know. Though I don't charge him anything, but it gives me a sense of fulfillment.

I want to learn a framework, because I heard it can make you accomplish more as a web developer and makes life much easier.

Can I learn a framework without having OOP knowledge?
I know how to create and use functions, though I don't use it much

I know my question is not straight forward, but I know you will understand were I'm coming from and advice me appropriately. I wish to become a professional Web Developer.

I really need your professional advice.


答:
My first concern would be: Is this clause in the contract ?

If:

you don't have a contract

the clause is not the contract

then it's invalid.

It seems fishy, really...

I would advise that you refrain from comfronting him, but move the hell out of here as soon as you can.

Also, I would avoid in your stead to speak about this experience with your future employers. Employers ask for verifiable references and this guy will undoubtely not back you up here, so there is no point in confusing future employers.


问:
AGPL-compatible license
I am using a java library licensed under AGPL3.
However, I would like to license my own work as BSD, such that my code could then be integrated in proprietary projects if one strips the library. Will I be allowed to do that?

So far, I couldn't find a clear answer for my problem on the net or in the license text(not a lawyer). Dual-licensing seems cumbersome and ugly.

EDIT: What happens if I use other libraries which are licensed under BSD or anything else?

答:
Here's a quote from the Licensing section of the GNU website:

It has always been the FSF's position
  that dynamically linking applications
  to libraries creates a single work
  derived from both the library code and
  the application code. The GPL requires
  that all derivative works be licensed
  under the GPL, an effect which can be
  described as “hereditary.” So, if an
  application links to a library
  licensed under the GPL, the
  application too must be licensed under
  the GPL.

(the specific page is discussing Java and LGPL, but the general point applies here)

If you want to license your original application as BSD, you must first create it without using that library at all.

Then, you can create a derivative work by combining your BSD application and the AGPL3 library, with the whole thing licensed as AGPL3.

This would effectively be a new, different application, and is not dual-licensing.

Since you want your BSD application to be used commercially, you would need to release it separately from the extended AGPL3 version of the application - which means two distinct links on your download page, with a clear explanation on the difference.

(NOTE: Anywhere I use "BSD" in this answer, it's important to note this refers to the "modified BSD" not the original BSD.)

What happens if I use other libraries which are licensed under BSD or anything else?

That's fine. So long as the license allows for the code to be re-released under a compatible license and the AGPLv3 is considered compatible (which the BSD is - see a full list here), then you've got no problem.

If you plan on using lots of libraries/etc then it's a good idea to maintain a distinct credits file, where you can list each specific component you use, its website address, licensing requirements, and so on.

(usual disclaimer: I'm not a lawyer, follow at own risk, etc)

Title: AGPL-compatible license

ContentLicense: CC BY-SA 2.5


答: Eclim is a completion package which uses Eclipse as a backend for completion and it has an emacs frontend too, so it combines the power of Eclipse's language support with the power of the Emacs interface.</p>

Title: emacs - project explorer and auto complete features - is it available?

Body:
I know that Emacs is a very powerful editor out there. I try to use it occasionally and want to learn it better. But to learn it better i have to use it more frequently than I am using now.

But one big obstacle is that I could not find the basic properties like a project auto completion. Maybe I am lazy but I dont want to write again and again the same long method names.
Another one is go to definition stuff, I want to see the real declaration of any class or method or even a variable.

Also I know that it can handle the make files but an actual representation of a project alongside the editor would be very good.
So, what I am asking is, is there a way to provide these options in Emacs? Or is there an extended version of Emacs that supports these features?


问:
Comparison of operator overloading abuse in different languages
A common argument against operator overloading is that it can be and is abused, e.g. A+B doing something completely different to addition. Examples are often quoted in C++ snippets, where the functions overloading the operators don't name the operators (e.g. operator+()). Compare this to Python, where the operators are named (e.g. __add__).

Does this help to deter programmers from abusing overloading in the aforementioned manner? Anyone have any experiences of Python operator overloading being abused?

答:
I haven't try much languages, neither Python, but, in case of C++ / Java / c# I think support for operator overloading is confusing, and maybe bad implemented.

In C++, a bad example is the "<<" and ">>" operators for streams, I acutally avoid using them.

Maybe you would want to rephrase your question like "How do I avoid operator overloading in Python or other languages ?".

Many times, If I using Object Oriented programming, and need to overload and operator, I rather use functions instead of operators.


问:
Reference website for CSS 3 properties (like box-reflect)
Today, I started reading the book CSS Mastery 2nd edition. It is really a good book for anyone who is interested in learning some techniques. On page 151, I discovered the box-reflect property from CSS3. I tried to find out more information about which browser suports it and the syntax of the property, but I only found a site that didn't explain much.

Can anyone please provide me with a link to a website that is up to date regarding the CSS3 elements? The site should also contain information about browser-support for the different elements. I'm primarily interested in the box-reflect property and to update my knowledge of CSS3 properties.

答:
The definitive source, really, is http://www.w3.org/Style/CSS/. However, this doesn't include vendor-specific implementations.

For vendor-specific implementations, check out http://peter.sh/experiments/vendor-prefixed-css-property-overview/.


答:
Whatever the client has added ex post facto (that's the extent of my legal-ese) is inconsequential. The client can only add contractual obligations going forward. And, pay specific attention to how the client defines telling others about the work you do (for him) ...

I was in the intelligence branch of the US military so I don't question when someone asks for discretion. In this case, if it were me, I would do the work and take his money. That said, if I am not able to provide a link to the client's site for my portfolio, I would adapt:

Make a demo on your own site that performs like functionality to what you provided the client. You have displayed your skill and expertise without exposing anything directly linked to the client.


答:
Like Demian said, the best source is the official W3 CSS page.

Here you can find compatibility issues.

And here's an online editor to automatically write cross browser css rules.

Title: Reference website for CSS 3 properties (like box-reflect)

Body:
Today, I started reading the book CSS Mastery 2nd edition. It is really a good book for anyone who is interested in learning some techniques. On page 151, I discovered the box-reflect property from CSS3. I tried to find out more information about which browser suports it and the syntax of the property, but I only found a site that didn't explain much.

Can anyone please provide me with a link to a website that is up to date regarding the CSS3 elements? The site should also contain information about browser-support for the different elements. I'm primarily interested in the box-reflect property and to update my knowledge of CSS3 properties.


答:
Sometimes a developer starts a project, thinking he will not require any help. And, eventually, realize he/she can't get the project by itself.

Maybe he doesn't wants its customer company, to know that he required help, for "professional capacity", been too much proud. But, I also know a lot of companies, that hire a software company for an ammount of money, and eventually try to hire the developers, trying to pay a lot of less money (been "cheap").

Is there a contract (and clause) about your project participation ?

Consider 2 things, How are you going to deal with this particular project ("correction"), and how are you going to deal with future projects ("prevention").

I usually take snapshots of my projects, when I have to go to another, and ask for a "portafolio", I show the snapshots. I don't take code, because its "code theft".

I have been in job interviews where the interviewers insist in seen real code, sometimes its because they are testing if the candidate steals code.

I have been in a case where a company was customer of a previous Software Consulting employer, in which we where making a website. The customer & the consulting companies break the contract.

Months later, I was call by the customer, when I already left the consulting company, and, in the job interview they want me to get the source code of the project. I asked them I don't have it, but I could make a new better website. They didn't want, and Insist If I know someone else that they could get the source code. I leave inmediatly.

Hope it helps.


问:
Under what circumstances are flowcharts still a valuable and useful tool?
When I first started programming, I relied heavily on flowcharts (and printer spacing charts). While I was in COBOL class, I couldn't start writing any code until my flowchart was signed off by the instructor. Back then, I had to make flowchart for everything.

Today, twenty-five years later, I find myself only flowcharting two types of things. Very specific algorithms where the logic is tricky or very general concepts to ensure that I get all the big steps defined and in the proper order.

Are there other use cases for flowcharts that I've simply overlooked?

答: Flowcharts are useful when things need to be done in a specific order. Where they really shine in my mind is showing where decisions are made and making sure that each possible decision has a path. This prevent creating programs where a mamager approval is required but have no way to deal with it if the manager (who approves 98% of the time) says no. They remind us that the most common path is not the only path. I find them  useful in talking to users about requirements because often they will only tell you the most common path.</p>


问:
Could spending time on Programmers.SE or Stack Overflow be substitute of good programming books for a non-beginner?
Could spending time (and actively participating) on Programmers.SE and Stack Overflow help me improve my programming skills any close to what spending time on reading a book like Code Complete 2 (which would otherwise be next in my reading list) will help.

Ok, may be the answer to this question for someone who is beginning with programming might be a straight no, but I'd like to add that this question I'm asking in context when the person is familiar with programming languages but wants to improve his programming skills. I was reading this question on SO and also this book has been recommended by many others (including Jeff and Joel).

To be more specific, I'd also add that even though I do programming in C, Java, Python,etc but still I'm not happy with my coding skills and reading the review of CC2 I realized I still need to improve a lot.

So, basically I want to know what's the best way for me to improve programming skills -  spend more time on here/SO or continue with CC2 and may be come here as and when time permits.

答: As you answered yourself, no, but spending time here is a useful adjunct to more structured learning.  I wouldn't depend on it standalone as there may be gaps in some concepts that may not be covered.  One of your best bets for improving your coding for guys at the intermediate level is reading other good developer's code by spending time on GitHub or other open-source repository. </p>


答:
Your programming skills is improved the best not by reading web sites or books, but by repeating

write code based on current knowledge

evaluate result

learn from evaluation about what to do and what not to do.

go to 1

Practice makes perfect.  What looks nice on a blog or in a book may prove to be cumbersome to use for some reason not understood by the blog writer, or that the book author didn't cover.

Title: Could spending time on Programmers.SE or Stack Overflow be substitute of good programming books for a non-beginner?

Body:
Could spending time (and actively participating) on Programmers.SE and Stack Overflow help me improve my programming skills any close to what spending time on reading a book like Code Complete 2 (which would otherwise be next in my reading list) will help.

Ok, may be the answer to this question for someone who is beginning with programming might be a straight no, but I'd like to add that this question I'm asking in context when the person is familiar with programming languages but wants to improve his programming skills. I was reading this question on SO and also this book has been recommended by many others (including Jeff and Joel).

To be more specific, I'd also add that even though I do programming in C, Java, Python,etc but still I'm not happy with my coding skills and reading the review of CC2 I realized I still need to improve a lot.

So, basically I want to know what's the best way for me to improve programming skills -  spend more time on here/SO or continue with CC2 and may be come here as and when time permits.


答:
No, it is not a substitute, but a perfect complement. I feel a combination of the two holds a lot of power.

Why is it that a good lecture teaches you more than just reading a book? Interaction and the ability to ask questions.

By just reading a book, some questions might pop up to which you can't find any answers. Look for those questions here, or ask them if they haven't been discussed before.


答:
Learning needs some ingredients:

Learner (which is of course you)

Time (which you should manage and dedicate)

Resources (from which, SE sites are only a small portion)

Are you a good learner? Do you spend enough time on learning? If the answer of these 2 questions are yes, then you already have enough potential to learn almost from any resource.

But to answer your question, yeah, I personally learned a lot from SE sites. IMHO, they shouldn't become your only learning source, but they are beneficial.


答:
Even if you use PayPal authentication, you still need to store lots of information about your users, if you want to act professionally and provide high-level, worthy service. Consider SE sites for example. While they provide almost all kinds of authentication mechanisms, they still store a very good amount of data for each user, including his/her questions, badges, tags, etc.

Talking from my own experience, I think a day comes when you need to implement your own solution. Thus I suggest you create it, instead of trying to reuse it.

Also keep in mind that PayPal (or OpenID in general) is an external service and it might be filtered in some countries, and it might have some special policies in other countries. This means that instead of defining your own business, you should follow their business. In other words, I think you shouldn't become dependent on external resources, or you get engaged in issues which are not related to programming at all, and are in nature law-based issues, unless you have a lawyer at your service.

Title: Using Paypal (or similar) to log into my site?

Body:
I have a web site and I want to offer a few levels of service - one free, one for a one-off payment, and one for a subscription.  My first inclination is to use Paypal for the payment options.  I understand that I can make some login page on my site where you create an account or login to an existing account, and then I can make an API call to Paypal to see what they've paid for and give them the appropriate level of access, and redirect to Paypal for them to pay for the access they want.  I'm not sure yet if the free service will require a login or not.

But having read Joel Spolsky's and Bruce Schnier's blogs, I'm conscious of how hard it is to do authentication right, and what a pain it is for users to have to create an account or login to my site, and then create an account or login to Paypal.  Is there a way to use Paypal's login system directly, so they login to Paypal and Paypal sends me back a token saying who they are and what they've paid for?  That kind of sounds like almost an OpenID, or something similar?


答:
```<code>Does this help to deter programmers from abusing overloading
in the aforementioned manner?
</code>```

Well, I think first we should define what the abuse is? File.Delete in C# simply deletes a file without even notifying the user about it. Thus, as a developer, I can simply write this code:

```<code>List<string> files = Directory.GetFile("path").ToList();
files.ForEach(f => {
    File.Delete(f);
});
</code>```

Is it considered abuse? OK, you're free to define + symbol (character) as an operator which votes up and - as a vote-down operator. But is it considered abuse?

Also, are you forced to misuse these features? For example, a driver can simply turn the wheel to get to pedestrian area and kill may people? Should we lock the wheel?

I mean, after all, even if there is an opportunity for any kind of abuse, who's gonna get hurt? Developer.

In spite of highly OO infrastructure, you can write procedurally in C#. Is it abuse?

Title: Comparison of operator overloading abuse in different languages

Body:
A common argument against operator overloading is that it can be and is abused, e.g. A+B doing something completely different to addition. Examples are often quoted in C++ snippets, where the functions overloading the operators don't name the operators (e.g. operator+()). Compare this to Python, where the operators are named (e.g. __add__).

Does this help to deter programmers from abusing overloading in the aforementioned manner? Anyone have any experiences of Python operator overloading being abused?

Body:
Does this help to deter programmers from abusing overloading
in the aforementioned manner?

Well, I think first we should define what the abuse is? File.Delete in C# simply deletes a file without even notifying the user about it. Thus, as a developer, I can simply write this code:

List<string> files = Directory.GetFile("path").ToList();
files.ForEach(f => {
    File.Delete(f);
});

Is it considered abuse? OK, you're free to define + symbol (character) as an operator which votes up and - as a vote-down operator. But is it considered abuse?

Also, are you forced to misuse these features? For example, a driver can simply turn the wheel to get to pedestrian area and kill may people? Should we lock the wheel?

I mean, after all, even if there is an opportunity for any kind of abuse, who's gonna get hurt? Developer.

In spite of highly OO infrastructure, you can write procedurally in C#. Is it abuse?


答:
It doesn't make any difference.  It may be that Python programmers are less prone to abusing operator overloading.  If that is true, it is due to the skill of the programmers, not the difference in syntax.

For a time, C++ was being used by a huge number of commercial programmers writing in-house Windows applications.  It's a powerful language designed by experts for experts.  It's no surprise that its features were widely misunderstood and abused.

Any language feature, including operator overloading, can be used badly.  Removing (or barring the use of) a language features won't prevent poor programmers from coding badly, just as removing words from English won't prevent bad writers from writing badly.   Instead, it will frustrate good programmers, forcing them to work around the missing feature.


答:
You can do the same things with function names, like using list.next () to return the length of the list, or list.length () to return a boolean.

A difference is, that we have strong expectations from math, that

```<code>a + b == b + a
</code>```

which is, for example, violated in String concatenation, but I never meet a person, who had problems to accept + as concatenation operator, and who expected "foo" + "bar" to return "barfoo".

In my opinion it is an argument from phantasy. Yes - we can imagine things go wrong, but in reality, they don't occur.

Another pitfall would be to expect

```<code>a + b * c to be evaluated a + (b * c), and
(a + b) * c to be the same as (a*c) + (b*c)
</code>```

But is it a problem in reality? I don't think so.

Body:
You can do the same things with function names, like using list.next () to return the length of the list, or list.length () to return a boolean.

A difference is, that we have strong expectations from math, that

a + b == b + a

which is, for example, violated in String concatenation, but I never meet a person, who had problems to accept + as concatenation operator, and who expected "foo" + "bar" to return "barfoo".

In my opinion it is an argument from phantasy. Yes - we can imagine things go wrong, but in reality, they don't occur.

Another pitfall would be to expect

a + b * c to be evaluated a + (b * c), and
(a + b) * c to be the same as (a*c) + (b*c)

But is it a problem in reality? I don't think so.


答:
Definition

First you need to define abuse in this context.

To me this means re-defining the operators so that they do not work intuitively for anybody reading the code.

But of course intuitively is also dependent on the context, but not only the context but the classes that are involved. So it boils down too will the use of operator overloading make the code harder to read or lead to any misunderstanding by somebody naively reading the code without understanding the full context.

```<code>Matrix   x;
Matrix   y;
Matrix   z  = x * y; // Is this abuse.
</code>```

That depends. Is your primary audience mathematicians (or smart CS students). If yes then the this is not abuse but tidy short hand. If your primary audience is an English Literature professor then maybe you should have written it like this:

```<code>WordUsage      Hamlet;
WordUsage      Othello;
WordUsage      Shakespeare = Hamlet.DeduceLoveCorrelation(Othello);
           // OK that was not clear to me but I am not an Literature buff.
           // But to a literature person those identifiers may mean something.
</code>```

Usage

So in C++ you can redefine the operators to do anything (C++ gives you a lot of flexibility (but this is also how the stream operators were introduced)). So abuse can turn into common usage if the idiom is accepted by the community as useful shortcut.

Does this help to deter programmers from abusing overloading in the aforementioned manner?

Does making it more convoluted to define operator overloading deter abuse. No. Its not as if using  __add __ is any less hard than using operator+().

Anyone have any experiences of Python operator overloading being abused?

I think the python community has learned from the abuse and subsequent press about abuse that C++ had over a decade ago. When C++ came out it was the first mainstream  language that allowed overloading of operators and people went hog wild experiment with the concept. This lead to a lot of frustration from maintainers and articles about overloading operators is an abuse (which led to a backlash and languages like Java banning them for no good reason (other than the author was swayed by public opinion).

Note: A couple of less popular language did it first (operator overloading) but they were mainly used by sensible people in research establishments. So either they were smart enough not to abuse the operators, or there research was so narrow that few bothered to read their code and thus it got no press.

Body:
Definition

First you need to define abuse in this context.

To me this means re-defining the operators so that they do not work intuitively for anybody reading the code.

But of course intuitively is also dependent on the context, but not only the context but the classes that are involved. So it boils down too will the use of operator overloading make the code harder to read or lead to any misunderstanding by somebody naively reading the code without understanding the full context.

Matrix   x;
Matrix   y;
Matrix   z  = x * y; // Is this abuse.

That depends. Is your primary audience mathematicians (or smart CS students). If yes then the this is not abuse but tidy short hand. If your primary audience is an English Literature professor then maybe you should have written it like this:

WordUsage      Hamlet;
WordUsage      Othello;
WordUsage      Shakespeare = Hamlet.DeduceLoveCorrelation(Othello);
           // OK that was not clear to me but I am not an Literature buff.
           // But to a literature person those identifiers may mean something.

Usage

So in C++ you can redefine the operators to do anything (C++ gives you a lot of flexibility (but this is also how the stream operators were introduced)). So abuse can turn into common usage if the idiom is accepted by the community as useful shortcut.

Does this help to deter programmers from abusing overloading in the aforementioned manner?

Does making it more convoluted to define operator overloading deter abuse. No. Its not as if using  __add __ is any less hard than using operator+().

Anyone have any experiences of Python operator overloading being abused?

I think the python community has learned from the abuse and subsequent press about abuse that C++ had over a decade ago. When C++ came out it was the first mainstream  language that allowed overloading of operators and people went hog wild experiment with the concept. This lead to a lot of frustration from maintainers and articles about overloading operators is an abuse (which led to a backlash and languages like Java banning them for no good reason (other than the author was swayed by public opinion).

Note: A couple of less popular language did it first (operator overloading) but they were mainly used by sensible people in research establishments. So either they were smart enough not to abuse the operators, or there research was so narrow that few bothered to read their code and thus it got no press.


答:
The abuse, or misuse, of the operator overloading depends from who writes the code, not from the syntax used by the programming language.

To make an example, if overloading the + operator to make it not commutative were considered a bad practice, the compiler (or the interpreter) could not do anything to avoid you create a non commutative version of the + operator, as it doesn't check if the result of a + b is equal to the result of b + a.

If the programmers that use a specific programming language consider a bad practice to overload the + operator to make a non-commutative version, then they will not overload that operator to use it as concatenation operator for strings.


答:
I've (currently) been a member of StackOverflow for 1 year and 10 months. During this time I have become a disciplined student of the art: cognizant of architecture, patterns, decoupling, unit-testing, and the list could go on ...but, what role did SO play???

First, it answered my immediate questions. But as I began to explore SO, I discovered that I was a very bad programmer. Desiring to be an artisan at my craft, I bought books ...but it wasn't C# Unleashed, Learn C# Programming, or other sub-standard beginner text that I needed. I bought the right kind of books that targeted skill areas I discovered were deficient. Of course, I took the time to see what the experts on SO recommended.

Second, SO gave me a place to continue learning from those who (represented by reputation) really know what they're doing - syntactically and philosophically. There is a certain amount of insight to be gained on SO, CodeReview, and Programmers that you simply cannot get from a book.

Obviously, SO cannot replace books or all other web resources (although, if I could combine MSDN and SO into a single content resource ...); instead, SO complements these other resources. The best teacher, however, remains experience.


问:
How should I specify a grammar for a parser?
I have been programming for many years, but one task that still takes me inordinately long is to specify a grammar for a parser, and even after this excessive effort, I'm never sure that the grammar I've come up with is good (by any reasonable measure of "good").

I don't expect that there is an algorithm for automating the process of specifying a grammar, but I hope that there are ways to structure the problem that eliminate much of the guesswork and trial-and-error of my current approach.

My first thought has been to read about parsers, and I've done some of this, but everything I've read on this subject takes the grammar as a given (or trivial enough that one can specify it by inspection), and focuses on the problem of translating this grammar into a parser.  I'm interested in the problem immediately before: how to specify the grammar in the first place.

I'm primarily interested in the problem of specifying a grammar that formally represents a collection of concrete examples (positive and negative).  This is different from the problem of designing a new syntax.  Thanks to Macneil for pointing out this distinction.

I had never really appreciated the distinction between a grammar and a syntax, but now that I'm beginning to see it, I could sharpen my first clarification by saying that I'm primarily interested in the problem of specifying a grammar that will enforce a predefined syntax: it just so happens that in my case, the basis for this syntax is usually a collection of positive and negative examples.

How is the grammar specified for a parser? Is there a book or reference out there that's the de-facto standard for describing best practices, design methodologies, and other helpful information about specifying a grammar for a parser? What points, when reading about parser grammar, should I be focusing on?

答:
From the sample files you will need to make decisions based on how much you want to generalize from those examples. Suppose you had the following three samples: (each is a separate file)

```<code>f() {}
f(a,b) {b+a}
int x = 5;
</code>```

You could trivially specify two grammars that will accept these samples:

Trivial Grammar One:

```<code>start ::= f() {} | f(a,b) {b+a} | int x = 5;
</code>```

Trivial Grammar Two:

```<code>start ::= tokens
tokens ::= token tokens | <empty>
token ::= identifier | literal | { | } | ( | ) | , | + | = | ;
</code>```

The first one is trivial because it accepts only the three samples. The second one is trivial because it accepts everything that could possibly use those token types. [For this discussion I'm going to assume that you aren't concerned about the tokenizer design much: It's simple to assume identifiers, numbers, and punctuation as your tokens, and you could borrow any token set from any scripting language you'd like anyway.]

So, the procedure you'll need to follow is to start at the high level and decide "how many of each instance do I want to allow?" If a syntactic construct can make sense to repeat any number of times, such as methods in a class, you will want a rule with this form:

```<code>methods ::= method methods | empty
</code>```

Which is better stated in EBNF as:

```<code>methods ::= {method}
</code>```

It will probably be obvious when you only want zero or one instances (meaning that the construct is optional, as with the extends clause for a Java class), or when you want to allow one or more instances (as with a variable initializer in a declaration). You'll need to be mindful of issues like requiring a separator between elements (as with the , in an argument list), requiring a terminator after each element (as with the ; to separate statements), or requiring no separator or terminator (as the case with methods in a class).

If your language uses arithmetic expressions, it would be easy for you to copy from an existing language's precedence rules. It's best to stick to something well-known, like C's expressions rules, than going for something exotic, but only provided that all else is equal.

In addition to precedence issues (what gets parsed with each other) and repetition issues (how many of each element should occur, how are they separated?), you will also need to think about order: Must something always appear before another thing? If one thing is included, should another be excluded?

At this point, you may be tempted to grammatically enforce some rules, a rule such as if a Person's age is specified you don't want to allow their birthdate to be specified as well. While you can construct your grammar to do so, you may find it easier to enforce this with a "semantic check" pass after everything is parsed. This keeps the grammar simpler and, in my opinion, makes for better error messages for when the rule is violated.

OwnerDisplayName: anon

Body:
From the sample files you will need to make decisions based on how much you want to generalize from those examples. Suppose you had the following three samples: (each is a separate file)

f() {}
f(a,b) {b+a}
int x = 5;

You could trivially specify two grammars that will accept these samples:

Trivial Grammar One:

start ::= f() {} | f(a,b) {b+a} | int x = 5;

Trivial Grammar Two:

start ::= tokens
tokens ::= token tokens | <empty>
token ::= identifier | literal | { | } | ( | ) | , | + | = | ;

The first one is trivial because it accepts only the three samples. The second one is trivial because it accepts everything that could possibly use those token types. [For this discussion I'm going to assume that you aren't concerned about the tokenizer design much: It's simple to assume identifiers, numbers, and punctuation as your tokens, and you could borrow any token set from any scripting language you'd like anyway.]

So, the procedure you'll need to follow is to start at the high level and decide "how many of each instance do I want to allow?" If a syntactic construct can make sense to repeat any number of times, such as methods in a class, you will want a rule with this form:

methods ::= method methods | empty

Which is better stated in EBNF as:

methods ::= {method}

It will probably be obvious when you only want zero or one instances (meaning that the construct is optional, as with the extends clause for a Java class), or when you want to allow one or more instances (as with a variable initializer in a declaration). You'll need to be mindful of issues like requiring a separator between elements (as with the , in an argument list), requiring a terminator after each element (as with the ; to separate statements), or requiring no separator or terminator (as the case with methods in a class).

If your language uses arithmetic expressions, it would be easy for you to copy from an existing language's precedence rules. It's best to stick to something well-known, like C's expressions rules, than going for something exotic, but only provided that all else is equal.

In addition to precedence issues (what gets parsed with each other) and repetition issues (how many of each element should occur, how are they separated?), you will also need to think about order: Must something always appear before another thing? If one thing is included, should another be excluded?

At this point, you may be tempted to grammatically enforce some rules, a rule such as if a Person's age is specified you don't want to allow their birthdate to be specified as well. While you can construct your grammar to do so, you may find it easier to enforce this with a "semantic check" pass after everything is parsed. This keeps the grammar simpler and, in my opinion, makes for better error messages for when the rule is violated.


问:
How to pay more attention to detail as a developer?
Are there any resources for paying more attention to detail as a software developer?  (Especially edge cases, or small mistakes in code, details in the problem description, ramifications for certain changes to a large system)

Some thoughts so far:

- Books of some sort?

- Exercise of some sort (e.g. just solving math problems [a professor during undergrad mentioned math teaches attention to detail..although another said assembly language programming teaches detail too...])?

- Some type of method for decomposing problems/thinking to force attention to every detail?

- Some way of noting down details so as not to forget them later

Example of what I mean:

Someone said a good question to ask a prospective developer how many 7's between 0 and 100.  I did it quickly and thought of 10, forgetting about 70-76 and 78-79.  Basically it's just a lack of attention to detail....

Another example is during a white board coding interview, there was an easy problem and while the initial version was correct, as we kept making it more efficient I kept making more and more small mistakes.  Once pointed out it was easy for me to fix them, but it was embarrassing to have them pointed out by the interviewer instead of me finding the issues on my own and fixing them.

Another example is just compiling code.  Initially I would write code, go over it once before compiling and catch many errors.  Now I miss many more errors and the compiler (or interpreter) finds many more errors than it used to.

Also I noticed that when I first came out of undergrad it was much easier to hang onto tons of detail where as now even the detail that I initially knew I seem to forget more as time goes on.  Which is why in addition to paying attention to detail for new problems I could also use resources for keeping track of detail from older problems without having to rely on memory.

答:
Learn how to unit test and write testable code.

If you write good unit tests, you will ensure all edge cases are covered. At the very least, writing unit test will force you to think about the code you are writing and help with getting the detail right.

When you have good coverage by unit tests, mistakes made when changing the code (say for performance) will be caught.

The art of unit testing is a good book to get to learn what unit testing is all about.

As a side note - it is more important to be correct than fast. If you need to think things for an hour and only then start coding, you are doing well. Simply taking the time to think things through will already help with lots of the edge cases and general class and method design.


答:
Slow down. Think before you speak. Practice checking your work, even when it's all in your head. Everybody makes mistakes, especially in a stressful situation like an interview, but you'll make fewer of them if you give yourself time to think. Most people, including interviewers, appreciate a thoughtful answer more than a speedy one.

If an interviewer asks you a question with an obvious answer, pause for a moment and consider whether that's the only answer. The 7's question could be answered a number of ways:

20: That's the number of times the digit '7' occurs between 0 and 100.

1: Only one of the numbers between 0 and 100 is 7.

14: If you divide the numbers between 0 and 100 into groups of 7, you get 14 plus a few extra.

Infinitely many: I'll let you figure out why.

There are plenty of books out there to help you improve your memory but when it comes to code, it's better to spend time writing code that's as clear as possible than to try to memorize all the details. If your code is easy to understand, you don't have to remember all the details. Take that a step further: If you have to remember details about the code in order to understand it, the code should be rewritten until that's no longer necessary.

Title: How to pay more attention to detail as a developer?

Body:
Are there any resources for paying more attention to detail as a software developer?  (Especially edge cases, or small mistakes in code, details in the problem description, ramifications for certain changes to a large system)

Some thoughts so far:

- Books of some sort?

- Exercise of some sort (e.g. just solving math problems [a professor during undergrad mentioned math teaches attention to detail..although another said assembly language programming teaches detail too...])?

- Some type of method for decomposing problems/thinking to force attention to every detail?

- Some way of noting down details so as not to forget them later

Example of what I mean:

Someone said a good question to ask a prospective developer how many 7's between 0 and 100.  I did it quickly and thought of 10, forgetting about 70-76 and 78-79.  Basically it's just a lack of attention to detail....

Another example is during a white board coding interview, there was an easy problem and while the initial version was correct, as we kept making it more efficient I kept making more and more small mistakes.  Once pointed out it was easy for me to fix them, but it was embarrassing to have them pointed out by the interviewer instead of me finding the issues on my own and fixing them.

Another example is just compiling code.  Initially I would write code, go over it once before compiling and catch many errors.  Now I miss many more errors and the compiler (or interpreter) finds many more errors than it used to.

Also I noticed that when I first came out of undergrad it was much easier to hang onto tons of detail where as now even the detail that I initially knew I seem to forget more as time goes on.  Which is why in addition to paying attention to detail for new problems I could also use resources for keeping track of detail from older problems without having to rely on memory.


问:
Haskell AND Lisp vs. Haskell OR Lisp
I currently code with C, C++, and Python. I'm wanting to pick up a functional programming language, and right now I'm leaning toward Haskell. I do NOT want to start a "Haskell vs Lisp" war here; what I want to know is this: if I learn Haskell primarily for exposure to functional programming, what benefits, if any, will I gain from later learning Lisp?

答:
Haskell and Lisp are two totally different beasts.

Haskell is kindof "pure functional programming in an ivory tower"

Lisp is kindof "code-is-data / data-is-code / make your own language constructs". You can manipulate your code in whatever way you can imagine.

They are very different. Both share the "functional programming" aspect, but that's really a tiny little common point compared to their differences. Just try them out and you will see how different they are!

Title: Haskell AND Lisp vs. Haskell OR Lisp


答: Just take your time and remember: its not the AMOUNT of code, its the quality of it. keeping that always in the back of your mind will force you to think beforebjust typing code at 100the words per minute.


答:
There are several degrees between proper use of operator overloading and plain out abuse.

Proper use would be when the overloaded operator meets both the formal constraints of the original operator, AND matches intuitively and conceptually. For example, if you implement a bigint class in C++, then overloading the arithmetic operators is perfectly reasonably, because they do the bigint equivalents of integer operators.

On the other end of the spectrum, we have operator overloading that completely changes the meaning of the operator, introduces non-obvious side effects, violates the behavior of the operator it is supposed to be modelling (commutativity, associativity, destructiveness, etc.) or otherwise leads to misleading code. An example would be overloading the unary-minus operator to convert a string to all-uppercase: uppercasing is not reversible, and it has nothing to do, conceptually, with flipping the sign of a number.

Somewhere between these two extremes, there is a line; where exactly you draw it depends on personal preference. Language designers usually have ideas about where to draw that line, and the language reflects this in a way. The difference between the C++ way and the Python way, however, is merely syntax sugar.

I think operator overloading is a powerful tool that can lead to very expressive code, if used tastefully. Going wild should be avoided, but just like with any powerful language feature, it is the responsibility of the programmers, not the compiler, to guard this.


答:
Where can I learn how to specify the grammar for a parser?

For most parser generators, it's usually some variant of Backus-Naur's <nonterminal> ::= expression format.  I'm going to go on the assumption that you're using something like that and not trying to build your parsers by hand.  If you can produce a parser for a format where you've been given the syntax (I've included a sample problem below), specifying grammars isn't your problem.

What I think you're up against is divining syntax from a set of samples, which is really more pattern recognition than it is parsing.  If you're having to resort to that, it means whoever is providing your data can't give you its syntax because they don't have a good handle on its format.  If you have the option of pushing back and telling them to give you a formal definition, do it.  It isn't fair for them to give you a vague problem if you could be held responsible for the consequences of a parser based on a deduced syntax accepting bad input or rejecting good input.

...I'm never sure that the grammar I've come up which is good (by any
  reasonable measure of "good").

"Good" in your situation would have to mean "parses the positives and rejects the negatives."  Without any other formal specification of the syntax of your input file, the samples are your only test cases and you can't do any better than that.  You could put your foot down and say that only the positive examples are good and reject anything else, but that probably isn't in the spirit of what you're trying to accomplish.

Under saner circumstances, testing a grammar is like testing anything else:  you have to come up with enough test cases to exercise all variants of the nonterminals (and terminals, if they're being generated by a lexer).

Sample Problem

Write a grammar that will parse text files containing a list as defined by the rules below:

A list consists of zero or more things.

A thing consists of an identifier, an open brace, an item list and a closing brace.

An _item_list_ consists of zero or more items.

An item constsis of an identifier, an equal sign, another identifier and a semicolon.

An identifier is a sequence of one or more of the characters A-Z, a-z, 0-9 or the underscore.

Whitespace is ignored.

Example of input (all valid):

```<code>clank { foo = bar; baz = bear; }
clunk {
    quux =bletch;
    281_apple = OU812;
    He_Eats=Asparagus ; }
</code>```

Title: How should I specify a grammar for a parser?

Body:
I have been programming for many years, but one task that still takes me inordinately long is to specify a grammar for a parser, and even after this excessive effort, I'm never sure that the grammar I've come up with is good (by any reasonable measure of "good").

I don't expect that there is an algorithm for automating the process of specifying a grammar, but I hope that there are ways to structure the problem that eliminate much of the guesswork and trial-and-error of my current approach.

My first thought has been to read about parsers, and I've done some of this, but everything I've read on this subject takes the grammar as a given (or trivial enough that one can specify it by inspection), and focuses on the problem of translating this grammar into a parser.  I'm interested in the problem immediately before: how to specify the grammar in the first place.

I'm primarily interested in the problem of specifying a grammar that formally represents a collection of concrete examples (positive and negative).  This is different from the problem of designing a new syntax.  Thanks to Macneil for pointing out this distinction.

I had never really appreciated the distinction between a grammar and a syntax, but now that I'm beginning to see it, I could sharpen my first clarification by saying that I'm primarily interested in the problem of specifying a grammar that will enforce a predefined syntax: it just so happens that in my case, the basis for this syntax is usually a collection of positive and negative examples.

How is the grammar specified for a parser? Is there a book or reference out there that's the de-facto standard for describing best practices, design methodologies, and other helpful information about specifying a grammar for a parser? What points, when reading about parser grammar, should I be focusing on?

Body:
Where can I learn how to specify the grammar for a parser?

For most parser generators, it's usually some variant of Backus-Naur's <nonterminal> ::= expression format.  I'm going to go on the assumption that you're using something like that and not trying to build your parsers by hand.  If you can produce a parser for a format where you've been given the syntax (I've included a sample problem below), specifying grammars isn't your problem.

What I think you're up against is divining syntax from a set of samples, which is really more pattern recognition than it is parsing.  If you're having to resort to that, it means whoever is providing your data can't give you its syntax because they don't have a good handle on its format.  If you have the option of pushing back and telling them to give you a formal definition, do it.  It isn't fair for them to give you a vague problem if you could be held responsible for the consequences of a parser based on a deduced syntax accepting bad input or rejecting good input.

...I'm never sure that the grammar I've come up which is good (by any
  reasonable measure of "good").

"Good" in your situation would have to mean "parses the positives and rejects the negatives."  Without any other formal specification of the syntax of your input file, the samples are your only test cases and you can't do any better than that.  You could put your foot down and say that only the positive examples are good and reject anything else, but that probably isn't in the spirit of what you're trying to accomplish.

Under saner circumstances, testing a grammar is like testing anything else:  you have to come up with enough test cases to exercise all variants of the nonterminals (and terminals, if they're being generated by a lexer).

Sample Problem

Write a grammar that will parse text files containing a list as defined by the rules below:

A list consists of zero or more things.

A thing consists of an identifier, an open brace, an item list and a closing brace.

An _item_list_ consists of zero or more items.

An item constsis of an identifier, an equal sign, another identifier and a semicolon.

An identifier is a sequence of one or more of the characters A-Z, a-z, 0-9 or the underscore.

Whitespace is ignored.

Example of input (all valid):

clank { foo = bar; baz = bear; }
clunk {
    quux =bletch;
    281_apple = OU812;
    He_Eats=Asparagus ; }


答:
What's the best way for me to improve programming skills?

Programming more. Reading books and web pages is secondary.

You learn best by doing.


答:
Like most fields that are detailed in nature it takes practice to get good at the details.  Structured practice using a concept called Code Katas can help because it is done away from your main job so it allows for practicing doing detailed thinking away from the pressure of having to finish something fast. And most of the sites that give example Katas to do also emphasize test-driven and/or behavior-driven development.

The seminal "Bowling Game Kata" is a good one to start with.

Here are some references to get started:

CodeKata by Dave Thomas

Software Craftmanship - Katas


答:
To start with my beloved quote on the subject:

I saw `cout' being shifted "Hello world" times to the left and stopped
  right there.

      — Steve Gonedes

Much like any powerful feature, or like any feature, it can and will be misused by someone. That being said, making it a little harder to do it, is probably worth the effort.

What you really don't want to happen, is to have people defining non-evident operators. Let me give you some examples of binary operators (with a and b being the operands):

Array<T> * int : returns an Array<T> of length a.length * b by concatinating a b times to an empty array

Array<int> * int : returns an Array<int>, where each element of a is multiplied b

Array<T> * T->R : returns an Array<R>, where each element is the return value of calling b with the element from a (functional map)

Array<T> / T->bool: returns an Array<T>, where only those elements are included, for which b returns true

...

You can have a lot of fun with this. And people do. And it's arguably ok, if it's not ambiguous (example 1 and example 2) and people understand it (example 3 and example 4), which is generally achieved by choosing relatively clear operators and then sticking to them consistently.

The only language, where I toyed with operator overloading was Ruby, which makes it very simple as well. Interestingly, people don't tend to abuse it. To speculate about some reasons:

Ruby's standard library includes most of the collections you will need and overloads operators on them in a sparse, yet very meaningful way. From a programmers perspective, the most commonly overloaded operator is probably the space ship operator, but for obvious reasons, with obvious consequences.

Ruby has a "tighter" community than C++ (probably rubygems play a role in this, or maybe the long time in the shadows before the hype did), so you don't have too many people writing their own collections-DSL through operator overloading

Ruby calls can omit parentheses. You'll probably laugh at that. Programmers are extremely lazy and parentheses are rather slow to type. Therefore writing a.add b is a viable alternative to overloading +.

So from that I would say: the best way to stop people from abusing operator overloading is to provide good alternatives.


问:
How much Stack Overflow reputation makes it worth putting in CV?
A lot of answers on here suggest linking to your Stack Overflow account on your CV. I only have 300 some points over on Stack Overflow, so I don't think I'll be mentioning it just yet.

Still, I'm curious to know how much reputation I should get before "boasting" about it on my CV.

答:
Seeing as you can get +1000 rep by simply suggesting edits (which get accepted), I would say that the actual rep is not as important as the quality of your questions and answers.

Simply post that you participate in SO/Programmers with a link to your profiles and let these speak for themselves. The fact that you participate in the community is more important than rep.

If you have anything that you are particularly proud of, link to that.


问:
Developing a simple web-application?
I decided to do a mini-project by myself to help me understand a bit more about developing web applications before starting the new university semester. Using the Java SE and JEE/J2EE platforms. I will be creating a simple web application that will retrieve data from a database and display the data.

I decided to use a Model-View-Controller type pattern and so far decided that the:

Models: Will be Java objects which are persisted in the database using a framework.
View: will only be the front end, probably written in HTML with some CSS.

I have not (at a high level) decided how the controller should be implemented, I initially went along with the idea that I will use JDBC to query results from the database and display it to the front end but the use of frameworks should ease the process.

I was told that there are some open source frame-works that help in making web application and a few I looked up were Spring and Hibernate.

My question then is there a way of incorporating these frameworks to what I proposed and if so how can I learn about these frameworks in order to create a web application?

Would appreciate advice and experiences about developing web-applications.
This is something I have not done before so it’s all a new and a learning process for me.

In essence I want to create is a web-application using Java as the primary programming language in which database querying functionalities help in displaying outputs to the front end.

Edit: Edited question to make it clearer for those who want to start similar type projects.

答: I will have to suggest the Java EE 6 Tutorial. It will be better if you go or skim through all the parts but I think for your case the essential parts are Part I, II, V, VI and VII.</p>

Title: Developing a simple web-application?


答:
You're not going to get it right the first time. Go into Creative mode do solve problems. Step away from your code and return as more of a reviewer or editor. Here you'll find more mistakes. There may be more errors found in a code review. It's not that you get sloppy thinking someone else will catch mistakes, it's just going to happen.

Your asking yourself to the the writer and the editor simultaneously. That's impossible to do effectively in both areas.


问:
How to manage a project in school?
I just started doing PhD and we are supposed to do a project for a class, there are 14 people taking the class and we are supposed to develop a system all together.

I was away from academia and working in the industry before, and I know it is very hard to manage even a couple of people towards the same goal.

We are going to make the first meeting in a couple of weeks. First, I will suggest using a version control system like SVN. Second, I will try to take the lead for the architecture of the system, because I think I am more experienced. Since the class is about computer vision and I anticipate that most of the people's background is research related so there is a big chance that I am more experienced. I will gladly hand architecture to someone else if he/she is more experienced.

What else should we do to progress without much hassle?

PS. You can assume every one of us is going to work remotely, and meet once in a week at it's best (not everyone will attend though). And the project needs to be finished in 2 months. It does not need to be a perfect, complete product, we just need to make a prototype.

PPS. The aspects of the group reminds me of open source project groups, maybe the answers will be helpful for those groups as well.

答:
A DVCS like git or hg sounds more appropriate than svn for what you're descibing.

Setting up some web based project management tool would help in keeping track of who's working on what etc.

Title: How to manage a project in school?


问:
Writing documentation for well understood methods like equals in Java
Is it a good practice to write comments for widely known methods like equals, compareTo etc?

Consider the below code.

```<code> /**
 * This method compares the equality of the current object
  with the object of same type
 */
@Override
public boolean equals(Object obj) {

               //code for equals

     }
</code>```

My company madates to enter comments like the above.Is the above Javadoc comment required?
Is it not obvious and well understood what the equals method and the likes (compare,compareTo) etc does?

What are your suggestions?

答:
Knowing that those methods are common and most of the developers will know what they are for then, IMO, you won't need to put any comments there. Comments are not that reliable in the long run as there are chances that these may not get updated when the implementation is updated and might cause confusion. So it is always better to make your code readable as this is what you can mostly trust.

Furthermore, I would say that if the code you are creating/editing is not for a public API then just leave out the javadocs for common methods as these will just add clutter and noise.


问:
Web development in a small team - best practices
Currently developing a web app in a team of two maybe three in the near future. Tech stack is at the moment : flask, mongodb, and extjs for the fontend. I currently have the project under version control using mercurial and bitbucket.

Question

What is exactly the best way to work as a team on a we app peoject? I ussually work on the back end while my colegue works on the frontent. Sometimes i also help out on the front end. How should we do this? Each has a repo on their system but whee is the web server started? Curentlly i have it on my computer but that means that my partner needs to commit and push for each modification and i need to pull the changes and merge for each change. And for frontend stuff there needs to be a lot of changes.
We tried having a server started on each of our machines but its a pain with multiple mongodb servers.

Anyway any tips, clues and advices are greatly appreciated and welcomed.

答:
There are excellent tools to allow collaboration from small to big teams, what tools you choose depend on the size of the team, size of the project, ...

One goal is to have constant communication with your team. For that I recommend:

Stay connected, use IRC (and log it)! Use skype/video/gmail or whatever for 1 to 1 communication, but for teams IRC allows a kind of communication that others somehow don't fulfill. You should be on IRC anyways if you are developer, and you can integrate other tools to send notification to your channel (commits, tests)

Use a bugtracking system, plenty of which to choose from.

Use any kind of project management system, tools like redmine, agilezen.com, or an excel sheet. take your pick.

Another goal is for all the developers to have the exact same development environment and kind of data, in a reproducible and automated way. For this you can you a combination of tools:

vagrant + provisioner (provy,chef,puppet) + fabric

use fixtures, mock data apps, random fixture generators for your data, and mock 3rd party services in way that you can reproduce and depend on.

The use of virtualmachines provisioned programatically also allows you to develop very closely to your deployment environment, without having all your team members having to install and configure them locally, without losing the flexibility and without the headaches that sharing resources can bring (specially if the team is geographically apart).

Another goal is that team members don't step on each other's toes. Not only not breaking your colleagues code, but also includes avoiding duplicate efforts. Some things you can use:

use a DVCS with a centralized server (i.e. bitbucket) with a coherent commit workflow that also includes deployment. "i.e. git-flow like workflows or always deploy trunk workflows"

setup a Continuos Integration server (jenkins or teamcity i.e.) and write tests like crazy. Track your code coverage and commit to keeping your code with the highest coverage you can. Use unittests, but also use browser testing, i.e. selenium (i like using selenium for more general storylike tests, and unittests for more low level operations, and selenium allows you to test the interactions of the backend and frontend code)

commit contract: Have your team use branches for development, and commit code to the main branch when all the tests pass.

automate your deployment, setup a staging server (that can/should be provisioned with the same scripts as your vagrant box) and hook up your CI server to deploy to it at least once a day when all tests are green from the main branch. After automated deployment, run tests against the server, including load tests, (i.e. with funkload, or selenium, etc..) and graph it using graphite!

Use a bugtracking system. Its a waste of time if two on your team are tracking down the same bug and trying to fix it at the same time without knowing.

You don't have to setup everything from the start, and you might not need to use all the tools. Just keep on eye on those moments where you start to need them.

OwnerDisplayName: InnocentPixel


答:
In some post on careers.SE Joel pointed out (edit: See @Atul's answer), that actual rep is not so much what matters. What you should do, is to add links to answers (or questions) that you think really show your knowledge and skill.

In fact, rep has two major problems:

it follows some weird group dynamics. There's a lot of uneven amplification effects, that distort it even as a measure for the "absolute" value of an answer.

using it as a measure for a whole person basically dumbs it down to measuring something very individual and complex on a linear scale.

However your profile as a whole tells a story. One can see, whether you're a specialist, or a generalist. One can quickly see your top answers and questions, to see what you master and what intrigues you. Your style of writing reflects on your personality and so on.

I guess the point where you should use your SE profile as part of your CV is the point when you like the story it tells.

Title: How much Stack Overflow reputation makes it worth putting in CV?

Body:
A lot of answers on here suggest linking to your Stack Overflow account on your CV. I only have 300 some points over on Stack Overflow, so I don't think I'll be mentioning it just yet.

Still, I'm curious to know how much reputation I should get before "boasting" about it on my CV.


问:
Web Developers not learning "traditional" techniques?
I ran across this question on SO: https://stackoverflow.com/questions/7373066/webpage-source-code-incomplete-hidden-code

Without trying to infer too much or start a side-discussion of the sort that SO discourages, I think it's fair to conclude that the OP is someone who is  familiar with HTML, Javascript, CSS and the basic architecture of the Web. Yet this question suggests that they have never worked with code that used a traditional form post. Is it really the case that people starting to work in the Web nowadays don't learn about that crufty old stuff any more?

I don't even mean this question to be as crotchety as it probably sounds. I'm not suggesting people learn about <marquee>, implement all UI layout in tables, dynamic content with document.write etc. But form posts seem like one of those critical pieces a person should understand, specifically before getting into Ajax. Did I stumble on an anomaly or a trend here? Am I wrong?

答:
If said user came from a web design/static HTML background, I wouldn't expect them to understand how forms work, nor the whole client/server architecture.

The profile of the user seems to indicate lots of "front end" work and little or no back end (though node.js is in the tags a number of times).

And with the prevalence of AJAX these days (how easy does jQuery make it, eh?), I can see how some developers will end up seeing forms as temporary data holders, used to build those AJAX calls from.

I can see how someone self taught, who has come into web development recently (i.e. when AJAX became the vogue) wouldn't know how the form element operates, in particular if JS is not used.


答:
Attention to details requires:

systematic way of browsing through the details

some efficient way to regognize which piece is important and which is less important

ability to quickly change the details which requires modification

It's always good to remember the fundamental limits of what humans have:

people can only remember 7 things in their short-term memory - your details need to flow through these 7 things or you cannot handle large volumes of details

Learning how to use your short-term memory for details takes very long time, like 10-20 years and only happens through constant practise

Large volumes of details are harmful in the long term, so sufficient holiday time is required where details are not available (given internet's availability of large amounts of details, this is sometimes forgotten)


问:
Test-driven development and improving white box testing skills
I am an entry level Java Programmer straight out of school.
I have good knowledge and experience with J2SE.
Can anyone advise me on how to improve or tune my skills towards being a Java white box tester? Wide range of inputs are welcome.

And what is Test Driven Development?

答: I am not sure if my suggestion will be considered as tools for white box testing but you can also look at dbUnit for database-driven projects and Selenium for web testing(e.g. inspection of elements that should be existing based on some results). </p>


问:
Using third-party libraries - always use a wrapper?
Most projects I am involved with use several open-source components. As a general principle, is it a good idea always to avoid binding all components of the code to the third-party libraries and instead go via an encapsulating wrapper to avoid the pain of change?

As an example, most of our PHP projects directly use log4php as a logging framework, i.e. they instantiate via \Logger::getLogger(), they use ->info() or ->warn() methods, etc. In the future, however, a hypothetical logging framework may appear which is better in some way. As it stands, all the projects which closely couple to the log4php method signatures would have to change, in dozens of places, in order to fit the new signatures. This would obviously have a wide impact on the codebase and any change is a potential problem.

To future-proof new codebases from this kind of scenario, I often consider (and sometimes implement) a wrapper class to encapsulate the logging functionality and make it easier, though not foolproof, to alter the way in which logging works in future with minimal change; the code calls the wrapper, the wrapper passes the call to the logging framework du jour.

Bearing in mind that there are more complicated examples with other libraries, am I over-engineering or is this a wise precaution in most cases?

EDIT: More considerations - using dependency injection and test doubles practically requires that we abstract out most APIs anyway ("I want to check my code executes and updates its state, but not write a log comment/access a real database"). Isn't this a decider?

答:
If you only use a small subset of the third party API, it makes sense to write a wrapper - this helps with encapsulation and information hiding, ensuring you don't expose a possibly huge API to your own code. It can also help with making sure that any functionality you don't want to use is "hidden".

Another good reason for a wrapper is if you expect to change the third party library. If this is a piece of infrastructure you know you will not change, do not write a wrapper for it.


答:
In addition to what @Oded already said, I'd just like to add this answer for the special purpose of logging.

I always have an interface for logging but I never had to substitute a log4foo framework yet.

It takes only half an hour to provide the interface and write the wrapper, so I guess you don't waste too much time if it turns out to be unecessary.

It's a special case of YAGNI. Although I don't need it it doesn't take much time and I feel safer with it. If the day of exchanging the logger really comes, I'll be glad I invested half an hour because it'll save me more than a day exchanging calls in a real world project. And I've never written or seen a unit test for logging (apart from tests for the logger implementation itself), so expect defects without the wrapper.

Title: Using third-party libraries - always use a wrapper?

Body:
Most projects I am involved with use several open-source components. As a general principle, is it a good idea always to avoid binding all components of the code to the third-party libraries and instead go via an encapsulating wrapper to avoid the pain of change?

As an example, most of our PHP projects directly use log4php as a logging framework, i.e. they instantiate via \Logger::getLogger(), they use ->info() or ->warn() methods, etc. In the future, however, a hypothetical logging framework may appear which is better in some way. As it stands, all the projects which closely couple to the log4php method signatures would have to change, in dozens of places, in order to fit the new signatures. This would obviously have a wide impact on the codebase and any change is a potential problem.

To future-proof new codebases from this kind of scenario, I often consider (and sometimes implement) a wrapper class to encapsulate the logging functionality and make it easier, though not foolproof, to alter the way in which logging works in future with minimal change; the code calls the wrapper, the wrapper passes the call to the logging framework du jour.

Bearing in mind that there are more complicated examples with other libraries, am I over-engineering or is this a wise precaution in most cases?

EDIT: More considerations - using dependency injection and test doubles practically requires that we abstract out most APIs anyway ("I want to check my code executes and updates its state, but not write a log comment/access a real database"). Isn't this a decider?


答: Yes, its common.  I dont know if its so much a trend as it is a procession, with newer developers working with continuously higher levels of abstraction as they become available.  It probably looked pretty odd to programmers 20 years ago to talk to young programmers who never learned assembly.  I've seen people on here suggest things such as not needing to know HTML to make web apps (ExtJS does it all for you...), not needing to know SQL (thats what ORM is for), etc.  Sure, it can be done without understanding underlying technologies.  But if someone doesnt understand the basic foundations they are working on top of, as soon as they try to do anything outside of the box, they're out of their depth.

Title: Web Developers not learning "traditional" techniques?

Body:
I ran across this question on SO: https://stackoverflow.com/questions/7373066/webpage-source-code-incomplete-hidden-code

Without trying to infer too much or start a side-discussion of the sort that SO discourages, I think it's fair to conclude that the OP is someone who is  familiar with HTML, Javascript, CSS and the basic architecture of the Web. Yet this question suggests that they have never worked with code that used a traditional form post. Is it really the case that people starting to work in the Web nowadays don't learn about that crufty old stuff any more?

I don't even mean this question to be as crotchety as it probably sounds. I'm not suggesting people learn about <marquee>, implement all UI layout in tables, dynamic content with document.write etc. But form posts seem like one of those critical pieces a person should understand, specifically before getting into Ajax. Did I stumble on an anomaly or a trend here? Am I wrong?


答:
Careers 2.0: It’s About Reputation, Not “Rep” Take a look at this SO Blog posting.

As Joel Spolsky says in the blog post (I boldfaced that last line to highlight it):

But more importantly, sheer reputation scores are not how Careers 2.0 works, and it’s not what Careers 2.0 hiring managers are looking for. What they want to see is a sample of your work. They don’t need to see your answers to 7000 questions—they want to see five really good ones.

So, (as also suggested by others) it's the quality not quantity that matters.


答:
The answers by Macneil and Blrfl are great. I just want to add some comments about the beginning of the process.

A syntax is just a way to represent a program. So the syntax of your language should be determined by your answer to this question: What is a program?

You might say that a program is a collection of classes. Okay, that gives us

```<code>program ::= class*
</code>```

as a starting point. Or you may have to write it

```<code>program ::= ε
         |  class program
</code>```

Now, what is a class? It's got a name; an optional superclass specification; and a bunch of constructor, method, and field declarations. Also, you need some way of grouping a class into a single (unambiguous) unit, and that should involve some concessions to usability (eg, tag it with the reserved word class). Okay:

```<code>class ::= "class" identifier extends-clause? "{" class-member-decl * "}"
</code>```

That's one notation ("concrete syntax") you could choose. Or you could just as easily decide on this:

```<code>class ::= "(" "class" identifier extends-clause "(" class-member-decl* ")" ")"
</code>```

or

```<code>class ::= "class" identifier "=" "CLASS" extends-clause? class-member-decl* "END"
</code>```

You've probably already made this decision implicitly, especially if you have examples, but I just want to reinforce the point: The structure of the syntax is determined by the structure of the programs it represents. That's what gets you past the "trivial grammars" from Macneil's answer. Example programs are still very important, though. They serve two purposes. First, they help you figure out, at the abstract level, what a program is. Second, they help you decide what concrete syntax you should use to represent your language's structure.

Once you've got the structure down, you should go back and deal with issues like allowing whitespace and comments, fixing ambiguities, etc. These are important, but they're secondary to the overall design, and they're highly dependent on the parsing technology you're using.

Finally, don't try to represent everything about your language in the grammar. For example, you may want to forbid certain kinds of unreachable code (eg, a statement after a return, like in Java). You probably shouldn't try to cram that into the grammar, because you'll either miss things (whoops, what if return is in braces, or what if both branches of an if statement return?) or you'll make your grammar way too complicated to manage. It's a context-sensitive constraint; write it as a separate pass. Another very common example of a context-sensitive constraint is a type system. You could reject expressions like 1 + "a" in the grammar, if you worked hard enough, but you couldn't reject 1 + x (where x has type string). So avoid half-baked restrictions in the grammar and do them correctly as a separate pass.

Body:
The answers by Macneil and Blrfl are great. I just want to add some comments about the beginning of the process.

A syntax is just a way to represent a program. So the syntax of your language should be determined by your answer to this question: What is a program?

You might say that a program is a collection of classes. Okay, that gives us

program ::= class*

as a starting point. Or you may have to write it

program ::= ε
         |  class program

Now, what is a class? It's got a name; an optional superclass specification; and a bunch of constructor, method, and field declarations. Also, you need some way of grouping a class into a single (unambiguous) unit, and that should involve some concessions to usability (eg, tag it with the reserved word class). Okay:

class ::= "class" identifier extends-clause? "{" class-member-decl * "}"

That's one notation ("concrete syntax") you could choose. Or you could just as easily decide on this:

class ::= "(" "class" identifier extends-clause "(" class-member-decl* ")" ")"

or

class ::= "class" identifier "=" "CLASS" extends-clause? class-member-decl* "END"

You've probably already made this decision implicitly, especially if you have examples, but I just want to reinforce the point: The structure of the syntax is determined by the structure of the programs it represents. That's what gets you past the "trivial grammars" from Macneil's answer. Example programs are still very important, though. They serve two purposes. First, they help you figure out, at the abstract level, what a program is. Second, they help you decide what concrete syntax you should use to represent your language's structure.

Once you've got the structure down, you should go back and deal with issues like allowing whitespace and comments, fixing ambiguities, etc. These are important, but they're secondary to the overall design, and they're highly dependent on the parsing technology you're using.

Finally, don't try to represent everything about your language in the grammar. For example, you may want to forbid certain kinds of unreachable code (eg, a statement after a return, like in Java). You probably shouldn't try to cram that into the grammar, because you'll either miss things (whoops, what if return is in braces, or what if both branches of an if statement return?) or you'll make your grammar way too complicated to manage. It's a context-sensitive constraint; write it as a separate pass. Another very common example of a context-sensitive constraint is a type system. You could reject expressions like 1 + "a" in the grammar, if you worked hard enough, but you couldn't reject 1 + x (where x has type string). So avoid half-baked restrictions in the grammar and do them correctly as a separate pass.


问:
When to release a lite version of an iOS app?
I have created an iPhone application and I have submitted it to Apple and it is currently waiting for review and I have been debating with myself for the past half an hour if I should release a lite version of an app.

I was wondering when one should release a lite version of an app once the full app is in the App Store?

答:
I believe you should release a lite app as soon as possible. On my adventures through the app store, and looking at statics, you get more people downloading you free app than your paid app (no brainer of course).

If you do a good job on you lite app and get people interested, you'll find people converting to the fully paid app.


答:
Without knowing what super-great new features this alleged future improved logger will have, how would you write the wrapper?  The most logical choice is to have your wrapper instantiate some sort of logger class, and have methods like ->info() or ->warn().  In other words, essentially identical to your present API.

Rather than future-proof code that I may never need to change, or that may require an unavoidable rewrite anyway, I prefer to "past-proof" code.  That is, on the rare occasions when I do significantly change a component, that's when I write a wrapper to make it compatible with past code.  However, any new code uses the new API, and I refactor old code to use it whenever I'm making a change in the same file anyway, or as schedule permits.  After a few months, I can remove the wrapper, and the change has been gradual and robust.

Put another way, wrappers really only make sense when you already know all the APIs you need to wrap.  Good examples are if your application currently needs to support many different database drivers, operating systems, or PHP versions.


答: You should deploy a "lite" app if you think it will get a lot more downloads than the paid full version, and the conversion rate from lite to paid is higher than the paid app sales cannibalization caused by people who are content to use only what the free lite app provides.  There is also possible advertising revenue that could be gotten from a free app if the download count is many digits in size.</p>

Title: When to release a lite version of an iOS app?

Body:
I have created an iPhone application and I have submitted it to Apple and it is currently waiting for review and I have been debating with myself for the past half an hour if I should release a lite version of an app.

I was wondering when one should release a lite version of an app once the full app is in the App Store?