问:
Is it possible to work with distrusting clients
One of our junior developers has been assigned a new client (we don't have the client yet, we're still working with him to see if we can meet his needs) and the junior developer said the client will hire us if we can do the work on his project without getting access to his server.

I've had a direct conversation with the client who turned out to have had his code stolen before by some offshore company that he outsourced. This made me more sympathetic but I still have mixed feelings about this.

On one hand I want to prove to the client that we're not all bad apples. Also if we do a good job with him, we get a loyal client who'll hire us for all his projects. I haven't heard of this happen before but I guess it happens more often than we'd all like to admit.

On the other hand I'm hesitant to accept working with him because deployment time is going to be a nightmare and no where in my career or education has anyone taught me how to work with clients like him. I (or the junior developer) would have to write a detailed description of exactly what to do with the source to deploy it and that is an annoying burden when I could deploy and test the whole thing in an hour myself.

As I said, I've never had to deal with this before (we're signing a non-disclosure but apparently so did the offshore company before us). We're not fully fully booked so it's not like I have an immediate replacement, but we're not begging for work either and I wonder if working under such restricted environment is worth the trouble.

Another side is that the experience itself could be rewarding for us, but is it experience worth having, as in what's even the likelihood of getting a similar client anytime soon. Are we even expected to comply with such clients?

So since I don't have any first hand experience with this and it definitely wasn't covered in school, how would those with longer experience working with clients deal with a distrusting client like this? Would you even accept the job?

答:
Explain to the client the full implications of their restrictive policy. Charge for extra work during development and deployment. It is for them to decide if the restrictive policy is worthwhile.

The most serious downside is not the extra hassle you will go through in development, but slow turnaround with bug fixes after launch. Unless your system is dead-simple (or your name is Donald Knuth), you will have bugs after deployment, no matter how careful you are.


问:
Programming a chatterbot - understanding language
I hope this is an answerable question. Let me give it some context:

I am a psychology student and a programmer. I'm going to look into creating a artificial intelligence in the form of a chatterbot. I've been looking around the web, and read about projects such as Eliza which was a first simple psychotherapy program, that has now actually been written in javascript (so you can see how simple this was).

I want to create a chatterbot that can converse, and that will understand semantically and grammatically a sentence, for the purpose of reciprocal communication rather than simply outputting an answer. I'm interested in ways to learn about programming with "language". I know that this is a complex question, so the answer will probably be complex too.

What programming languages/frameworks should I look into when wanting to analyze the semantics. I know of the excellent Wolfram Alpha project that has an API. But I don't want to create an artificial intelligence that can answer any random question.

To paraphrase: What frameworks / programming languages are suited to work with deconstructing linguistic units and understanding language, for the purpose of conversing? Also do you know of any projects that implement these?

答:
If you're looking for an entry point into this huge topic, there are worse places to start than the Natural Language Toolkit. The API is Python. It's well documented. The book, Natural Language Processing with Python - Analyzing Text with the Natural Language Toolkit, is even available to read online.

I don't want to mislead you. The NLTK isn't a short-cut to a convincing chatterbot. It is however

"suited to work with deconstructing linguistic units and understanding language..."

If you don't have tight deadlines, Stanford is offering a free course on natural language processing in Feb. 2012.

ContentLicense: CC BY-SA 3.0


问:
What is the proper way to suggest features to be added to the C# language?
What is the proper way to suggest features to be added to the C# language?

For example, I would like to have an operator similar to ?? but for selecting the min or max values.

I'd like a <? b to expand to a < b ? a : b
likewise for >?

答:
Microsoft Connect is the central Hub regarding all suggestions about Microsoft products.

Concerning Visual Studio and the .NET ecosystem, you will have to go through the "Visual Studio and .Net Framework" product and you will end up on the Visual Studio User Voice website where ideas can be submitted. You can also find discussions and issues on GitHub, for the open-sourced version of .NET.

There is also a new Q/A site for both Visual Studio and TFS.

Concerning C#, now that roslyn is open-source, the evolution of C# is discussed in the open, and is still designed by the C# Language Design Team (LDT). You can request and discuss new features of C# on GitHub.


问:
What's the benefit of avoiding the use of a debugger?
Over the course of my career, I've noticed that some developers don't use debugging tools, but do spot checking on erroneous code to figure out what the problem is.

While many times being able to quickly find errors in code without a debugger is a good skill to have, it seems it's less productive to spend a lot of time looking for issues when a debugger would easily find little mistakes like typos.

Is it possible to manage a complex without a debugger? Is it advisable? What benefits are there to be had by using "psychic debugging?"

答:
If the bug occurs in a client's computer, or in a computer that its environoment is much different than yours, then setting up a debugger / remote debugger is cumbersome.
So, for the cold day where you get a bug from the field, the response of 'but ... i don't have a debugger' doesn't help.
Therefore, you need to develop a skill set of trouble shooting and finding the bug just through understanding of code and log files.</p>


问:
How can I deal with developers who don't use English in code?

Possible Duplicate:

  Code maintenance: keeping a bad pattern when extending new code for being consistent, or not?

I'm working on a project for a Greek public organization, as a part for a course semester project. I have to develop a 3-tier application that manages financial data. A professor of mine acts as an advisor and is helping me on the project.

I write my own code but there are also pieces of code written by other developers that I can also use, and some the code is also written by my professor. The Greek developers program without using any patterns or conventions, they are generally unaware of phrases like "best-practices" and "programming methodology". They just write code of pure quality. Most of them are at least 10 years more experienced than me but I am on my way. My professor is a "pragmatic programmer" and produces "clean code that works" of high quality.

The Greek developers speak English as well. The problem is that some of them use greeklish for the various names of variables, classes and methods-obviously greek charachters cannot be used for such purposes. For example, the greek translation of "user" is "χρήστης" which in greeklish could be written in the following ways:

xristis,

xrhsths,

hristis,

christis,

...

As a result, the same meaning can be expressed with different characters. Some of the developers use English in their code, and there are no naming conventions at all.

I'm working on this project just for the sake of knowledge and further practice. I would like to apply practices I read in books in software that can also be used and modified by others.

Should I keep using greeklish just to be in harmony with the already existing code? In that case, who knows In a few months I may get valuable feedback for my effort, which will eventually make me a better programmer.

Or, should I just keep doing the right thing, taking example from my professor? In that case my code might be an one-use throw-away effort because none of the Greek developers would like to follow a new set of conventions.

答:
I'm biased, but use English.  For a few reasons.

Most developers, even if it's not their native language, know English.  It's the defacto language of science.  Most papers are published in English.

If your developers all know English to some extent, it won't exclude anybody.  I work in a shop with developers from all over the world, Egypt, India, Canada, USA, Singapore, France, etc... and we all develop in English.

As you can see from your example, you can type the words. You don't require special characters, and phonetics to be able to type.  Thus, it reduces confusion.


答:
Greeklish is no different than any other internet only form of slang. It originates in a dark era when there was minimal support for the language on computers, back when we said code page instead of character encoding. Nowadays, what you are describing is the equivalent of using "lolspeak", and it has no place in code.

You should really use English, and if possible advocate against Greeklish and for proper naming conventions. In any case, consistency is key. If they refuse to adopt English, at least they have to make sure to use exactly the same form of each word everywhere.

I know a little too well how public organizations work in Greece, so that's probably a lost cause and you should just tough it out.

Did you discuss any of this with your professor?

Title: How can I deal with developers who don't use English in code?

Body:
Possible Duplicate:

  Code maintenance: keeping a bad pattern when extending new code for being consistent, or not?

I'm working on a project for a Greek public organization, as a part for a course semester project. I have to develop a 3-tier application that manages financial data. A professor of mine acts as an advisor and is helping me on the project.

I write my own code but there are also pieces of code written by other developers that I can also use, and some the code is also written by my professor. The Greek developers program without using any patterns or conventions, they are generally unaware of phrases like "best-practices" and "programming methodology". They just write code of pure quality. Most of them are at least 10 years more experienced than me but I am on my way. My professor is a "pragmatic programmer" and produces "clean code that works" of high quality.

The Greek developers speak English as well. The problem is that some of them use greeklish for the various names of variables, classes and methods-obviously greek charachters cannot be used for such purposes. For example, the greek translation of "user" is "χρήστης" which in greeklish could be written in the following ways:

xristis,

xrhsths,

hristis,

christis,

...

As a result, the same meaning can be expressed with different characters. Some of the developers use English in their code, and there are no naming conventions at all.

I'm working on this project just for the sake of knowledge and further practice. I would like to apply practices I read in books in software that can also be used and modified by others.

Should I keep using greeklish just to be in harmony with the already existing code? In that case, who knows In a few months I may get valuable feedback for my effort, which will eventually make me a better programmer.

Or, should I just keep doing the right thing, taking example from my professor? In that case my code might be an one-use throw-away effort because none of the Greek developers would like to follow a new set of conventions.


问:
Make a big deal out of == true?
There is a colleague of mine who constantly writes:

```<code>if (someBool == true)
</code>```

It drives me up the wall!  Should I make a big deal of it or just drop it?

答:
I have a colleague who will have some code like this:

```<code>if(something == true)
</code>```

And then, for some sort of test/debugging, he will wish to not call this block so he'll change it to:

```<code>if(something == true && false)
</code>```

And then occasionally he'll change it to:

```<code>if(false)
</code>```

The worst thing is, this type of debugging has rubbed off on me on occasion and is really bad for other developers to read!

ContentLicense: CC BY-SA 2.5

Title: Make a big deal out of == true?

Body:
I have a colleague who will have some code like this:

if(something == true)

And then, for some sort of test/debugging, he will wish to not call this block so he'll change it to:

if(something == true && false)

And then occasionally he'll change it to:

if(false)

The worst thing is, this type of debugging has rubbed off on me on occasion and is really bad for other developers to read!


答:
Natural language processing is incredibly difficult, because human languages are so ambiguous, and require a lot of general background context to make sense of what is being said.  Consider the following sentences:

"Monkeys like bananas when they wake up"

"Monkeys like bananas when they are ripe"

"I saw the lab technician with the microscope."

In (1) and (2) does the "they" refer to the monkeys or the bananas?  Well, as a human being it's clear to me that in (1) the "they" refers to the monkeys, whereas in (2) it refers to the bananas.  But how exactly did I know that?  The information isn't inherent in the grammar of the sentence - it's only available because as a human being I have access to a large database of background knowledge in my brain, which tells me that bananas don't ever "wake up", and that monkeys aren't "ripe".  Therefore, my brain provides the contextual information to parse the sentence properly.

In (3) we see a similar problem:  Does (3) mean that I saw a lab technician who was using a microscope, or does it mean I actually used a microscope to see a lab technician?  Grammatically speaking, it could mean either.  But to a human being there is no ambiguity.  It must mean the former, because the latter is absurd.  But the only reason that I even realize that the latter is absurd is because I know what a microscope is, I know that a lab technician is a person, I know that you wouldn't use a microscope to see a person, and I know that lab technicians often work with microscopes.  So my brain synthesizes all of that background knowledge, allowing me to interpret the sentence correctly.

Now imagine trying to parse sentences like these with a computer.  You'd need a vast database (known as an ontology) of real-world facts and relationships to provide context, and a pretty sophisticated parser.  There have been some attempts to do this in the past, but it's still a very theoretical, very research-oriented endeavor.

Title: Programming a chatterbot - understanding language

Body:
I hope this is an answerable question. Let me give it some context:

I am a psychology student and a programmer. I'm going to look into creating a artificial intelligence in the form of a chatterbot. I've been looking around the web, and read about projects such as Eliza which was a first simple psychotherapy program, that has now actually been written in javascript (so you can see how simple this was).

I want to create a chatterbot that can converse, and that will understand semantically and grammatically a sentence, for the purpose of reciprocal communication rather than simply outputting an answer. I'm interested in ways to learn about programming with "language". I know that this is a complex question, so the answer will probably be complex too.

What programming languages/frameworks should I look into when wanting to analyze the semantics. I know of the excellent Wolfram Alpha project that has an API. But I don't want to create an artificial intelligence that can answer any random question.

To paraphrase: What frameworks / programming languages are suited to work with deconstructing linguistic units and understanding language, for the purpose of conversing? Also do you know of any projects that implement these?


问:
When learning Android, should I focus on the latest and greatest?
I'm a Java developer and I'm going to start working with Android to get familiar with mobile apps.  I've worked with Ajax toolkits, but haven't done any mobile development.

I've seen a huge change in development on certain toolkits where the learning curve really jumps up, as in GWT 1.5 versus 2.4.  I'm just wanting to jump in and get the basics (along with best practices) down for now.  I don't know if Android 2 versus version 4 would do that, but version 4 might just throw in extra features that I might not need to know about for now and take away from my main focus.

Is it better to go with the latest version of Android or, to make sure the fundamentals are covered, take an older version that would be easier to get in and start developing with?

答:
Anything which is related to Android 1.6 and earlier can be skipped, they consitute a very small range of devices. After Android 1.6 there weren't many great changes to APIs, so I can talk about the particular changes.

Fragments. Absoultely worth learning. They were introduced in Android 3.0, but they are available via a compatibility package on Android 1.6+, and using them is a good thing because they make it easy to break UI into self-contained parts. Activities also do that, but to a lesser extent.

Loaders. They were introduced at the same time as fragmetns, and their purpose is asynchronous data retrieveing and updating. Everything I said about fragments applies to them: you can use them via compatibility package, and they are very useful.

Action bar. Also introduced in Android 3.0, but it is unavailable on devices prior to it. You can make it show in your application if it is run on the Android 3.0+ devices, but right now they are in minority. Their share will increase, of course, but this will not happen all of a sudden.

Drag and drop. Yet another feature from Android 3.0 (yes, most changes happened there since it's the first release to support tablets), but it's not available on devices prior to Android 3.0, so it's not very important at this time.

Supporting both tablets and handsets. This is not a feature, of course, it is something you will have to keep in mind if you intend your application to run correctly both on the devices with Android 2.x and 3.0+. Before the tablet support in Android 3.0 you didn't have to think about the large screens. Android 3.x releases, however, are aimed at the tablets, and Android 4.0+ runs on both tablets and handsets. Tablets with Android 3.0+ are not so numerous nowadays, but it wouldn't hurt to design your application in a way that makes it easy to use it on either device type.

Besides that, there are really no major changes in the development since 1.6. Of course new APIs got added, but nothing that would call for relearning the platform. The fundamentals are all the same.


问:
Why does HTML TextArea have its own HTML tag?
```<code><input id='input1' type='text'></input>
<input id='input2' type='button'></input>
<input id='input3' type='checkbox'><input>
<textarea id='myTextArea'></textarea>
</code>```

In HTML markup, most places where the user can interact with the page are denoted with the <input> tag.  Why is it that textarea has its own tag, <textarea> as opposed so, say, <input type='textarea'>

答:
Okay, @maple_shaft's answer got me curious, so after about 20 minutes of Googling...

From one of the original HTML drafts:

NOTE: In the initial design for forms, multi-line text fields were
supported by the Input element with TYPE=TEXT. Unfortunately, this
causes problems for fields with long text values. SGML's default
(Reference Quantity Set) limits the length of attribute literals to
only 240 characters. The HTML 2.0 SGML declaration increases the limit
to 1024 characters.

So no, it did not have to do with rows and cols being unique to textarea, like the accepted answer claims.


问:
GitHub: Are there external tools for managing issues list vs. project backlog
Recently I posted one of my the projects1 on GitHub and as I was exploring capabilities of the site, I noticed they have a rather decent issue tracking section.

I want to use that section as a) other people can report bugs if they'd like and b) other people can see which bugs I'm aware of. However, as others have noted, issues list cannot be prioritized in order to create a project backlog. For now my backlog has been a text file, but I'd like to be able to have it integrated so the same information isn't maintained in different places.

Having a fully ordered list, which is something we also practice at work, has been very useful as I can open one file, start with line 1 and fire off 2 or 3 items in one sitting without having to go back to a full issues/stories bucket. GitHub doesn't offer this.

What GitHub does offer is a very nice and clean API so issues can easily be exported into anything else. I've searched to see if there are other websites (like Trello) that integrate with GitHub issues, but did not find anything.

Does anyone know of such a product, service or offline tool? Those that use GitHub, what is your experience in managing backlog? I kinda hate the idea of manually managing two disconnected lists like some people seem to be doing with Wiki project pages.

1 - are shameless plugs allowed no this site? Searched but didn't find a definite answer. If it's bad practice, STOP and don't read further

As a developer I got sick and tired of navigating to same set of folders 30 times a day, so I wrote a little, auto-collapsible utility that gets stuck to the desktop and allows easy access to the folders you constantly use.

答: I think that if you use Eclipse for development, you can make use of their Mylyn connector for github.</p>


答:
Related to coding practices:

Consistency is king. Whichever way you name your variables you either:

Stick to it no matter how weird it is as long as it is consistent, or

Refactor the rest of the codebase to fit the new convention.

Regarding the language, it is never possible to code only in a native language. You can either code entirely in US English or use a weird hybrid language. Even if you name all your your variables and functions in Greek, you'd still have library calls in English and in languages like Java, you'd have to create even more weird names like getHristis.

I've seen some code written in a mix of Serbian and English a few times(I guess you'd call it Serblish) and my reaction was similar to yours. That practice doesn't have any benefit at all, since you'd get code that no one understands. Although I am a native speaker of Serbian I couldn't understand some parts of the code clearly, because some Serbian words were mutilated in order to fit the code. Not to mention the problem with false friends.

But, you know all that already. The problem you have is

Related to organizational practices:

Unfortunately, you don't create the coding conventions in your current team.

Try to find out what the conventions are (if any) and try to stick with them. You could try to tell your teammates what you think, but don't hold your breath over it. You said yourself that they are very experienced programmers. At best, they've probably been told the same many times before, but kept doing the same. At worst they'll call you a hippie.

But, don't worry. You already have an idea on what the good coding practices are. As soon as you find yourself in a different situation in a team that cares about code quality these things will emerge. Better than the other way around.


问:
How might the role of product owner go against the idea of open source, or work for it?
On a related questions about "Finding and/or becoming an open source product owner" -- the first comment to the question itself was "the idea of a product owner goes against the idea of open source."

Is this true, and if so, why?

If not, what circumstances and/or context would it make sense for open source project to have a product owner role?

I've attempt to find an example of this role at Mozilla.org -- but I've had no luck so far.

(Just to be clear, I'm talking about a volunteer role, not a paid position at a non-profit.)

答:
It's not a traditional role in open source projects, as the Product Owner is typically an individual responsible for a project's success by:

leading the development effort by conveying his or her vision to the team,

outlining work in the scrum backlog,

and prioritizing it based on business value.

In open source communities these responsibilities are typically shared between senior members, or assigned to package managers and so on, depending on the methodology (or lack of) the project. But there is no reason at all an open source project couldn't adopt Scrum and appoint a Product Owner.

Typically, if the original author(s) of the project are still active, they may have a bit more say in operations and processes that fall within the Product Owner's responsibilities. A common term for them is Benevolent Dictator for Life, which albeit tongue in cheek and casual, is reserved for project founders with a fair share of active participation and leadership initiatives and responsibilities.

As for Mozilla, a related role would be Module Owner:

A "module owner" is the person to whom leadership of a module's work has been delegated. The responsibilities of module ownership might include, in the case of a code module: improving code quality, implementing revisions and innovations as appropriate, coordinating development with that of the rest of the codebase, developing and maintaining a shared understanding of where the module is headed, developing APIs where appropriate, documenting as much as possible, responding appropriately to code contributions, design suggestions and stated needs of the community, and creating an environment where competent newcomers are welcomed and included.

But the role is quite more similar to Scrum Master than Product Owner.


答: The concept for Benevolent Dictator for Life is similar. Certain Open Source projects have creators that aren't necessarily directly involved in every change but have either an explicit or implicit veto on anything that happens with that software or language. Examples include Larry Wall of Perl, Guido Van Roussom of Python and Linus Torvalds for Linux.</p>

Title: How might the role of product owner go against the idea of open source, or work for it?

Body:
On a related questions about "Finding and/or becoming an open source product owner" -- the first comment to the question itself was "the idea of a product owner goes against the idea of open source."

Is this true, and if so, why?

If not, what circumstances and/or context would it make sense for open source project to have a product owner role?

I've attempt to find an example of this role at Mozilla.org -- but I've had no luck so far.

(Just to be clear, I'm talking about a volunteer role, not a paid position at a non-profit.)


答:
To me, it doesn't seem that the role of a product owner goes against the idea of open source.

The ideas of open source software is that of freedom to learn, improve, change, and distribute in the best possible manners that solve real-world problems. It's all about collaboration to create a product that's available to the general public and that's usable, with a great sense of transparency and visibility.

The question you linked to discusses a product owner in the sense of Scrum - an individual who represents the voice of the customer/user for the development team. This is a person who ensures that the product is valuable by creating (or, in some cases, transforming into a usable form) and prioritizing requirements and defect reports.

There are different structures for running open-source projects, just like there are different development methodology and team structures in companies developing commercial software. I don't know of any open source teams that have a "product owner" role, but I can see it being useful in some cases.

The role of a product owner would probably be most useful on a project where the development team is disjoint (fully or partially) from the users of the software. Looking at open source software packages, things like GNUmed, Koha, and Tux Paint stand out - the target audience are people with vastly different backgrounds than software developers (although some users of the packages might have software development experience), and often have special needs or requirements that must be understood. Someone or some people in a role similar to product owner would be useful to ensure that the product is useful to the target audience.

If anything would have a more detailed, authoritative discussion of this, I would suspect it would be the writings of Eric S. Raymond. It sounds like something that might be discussed in The Cathedral and The Bazaar, or a similar essay by Raymond. However, it's been a while since I read these works, so I can't quote anything in particular.


问:
Finding and/or becoming an open source product owner
Are there any open source projects that have roles that would be equivalent to a Scrum product owner role? If so, how did you go about finding these examples, and how do you believe those product owner roles came to be? </p>

<p>(Just to be clear, it's not a requirement the project is Scrum based, just that it's open source and roles stated are equivalent to a Scrum product owner role. Also, I'm talking about a volunteer role, not a paid position at a non-profit.)</p>

答:
Open source projects have product owners.

Python's product owner is Guido Van Rossum, the Benevolent Dictator for Life.

All open source projects with a single decision-maker (not a committee) have a product owner.  All.

Most open source projects are small.  There are a few committers and one decision-maker.  The product owner.

A few open source projects are large.  With a committee.

Some open source projects endure "forks" because more than one person wants to be product owner.


答:
I was curious about this question myself recently. Although I haven't done much reading on the topic. It seems to me the concept of product owner is as important to open source as other types of projects because product owner is what sets the priority (i.e. decides what features are important and which ones can be delayed or dropped).

Even open source teams need to have a backlog that they manage and this backlog needs to be prioritized based on importance.

However, while the concept of "product owner" is important, it could probably be done by more than one person since in open source just about everyone is a volunteer so clearly time might need to be split across multiple people.

Then there are few options:

If the open source project has one or few major customers/primary users.  Product owner person or group of people should work on maintaining active, healthy relationship with these users so that they can come back to the rest of open source project team and communicate the needs of those end-users.

If open-source project is used by a wide audience and it is difficult to get general sense of what features are important by talking to select few, another option would probably be to setup a public feature request/bug reporting website.  Then monitor it and see what kind of features/bug fixes people are asking for the most.  Again product owner person/group (whoever volunteers) would have to sift through those reports and adjust the backlog accordingly.


问:
A colourblind member of our team
My team relies a lot on colour within our code to outline features that need to be worked on (we colour lines of code that need attention). We have a close friend who is colourblind and wants to join our team. What can we do to highlight what needs work without using colour? We have about 25 people on the team that are all accustomed to the line colouring system and we have found it to be most efficient.</p>

答: Late to the party, but: Color Oracle is a program that runs on your computer and makes your desktop look like it would to a person with any of the different types of colorblindness. Run it with your IDE open, and tweak the colors you use for various things. Very few people are totally colorblind, in the sense that they can't perceive any color differences at all; you might be able to choose a set of colors that works for this person and for your team.

Title: A colourblind member of our team


问:
What is the easiest and cheapest way to distribute apple iOS enterprise app?
I work as a developer in a company, The company I work with has to deploy the app I made to their client. Number of clients are 3 and each client has around 100 iPads. Now my question is,

What different ways we can use in order to deploy and distribute app seamlessly?

How good is AppCentral to distribute applications?

答:
You may consider the use of some Mobile Device Management (MDM) software. Generally, they are subscription-based (per month/annum) per user (device) license, and allow for remote monitoring and management of the device.

Two such products in this area are Fiberlink's MaaS360 or Air Watch, and allow for both app types (public/enterprise) to be distributed from within their main admin portal area. You could upload or point the portal to your .ipa file (no provisioning file needed) and then get it to push your app OTA to any devices registered with the software.

Hope this is of some help as to the alternative app distribution methods out there.


答:
I have worked with a fundamentally distrusting client and it made life exceedingly difficult.

In most countries if you have a contract with a client then you can make explicit what will and will not take place and the contract will be binding. You may be able to reassure your client by pointing out that as a company based in the same territory, their complaint will have full force of law if you do steal their code.

However there is a difference between someone who has had their fingers burnt and someone with a paranoid nature. In the latter case I would avoid the client altogether as they will be difficult and expensive to deal with. Not impossible, but very difficult, very irritating and most likely to be among the 20% of clients who provide 80% of your support load.

Title: Is it possible to work with distrusting clients

Body:
One of our junior developers has been assigned a new client (we don't have the client yet, we're still working with him to see if we can meet his needs) and the junior developer said the client will hire us if we can do the work on his project without getting access to his server.

I've had a direct conversation with the client who turned out to have had his code stolen before by some offshore company that he outsourced. This made me more sympathetic but I still have mixed feelings about this.

On one hand I want to prove to the client that we're not all bad apples. Also if we do a good job with him, we get a loyal client who'll hire us for all his projects. I haven't heard of this happen before but I guess it happens more often than we'd all like to admit.

On the other hand I'm hesitant to accept working with him because deployment time is going to be a nightmare and no where in my career or education has anyone taught me how to work with clients like him. I (or the junior developer) would have to write a detailed description of exactly what to do with the source to deploy it and that is an annoying burden when I could deploy and test the whole thing in an hour myself.

As I said, I've never had to deal with this before (we're signing a non-disclosure but apparently so did the offshore company before us). We're not fully fully booked so it's not like I have an immediate replacement, but we're not begging for work either and I wonder if working under such restricted environment is worth the trouble.

Another side is that the experience itself could be rewarding for us, but is it experience worth having, as in what's even the likelihood of getting a similar client anytime soon. Are we even expected to comply with such clients?

So since I don't have any first hand experience with this and it definitely wasn't covered in school, how would those with longer experience working with clients deal with a distrusting client like this? Would you even accept the job?


问:
Advanced JavaScript design patterns
I'm looking for books, online resources or suggestions about how to structure big projects or build a framework in JavaScript.

I'm not looking for books explaining how inheritance or closures work. I'm more looking for design patterns and techniques to organize (and develop) complex applications.

At the moment I found:

this old topic Advanced javascript guidance

the pdf Building A JavaScript Framework

the article Let's Make a Framework: Library Architecture

Any other suggestion?

答:
IMHO (driven by my experience)..

If you want to learn abstract concepts, concentrate on the abstract concept. In other words, if you're looking at design patterns, read books such as GOF's Design Patterns book. Check out Wikipedia's Software Design Patterns page. Learn them. Love them.

If you want to learn Javascript, read ECMA-262. Learning and understanding the spec will help you in becoming an expert with the language.

Then..

You won't be asking these questions (not that there's anything wrong with them). You'll have a solid understanding of both areas and will be able to implement anything you need relatively trivially.

OwnerDisplayName: Ghigo

Title: Advanced JavaScript design patterns


答:
It's a no brainer, but really, do not rely a lot on color, on your code.

And in general, do not rely in a mandatory editing system.

(an IDE may be tolerable, but only given enough tradeoffs in term of productivity)

Establishing a proper indenting convention is already quite hard, time consuming, a matter of feuds, and a source of discontent. Mandating color would make most people I know mount the barricades.

Title: A colourblind member of our team

Body: My team relies a lot on colour within our code to outline features that need to be worked on (we colour lines of code that need attention). We have a close friend who is colourblind and wants to join our team. What can we do to highlight what needs work without using colour? We have about 25 people on the team that are all accustomed to the line colouring system and we have found it to be most efficient.</p>


答:
I am a Greek speaking language, too many years programmer, actually from my age of 13, and I just take a look now on many of my code to check my self if I use greeklish (that I also avoid them).

I found on my code that I use them in this cases.

when I do not know the english word, or not familiar with it.

when I am rush to write some code.

when the english and the greek are similar words, like "type" "typos", "seira" "serial", "idea"... etc

I never use greeklish for common words like the "User" -> Xristis, because the word "User" is used also from many libraries and this make confuse, but I found now that I review my code some words like "etisi" (αιτηση) that I am not sure how to say it in enlgish, is not a request, is not an application, is an ask for.. anyway.

I understand your problem, how can you try to learn words that actually not exist ! and there are not even help you to learn something.

I think that its their fault that mix up the language when all the involved developers do not know Greek, and you with a polite way, must find a way to tell them that this situation make your work slower and harder, and the code difficult to debug and understand.

I am against greeklish not only in programs but in Greek language also.


答: From comments I see that you're using a tool that you've developed in house. Given that, the solution is simple. Go through the code line by line and mark every line that impacts the way code is displayed as needing significant improvement. Then, fix your code. The value that your tool provides isn't in the particular color scheme you've chosen or even that the whole team currently uses one scheme. The value is that you can mark up code in a meaningful way. How that meaning is represented should be completely configurable. Think of the job as a welcome opportunity to improve your product.

Title: A colourblind member of our team


问:
Getting users to write decent and useful bug reports
Does anyone know a good way to get users to write a semi-decent (read: useful) bug report?

We wanted to put up something that would make sense to most users (be easy to read and understand), yet give useful information to developers as well.

It does not work when I click the blue button! Ahhh, I just lost a week's work ... make it work.

isn't very useful, as it is.

I started to fix about a list, but thought to check up with you guys, whether a similar method already exists.

答:
You might consider taking some ideas from Mozilla and Sun on this topic:

Bug writing guidelines - Mozilla MDN article

How to Write a Proper Bug - Mozilla QMO article

How to Write a Helpful Bug Report - Sun SDN article

Particularly (from the Mozilla "How to Write a Proper Bug" page):

General Outline of a Bug Report

Summary: How would you describe the bug in less than 60 characters? It should quickly and uniquely identify a bug report as
well as explain the problem, not your suggested solution.

Good: “Cancelling a File Copy dialog crashes File Manager”

Bad: “Software crashes”

Bad: “Browser should work with my web site”

Component: In which sub-part of the software does it exist?This field is a requirement to submit any bug report. Click the word
“Component” to see a description of each component. If none seems
appropriate, highlight the “General” component.

OS: On which operating system (OS) did you find it? (e.g. Linux, Windows XP, Mac OS X.)Example: “If you know the bug happens on more
than one type of operating system, choose “All”. If your OS isn’t
listed, choose Other”.

Description: The details of your problem report, including:

-Overview: This is a larger detailed restatement of the summary. An example would be: “Drag-selecting any page crashes Mac builds in the
NSGetFactory function”.

-Build Id: To find this either go to the “about:” page via the location bar or, if you have MozQA’s Nightly Tester Tools extension,
then go to Tools | Nightly Tester Tools and select the option that
contains the output of the build Id. It should look something like
this: “Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US;
rv:1.9.1b3) Gecko/20090305 Firefox/3.1b3″.

-Additional Builds and Platforms: Whether or not the bug takes place on other platforms (or browsers, if applicable). It should look
something like this: “Doesn’t Occur On Mozilla/5.0 (Macintosh; U;
Intel Mac OS X 10.5; en-US; rv:1.9.1b3) Gecko/20081107 Firefox/3.1b2″.

Steps to Reproduce: Minimized, easy-to-follow steps that will trigger the bug. If they’re necessary, make sure to include any
special setup steps.A good example of this would look like the
following:    1) View any web page. (I used the default sample page,
http://www.google.com/).    2) Drag-select the page. Specifically,
while holding down the mouse button, drag the mouse pointer downwards
from any point in the browser’s content region to the bottom of the
browser’s content region.

Actual Results: What the application did after performing the above steps.An example would be: The application crashed.

Expected Results: What the application should have done, were the bug not present.An example would be: The window should scroll
downwards. Scrolled content should be selected. Or, at least, the
application should not crash.

OwnerDisplayName: ldigas

OwnerDisplayName: Brian Snow

ContentLicense: CC BY-SA 4.0


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

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

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

答:
Lighting that doesn't make you feel like your on a supermarket floor.

Some nice big green plants

High performance pcs, Dual 22" LCD screens

A developer wiki

Sectional dividers so everyone can have their little privacy and not look at each other all day. Avoid cubicles though... there still has to be an interaction environment.

Ample workspace

Game room witha pool table/Ping Pong table, nice tv, PS3/XBox/Wii with some multiplayer games.

A nice kitchen

Balanced snack/drink machine that caters to healthy and non healthy eaters.

Nice outside area that is cool in summer where people can sit and relax and eat.

The work is the most important aspect. You can have all these things but still feel like your stuck in a terrible job. Work ahs to feel like fun, and the fun stuff has to be a bonus.


答:
The term product owner is a little ambiguous. The obvious (but usually incorrect) interpretation would be "someone who has legal ownership of the product, code, and related resources". The less obvious but more correct (in software development circles) interpretation is "the person who has responsibility for making final decisions about the product."

The first meaning is clearly at odds with many open source products since individual contributors often keep the rights to the code that they contribute. In such cases, a single product might have hundreds or thousands of "owners" who each "own" a small part of the code that produces the final product. Some projects ask contributors to assign their rights to an organization (such as the FSF) so that the code can be better protected, but even then the organization that "owns" the rights to the code usually isn't the "product owner" in the software development decision maker sense.

The second meaning, which from your question is clearly the one that you intended, might sometimes seem to be at odds with the usual open source process, which is often viewed as being democratic. An often-stated advantage of open source software is that if a product doesn't have a feature you want, you can add that feature and then contribute the code to the project for the benefit of everyone else. Although it does work that way much of the time, one would be mistaken to think that there's not someone who has the responsibility to review submissions and decide which ones to accept and which to reject. Just because you get your way a lot of the time doesn't mean that there's not a dictator. That person is the product owner, and most projects have one.


答:
If you want to be an open source product owner, follow these steps:

Create a useful product. It doesn't have to be complete, but it should be useful enough that other people are drawn to it and decide to start using it and contributing to it.

Make the source code available, along with an appropriate license. The details of how to do that are up to you, but there are plenty of good examples out there. Github seems popular for distributing source, and there are any number of licenses to choose from.

Continue to develop the project, and integrate appropriate contributions from other people. At some point during this phase, you might want to pick up a book about open source project administration. Or not. You're in charge.

Congratuations! You're an open source product owner!

Alternately:

Find an open source product that you like and to which you can make a meaningful contribution.

Become active in the development community for that product. Contribute heavily. Gain trust. Work your way through the ranks of contributor, committer, etc. Make it obvious through your deeds that you're the best person to lead it after the current product owner steps down.

Continue to participate actively in the development of the product while waiting for the current product owner (often the project founder) to become tired of the product, too busy to actively maintain it, or otherwise decide to hand the reins over to you.

Good luck.

Title: Finding and/or becoming an open source product owner

Body:
Are there any open source projects that have roles that would be equivalent to a Scrum product owner role? If so, how did you go about finding these examples, and how do you believe those product owner roles came to be? </p>

<p>(Just to be clear, it's not a requirement the project is Scrum based, just that it's open source and roles stated are equivalent to a Scrum product owner role. Also, I'm talking about a volunteer role, not a paid position at a non-profit.)</p>


答:
In my opinion, what's more important is using the bug to establish meaningful on going contact with the user. Writing and understanding bug reports is a skill, and my advice would to be to make it as easy as possible for the user to make first contact, then progressively make their feedback of more value as needed.

For example, just get the user's email, and give them a plain-text field with the following text to complete:

```<code>"I did _____ , and expected ______ to happen, but ______ happened instead."
</code>```

After you get the email, do an auto-reply to get a double-opt to confirm they submitted the bug, you've received it, and follow-up on the bug is okay.

Title: Getting users to write decent and useful bug reports

Body:
Does anyone know a good way to get users to write a semi-decent (read: useful) bug report?

We wanted to put up something that would make sense to most users (be easy to read and understand), yet give useful information to developers as well.

It does not work when I click the blue button! Ahhh, I just lost a week's work ... make it work.

isn't very useful, as it is.

I started to fix about a list, but thought to check up with you guys, whether a similar method already exists.

Body:
In my opinion, what's more important is using the bug to establish meaningful on going contact with the user. Writing and understanding bug reports is a skill, and my advice would to be to make it as easy as possible for the user to make first contact, then progressively make their feedback of more value as needed.

For example, just get the user's email, and give them a plain-text field with the following text to complete:

"I did _____ , and expected ______ to happen, but ______ happened instead."

After you get the email, do an auto-reply to get a double-opt to confirm they submitted the bug, you've received it, and follow-up on the bug is okay.


问:
when to load partial views
When creating a website, when should you load partial view and when should you do a complete page refresh?

I was looking at github's site and noticed that pretty much the only place they do partial loading is in a project's folder area.  I could see a couple places where they could have but didn't(tab navigation: feed, your actions, ...). But, Google plus does partial loads for search, and clicking on any of the header navigation buttons (pictures, games, circles, ...).

Why would you not do partial loading if the main container stays the same and the content is the only thing that is changing?

答: For SEO purposes too. If you want to have one page for everything, google will think that your site consists of one page. Not good. Better to have separate pages with good tags. </p>

Title: when to load partial views


问:
Difference between Controller and Dispatcher in MVC for web frameworks?
In MVC applied to WSGI or Java EE, is the Servlet a controller, dispatcher, or both? I think I've seen system diagrams where the controller and the dispatcher are different. Could the controller control SQL statements which should not be in the dispatcher?

Thank you

答:
Controller

The controller is the initial contact point for handling all requests in the system. The controller may delegate to a helper to complete authentication and authorization of a user or to initiate contact retrieval.

Dispatcher

A dispatcher is responsible for view management and navigation, managing the choice of the next view to present to the user, and providing the mechanism for vectoring control to this resource.

A dispatcher can be encapsulated within a controller or can be a separate component working in coordination. The dispatcher provides either a static dispatching to the view or a more sophisticated dynamic dispatching mechanism.


问:
Difference between a service class and a Helper class
I would like to know what differentiates  a Service class from a utility class or a helper class?
A class only with underlying methods calls the dao's is a service? Doesn't the usage of Helper classes violates SRP?</p>

答:
Service Class : Contain Business logic.

Helper Class : this class is one type of reusable component.


答:
One thing to be wary of is the multiple definitions of 'service' in DDD:

Application service: These sit in the application layer and communicate with the domain and data layer, they are the interface through which external systems/UI interact with the DDD system.

Domain Service: This can be used by the domain or the application layer, and contain business logic that does not fit neatly into one particular entity.

Infrastructure Service: These are used by the domain to communicate with external resources.

Helper classes tend to contain pieces of code or algorithms that would be reused by multiple entities, so can't really go into entities without violating the DRY principle. They are probably closest to Domain Services, in that they sort fulfil the same purpose (externalising business logic from entities) but they do it for different reasons.

Title: Difference between a service class and a Helper class

Body:
I would like to know what differentiates  a Service class from a utility class or a helper class?
A class only with underlying methods calls the dao's is a service? Doesn't the usage of Helper classes violates SRP?</p>


问:
How to Use Subversion Repository Inside Git Repository?
I'm developing a project in Git.  IT depends on another project, that's in a Subversion repository.  I'd like to be able to make changes to the Subversion project in the tree, and commit to/update from the Subversion repository from within the Git project.  Is that possible?</p>

答:
Are you just looking for git-svn? By depends do you mean the parent version is in svn, or it has vendors which are svn projects?

Assuming by depends you mean dependency:

You can put any kind of repo inside a git repository without problems. e.g.

```<code>$ mkdir ~/project
$ cd ~/project
$ git init
$ ...
$ git commit -va
[master (root-commit) xxxxxxx] Did something
 ...
$ mkdir vendors
$ cd vendors
$ svn checkout svnproject(url)
$ cd svnproject
$ ...
$ svn ci -m "committing to svnproject"
</code>```

etc.

And then manage svnproject as you normally would. You can of course use git-svn instead to interact with your svn repo using git commands.

You can also then do this:

```<code>$ cd ~/projects
$ git add vendors/svnproject
$ git commit -m "adding svnproject source to main repo"
</code>```

In that case, updates you make to files in svnproject will show up as both svn and git diffs. An example where /tmp/gitproject is a .. git project, and /tmp/gitproject/vendor/minify is a (random) svn checkout:

```<code>[andy@laptop:/tmp/gitproject/vendor/minify]$ vim README.txt
[andy@laptop:/tmp/gitproject/vendor/minify]$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working     directory)
#
#   modified:   README.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
[andy@laptop:/tmp/so/vendor/minify]$ svn status
M       README.txt
[andy@laptop:/tmp/so/vendor/minify]$
</code>```

If you use git-svn to interact with your svn-dependent repository, it's possible to keep it in sync with changes you've made in the parent git project using git-filter-branch and therefore not need to commit to each repository individually.

As an aside: from experience keeping a git and svn project in sync is generally quite problematic unless one or the other is read-only.

Body:
Are you just looking for git-svn? By depends do you mean the parent version is in svn, or it has vendors which are svn projects?

Assuming by depends you mean dependency:

You can put any kind of repo inside a git repository without problems. e.g.

$ mkdir ~/project
$ cd ~/project
$ git init
$ ...
$ git commit -va
[master (root-commit) xxxxxxx] Did something
 ...
$ mkdir vendors
$ cd vendors
$ svn checkout svnproject(url)
$ cd svnproject
$ ...
$ svn ci -m "committing to svnproject"

etc.

And then manage svnproject as you normally would. You can of course use git-svn instead to interact with your svn repo using git commands.

You can also then do this:

$ cd ~/projects
$ git add vendors/svnproject
$ git commit -m "adding svnproject source to main repo"

In that case, updates you make to files in svnproject will show up as both svn and git diffs. An example where /tmp/gitproject is a .. git project, and /tmp/gitproject/vendor/minify is a (random) svn checkout:

[andy@laptop:/tmp/gitproject/vendor/minify]$ vim README.txt
[andy@laptop:/tmp/gitproject/vendor/minify]$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working     directory)
#
#   modified:   README.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
[andy@laptop:/tmp/so/vendor/minify]$ svn status
M       README.txt
[andy@laptop:/tmp/so/vendor/minify]$

If you use git-svn to interact with your svn-dependent repository, it's possible to keep it in sync with changes you've made in the parent git project using git-filter-branch and therefore not need to commit to each repository individually.

As an aside: from experience keeping a git and svn project in sync is generally quite problematic unless one or the other is read-only.


答:
Assuming that we're talking about the "Free / Libre Open Source Software" (FLOSS) movement, then the concept of software ownership is completely incompatible. One of the core ideas in FLOSS is that software, just like works of literature, art, and music, cannot be owned by anyone. Once you have written the software, it must be made available to anyone, with only minimal restrictions (if any).

Within the communities, opinions differ which restrictions can be put on software to make it maximally 'free', but none of them is compatible with a concept of ownership. Ownership implies that the owner has a right to prevent others from using the software; FLOSS requires that no such restriction exists.

The closest thing to a project owner, in Free Software, would be the project lead or project maintainer. Often, this person is also the original author, and he / she publishes the "official" version, deciding which changes are included and which aren't. However, even for the most rigidly organized projects, the project owner does not have 'absolute' power - anyone is free to fork the project, modify it in any way they want, and redistribute the result, and if the project maintainer takes grossly impopular decisions, the community tends to mass-migrate to a saner fork, which then becomes the new standard.


问:
Testing an IRC Bot
I'm using Autumn gem to create a Ruby IRC bot for a game. However, it makes me feel rather embarrassed because I don't know how to test this kind of program...

I think I should mock the IO process to have a control over it but I can't see how in this case when using the gem.

Has anyone an idea ?

答: Why don't you run a local IRC server? Restrict it to the local network, or even just localhost, and you can easily test your bot using your favorite IRC client.</p>

Title: Testing an IRC Bot


问:
Is Independent Java Development Worth it Compared to Objective-C?
First I would like to say that I'm not developer, but I love to code whenever I can. I mainly use Perl which is the language I use when doing System Administration.

For different reasons (that I'm not sure of) I recently have been told to learn Java by my manager, so I'm starting to do so.

I was thinking that I should take advantage to the situation to build some Android Apps. But it seems that Objective C has increased in popularity recently because of the iPhone and iPad.

I want to know if it's worth it to develop with Java for Android compared with to develop with Objective C for iPhone (or iPad). Of course, not based on the APP functionality, let's say someone has developed the APP X for both platforms. In which platform would it become the worthiest?

And no, I'm not gonna learn both (sadly ain't got much time)

Thank you!

答:
And no, I'm not gonna learn both (sadly ain't got much time)

I wouldn't be so hasty. Java and Objective-C are similar enough that once you're familiar with one the other should be very easy to pick up. Likewise Android and iOS aren't all that different either. So you can view one as a stepping stone to the other.


答:
Do you have a Mac?

If no. Problem solved, you're doing Java.

will your boss expect you to use the Java he's asking you to learn?
If yes. Problem solved, you only want to learn one, you need Java, learn Java.

Personally I disagree strongly with GrahamParks assertion that Objective C and Java are similar. There are a lot of similarities, but you're talking about a perhaps a week of saved effort learning the language structure. I found the idioms of Objective C harder to pick up than Java, and the APIs for both are huge and very different, even where they achieve the same thing.

If I were going to do mobile development professionally, six months ago or more I would of started on iPhone. Single platform, limited range of hardware to cater for, limited range of versions and feature variations all make life much much easier.

These days, I'd probably start on Android. The variety of form factors and versions is still an issue, but the user base is large enough and the platforms are converging enough for it to feel more practical now.

Title: Is Independent Java Development Worth it Compared to Objective-C?

Body:
First I would like to say that I'm not developer, but I love to code whenever I can. I mainly use Perl which is the language I use when doing System Administration.

For different reasons (that I'm not sure of) I recently have been told to learn Java by my manager, so I'm starting to do so.

I was thinking that I should take advantage to the situation to build some Android Apps. But it seems that Objective C has increased in popularity recently because of the iPhone and iPad.

I want to know if it's worth it to develop with Java for Android compared with to develop with Objective C for iPhone (or iPad). Of course, not based on the APP functionality, let's say someone has developed the APP X for both platforms. In which platform would it become the worthiest?

And no, I'm not gonna learn both (sadly ain't got much time)

Thank you!


问:
How should HTML data formats be applied in everyday situations?
Given Google's shift towards a stronger focus on page markup data, how do the data formats used in Schema.org work alongside those for Microformats? How do these (and other specs) compliment each other and which should be used in preference in different situations?

Edit:

It seems from established content on the subject that opinion seems to be divided between those who believe Schema.org is doom, hellfire and brimstone and those who think it will ultimately be a good thing either way regardless of uptake.

Both articles agree at least that the different formats can coexist happily without causing search engines undue grief. The question about how the different options might be used in specific cases still remains though.

答:
Metadata and the related format types in the end come down to the net return provided (return=value-cost) and the uptake in their popularity, which follows the same technology adoption life cycle of any new approach.

The cost of Google supporting a format is low, so I would not read anything into that. Both formats have been around a long-time, and to my knowledge trace back to the concept of the Semantic Web; which is to say the idea and formats have been around forever in internet time, so is nothing new. That said, the clearly over-hyped article you link to titled, "Google Will Change Web Marketing in 2012", which makes me laugh just hearing the title, isn't completely off in that Google over the years has been pulling more and more metadata into it's search results, and often them doing so creates opportunities in marketing; best example to my knowledge being local search results, which provided Google, users, and businesses real value.

As for conflicts between the two formats, it's unlikely, just be consistent about the data presented across the board, and about when that data is updated; this based on how Google handles other duplicate content/metadata in varying formats, for example HTML-vs-sitemap.xml link/content/metadata.

(If for some reason I've missed a key-point in your question, just let me know and I'll attempt to address it.)


问:
Never use Strings in Java?
I stumbled upon a blog entry discouraging the use of Strings in Java for making your code lack semantics, suggesting that you should use thin wrapper classes instead. This is the before and after examples the said entry provides to illustrate the matter:

```<code>public void bookTicket(
  String name,
  String firstName,
  String film,
  int count,
  String cinema);

public void bookTicket(
  Name name,
  FirstName firstName,
  Film film,
  Count count,
  Cinema cinema);
</code>```

In my experience reading programming blogs I've come to the conclusion that 90% is nonsense, but I'm left wondering whether this is a valid point. Somehow it doesn't feel right to me, but I couldn't exactly pinpoint what is amiss with the style of programming.

答:
I think you have to look at this concept from another starting point. Take a look from the perspective of a database designer: the types passed in the first example do not define your parameters in a unique way, let alone a useful way.

```<code>public void bookTicket(
  String name,
  String firstName,
  String film,
  int count,
  String cinema);
</code>```

Two parameters are needed to specify the actual patron that is booking tickets, you might have two different movies with identical names (e.g. remakes), you might have the same movie with different names (e.g. translations). A certain chain of movie theaters might have different branch offices, so how are you going to deal with that in a string and in a consistent way (e.g. are you using $chain ($city) or $chain in $city or even something else and how are you going to make sure that this is used consistently. The worst actually is specifying your patron by means of two parameters, the fact that both a first name and surname are provided does not guarantee a valid customer (and you cannot distinguish two John Does).

The answer to this is to declare types, but these will rarely be thin wrappers as I show above. Most likely, they will function as your data storage or be coupled with some kind of database. So a Cinema object will likely have a name, location, ... and that way you get rid of such ambiguities. If they are thin wrappers, they are by coincidence.

So, IMHO the blog post is just saying "make sure you pass the correct types", its author just made the overly-constrained choice to pick at basic data types in particular (which is the wrong message).

The proposed alternative is better:

```<code>public void bookTicket(
  Name name,
  FirstName firstName,
  Film film,
  Count count,
  Cinema cinema);
</code>```

On the other hand, I think the blog post goes too far with wrapping everything. Count is too generic, I could count apples or oranges with that, add them and still have a situation on my hands where the type system allows me to do nonsensical operations. You can of course apply the same logic as in the blog and define types CountOfOranges etc., but that is also plain silly.

For what it's worth, I'd actually write something like

```<code>public Ticket bookTicket(
  Person patron,
  Film film,
  int numberOfTickets,
  Cinema cinema);
</code>```

Long story short: you shouldn't be passing nonsensical variables; the only times you'd actually specify an object with a value that doesn't determine the actual object, is when you either run a query (e.g. public Collection<Film> findFilmsWithTitle(String title)) or when you are putting together a proof-of-concept. Keep your type system clean, so don't use a type that is too general (e.g. a movie represented by a String) or too restrictive/specific/contrived (e.g. Count instead of int). Use a type that defines your object uniquely and unambiguously whenever possible and viable.

edit: an even shorter summary.
For small applications (e.g. proof of concepts): why bother with a complicated design? Just use String or int and get on with it.

For large applications: is it really that likely that you have lots of classes that consist of a single field with a basic data type? If you have little such classes, you just have "normal" objects, nothing special going on there.

I feel the idea of encapsulating strings, ... is just a design that is incomplete: overly complicated for small applications, not complete enough for large applications.

Title: Never use Strings in Java?

Body:
I think you have to look at this concept from another starting point. Take a look from the perspective of a database designer: the types passed in the first example do not define your parameters in a unique way, let alone a useful way.

public void bookTicket(
  String name,
  String firstName,
  String film,
  int count,
  String cinema);

Two parameters are needed to specify the actual patron that is booking tickets, you might have two different movies with identical names (e.g. remakes), you might have the same movie with different names (e.g. translations). A certain chain of movie theaters might have different branch offices, so how are you going to deal with that in a string and in a consistent way (e.g. are you using $chain ($city) or $chain in $city or even something else and how are you going to make sure that this is used consistently. The worst actually is specifying your patron by means of two parameters, the fact that both a first name and surname are provided does not guarantee a valid customer (and you cannot distinguish two John Does).

The answer to this is to declare types, but these will rarely be thin wrappers as I show above. Most likely, they will function as your data storage or be coupled with some kind of database. So a Cinema object will likely have a name, location, ... and that way you get rid of such ambiguities. If they are thin wrappers, they are by coincidence.

So, IMHO the blog post is just saying "make sure you pass the correct types", its author just made the overly-constrained choice to pick at basic data types in particular (which is the wrong message).

The proposed alternative is better:

public void bookTicket(
  Name name,
  FirstName firstName,
  Film film,
  Count count,
  Cinema cinema);

On the other hand, I think the blog post goes too far with wrapping everything. Count is too generic, I could count apples or oranges with that, add them and still have a situation on my hands where the type system allows me to do nonsensical operations. You can of course apply the same logic as in the blog and define types CountOfOranges etc., but that is also plain silly.

For what it's worth, I'd actually write something like

public Ticket bookTicket(
  Person patron,
  Film film,
  int numberOfTickets,
  Cinema cinema);

Long story short: you shouldn't be passing nonsensical variables; the only times you'd actually specify an object with a value that doesn't determine the actual object, is when you either run a query (e.g. public Collection<Film> findFilmsWithTitle(String title)) or when you are putting together a proof-of-concept. Keep your type system clean, so don't use a type that is too general (e.g. a movie represented by a String) or too restrictive/specific/contrived (e.g. Count instead of int). Use a type that defines your object uniquely and unambiguously whenever possible and viable.

edit: an even shorter summary.
For small applications (e.g. proof of concepts): why bother with a complicated design? Just use String or int and get on with it.

For large applications: is it really that likely that you have lots of classes that consist of a single field with a basic data type? If you have little such classes, you just have "normal" objects, nothing special going on there.

I feel the idea of encapsulating strings, ... is just a design that is incomplete: overly complicated for small applications, not complete enough for large applications.


问:
Are C and/or C++ viable/practical options for web development?
I am proficient in C, and I am learning C++ right now. I always played with websites (HTML/CSS), and I was wondering if it would be viable/practical to create some simple web apps using C and/or C++.

For C it would be via CGI scripts, as explained in this tutorial for example -> http://www.cs.tut.fi/~jkorpela/forms/cgic.html

For C++ it could be via a web toolkit like Wt -> http://www.webtoolkit.eu/wt

Notice that I know it's possible (as explained in this previous question -> Can C++ be used as a server-side web development language? ).

What I am asking is if it's viable/practical (i.e., not a nightmare). I am not keen on picking up another language yet as I just started with C++, but if it would make web dev incredibly easier I will consider it (or I'll postpone my web dev projects until I am ready to pick up a new language).

Also, in case you think it's viable/practical, recommendations on the route to follow would be highly appreciated (i.e., forget C and go with C++, what framework to use and so on).

答:
C++ as a web server language is a good idea under some constraints only. From the CPPCMS website :

When CppCMS Should Be Used.

C++ language is far from being popular for Web development for many
  reasons: lack of appropriate tools, skills of developers and many
  more.

However, there are areas where C++ web programming with CppCMS becomes
  very useful and efficient, and some where it is just a waste of time.

When CppCMS should or can be used?

High load web sites and application with hundreds and thousands hits
  per second, where high performance, efficiency and scalability is
  required.

Application that require scalable Comet/Server Push1
  technologies --- CppCMS can efficiently handle hundreds and thousands
  simultaneous HTTP connection with minimal resources usage.

Embedding web interface2 into existing C++ applications/services with a small
  cost of additional library.

Embedded underpowered devices -- CppCMS
  allows creation of rich applications with relatively low cost of
  hardware that would perform reasonably fast.

When Not To Use?

If you create small web applications that do not require high loads
  and require very short time-to-market period -- probably tools like
  Django or RoR would be more appropriate for such tasks.

Also, take a look at the rational for the need of CPPCMS.

If you build your personal blog, create small or even medium community
  or building a web site for a small company --- CppCMS is not for you.
  Take any of existing and good CMS like Drupal or develop with great
  Django framework, you'll be fine.

However, when the loads become more then average, the process of
  scale-up using existing web frameworks may be painful:

Low performance of dynamic or JIT languages enforces you to add more
  servers even on quite small loads. The caching becomes more
  complicated and less efficient because the system becomes distributed
  and does not scale-up linearly. Creation of such system requires
  skilled stuff and costs even more. CppCMS allows you to increase the
  performance of typical system by an order of magnitude and thus:

Remove requirement of maintaining a big server farm where few servers
  or even single one would solve the load problems. Reduce maintenance
  costs and power consumption.

Now, if you think you'll make this kind of website, it might be of interest.

Note that most devs will not need such power. If you want to do something that might really be power consuming, and in a way that is obvious, not because you pessimize, then why not use C++.


问:
Is it OK to include another person's open-source module in a project that you are uploading to GitHub?
This seems like it would be an obvious "yes". However, I just want to be sure and I've tried googling around to no avail.

I am learning Python/Django and uploading all of the projects I'm creating to GitHub. I'm starting to add in existing modules from other open-source projects that do not belong to me. Is it still okay to upload MY projects to GitHub, even though they include other people's open source modules as well? Should I give them credit in the README, or by commenting where their code is included?

Thanks.

答:
"open-source" is a wide term. The answer depends on the particular license of those projects (and yours), so look that up, or better yet, ask the author.

Personally, I prefer if the dependencies of the project are listed in a text file. If installable on popular linux distributions by the package manager, providing the command line for that is a great convenience. If not, a script that fetches them and puts somewhere so the build script/Makefile finds them is also great. This solves the question of licensing because you don't include them in your repo.

In the case that all these dependencies are available as publicly "clone-able" git repos, you can use submodules to manage them.


问:
PHP web application architecture/design
I've been thrown head-first into a new job developing web applications in PHP. I'm by no means new to PHP, but I haven't developed large-scale applications before. I'm wondering how to structure my development to avoid setting myself up for problems in the future. How do I design and architect my applications in a sound way that allows them to scale over time in terms of functionality and performance. I'm thinking of things like:

Separating back end from front end

Directory structures

I would appreciate pointers to architectural and application design patterns, frameworks and methods that allow me to approach large-scale PHP web application development in a sustainable way.

答:
IBM's developerworks web site has a huge pile of PHP articles, a lot of them quite good.  They have a series of articles comparing PHP web frameworks, and another series about web sites using the CakePHP framework.

O'Reilly's old "Onlamp" website has an article about MVC in PHP.  The author of that article went on to explain MVC in some detail.

The O'Reilly articles are a little old, but they'll get you going.  The IBM developerworks stuff is really good, and covers a lot of what you're asking for.

Title: PHP web application architecture/design


答:
I've been working around PHP for a few years now. Altough I agree with Yannis that this question is somehow open, I think I'd be giving you a few pointers. First, as Yannis said, yu should look into MVC, to do so, the two frameworks I can recommend are CodeIgniter and Symfony. The first one is lightweight and very easy to get started with, however, you might just need to add some extra customizations to get a nice setup working, will get into that soon. Symfony is a project started by Fabien Potencier that uses many of the design patterns in software engineering, however, the learning curve is much steeper than CodeIgniter's.

Now, second, you should look into database connection, which takes me into the two most prominent ORM frameworks for PHP, Doctrine and Propel. Personally I love Propel and even wrote on how to set up a clean Propel install on a CodeIgniter based app, however, Symfony is more into Doctrine, but let's you use either one. If you'd like to check out some more on Doctrine and Propel, take a look to this question I asked some time ago.

Finally, you should look into a templating framework, like Smarty, Dwoo or Twigg. Smarty is the oldest and hence the most stable. Dwoo inherits from Smarty and adds a thing or two to support OOP better on PHP 5. Finally Twigg is the templating alternative provided the Symfony team, I haven't see it myself but if it comes from the Symfony team it should be nice.

Hope this whole speach makes some sense,
David

Title: PHP web application architecture/design

Body:
I've been thrown head-first into a new job developing web applications in PHP. I'm by no means new to PHP, but I haven't developed large-scale applications before. I'm wondering how to structure my development to avoid setting myself up for problems in the future. How do I design and architect my applications in a sound way that allows them to scale over time in terms of functionality and performance. I'm thinking of things like:

Separating back end from front end

Directory structures

I would appreciate pointers to architectural and application design patterns, frameworks and methods that allow me to approach large-scale PHP web application development in a sustainable way.


答:
I've done web development in C++, and I'm convinced that it's the wrong tool for the job.  Mostly because it's a "batteries not included" language, where those "batteries" are things like:

Unicode support

Parsers/builders for common data formats:

XML

JSON

MIME messages

a SQL database client

which are present in the Python standard library or the .NET Framework.

You can get this functionality in C++ with third-party libraries like POCO, but it's still less convenient than having it standard.

Title: Are C and/or C++ viable/practical options for web development?

Body:
I am proficient in C, and I am learning C++ right now. I always played with websites (HTML/CSS), and I was wondering if it would be viable/practical to create some simple web apps using C and/or C++.

For C it would be via CGI scripts, as explained in this tutorial for example -> http://www.cs.tut.fi/~jkorpela/forms/cgic.html

For C++ it could be via a web toolkit like Wt -> http://www.webtoolkit.eu/wt

Notice that I know it's possible (as explained in this previous question -> Can C++ be used as a server-side web development language? ).

What I am asking is if it's viable/practical (i.e., not a nightmare). I am not keen on picking up another language yet as I just started with C++, but if it would make web dev incredibly easier I will consider it (or I'll postpone my web dev projects until I am ready to pick up a new language).

Also, in case you think it's viable/practical, recommendations on the route to follow would be highly appreciated (i.e., forget C and go with C++, what framework to use and so on).


答:
Yes C++ can be used. I would recommend using a framework like Lacewing to simplify things.

There are two good reason to use C++ for web development

You need a HTTP server on a embedded device

You need speed, real speed. Your either scaling into the millions or are doing CPU bound computation (think dynamic image processing or heavy AI)


答:
Today C++ web development is as easy as web development with other languages that are traditional for this field (Java, C#, Ruby, PHP, Python).

CppCMS gives you all you need to do web development in C++.

So if C++ is the language of your choice... There is no reason not to use C++.

However you will still need to learn many web development concepts: HTML, Ajax, Forms, MVC, SQL, Session management and so on.

Disclosure: I'm the author of CppCMS.


答: Where possible, I contact the authors and ask their permission, then make sure to put highly visible attributions in the README. I'm not sure about the legal aspect, but it's just courteous, in keeping with the spirit of the community and to date no-one refused. It's also a great chance to connect with other devs!</p>

Title: Is it OK to include another person's open-source module in a project that you are uploading to GitHub?

Body:
This seems like it would be an obvious "yes". However, I just want to be sure and I've tried googling around to no avail.

I am learning Python/Django and uploading all of the projects I'm creating to GitHub. I'm starting to add in existing modules from other open-source projects that do not belong to me. Is it still okay to upload MY projects to GitHub, even though they include other people's open source modules as well? Should I give them credit in the README, or by commenting where their code is included?

Thanks.


问:
What benefits are there to native JavaScript development?
Given how much simpler jQuery development is, when compared to native JavaScript, what makes people forgo libraries like jQuery altogether?

Is this because jQuery has limitations or it is slow? I mean, if jQuery is so easy compared to native javascript, what reasons do people have to still use pure javascript?

答:
I can add two more reasons that weren't mentioned:

When I pick up brand new technology, a lot of times, I would start with lower-level constructs before going to higher-level ones. I'm primarily a C++/C# developer, but a while ago when I first started playing around with HTML/CSS/JavaScript, I chose not to use any framework because I wanted to first get understanding of the technology (that is, the JavaScript language itself) that those frameworks are built on top of.

Having said that, I've since discovered jQuery and would never want to go back to coding by hand what jQuery can do for you in 1-2 lines of code.

I don't know how common this is, but to me it seems that there are a lot of people who when they see the next framework/technology/language, their first response is, "not another API for me to learn!" They don't care how easy jQuery is, but they simply see it as standing in the way between them and delivering work using their "true and tried" methods. This is the same category of people who refuse to use the Boost library or any of STL and continue to use malloc for just about everything. You asked why they pick pure JavaScript over jQuery and in reality they never made the pick because most of the time they refused to evaluate jQuery in the first place and are perfectly happy with their current pace of development, no matter how slow it is.

OwnerDisplayName: Mike


答:
A rough diagram of the architecture of the latest large scale project I was involved in.

It's only a basic outline, adapted from the actual architecture documents and presented in a way that resembles a typical n-tier approach combined with a typical MVC approach. As you can see the logic and data tiers are connected via a service layer, and more specifically a REST API, that was inspired by Recess, a lesser known PHP framework.

Don't reinvent the wheel

I work with three frameworks:

Zend Framework

The behemoth of PHP frameworks, with an impressively well written codebase and extensive list of features. On large scale applications you'll find yourself tweaking the framework more often than not, and I find ZF's codebase the most pleasant to work with. But beware, it's not an entry level framework.

Kohana

Kohana started out as a fork of CodeIgniter, and that was reason enough for me not to use it, initially. Nowadays it has grown into a solid and elegant framework that differentiates itself from every other by following an Hierarchical MVC approach. HMVC allows for a greater extend of modularization than MVC. For the project in the diagram I adapted Kohana's HMVC to ZF, but I've started using Kohana for smaller projects and considering it for larger as well.

CodeIgniter

I only use it because of a legacy project I inherited, avoid if possible.

As the other answers pointed out, an ORM always comes handy. I use Doctrine extensively, and you should take a look at its brand new mappers for CouchDB and MongoDB. Scalability is a must on large scale applications and you should evaluate NoSQL solutions.

All that said, the important thing to remember is that larger applications usually have unique challenges. You should evaluate every popular third party solution there is, and you will probably gain a lot from a couple of obscure ones. When I first evaluated Recess it was far from production ready but its approach essentially made it into the project.

Performance

On typical websites you may get away with simple output caching and opcode caching but on large scale applications you should really consider memory caching, that most commonly is build around memcached.

xdebug is mostly known as a debugger, but can serve as a profiler as well. I've recently started using Zend Server and I absolutely adore its code tracing features. Unfortunately those are not available in the Community Edition, but xdebug is a
pretty decent alternative.

If you are using Apache, make sure to optimize the hell out of it. nginx and lighttpd are apparently better choices, performance wise, but I haven't used them a lot and I can't really say.

As for the database, Doctrine's query & result caching works wonders, especially combined with memcached. And of course, we can't forget about the front end. Yahoo's Exceptional Performance team has assembled an extensive list of best practices. I'm not really a front end developer, but I've seen amazing results on solo projects.

Lastly PHP has a brand new garbage collection mechanism, worth looking into.

Security

The world of PHP security is chaotic, to say the least. I'm no expert, so treat the following as generic tips:

Open Web Application Security Project

Lot's of good stuff in there, but for a quick overview you should start with the top ten list. And research PHP solutions for those common vulnerabilities.

Stack vulnerabilities

A good habit is to periodically monitor PHP's open bugs. Even if you are no expert yourself, there are almost always workaround tips on security threats. And of course, you should extend the habit to every other part of the stack, especially the most vulnerable ones, like the web server and the database.

The crowd over at IT Security Stack Exchange can help you with more educated answers.

Further reading

What should every programmer know about web development?

Is it possible to effectively develop PHP applications on Windows that will be deployed on servers running Linux?

Towards RESTful PHP - 5 Basic Tips

Is ORM an Anti-Pattern?

Writing Secure PHP

Title: PHP web application architecture/design


问:
Why are cons lists associated with functional programming?
I have noticed that most functional languages employ a singly-linked list (a "cons" list) as their most fundamental list types. Examples include Common Lisp, Haskell and F#. This is different to mainstream languages, where the native list types are arrays.

Why is that?

For Common Lisp (being dynamically typed) I get the idea that the cons is general enough to also be the base of lists, trees, etc. This might be a tiny reason.

For statically typed languages, though, I can't find a good reasoning, I can even find counter-arguments:

Functional style encourages immutability, so the linked list's ease of insertion is less of an advantage,

Functional style encourages immutability, so also data sharing; an array is easier to share "partially" than a linked list,

You could do pattern matching on a regular array just as well, and even better (you could easily fold from right to left for example),

On top of that you get random access for free,

And (a practical advantage) if the language is statically typed, you can employ a regular memory layout and get a speed boost from the cache.

So why prefer linked lists?

答:
Linked lists are important for the following reason:

Once you take a number like 3, and convert it to successor sequence like succ(succ(succ(zero))), and then use substitution to it with {succ=List node with some memory space}, and {zero = end of list}, you'll end up with a linked list (of length 3).

The actual important part is numbers, substitution, and memory space and zero.


答:
The most important factor is that you can prepend to an immutable singly linked list in O(1) time, which allows you to recursively build up n-element lists in O(n) time like this:

```<code>// Build a list containing the numbers 1 to n:
foo(0) = []
foo(n) = cons(n, foo(n-1))
</code>```

If you did this using immutable arrays, the runtime would be quadratic because each cons operation would need to copy the whole array, leading to a quadratic running time.

Functional style encourages immutability, so also data sharing; an array is easier to share "partially" than a linked list

I assume by "partially" sharing you mean that you can take a subarray from an array in O(1) time, whereas with linked lists you can only take the tail in O(1) time and everything else needs O(n). That is true.

However taking the tail is enough in many cases. And you have to take into account that being able to cheaply create subarrays doesn't help you if you have no way of cheaply creating arrays. And (without clever compiler optimizations) there is no way to cheaply build-up an array step-by-step.

Title: Why are cons lists associated with functional programming?

Body:
I have noticed that most functional languages employ a singly-linked list (a "cons" list) as their most fundamental list types. Examples include Common Lisp, Haskell and F#. This is different to mainstream languages, where the native list types are arrays.

Why is that?

For Common Lisp (being dynamically typed) I get the idea that the cons is general enough to also be the base of lists, trees, etc. This might be a tiny reason.

For statically typed languages, though, I can't find a good reasoning, I can even find counter-arguments:

Functional style encourages immutability, so the linked list's ease of insertion is less of an advantage,

Functional style encourages immutability, so also data sharing; an array is easier to share "partially" than a linked list,

You could do pattern matching on a regular array just as well, and even better (you could easily fold from right to left for example),

On top of that you get random access for free,

And (a practical advantage) if the language is statically typed, you can employ a regular memory layout and get a speed boost from the cache.

So why prefer linked lists?

Body:
The most important factor is that you can prepend to an immutable singly linked list in O(1) time, which allows you to recursively build up n-element lists in O(n) time like this:

// Build a list containing the numbers 1 to n:
foo(0) = []
foo(n) = cons(n, foo(n-1))

If you did this using immutable arrays, the runtime would be quadratic because each cons operation would need to copy the whole array, leading to a quadratic running time.

Functional style encourages immutability, so also data sharing; an array is easier to share "partially" than a linked list

I assume by "partially" sharing you mean that you can take a subarray from an array in O(1) time, whereas with linked lists you can only take the tail in O(1) time and everything else needs O(n). That is true.

However taking the tail is enough in many cases. And you have to take into account that being able to cheaply create subarrays doesn't help you if you have no way of cheaply creating arrays. And (without clever compiler optimizations) there is no way to cheaply build-up an array step-by-step.


答:
You can use Cons nodes easily only if you have a garbage collected language.

Cons Nodes match a lot with the functional programming style of recursive calls and immutable values. So it fits well into the mental programmer model.

And don't forget historical reasons. Why are they still called Cons Nodes and worse still use car and cdr as accessors? People learn it from text books and courses and then use it.

You are right, in the real world arrays are much easier to use, consume only half the memory space and are much performanter because of cache level misses. There is no reason to use them with imperative languages.


问:
How can I prevent programmers from capturing data entered by users?
I'm developing a web application with a strong focus on security. What measures can be taken to prevent those who work on the application (programmers, DBAs, quality assurance staff) from capturing user entered values that should be well-protected, such as passwords, social security numbers, and so forth?</p>

答:
This is quite simple.  Banks do it all the time.

You have three groups of people involved.  These are security groups.  With distinct authorizations.

Developers cannot assign security authorizations and cannot see production data.

Operators cannot assign security authorizations and cannot create software.

Security folks who set the authorizations and can neither create software nor operate the software.

The developers create software.  The operators install it and operate it.  The security folks assure that the two groups are kept separated.