答:
Web API takes advantage of the http protocol more natively. Odata is an Open standard embraced by a lot of the big players. I can only speak from my experience int toying  around with Odata, and recently discovering Web API and doing some research.

OData is cool because it's an actual standard. You can easily create a database and expose it over HTTP. This means you can traverse your table structure without any configuration (i say that loosely). You can also run queries through the URL which can include some light LINQ:

```<code>/products/orders/[put some linq-ish query here]
</code>```

This is arguably good or bad. Authentication is standard and built it.

Web API, is more interesting from my perspective. It utilized the HTTP functionality (error messages, et al.) and is a bit more "native" to true RESTful requests. I really haven't played with it too much.. But i've read around and have kind of "heard" that MVC and Web API may be "married" some day, again, maybe good maybe bad...

When i was playing with OData, i created a Stored Proc, Mapped it into the entity surface, configured a strong return type and then hooked it up to a URL request and BANG, there's my RESTful request mapped to my typed result stored proc. It was fairly straightforward, and i was able to get exactly what i needed.

In Conclusion
I haven't had a chance to play with WCF API in too much detail, but i would say it's the way to go for client development since it's more of a purist approach to REST. If you're going to be making more or less "straight" back and forth calls and retrieving "View Models", it will provide a more native interaction.

On the other hand. If you'll be making complex (ish) queries on the data based on the client interaction and you want to "build" the query logic and pass it as a parameter, then Odata could work.

The way i look at it is if i need to expose my data in a structural format (meaning table / relationship structure) and then query it directly form a client, then Odata will work best. It's also good for allowing "Others" to access the data (with proper auth etc..) which is why it adhere's to the OData protocol

If you want RESTful requests where you're dictating the URL (/products/orders/22, and creating complex "result sets" from your "hidden" managed code and data structure AND you might also benefit from the HTTP response messages, then the Web API would probably be the best bet..

again, this is all from research and toying. I haven't implemented either in a production / full blown app scenario. I think they'll both have their strengths and weaknesses, and there's definitely some overlap

Title: WCF Data Services (OData) Vs ASP.NET Web API? Hypermedia?

Body:
I'm desiging a distributed application that will consist of REST services and a variety of clients (Silverlight, iOS, Windows Phone 7, etc).  I was ready to decide that I would implement my REST services using WCF Data Services (OData) but now the the MVC 4 Web API has made me question that decision.

What I liked about OData was the URI querying and hypermedia capabilities you get for free.  What I disliked was the verbosity of the OData payload; lots of unnecessary characters coming over the wire.

What I like about the Web API is that the payloads are much more concise and it has the URI querying capability of OData, however it seems to be lacking hypermedia (out of the box, at least).  My boss is also pushing for the Web API because "the powers that be at Microsoft are backing it and OData hasn't been getting traction."

So I have two questions:

1) Can anyone comment on the backing/traction of the Web API and OData?

2) Is the Web API expected to natively support hypermedia by release time or are there any off-the-shelf implementations or examples I should look into?

Thanks!

Body:
Web API takes advantage of the http protocol more natively. Odata is an Open standard embraced by a lot of the big players. I can only speak from my experience int toying  around with Odata, and recently discovering Web API and doing some research.

OData is cool because it's an actual standard. You can easily create a database and expose it over HTTP. This means you can traverse your table structure without any configuration (i say that loosely). You can also run queries through the URL which can include some light LINQ:

/products/orders/[put some linq-ish query here]

This is arguably good or bad. Authentication is standard and built it.

Web API, is more interesting from my perspective. It utilized the HTTP functionality (error messages, et al.) and is a bit more "native" to true RESTful requests. I really haven't played with it too much.. But i've read around and have kind of "heard" that MVC and Web API may be "married" some day, again, maybe good maybe bad...

When i was playing with OData, i created a Stored Proc, Mapped it into the entity surface, configured a strong return type and then hooked it up to a URL request and BANG, there's my RESTful request mapped to my typed result stored proc. It was fairly straightforward, and i was able to get exactly what i needed.

In Conclusion
I haven't had a chance to play with WCF API in too much detail, but i would say it's the way to go for client development since it's more of a purist approach to REST. If you're going to be making more or less "straight" back and forth calls and retrieving "View Models", it will provide a more native interaction.

On the other hand. If you'll be making complex (ish) queries on the data based on the client interaction and you want to "build" the query logic and pass it as a parameter, then Odata could work.

The way i look at it is if i need to expose my data in a structural format (meaning table / relationship structure) and then query it directly form a client, then Odata will work best. It's also good for allowing "Others" to access the data (with proper auth etc..) which is why it adhere's to the OData protocol

If you want RESTful requests where you're dictating the URL (/products/orders/22, and creating complex "result sets" from your "hidden" managed code and data structure AND you might also benefit from the HTTP response messages, then the Web API would probably be the best bet..

again, this is all from research and toying. I haven't implemented either in a production / full blown app scenario. I think they'll both have their strengths and weaknesses, and there's definitely some overlap


问:
Offshoring a Software Project -- Conflict Resolution
I had been tasked with managing a project which was outsourced to some Ukrainian developers.

The company hired them through Elance at a fixed price. At that point my boss left me alone to handle them and get the work done. I created a detailed specification of the complete thing that needed to be done.

The project involved dealing with such things as XMPP, RabbitMQ, and Database. In my first meeting with them (always IM) I explained thoroughly what they needed to do. They seemed to understand it -- and they were very confident that it would be done easily.

So far so good. But after one week, when we met again, they were full of misunderstandings about what needed to be done. When I asked one of the developers if he knew XMPP, he said he was working with it for the first time. At our first meeting I'd very specifically mentioned the complexity of the project and the technologies involved. Plus, I had repeatedly asked them to write a functional specification of exactly HOW they would do it. But they said NO, and insisted that they would rather write the code. I said OK.

The project completed after 3 weeks and they delivered what was needed. At that point I started to review the code. It was okay for the most part, but there ware some important problems:

they hard-coded some of the things that needed to be separated out into a config file

there were multiple config files that I needed to be consolidated in one

they wrote absolutely NO documentation

some other minor changes

I asked them to make these changes (except documentation) -- And, we had an argument.

They said, since the price was fixed, I was being unfair in asking them to make any changes once they completed the working code. That they had worked for unreasonable amount of time on the project and now it was completely wrong to ask for anything.

Finally now they have made the changes, and the project is over. But it leaves some  questions in my mind...

They did what was needed but I needed it properly done, and hence the changes. was I really unfair?

Why did I agree on letting them code without having a functional specification?

Why did I not make sure that they understood everything the first time?

Does anyone find themself in the same position? Do you think there is a better way to manage outsourced projects?

-- UPDATE --

Thanks for all the opinions -- after reflecting upon entire experience, I can conclude...

Although I wasn't vague in the specifications from my side, I certainly didn't make them ironclad as suggested. So the take away is: always be as much specific as possible -- read your specs from their perspective too and see if you missed something. Repeat it at least three times.

Just specifying what the code should do it not enough. You must specify what the code is supposed to look like. What the directory structure will be; even the file names if possible. This will save you from lot of annoyance later. Strictly specify the coding guidelines, variable naming conventions, internal documentation format, etc. See to it that they abide by those guidelines, and if not, scream.

Demand a functional specification from their side -- insist that it be written before any code. This will get a lot of confusions and misunderstandings out of the way.

Review the code as it is being developed so that you identify the anomalies earlier and get them corrected. Talk to them at least once every other day.

Lastly, try to make a good rapport with them. Make them feel that you appreciate their work. Don't push them exaggeratedly to fit your guidelines -- instead request them to do so and tell them that it would make maintaining the code so much easier for you once they complete the project.

答:
The company hired them through Elance at a fixed price. At that point my boss left me alone to handle them and get the work done. I created a detailed specification of the complete thing that needed to be done.

So the two of you first made a contract and then they let you write a spec, and they accepted that spec to become part of your contract? If that's how it was, then it is not your fault, that's a fault of your contractor. You could have easily written a spec giving them 3 months of work instead of 3 weeks - all for the same price.

It was okay for the most part, but there ware some important problems:

they hard-coded some of the things that needed to be separated out into a config file

there were multiple config files that I needed to be consolidated in one

they wrote absolutely NO documentation

some other minor changes

Were these things part of your spec? If they were, it is their fault. If not, it is yours. If it was not really clear if these things are contained in the spec, then it is also your fault, since you wrote the document. Try to write a better spec next time.

ContentLicense: CC BY-SA 3.0


问:
Processes: documenting changing spec
A little background: I work at a relatively small (<10 developers) tech company which basically produces a single product, which is constantly evolving and being added to. The product is an off-the-shelf client/server product, where we run the server and the clients are mobile apps running on a variety of platforms (Android, iOS, WinMo, etc.). The bulk of the specification and documentation is maintained in an internal Wiki.

Whenever we add a new feature or expand an existing one to the client apps, the process goes more or less like this:

A spec. for the change is produced. Generally these specs are very low on detail, often just consisting of a few user stories: "As a user, I want to..."

The feature is implemented on a single platform. Which platform often depends on which developer is most free at the time, as different developers specialise in different platforms.

Once the feature is more or less completed on the lead platform, it gets ported to the other platforms.

Because the initial specification is so general, step 2 usually requires making a lot of the more detailed decisions - file formats, what to do when things go wrong, etc. Decisions are generally made after consultation with the project manager.

The problem we have is that there's no real procedure for making sure the decisions made in step 2 actually get documented. In an ideal world I guess responsibility might fall to the project manager, but since he's also a company director he frankly doesn't have the time!

My question is: Can anyone suggest a process (or processes) we could use to ensure these decisions get documented?

It's all very well to say "just update the wiki when decisions get made" but real-world considerations (time pressure, interruptions to deal with user support issues, etc.) often mean that it gets forgotten.

答:
You really DO need to "just update the wiki when decisions get made."  Interruptions and time pressure are NOT an excuse.

After all, you need to develop test cases, right?  And you'll need to run these tests on each platform, right?  Well, what should the tests be based on?  That's right--those decisions you're not documenting.  Document them, your testing will get better (and easier), your products will be assured of higher quality, and everyone is happy.

Title: Processes: documenting changing spec


答:
```<code>"The problem we have is that there's no real procedure for making sure the decisions made
 in step 2 actually get documented"
</code>```

I think you've isolated the step in your process which you can improve. Without getting into changing your entire organizations structure, i think someone just has to be tasked with maintaining the spec as it evolves. I know it's obvious, but it will be the easiest way to achieve what you're up against. Introducing a new system will have some initial overhead, "Changing" the way you do things will probably ruffle more feathers than anything.

Hey, why not just assign it to the new guy (the FNG)!! LOL!!

good luck!

Title: Processes: documenting changing spec

Body:
A little background: I work at a relatively small (<10 developers) tech company which basically produces a single product, which is constantly evolving and being added to. The product is an off-the-shelf client/server product, where we run the server and the clients are mobile apps running on a variety of platforms (Android, iOS, WinMo, etc.). The bulk of the specification and documentation is maintained in an internal Wiki.

Whenever we add a new feature or expand an existing one to the client apps, the process goes more or less like this:

A spec. for the change is produced. Generally these specs are very low on detail, often just consisting of a few user stories: "As a user, I want to..."

The feature is implemented on a single platform. Which platform often depends on which developer is most free at the time, as different developers specialise in different platforms.

Once the feature is more or less completed on the lead platform, it gets ported to the other platforms.

Because the initial specification is so general, step 2 usually requires making a lot of the more detailed decisions - file formats, what to do when things go wrong, etc. Decisions are generally made after consultation with the project manager.

The problem we have is that there's no real procedure for making sure the decisions made in step 2 actually get documented. In an ideal world I guess responsibility might fall to the project manager, but since he's also a company director he frankly doesn't have the time!

My question is: Can anyone suggest a process (or processes) we could use to ensure these decisions get documented?

It's all very well to say "just update the wiki when decisions get made" but real-world considerations (time pressure, interruptions to deal with user support issues, etc.) often mean that it gets forgotten.

Body:
"The problem we have is that there's no real procedure for making sure the decisions made
 in step 2 actually get documented"

I think you've isolated the step in your process which you can improve. Without getting into changing your entire organizations structure, i think someone just has to be tasked with maintaining the spec as it evolves. I know it's obvious, but it will be the easiest way to achieve what you're up against. Introducing a new system will have some initial overhead, "Changing" the way you do things will probably ruffle more feathers than anything.

Hey, why not just assign it to the new guy (the FNG)!! LOL!!

good luck!


答:
This has nothing to do with your special situation of "multiple platforms". Others have the same problem with just one platform. From a general point of view, I see two approaches to deal with this situation:

a) Do more up-front work in step 1. Try not to make just a functional spec, also try to specify non-functional requirements.

b) Avoid having to write avoidable documentation in step 2. Better teach your team how to write self-documenting code. Then there are less excuses like "we don't have the time for documentation". Of course, someone should update your Wiki also in step 2, but only for documenting high-level decisions. Those are most often only a small fraction of the things to be done at the code-level.

Here are two links to articles of Joel Spolsky which might be of interest for you:

http://www.joelonsoftware.com/articles/fog0000000036.html

http://www.joelonsoftware.com/articles/fog0000000035.html

Title: Processes: documenting changing spec


答:
The biggest problem with keeping documentation for code in a wiki is that a wiki's are nowhere near as flexible when it comes to version control.

That's one of the reasons I like to keep documentation as close to the code as possible, using a diff friendly documentation system like rst and storing the code in the project repository along with the code.

I distilled many of my thoughts on documentation into an answer to the question What are good ways to document scientific software? but they work as well for business code as for scientific code.

My third point about higher level documentation is the most directly relevant, but don't forget that once a project is complete, your unit tests probably document your requirements as implemented far better than your spec documents ever did, so you are probably better specifying future changes in terms of what you already have than what you originally wanted.

If you write your spec as a document in your project code repository, then if you branch your code for a new version, you also get a branch of the documentation. In your case, you would start a new branch of code development, update the spec, then update the code.

For the developer doing this everything would be in sync and no-one else would see the spec changes until they were ready to incorporate them.

Once the work had been done (or at least reached a deployable level) the changes in spec would be merged in with (ported) into the other projects along with the code that implements those spec changes.

The interesting thing is that the act of merging will also throw up merge conflicts if you have them, just as code would. That way you get to find out if two developers have changed the spec in ways which are mutually incompatible.

Title: Processes: documenting changing spec


问:
How to check or assess debugging skills of a person?
What kind of skills determine a person that is capable of debugging code with ease? Some time ago my friend carried out an interview with a relatively good programmer. The programmer got hired. He could write good code, understood the frameworks and design patterns. The thing he was missing was - debugging skills. He could not debug at all and finding problems with his or someone else's code was huge pain for him.

Since then we are thinking about how we can assess or estimate a person's debugging skills.

So the first question is: what skills determine if a person can effectively debug software?

And the second: how to test those skills during the interview?

答:
During an interview, ask them to tell you about a bug that they fixed in the past and the steps that they used in debugging it.

Make them tell you about the what they have done in their last job, homework assignment, etc.  And what they went through in finding the problem.


答:
Use test driven development!  Specifically, automate your system and integration tests when developing for the first platform.  This is good practice even for one-off projects, but the benefits multiply when you are implementing the same functionality several times.  I'm not sure what the tooling is like for iOS development, but I know there are tools you can use to drive UI testing in Android, for example.

Whether the tests are written up front (better) or added as you go (better than nothing), when you are finished that first version, you also have a complete, detailed and executable spec.  What's more, it is guaranteed to be accurate -- something that is rarely true of paper specs.  Use the same tests to drive your development for the other platforms (possibly with some tweeking) and you'll be sure you have uniformity of behavior even if you can't share a code base.

Title: Processes: documenting changing spec


答:
I will share a experience together with a recruits perspective about test of a candidate skills in debugging. I onced got on a interview that had three stages. The second stage was a "practical case". I didn't know more at that moment. While there I was informed there are a system that stopped working and they don't know. Some bugs is lying behind.

It was arranged as a remote desktop to a old testing environment. Probably to a unplugged or isolated environment. The project was a few webforms with some ASP.NET controls and related Code-file code. The codefile referred to a kind of business layer for which i just have a dll,  no source code and method descriptions. The Webforms did the CRUD functions you can expect. Also a small search function. The business layer, in turn, talked to Views and SP in a sql server.

They broked some parts at different levels. I was given a paper with symptoms. "Can't search" "The 'region' field disappeared after last update" and such. Such as you can receive from your users.

I don't remember all details but at least a table field got renamed, which lead to a broken  SP, which was used by the search function. That means no error in VS and no BL source code to trace field names. A SELECT parameter against Sqlcommand was misspelled and caused a webform to malfunction. Also a field was omitted which was the missing field in GridView (Autogeneratecolumns). A ASP.NET Button was referred to something who must meant to be a duplicated, enhanced, method and "forgot" to point button to new method.

Also such minor thing using title in a html tag that don't allow it. Also opposite ALT tag was omitted in a control that required it. There was also some errors with uncorrect closed html tags but which did not malfunction. Not sure if all those was a pure playhouse-project-error or perhaps same project for different recruitments. I never asked. The level of difficulty should of course match the need of the recruit.

Such test should probably be screened (not followed) to see, after interview, how debugging was done. For myself at that stage, I found the test a little ridiculous, but that's would also be the big point. If it was or wasn't, should worth a lot have the candidate in right place.

*I think that test was proved the candidates/my skills to *

* Analyze a foreign system

* Use a minimal of information to find errors and bug

* Under time stress and without someone help you, code assumed corrections

* Different levels of knowledge;

** sql db and stored procedures,

** use of dll in project,

** asp.net technique,

** layered architecture

** problem-oriented aspect

But also the more obvious things like handle the developer environment, find and understand Db Server Management tool. Surely there are candidates that looks really nice on paper but, in practice, could stuck on such tasks.

Title: How to check or assess debugging skills of a person?

Body:
What kind of skills determine a person that is capable of debugging code with ease? Some time ago my friend carried out an interview with a relatively good programmer. The programmer got hired. He could write good code, understood the frameworks and design patterns. The thing he was missing was - debugging skills. He could not debug at all and finding problems with his or someone else's code was huge pain for him.

Since then we are thinking about how we can assess or estimate a person's debugging skills.

So the first question is: what skills determine if a person can effectively debug software?

And the second: how to test those skills during the interview?


答:
I did a presentation a while ago about offshoring. It was called "Global Outsourcing, 10 tips to empower your business". Here is a summary of the 10 tips (this comes from up to 400 outsourced projects):

A. Choice

Avoid the lowest and highest bidders. This is just obvious, you don't want to take risks with lower bidders and highest bidders tend to be less valuable (value/price) than the median.

Check ratings (or references). I always check references & ratings.

Prioritize motivation. At equal price, I pick the bid that was motivated. For example having the bidder talk about your project right is a very good sign.

B. Supervision

Protect your intellectual property. This is one of the biggest mistake. Usually handled by the platform you use (such as vworker or elance).

Refuse custom frameworks. Or you risk to be tied to it, or more specifically to the developer that wrote it ;)

Impose standards. Related to previous tip. Using standard increases the value of your source code as it is understandable by a larger amount of developers.

Review early, review frequently. Most problem can be "adjusted" if you review the source code after the first week or work.

C. Strategy

Test providers with small projects. Before I give a big project to a provider, I test it with one or two smaller projects.

Accept multiple bidders to reduce risk. For critical project, I select two or three bidders then I take the best implementation. Work best with small projects (under $5000).

Assemble components. Another strategy is to outsource components that you assemble later. One advantage is that you can easily switch between providers and none really get access to the whole thing (reduce intellectual property risks).

Title: Offshoring a Software Project -- Conflict Resolution

Body:
I had been tasked with managing a project which was outsourced to some Ukrainian developers.

The company hired them through Elance at a fixed price. At that point my boss left me alone to handle them and get the work done. I created a detailed specification of the complete thing that needed to be done.

The project involved dealing with such things as XMPP, RabbitMQ, and Database. In my first meeting with them (always IM) I explained thoroughly what they needed to do. They seemed to understand it -- and they were very confident that it would be done easily.

So far so good. But after one week, when we met again, they were full of misunderstandings about what needed to be done. When I asked one of the developers if he knew XMPP, he said he was working with it for the first time. At our first meeting I'd very specifically mentioned the complexity of the project and the technologies involved. Plus, I had repeatedly asked them to write a functional specification of exactly HOW they would do it. But they said NO, and insisted that they would rather write the code. I said OK.

The project completed after 3 weeks and they delivered what was needed. At that point I started to review the code. It was okay for the most part, but there ware some important problems:

they hard-coded some of the things that needed to be separated out into a config file

there were multiple config files that I needed to be consolidated in one

they wrote absolutely NO documentation

some other minor changes

I asked them to make these changes (except documentation) -- And, we had an argument.

They said, since the price was fixed, I was being unfair in asking them to make any changes once they completed the working code. That they had worked for unreasonable amount of time on the project and now it was completely wrong to ask for anything.

Finally now they have made the changes, and the project is over. But it leaves some  questions in my mind...

They did what was needed but I needed it properly done, and hence the changes. was I really unfair?

Why did I agree on letting them code without having a functional specification?

Why did I not make sure that they understood everything the first time?

Does anyone find themself in the same position? Do you think there is a better way to manage outsourced projects?

-- UPDATE --

Thanks for all the opinions -- after reflecting upon entire experience, I can conclude...

Although I wasn't vague in the specifications from my side, I certainly didn't make them ironclad as suggested. So the take away is: always be as much specific as possible -- read your specs from their perspective too and see if you missed something. Repeat it at least three times.

Just specifying what the code should do it not enough. You must specify what the code is supposed to look like. What the directory structure will be; even the file names if possible. This will save you from lot of annoyance later. Strictly specify the coding guidelines, variable naming conventions, internal documentation format, etc. See to it that they abide by those guidelines, and if not, scream.

Demand a functional specification from their side -- insist that it be written before any code. This will get a lot of confusions and misunderstandings out of the way.

Review the code as it is being developed so that you identify the anomalies earlier and get them corrected. Talk to them at least once every other day.

Lastly, try to make a good rapport with them. Make them feel that you appreciate their work. Don't push them exaggeratedly to fit your guidelines -- instead request them to do so and tell them that it would make maintaining the code so much easier for you once they complete the project.


问:
Coding Guideline : Methods shouldn't contain more than 7 statements?
I was looking through the AvSol Coding Guidelines for C# and I agree with nearly everything but I'm really curious to see what other think of one specific rule.

AV1500

Methods should not exceed 7 statements  A method that requires more
  than 7 statements is doing too much, or has too many responsibilities.
  It also requires the human mind to analyze the exact statements to
  understand what the code is doing. Break it down in multiple small and
  focused methods with self-explaining names.

Do most of you follow this rule? Even if there's little to be saved from creating a new method (Your code is still DRY) aside from greatly increasing readability?  And is your number still as low as 7?    I would tend more toward 10.

I'm not saying I violate this rule all over the place--on the contrary, my methods are 95% small and focused but saying you should never violate this rule really blew me away.

I really just want to know what everyone thinks of NEVER violating this rule (It's a '1' on the coding standard--meaning NEVER do this).  But I think you'd have trouble finding a codebase that doesn't.

答:
Bad rule. With code for exception handling, setting database fields, validation, how can most methods be under seven statements? Should we never do inline lambda functions?

Lines of code are an arbitrary count of complexity. With extension methods I can create code like

```<code>                Parallel.ForEach(regions, region => {   Console.Write(region.Resorts.Where(x => x.name == "Four Seasons").OrderBy(x => x.RegionId).ThenBy(x => x.ResortId).ThenBy(x => x.name).ToList());   });
</code>```

Body:
Bad rule. With code for exception handling, setting database fields, validation, how can most methods be under seven statements? Should we never do inline lambda functions?

Lines of code are an arbitrary count of complexity. With extension methods I can create code like

                Parallel.ForEach(regions, region => {   Console.Write(region.Resorts.Where(x => x.name == "Four Seasons").OrderBy(x => x.RegionId).ThenBy(x => x.ResortId).ThenBy(x => x.name).ToList());   });


问:
Could you describe "GNU General Public License (GPLv2)" in "for Dummies" terms?
I just want to make sure I'm using the right license for my open source API wrapper project for some social networks and also make sure I understand it. Could you just describe the basics of that license? What I can and can't do, etc? Does these things suit the GPLv2 license:

Open Source'ness

Ability to use it in your own project

But also give credit for it on ones website and keep copyright notices at the top of source files

Have control over it as in if you don't like how someone is using your code, you can report it somewhere after contacting the developer.

I would also like to make commercial versions and add ads to my project - so exceptions in the license would be noted.

Thank you all for your answers and comments. I've gone with the shorter and easier to understand New BSD License (BSD). Thanks anyway.

答:
GPL may or may not be for you depending on what you mean by

Have control over it as in if you don't like how someone is using your code, you can report it somewhere after contacting the developer.

the GPL allows you to "have control" in the sense that you can force people to not distribute your code or modifications ONLY if they are not making your code/their modifications available to those they distribute to. Otherwise there is nothing you can do, if I legally obtain your code, I can do anything and everything I want with it.

There is one other exception, you may forbid distribution to a country if it would be illegal for you to distribute it there.


问:
Algorithm for scheduling a set of real life tasks that are input by the user
I am trying to write some code to schedule a set of real life tasks that are input by the user. These tasks are stored in an SQLite database. And at the moment, the only parameters I am taking into consideration are the,

```<code>The project to which a task belongs to --> p
The name of the task itself --> t
And the due date for this task --> d
</code>```

The project and due date parameters are optional. But assuming that the user will always input at least the task name and due date for every task.. I was wondering if it is possible to schedule the set of tasks using a scheduler like the Completely Fair Scheduler (CFS) for example. I realize that the CFS was written for scheduling tasks with much finer granularity (nanoseconds) than the set of tasks being proposed for this purpose... But I realized that it might be possible and maybe more efficient if I can modify it to work with tasks that are on the same time scale as our perception of time.

A typical entry in the database would be in the format (p, t, d). 'p' is optional. Here are a few examples:

```<code>(_, 'Call home', 29/2/2012)
(Work, 'Meet boss', 14/3/2012)
(Work, 'Ask for raise', 18/3/2012)
(_, 'Book tickets', 10/3/2012)
(Work, 'Quit', 14/4/2012)
(Personal, 'Get botox injections', 10/3/2012)
(Personal, 'Get breast implants', 10/10/2012)
(_, 'Dad bday', 7/10/2012)
</code>```

Here is a situation to consider. I would like to wake up in the morning. Run this "yet to be coded" algorithm on the set of tasks.. like the ones given above.. and I would like to receive a schedule for the rest of day, that maximizes throughput. At a later stage, I would like to pass arguments to this algorithms that would allow me to control the scheduler to return a set of tasks depending on my current situation. Like if I am at work, I want to be able to pass arguments to the algorithm, to ask it to only return tasks that can be completed at work..

I hope I am able to convey the gist of it. I understand that the due date alone is not sufficient to schedule tasks using the CFS for example... but if there are other parameters that I should consider, please do let me know. And any suggestions for the kind of scheduling algorithm to employ would be helpful.

答:
In order to find a somewhat optimal order of your task, you should at least include the parameters earliest start time and duration. Provided you have these time windows, you can further define a time window for each project. By default, the project time window could be the whole day.

Consider for example the section "Work": if it lies between 8 o'clock and 17 o'clock your application can filter all tasks that lie between the time span. If you want to schedule a whole day, you have to write an algorithm, that tries to find a solution in which no time windows violations occur. You can even build in an optimization criterion like: ,,minimize the distance between the actual start time of a task and its earliest start time"


答:
Carry out a design proposal early in stage 2

Once the developer has worked out how they are going to do it they do a quick stand-up proposal to the rest of the team. This should be short, snappy and to the point, but basically get across the key points of

What you're going to do

What you decided not to do and why

A few supporting diagrams are really useful for the proposal and they can stored in your wiki. But don't feel the urge to always do them in a diagraming tool, a whiteboard scrawl that is then photographed is fine.

During the stand-up the other developers can quickly understand what is being done, see the thinking behind it and challenge it where appropriate before too much effort is expended.

As a result you have also now passed over the information to them - so what gets stored in the wiki only has to be an aide-mémoire rather than a definative full record. So simply store the diagrams along with a few notes to cover the key questions and points raised during the proposal stand-up.

If you're really keen (or if the developer thinks penning down the few notes required is too onerous) you could simply video the proposal and store that.

Its worth remembering that the key point #2 above is as important to record as the first - it reduces the chance of people expending effort in the future going "well clearly it should have been done this way ... oh hang on now I see why they didn't do that".

Title: Processes: documenting changing spec


问:
Are code reviews necessary for junior developers?
I've worked at two companies, who each had a different methodology when it came to code reviews:

In the first company, a code review was conducted by the team leaders and was required after the completion of every module.

However, in the second company, team leaders weren't required to conduct any code reviews, and just checked for functionality and design issues.

So I am confused. Is the code review process really needed? If it is, why? And if it isn't, why not?

答:
Basically code review is needed for all programmers regardless of experience.  It is the Quality Control of software development, and one of the reasons Open Source can be of very high quality.

EDIT: The reason is that a code reviewer today is in exactly the same role as a maintainer later. If the code doesn't make sense to him today, it will not make sense later either, making bugs more expensive to fix. Hence, MAKE it understandable today while the developer still remembers the code. Also the reviewer may see bugs or omissions that the developer missed.

Unfortunately very few wants to do it, but seen from a business point of view it should be mandatory.


问:
Jumping around to work on different features when you get stuck, is it a source of project failures?
On personal projects (or work), if one gets stuck on a problem, or waiting to figure out a solution to the problem, if you jump to another section of your code, don't you think it will be a good reason your application will be buggy or worse yet never get completed?

Assuming you are not using git and code each feature to a specific branch, things can get out of hand since you have 3 different features you are working on, and you have unresolved issues in each.

So when you get done to work, you get stressed out because you have these hanging issues and half-baked code lingering about.

What's the best way to avoid this problem? (if you have it)

I'm guessing using something like git and creating a branch per feature is the safest way to avoid this bad habit.

Any other suggestions?

答:
This is not a issue. Temporarily stepping away from a perplexing problem is one of the best ways to have a breakthrough on such a problem (either later when you are thinking about it or the next time you sit down with a fresh perspective/mind).

Always make sure you utilize source control branching properly and you wont have to worry about the half solutions in code. Some people never commit breaks, but that is just a personal choice. You should never really push breaks to share with others though.


答:
I personally think that every piece of code should go through a code review, it doesn't matter if you are junior or senior developer.

Why? For starters your title doesn't state anything about how you develop, and a senior developer could learn something from the junior. At our company we shift around so one of the other members of the team review your code...mostly we are teamed a "junior" and a senior together, so all the stuff that doesn't get said on a daily basis can be caught in a follow up. If the senior doesn't like the junior code he should listen to why the junior did as he did and look at it and see if that's a feasible solution that might be used in the future...it's a matter of getting wiser no matter who you are.

One important thing about code review is not being too nice, if you are being a nice guy you'll just allow more and more messy code to evolve in the system. Just as yesterday I started reworking a complete application that a former employed juniordeveloper wrote, and my god that code could have needed a review before he left.

I don't see why it should be the teamleader only doing reviews but it requires a person that's not affraid of picking a "fight" over a piece of poorly developed code, and it has to be a person that cares about how the code should be. Not all companies hire people that actually care about what they do, and those bad eggs should IMO not be allowed to do code reviews as they are likely just to shrug their shoulders and say "OK" to bad code.

Title: Are code reviews necessary for junior developers?

Body:
I've worked at two companies, who each had a different methodology when it came to code reviews:

In the first company, a code review was conducted by the team leaders and was required after the completion of every module.

However, in the second company, team leaders weren't required to conduct any code reviews, and just checked for functionality and design issues.

So I am confused. Is the code review process really needed? If it is, why? And if it isn't, why not?


答:
Why are you documenting?  It's not because your customers demand you are ISOxxxx compliant, it's not to put it on a feature list, it's because you think it saves you time in the long run.  So saying you don't have time to do something that saves time only makes sense in a couple of situations:

Doing it later will allow you to do things that make you grow enough to make it a smaller problem later, relative to your size.

You are wasting time on purpose.

If you are growing so fast that #1 applies then stop reading this and get back to work.

If not, then the first time the documentation produces value is when you port to other platforms.  Rather than communicate what you currently communicate informally anyway, write it down.  Doing it later than that wastes some of the value it would have produced.

Title: Processes: documenting changing spec


答:
As smp7d mentioned, jumping around can give you a good mental break from the problem at hand. However, it is important to not forget that the code you were working on is still incomplete.  Make sure you know where you left off.

As smp7d mentioned, source control and branching is a great way to split your new feature code off, and see how it differs from the main code base.

One suggestion I have is that if you're working on a particular method, make sure that there is a well named unit test  around that method.  That way when you work on that code the next day/week/month/year, you should be able to clearly tell what the method is supposed to do, even if it doesn't currently pass the test.

Title: Jumping around to work on different features when you get stuck, is it a source of project failures?

Body:
On personal projects (or work), if one gets stuck on a problem, or waiting to figure out a solution to the problem, if you jump to another section of your code, don't you think it will be a good reason your application will be buggy or worse yet never get completed?

Assuming you are not using git and code each feature to a specific branch, things can get out of hand since you have 3 different features you are working on, and you have unresolved issues in each.

So when you get done to work, you get stressed out because you have these hanging issues and half-baked code lingering about.

What's the best way to avoid this problem? (if you have it)

I'm guessing using something like git and creating a branch per feature is the safest way to avoid this bad habit.

Any other suggestions?


问:
Convince a lone developer to use a separate build tool instead of the IDE one-click build
In my years of programming Java and more recently Scala, I've never used Ant, Maven, Gradle or any of those build tools for Java.  Everywhere I've worked there was a build manager who took care of all of that -- I'd compile locally with the IDE for development and unit testing, then check in the source code and notify the build manager who did what was necessary to compile everybody's files for the shared environment.

Now that I'm between contracts I've been working on my own self-funded project and it's getting to the point where it could be good enough to actually make money.  I even have a potential investor lined up and plan to show them a beta version in the next few weeks.

But all along I just click the build button on the IDE, and it creates the Jar file and it works just fine.  Of course, the conventional wisdom suggests that I "should" be writing my own Ant/Maven/Gradle scripts and using that instead of the IDE, but what are the concrete advantages of that in my situation (working alone)?

I've done some reading about how to use those build tools, and it just looks like I'd be writing hundreds of lines of XML (or Groovy or whatever) to do to what the IDE does in one click (the IDE-generated Ant XML for the project is over 700 lines).  It just looks error-prone and time-consuming and unnecessary for my situation.  Not to mention the learning curve, which would take away time from all the other work I'm doing to get the product ready to show people.

答: I would argue that, for a lone developer, having good process and structure like scripted builds is vastly more important than when you are on a team. Reason being you don't have teammates to call you out when you cut corners. A CI server running your build script makes for a great uncompromising teammate to keep you honest.</p>

OwnerDisplayName: Gigatron


答:
I pick an actual problem I encountered that's relevant to the position and I present it to the candidate much as it was presented to me.  Of course I offer them some general background, and a small amount of relevant documentation like a code snippet or a schematic diagram.

I tell them their job is to solve the problem and I offer to answer any technical questions they have and tell them the outcome of any experiments they want to perform.  If they say, "I'd put a scope probe here," then I will sketch them a trace of what they might find.  If they want to insert a printf in a loop I will tell them that it never comes out (!) or first prints "7" and then repeatedly "5".  If they get so far off in the weeds that I can't give meaningful answers I will admit that we're on the wrong track and back up to somewhere else.  If they become stuck I'll ask leading questions or give hints until we can move on.

What I want to see is orderly thought processes, determination to get to the solution, well considered questions and experiments, and ideally a successful identification of the problem.  Sometimes I choose problems that are too complex for someone to fully debug in a one hour interview and at the end I give them the real answer.  At that point I am looking for a reaction that shows that they were engaged with the problem and experience that "aha" moment and gratification at getting to the cause.  The best candidates will spontaneously ask followup questions at that point, trying to link their mental map of the problem with what was really going on.


问:
When should one read 'Code Complete'?
I'm pretty sure about who, but when?

The one with proficient knowledge of programming and software development or the one who's just a beginner in programming?

I'm pursuing bachelors right now, when is it preferable for folks like me to read this Must read for programmers book?

答:
Like Robert Harvey said, it's probably best to read it as an intermediate programmer. I read it after having programmed, more or less, for 10 years. After having read it, I wished I had read it at least 5 years sooner.

Code Complete is a bible of best (or at least very good) practices which you only really appreciate after first having tried out a few of your own. It's like doing a math exercise - you won't appreciate the solution unless you've first made your own stab at it. Maybe the book's solution solved the problem differently compared to your solution, and while the final answer may be the same it is the approach which is interesting. Some approaches are better than others, are more intuitive and yield a better understanding of the problem. The same goes for programming.

The following quote of Robert Harvey really says it best:

If you're a beginning programmer you won't understand a lot of the material, and if you are experienced, the book will only confirm what you already know.

ContentLicense: CC BY-SA 4.0

Title: When should one read 'Code Complete'?

ContentLicense: CC BY-SA 2.5


答:
Is it a problem? Not when it occurs to you for 10% of the features you are trying to implement. Sometimes you get your mind clearer when you do something different first.

Obviously it is a problem when you get stuck for 90% of the features you try to implement - then you either need help from others, or a slight kick-ass from your boss to finish what you have begon (of course, the latter will be contra-productive if you got stuck because of a real technical problems).

Best option for this case often is trying to split the feature you are working at into smaller sub-features or "feature-slices", which can be implemented, tested and debugged one-by-one. For me, it helps to write those feature-slices, open issues, parts to be done down on a list, give them priorities (A, B, C is enough), and work on the things with highest priority first.


答:
Give someone some awesome code your company runs in production. Ask them to introduce a subtle bug. Ask them why they picked that one. Ask them how they would go about finding and fixing it.

Bonus point if they find a bug in the original code.

Double bonus point if they can fix the bug in the original code.


答: I tend to ask people to describe to me the most difficult bug they ever had to track down and fix and what they did to find it and fix it. I also know that if the most difficult bug was something that you would expect only a beginner to find difficult, then likely they are not good troubleshooters (unless this is an interview for entry level). If it is something genuinely difficult and they describe their thought process as they tried to track it down, then I can get a feel for what their skill level is. What has alaways amazed me is the sheer number of people who get a "deer in the headlights" look and can't think of a single example of something they did that was complicated. Well sorry someone who leaves the hard problems for someone else to fix is not someone I'm interested in for anything except a straight-out-of-school, very junior level job.</p>


问:
How do I speed up XML parsing operation?
I currently have a php script set up to do some xml parsing. Sometimes the script is set as an on page include and other times it is accessed via an ajax call. The problem is the load time for this particular page is very long. I started to think that the php I had written to find what I need in the XML was written poorly and my script is very resource intense. After much research and testing the problem is indeed not my scripting (well perhaps you could consider it a problem with my scripting), but it looks like it takes a long time to load the particular xml sources.

My code is like such:

```<code>$source_recent = 'my xml feed';
$source_additional = 'the other feed I need';

$xmlstr_recent = file_get_contents($source_recent);
$feed_recent = new SimpleXMLElement($xmlstr_recent);

$xmlstr_additional = file_get_contents($source_additional);
$feed_additional = new SimpleXMLElement($xmlstr_additional);
</code>```

In all my testing, the above code is what takes the time, not the additional processing I do below.

Is there anyway around this or am I at the mercy of the load time of the xml URL's?

One crazy thought I had to get around it is to load the xml contents into a db every so often, then just query the db for what I need.

Thoughts? Ideas?

答:
I suggest you look into caching. Chances are the feeds don't change much, and if they do, maybe you can afford getting the changes into your application a little bit later.

Basic caching would go something like this:

Do we have the XML data in the cache?

If we do, just use the cached data.

If we don't, load and parse the XML file, and store the resulting DOM tree in the cache, then use the parsed data.

This would at least reduce your average response time; when the cache expires, one response will take longer, but the rest in between would completely skip the parsing step.

If you don't want any response to take longer, then you need to do the parsing asynchronously. Such a system requires three components: your existing web application, a daemon or cron job, and some kind of shared data store - a plain file in an easy-to-parse format, a memory cache such as memcached, or a database. The daemon process / cron job downloads and parses the XML files at regular intervals (say, every minute, or whatever makes sense) and updates the shared data store. If the data store update itself takes too long, consider using two data stores that you can swap atomically (e.g. using file renames or changing a symlink). The web application then never downloads or parses the XML itself, it simply queries the shared data store. Since the data there has been parsed already, the overhead is gone.


问:
How can I feel more confident about my programming skills?
Programming isn't alien to me. I first starting doing markup (HTML, now please don't laugh at me) when I was 12 and a little bit of BASIC when I was 13 (I knew much about Flowcharts, Pseudocodes at this point), but then I was admonished into Biology in high school and hence missed out on "real" programming knowledge of languages such as C, Java, etcetera. I took up CS for my UG B.E. (similar to BS, but way more theoretical). I learnt C & C++ (to a lesser extent) on my own (my prof was a total pain and the class was filled with code-jocks (who had already learnt it in school, and hence paid no attention to class and didn't let lesser mortals like me to pay any attention to class either)) and could whip up an awesome addition or multiplication program (ones which now even kinder-gardeners' whip up with way more finesse) and a piss-poor knowledge of Java (which has even grown rusty in recent times).

My main problem is that I've always felt inadequate and strangled by my limited programming skills and belittled by the code-jocks (believe me, I've come across this site ages ago, but could just now build up the courage to actually post a question) and have been at times even depressed over said inability. Most people say that Programming isn't necessarily about the language but the state of mind that the person has and the techniques they employ to solve problems/issues. I agree with such sentiments, but can I ever acquire such a "state of mind", and if such how should I approach "Programming/Coding", and if there are any set ways and steps one most go through to attain the "Zen of Coding". How do I do so? Also, it wouldn't hurt if some Saint wanted to mentor this downtrodden piece of $#!^.

P.S. I would forever be grateful to any person who considers me worth their time, and as a bonus would name my first piece of Software I ship after them. (If I ever get to ship one, i.e.,)

TL;DR: Never really learnt "Programming/Coding", can't solve problems even if I try to. Help me!

答:
Three things to consider: (Or not, of course.)

Practice. What if failure meant nothing more than an indication you are practicing? If you gave up learning to walk the first time you fell, you'd still be crawling about.

Play with whatever you're doing. Play is simply trying something and noticing what happens. Give up judging good/bad results, just play and see what happens. Give up being attached to a particular result, just try something and see what happens.

What if you're not the only programmer in the world who ever felt this way?

OwnerDisplayName: Ameen


问:
Is it advisable to force your web server to parse HTML files for PHP code?
I can't remember what site I glanced over and picked up that tidbit, but someone suggested that you should keep PHP parsing to .PHP files, and not modify one's webserver's htaccess to include PHP parsing within .HTML files.

Is this true? Is there any generally agreed upon reason as to doing it one way or the other?

答:
I would say yes it is true.  I don't know how to prove that it is generally agreed upon.

Ideally, all of your .html files have no php code in them, and you should not have the server parse them for php.

If for some reason you did have php code in .html files, then obviously you do need to have them parsed for php.  In this case, you should consider changing those files to ".php", but make sure you update any references to them, and make some kind of redirect if their urls were public.


问:
What should Competent Java programmer Be Able To Do?
To call yourself a competent Java programmer, what should you expect of yourself and what should others expect from you?

Does anyone have ideas for a project or problem that would help measure someones "java-smarts"?

答:
Hi Jozefg some of my thoughts, I believe if one considers to be a compitent Java Developer then I believe one should,

Be thoroughly familiar with the Java SE Libraries. E.g. the load factor in a HashMap and how knowing these can be important, good understanding of the Collections framework what to use and why (pros/cons), Generics, Concurrency to name a few.

Follow and understanding/awareness of the latest major version changes in the language http://docs.oracle.com/javase/specs/

How the JVM Works, see http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136373.html understanding of how the language works under the hood (Garbage collection for e.g.).

Solid OOP concepts and how implemented in Java. Coding conventions and design patterns.

I think there are other non language/technical related aspects as well such as having read at least a few books such as Effective Java (JBloch), Code Complete (uncle bob), Pragmatic Programmer, Head first design Patterns are few that comes to my mind. I think there is no such thing as a silver bullet and all can have different views or opinions on this, Hope this helps.


答:
I would have probably got the most from it around a year after I graduated. It was useful when I did read it ( about five years later ) but there was some stuff there that I had learned the hard way and I really wished I had known about sooner.

I read The Pragmatic Programmer at the same time and that was spot on- I wouldn't have been ready for that any earlier than when I read it.

Title: When should one read 'Code Complete'?

Body:
I'm pretty sure about who, but when?

The one with proficient knowledge of programming and software development or the one who's just a beginner in programming?

I'm pursuing bachelors right now, when is it preferable for folks like me to read this Must read for programmers book?


问:
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?

答:
There's no downside to partial views when implemented correctly.

If SEO is important, you do need a separate URL for each page to be indexed and show up in search results. However, there's a way to go around this using the new navigation history framework (HTML5), and some tweaking for Internet Explorer (IE):

The idea is to change the URL dynamically when a partial view is loaded, and to complement this, you design things so that a URL determines the partial views to load, therefore building the whole page just like it would have happened through user interaction.

This pattern allows both SEO and partial views to co-exist in harmony, and allows the user to user the back and forward navigation buttons.

Then all you need is to make all those URLs accessible to crawlers, either through a site map page, a sitemap.xml file, or by uploading all URLs to Google.

The pattern can be implemented easily in most popular browsers. For most versions of IE, Javascript libraries exist to update IE's navigation history using an IFrame and the URL's hash (#).

As @TomasAlabes says, there are certain user actions that suggest navigation, and the user will expect a complete page reload. However, even if just a few elements of the page will stay the same (e.g. header and footer), partial views will still reduce network traffic and user wait time.

No downside!

Title: when to load partial views


问:
Would the concept of source code layers be of any use?
I'm talking about something like layers in photoshop, except they apply directly to the source code.  For example, in pseudo-code... inventing what some project might look like - say a computational fluid dynamics program:

[base layer]

```<code>cfdTime runTime(0);

fieldVariable U;
fieldVariable p;
U.initialize();
p.initialize();

while (runTime.run())
{
    U.solve();
    p.solve()
    runTime++;
}
</code>```

[turbulence layer]

```<code>turbulenceModel turbulence;
scalar nu(readScalar(turbulence.dictionary("nu"));

while (runTime.run())
{
    turbulence.update();
}
</code>```

[base layer + turbulence layer]

```<code>cfdTime runTime(0);

fieldVariable U;
fieldVariable p;
U.initialize();
p.initialize();

turbulenceModel turbulence;
scalar nu(readScalar(turbulence.dictionary("nu"));

while (runTime.run())
{
    U.solve();
    p.solve()
    turbulence.update();
    runTime++;
}
</code>```

You get the idea.  Obviously a lot of things would need to be worked out.

I'm all over object-oriented programming (OOP).  This idea strikes me as an awkward alternative to OOP... and I don't think it's worth much... but I thought I'd toss it to the community... there just might be something useful in it that I'm not quite seeing.

It may be useful from a GUI-only perspective - creating layers in the GUI for complex functional programming... while the underlying code is always the same.  Or it may be useful for code optimisation, perhaps an alternative to #ifdef that developers won't run screaming from.  Or, it may be an entire alternative to OOP.

Your thoughts?

答:
In a sense, what you want to do is invent a new language that has the right primitives that you want (e.g., for fluid simulation) instead of expressing them in a lower level language. Macros are one way to implement this kind of thing, by allowing you to write what is essentially a domain-specific language (DSL) to solve your problem. You'll find the most powerful macro systems in languages like Racket, Scheme, Clojure, or other Lisps. Take a look at this article to see how far a language with macros gets you.

Alternatively, languages like Haskell and Scala also let you define new DSLs. Haskell mainly through monads and functional combinators. Scala using infix methods, call-by-name parameters, and implicits. Various other languages (too many to list) have their own ways of doing this kind of metaprogramming.

There are also software engineering approaches to solving this. For example, by using an editor that's capable of abstracting from your source code. This paper takes such an approach with Eclipse.

OwnerDisplayName: Marupio


答:
I'd say there are two major points to consider when making this, or any, programming/configuration decision:

1. Communication:

By default, HTML files are treated as HTML only. Most developers coming into your environment may assume a default configuration. However, if it's a general practice for system admins to change this, then those developers may assume the HTML files may contain PHP.

I believe that leaving HTML files as HTML-only is a great way to communicate to any other developers that page1.html is a pure-HTML file. This can make it easy for new team members to reverse engineer an existing project if this was the configuration used. In this case, there is no need to open the file for editing as one can simply look at the file extension.

2. Could this Create Unnecessary Overhead?:

Let's say you do have several static HTML files. Well, now your PHP server is going to have to parse your HTML files to look for non-existent PHP code. While I'm sure Apache is fast enough to where this isn't a huge, noticeable problem, it's still something to potentially take into consideration.

Summary:

In summary, my general approach to development is that if it ain't broke, don't fix it. There are a lot of things you can do if you do in fact need to do them, but if you don't have a very strong reason for using non-standard configuration, then it's probably not worth the cost of leaving your potential successor with misunderstandings or confusion.

With that said, I'm not a professional PHP developer, so making HTML files parseable by the server may or may not be considered standard procedure. I would opt to go with whatever is going to be easiest for other PHP developers who join me in my project.

Title: Is it advisable to force your web server to parse HTML files for PHP code?

Body:
I can't remember what site I glanced over and picked up that tidbit, but someone suggested that you should keep PHP parsing to .PHP files, and not modify one's webserver's htaccess to include PHP parsing within .HTML files.

Is this true? Is there any generally agreed upon reason as to doing it one way or the other?


答:
I think layers (from graphics programs) are similar to some kind of compositional unit of software (functions / objects ).     There might be better visualization tools that help see software composition in a way similar to layers.    Maybe even manipulate software composition.     perhaps even like Inventing on Principle.

Or potentially, the graphics world might like some of the ideas from the software world.... like inheritance or polymorphisim.

Title: Would the concept of source code layers be of any use?

Body:
I'm talking about something like layers in photoshop, except they apply directly to the source code.  For example, in pseudo-code... inventing what some project might look like - say a computational fluid dynamics program:

[base layer]

```<code>cfdTime runTime(0);

fieldVariable U;
fieldVariable p;
U.initialize();
p.initialize();

while (runTime.run())
{
    U.solve();
    p.solve()
    runTime++;
}
</code>```

[turbulence layer]

```<code>turbulenceModel turbulence;
scalar nu(readScalar(turbulence.dictionary("nu"));

while (runTime.run())
{
    turbulence.update();
}
</code>```

[base layer + turbulence layer]

```<code>cfdTime runTime(0);

fieldVariable U;
fieldVariable p;
U.initialize();
p.initialize();

turbulenceModel turbulence;
scalar nu(readScalar(turbulence.dictionary("nu"));

while (runTime.run())
{
    U.solve();
    p.solve()
    turbulence.update();
    runTime++;
}
</code>```

You get the idea.  Obviously a lot of things would need to be worked out.

I'm all over object-oriented programming (OOP).  This idea strikes me as an awkward alternative to OOP... and I don't think it's worth much... but I thought I'd toss it to the community... there just might be something useful in it that I'm not quite seeing.

It may be useful from a GUI-only perspective - creating layers in the GUI for complex functional programming... while the underlying code is always the same.  Or it may be useful for code optimisation, perhaps an alternative to #ifdef that developers won't run screaming from.  Or, it may be an entire alternative to OOP.

Your thoughts?


答:
I believe a competent Java developer should know the fundamentals of object oriented programming, as well as the following items:

Access Modifiers:  Know what "private", "public", "protected" means and when to use them to communicate to others whether or not your method is being used by other packages or classes.

Data Structures: As MalsR suggested, know the Collections framework and when to use a specific data structure. Don't get stuck in using just ArrayLists.

Frameworks:  Know how to use the framework you're using. For instance, if you're using Spring security, know the documentation and follow the examples from that community on the best practices.

Know Client-Side Languages: NOTE: This is critical if you work on Web applications!

Most importantly, don't get stuck on just Java. I see too many developers who work on web applications who can't write clean HTML/CSS or JavaScript.

While it's not important that you be able to write this from scratch, you should at least know enough to where you can make changes to existing HTML/CSS and JavaScript without turning it into spaghetti code.

HTML/CSS and JavaScript is the language of the web. If you're a C#, Perl, PHP, Python, nodeJS, or ColdFusion developer, and you're writing applications for the Web, then you're going to need to know some client side code.

Additionally, learning another language can help hammer home some important concepts that can even help you in Java.

In my experience, most of the Python developers I've met seem to do a great job of not just learning Python, but also they can hold their own on the front-end! Perhaps this had to do with them being contractors rather than employees of a larger company. As contractors they had more individual responsibility for bringing the client and server side components together.

Those individuals were able to take advantage of more opportunities because they had more transferable skills.

Title: What should Competent Java programmer Be Able To Do?

Body:
To call yourself a competent Java programmer, what should you expect of yourself and what should others expect from you?

Does anyone have ideas for a project or problem that would help measure someones "java-smarts"?


问:
WCF Data Services (OData) Vs ASP.NET Web API? Hypermedia?
I'm desiging a distributed application that will consist of REST services and a variety of clients (Silverlight, iOS, Windows Phone 7, etc).  I was ready to decide that I would implement my REST services using WCF Data Services (OData) but now the the MVC 4 Web API has made me question that decision.

What I liked about OData was the URI querying and hypermedia capabilities you get for free.  What I disliked was the verbosity of the OData payload; lots of unnecessary characters coming over the wire.

What I like about the Web API is that the payloads are much more concise and it has the URI querying capability of OData, however it seems to be lacking hypermedia (out of the box, at least).  My boss is also pushing for the Web API because "the powers that be at Microsoft are backing it and OData hasn't been getting traction."

So I have two questions:

1) Can anyone comment on the backing/traction of the Web API and OData?

2) Is the Web API expected to natively support hypermedia by release time or are there any off-the-shelf implementations or examples I should look into?

Thanks!

答: From the hypermedia point of view definitely Web API. OData, which is based on AtomPub, is just a way to expose a database using HTTP, you only get a limited set of predefined state transfers (CRUD). On the other hand, an hypermedia service is like an application, tailored for the client. With Web API you can embed all the links you want, plus you can also use the OData query syntax. Actually, the best hypermedia solution in the Microsoft stack is ASP.NET MVC, if you are willing to use HTML as base format.</p>


问:
How useful is a project log or diary?
I want to know how difficult/useful it is to keep a project log or diary. I'm worried that keeping track of what I did will eat up too much time...</p>

答:
Try it for 3 months.  Pick a simple format you can commit to and do it.  If it provides benefit, then keep it up, if not, drop it.  Each week review the format of your entries and adjust them if needed.

Try the following:

At the start of each day write down

What you are going to do (paragraph, spreadsheet, whatever form you like)

What problems you expect to encounter

At the end of each day write down

What you did

What obstacles got in your way

What three things you learned (technical, nontechnical, etc)

Each week, review

Probably takes 5 minutes at the start and end of each day.  You can later add things you ask yourself each week or things you find you care about.  Don't be afraid to change formats... paper one week, Wiki the next, Trello a third.  It will take a month or more to settle into a style and find a groove.

Title: How useful is a project log or diary?


答: You might be thinking up something like pretty-lisp, in that it is an IDE that visualizes a piece of lisp code.  But IDEs depend on languages, they are not language agnostic.</p>


答:
It's been my experience that "jumping around", or more clearly "Jumping randomly around" is a symptom of a more urgent problem, one of poorly stated goals.

If you have a very clear idea, in writing, whether post-it notes on the side of your monitor or in formal specs attached to your issue tracker of choice, then you almost always know exactly what to work on next.  If you are always working on one of those next things, then you are going to have a good chance of succeeding with the project.

If, on the other hand, your idea of what's the next most important thing is hazy, it's much harder to actually find a thing to work on that actually addresses the problem your project aims to solve, or more specifically, it's much less cut-and-dry when deciding that this particular change is complete and solves a particular issue.

If you have a goal like "make the UI easier to use", well, it's just about impossible to say what the next fix aught to be, or when you have finished "fixing the UI" and can move on to something else.  If, on the other hand, you have a goal like "combine these drop-downs into a search field with autocomplete" and "'foo' should auto complete to 'Fooly Brand Baring'", its totally obvious to when you've fixed that problem.

Don't write any code until you have a really clear idea of when to stop, and if you don't have any clear ideas, work on getting one of those instead of starting another branch for some general feature.

If you do have such a good spec of work (even for personal projects), then "jumping around" is totally fine and safe and useful.


问:
How do you stay focused at work?
Sometimes, the things I have to do for my job are interesting and engaging.  Sometimes, they aren't.  Occasionally, they really aren't.

Do you have any particular strategies or tricks for dealing with those dull stretches when your brain would rather be doing anything other than what you're supposed to be doing, particularly when the Internet and its boundless opportunities for interesting Slack beckon?

答:
I like to use Rescuetime.
RescueTime gives you a note between -2 and 2 to yours productivity. For me it is a challenge to have a note next to 2.</p>

Title: How do you stay focused at work?


问:
Flexible development environments for creating a common code base targeting tablets (iPad/Android) and x86 PCs
Hopefully this won't be flagged for being too vague, but I'm really looking for suggestions from anyone with experience in this sort of situation.

I work for a group that develops very specialized engineering calculations for Intel x86 platforms.

We do not intend to continue using this existing x86 code. Instead, we would like to start a new code base capable of targeting both x86 PCs and iPad and/or Android tablets. Clearly the UI code will have to be maintained independently. But I suspect the backend engineering code, which we want to keep common, is possible to be shared among all platforms.

I would like to know if there are any development environments or techniques for simplifying this multiple-platform development with a common backend code base, or will it be necessary to develop this backend code for each platform independently as well.

Please let me know if you need any clarification!

Thanks

EDIT

For example, we would need to write a large amount of code in C. Is it true both the iOS SDK's objective-C compiler can build native iOS code using the (relatively) same C code we would use to build native windows code using MSVC? Mind you, the code would not need to rely on specialized OS-dependent facilities.

Are there any tools for assisting in this sort of cross-platform development that may require multiple compilers? or perhaps any individual compilers that can target both platforms?

答:
Build most of the application with HTML and JavaScript, with PhoneGap to produce a native app for each platform.

The cross platform development will be easiest if the important parts are all in HTML, but you do have the option of writing some methods in native code as may be required for performance.

If you set it up so that the native components are optional, you can do most of the debugging with a local browser - much easier than anything that requires installation to a device or an emulator.


问:
Should I use Legitimate Email spoofing?
Recently I receive a request: users' emails are stored in the database, and as request of a user, the system will send an email on their behalves.

To add more context, it's like sending an email from the vendor, to their customers' email addresses. But it's not a fixed email (it depends on which vendor ask the system).

Using JavaMail, I can simply set the from field. But something doesn't seem right. When searching for this kind of work, I come across "Email spoofing" - which looks like what I'm going to do. There are some drawbacks for this approach, such as it may make the emails attractive to the spam filters, and so on...

Ofcourse I can just do as the client want, but I just wonder, is there any better alternative?

答:
From an ethics standpoint, I propose that the question can be boiled down to a simple test:

If the recipient of the email presented a copy of the email to your user, would the user be surprised at either the contents of the email or that an email had been sent on their behalf?

While you may be doing nothing wrong per se, if the answer to any part of the question is “yes, the user would be surprised,” you may be falling short of ethical behavior.

From an email deliverability standpoint, using a From address with a domain that you do not control, has implications on a number of standards that have the potential to prevent delivery of your email: DKIM, Sender ID, and SPF. I will address each separately.

SPF

The From address actually has no direct bearing on whether the SPF check passes or not. Most MTAs and framework APIs, however, use the From address to determine the SMTP Envelope Sender or  “MAIL FROM” address. The Envelope Sender is what is actually used for the SPF check. Consequently, for SPF to pass, you need to override the Envelope Sender to contain your email address (at a domain you control and publish the correct SPF record for).

For example, sendmail(1) offers the “-f” option to override the Envelope Sender. Specific instructions for accomplishing this with different technologies is (I believe) beyond the scope of this site; you might try asking on Stack Overflow or Server Fault (depending on the exact approach used).

In addition, the Envelope Sender address is used by the receiving MTA to determine the Return-Path address. The Return-Path address is where any bounce messages are sent, which is another reason why it is important to override the Envelope Sender so that bounce messages go to you and not to your user.

Sender ID

There are two separate mechanisms offered by Sender ID: spf2.0/mfrom and spf2.0/pra. The former functions the same as the SPF check, and shares the same implications.

The latter does not look at the Envelope Sender, instead it looks at the Purported Responsible Address (PRA). For this to pass, all you have to do is specify a Sender address in the header that contains your email address (at a domain you control and publish the correct Sender ID record for).

Specifying a Sender address can also make it clearer to the recipient that the email was sent by you on behalf of the user (of course, it all depends on the mail client / MUA that the recipient uses).

DKIM / DKIM-ADSP / Domain Keys

There is nothing to stop you from attaching a perfectly valid DKIM or Domain Keys signature to the email, however, you would have to set the "d=" parameter to your domain—not the From address domain. It is unclear to me whether or not this is a good idea, since the standards leave it completely open as to whether the "d=" domain should or shouldn’t match the From address, the Sender address, the Envelope Sender, or anything else; and I do not have specific knowledge of how people are filtering in practice.

The DKIM-ADSP standard, on the other hand, makes it quite clear that the “d=” domain is to be compared solely to the domain of the From address(es). Domains that publish the ADSP policy, dkim=discardable, (e.g. paypal.com), will outright prevent you from sending on behalf of users on that domain, at least when the recipient mail server is configured to filter according to the ADSP policy.

Final Considerations

Many other email deliverability concerns, such as iprev/FCrDNS, HELO/EHLO checks, etc. are neutral to the From address, so the standard advice applies. If the new DMARC standard ever gains traction, it may pose issues just as severe as DKIM-ADSP does, due to the aligned identifiers requirement.

Other than the limitations I have specified, you will in theory have no problem altering the From address, so long as you follow all my advice above. In practice, of course, there will always be issues, because email is a little like the wild west where everyone is free to implement the standards according to their personal interpretations.

Title: Should I use Legitimate Email spoofing?


问:
Pronunciation in programming?
How do you correctly or erroneously pronounce programming terms?  Any that you find need strict correction or history into the early CS culture?

Programming

char = "tchar" not care?

! = bang not exclamation?

# = pound not hash? Exception #! = shebang

* = splat not star?

regex = "rej ex" not "regg ex"?

sql = "s q l" not "sequel" (already answered, just i.e.)

Unixen

| = pipe not vertical bar?

bin = bin as in pin , not as in binary?

lib = lib as in library , not as in liberate?

etc = "ett see" , not "e t c" (as in /etc and not "&c")

Annoyance

/ = slash not backslash

LaTeX = "laytek" not "lay teks"

答:
Not really programming, but it bugs me when Americans say "Router" (first syllable rhymes with "out"), while Europeans say "Root-er".

I know that is based on how American's say "Route", but then why is the song Route 66 sung like it is?

Title: Pronunciation in programming?


问:
How are open source repositories managed for popular languages?
I'm a developer that creates Open Source code for a small language (LabVIEW), and am currently sharing this in several places. The vendor of LabVIEW has a certification process for Open Source libraries (mixed with commercial/closed libraries), but it's rather lengthy.

I was wondering how more popular languages manage large repositories of libraries (for instance Debian, or python-works) of Open Source libraries, are those strictly controlled and monitored for quality or can anyone contribute?

How would one set up the process for a centralized repository and accept incoming code?

Are there different levels of quality/trustworthy?

Is it allowed to rely on libraries outside the repository?

答:
The classic example i would like to refer is may be the Kernel.org where Linux kernel is hosted. Comitters can either submit a patch (mostly they can have account on kernel.org). While there is no restriction on submitting the patch, however, it doesn't go straight away into the main line.

Linus Torvalds, even till date validates each patch and he is a final authority to permit or reject each patch.

Apache on the other hand has a vision of shared leadership.

In all projects usually, there are no barriers to contributing however, there are always some core people who are trusted and only they announce the releases to ensure that things work fine.


问:
What's new in PL/I, DB2, and S/390 assembler?
I have an upcoming technical interview with a former employer that will focus on PL/I, DB2, and ISPF.  The job will be with systems that I architected and wrote myself 20 years ago. The few years of professional programming that I did since then was all assembly language.  The problem is that I haven't programmed professionally in 15 years, and the personal programming that I've done since then has been in other "modern" languages.  My question is whether there are new features in PL/I and DB2 that I should be aware of.  (When browsing through the latest "Principles of Operation" I saw machine instructions to support C style strings that weren't there in ancient times - cool.)</p>

答:
PL/I  at all as a has not changed much at all as a language. The implementation has changed drastically as under the covers the compiler is effectively a pre processor for the C++ compiler. This change has made native PL/I multi-threading problematic.

ISPF is just the same as it ever was, nothing noticeable has changed in the last 20 years. Most Z/OS shops that are doing any amount of development are using the the Rational workstation based tools which allow the development, and, debugging to take place on the PC (even though the compiling and execution are running in the mainframe itself).

DB2 is moving nicely with the times. CLOBS, BLOBS, 64 bit integers, native XML support plus a myriad of performance and connectivity enhancements.

The interesting changes in zOS over the last few years are:-

Sysplex clustering.

64 bit addressing.

C, C++ fully supported in all environments (batch,cics and USS) as a first class language.

USS -- a complete POSIX unix compatible sub-system, as a UNIX user of of old I can honestly say you would not know it wasn't really a unix box unless you knew exactly where to look.

Java support (runs inside USS) super-duper 64 bit java JVM, runs any JAR file that doesn't have JNI dependencies.

On top of USS and Java the Websphere J2EE application server runs nicely.

Some things never change though, JCL is still there, CLISTs are as horrible as ever and IBM rename their products every few weeks so you can never find the manuals on the web..


问:
how to find out if spelling mistakes in source code are a serious issue or not?
I find very troubling amount of spelling mistakes I see everyday in our codebase, from which I will reproduce a very short but representative example:

```<code>ArgumnetCount
Timeount
Gor message from queue
</code>```

Unfortunately this is in no way limited to one person. There is a lot of non-native English speakers in our team who contribute to that, however I can also pinpoint some of the worst spelling mistakes to our Software Architect who is American, born and raised.

These are also to be found even in emails, presentations, documents, whatever piece of written information we have in a software development company.

I'd like to know how to find out if it is a serious issue or not?

I've always met these spelling mistakes with concern, but my own, personal, official policy is that we are not paid to spell things right, we are paid to get things done, so inside the company I never really criticized anyone about it. But I have raised this issue with some of my close friends, and never settled it for good.

答:
Spelling errors can mean one of two things:

The person who makes them is not proficient in English, and doesn't take the time to compensate by using appropriate tools (dictionaries, spell checkers, etc.)

The person who makes them is proficient in English, but doesn't care about spelling at all.

Either is a fairly bad sign, because it means the person in question doesn't have readability, maintainability and elegance high on their priority list; if the cause is a lack of English language proficience, it also means that the person lacks two essential skills - written English communication, and a general feeling for languages (if you can't express your thoughts clearly in English, chances are you can't express them well in a programming language either).

But why exactly are spelling errors bad, all else being equal? After all, the code works, and the compiler doesn't care at all how you name your identifiers, as long as they don't violate the syntax rules. The reason is that we write code not only for computers, but also and most of all, for humans. If that weren't the case, we'd still be using assembly. Source code is written once, but read hundreds of times during its lifecycle. Spelling errors make reading and understanding the source code harder - mild errors cause the reader to stumble for a fraction of a second, many of them can cause considerable delays; really bad errors can render source code completely unreadable. There is another issue, which is that most of the code you write will be referred to by other code, and that code more often than not is written by someone else. If you misspell your identifiers, someone else will have to remember (or look up) not only what the name is, but also how exactly it is misspelled. This takes time and breaks the programming flow; and since most code gets touched more than once in maintenance, each spelling error causes a whole lot of interruptions.

Consider how developer time equals salary equals expenses, I think it should be easy enough to make a case of this; after all, breaking the flow and getting back into it can take up to 15 minutes. This way, a severe spelling error can easily cost a few hundred dollars in further development and maintenance (but they're indirect costs, not directly visible in estimates and evaluations, so they often get ignored by management).


答:
The problem here is not the engrish itself but the lack of comment clarity. Perfect english isn't necessary, clear English is. Its trivial to run something through google to pick up the obvious errors.

For example its not clear from first glance if Gor message from queue means "got a message from the queue" or "GOR message from queue". You would need to read the code to understand the meaning of the comment (thus defeating the object of the comment).

You should ask to implement code reviews in your company. You can then "criticize" people in a constructive way while they do the same to you.

Title: how to find out if spelling mistakes in source code are a serious issue or not?

Body:
I find very troubling amount of spelling mistakes I see everyday in our codebase, from which I will reproduce a very short but representative example:

```<code>ArgumnetCount
Timeount
Gor message from queue
</code>```

Unfortunately this is in no way limited to one person. There is a lot of non-native English speakers in our team who contribute to that, however I can also pinpoint some of the worst spelling mistakes to our Software Architect who is American, born and raised.

These are also to be found even in emails, presentations, documents, whatever piece of written information we have in a software development company.

I'd like to know how to find out if it is a serious issue or not?

I've always met these spelling mistakes with concern, but my own, personal, official policy is that we are not paid to spell things right, we are paid to get things done, so inside the company I never really criticized anyone about it. But I have raised this issue with some of my close friends, and never settled it for good.


答:
I actually doubt whether "Timeount" is a matter of not being a native speaker. People make tons of typos in their first language. I wouldn't qualify these particular examples  as "Engrish".

Having said that, I understand that it's not about these particular examples. I agree with you in principle. I've come across actual troubles caused by this type of stuff ("if there's no column named attachements, create attachments").

Being a programmer is about being precise and careful with typos, commas, semicolons, dots, which is human-language-agnostic most of the time.


答: If this issue bothers you, most IDE now allow spell checking in comments so that dyslexics can at least look like they know how to spell.  It sure helps me!  It is therefore a trivial "fix" to have good spelling.</p>


答:
In source code, internal presentations and documents etc. small typos that don't alter the meaning or hamper understanding are not a porblem. Just fix them in the source yourself if you find them irritating.

Also, particularly in comments, the substance is more important than the form. No Engrish here:

String s = "Wikipedia"; /* Assigns the value "Wikipedia" to the variable s. */

The fact is that some people are naturally more careful writers than some others (whether this is due to education, or due to attitude, or due to intelligence or whatever, is not relevant). How much to spend effort to fix that is a business value question: do you get more value from fixing the typos, than you spend effort in fixing them? In case of internal stuff, the answer is usually no. Your customers aren't going to complain about typos in your source code comments (unless you're doing open source).

Intentional mis-typing and inappropriate comments are unprofessional and should be avoided, but the focus should be in things that matter (i.e. generate business value, if you work for business).

Publicly visible stuff must of course be carefully proof-read.


答:
Correct spelled english is a must in code. I also have a large codebase full of gibberish in it and it's a nightmare to maintain.

Don't let this get out of hand. Try to educate everyone that the code maintainers are not mind readers.


问:
Is Information Technology really Engineering?
While travelling I met a mathematician who was sitting near me. In a discussion he said: "...there is nothing like engineering in IT or rather programming". A true engineering is what Architecture is, what Electrical and Mechanical is.

It made me think and I was puzzled. A percent of my brain agreed also because in Indian Army, there is no subject like Computer Engineering in the Engineering Corps. They don't consider programming as engineering. This is what I heard few years back, I don't know what Indian Army thinks now.

What are your views?

答:
It depends on the country, on their definition, on their academic system and so on. Some for example do not count architecture as engineering - unlike civil engineering, it is viewed as more of a mix between engineering and art.

It all depends on how you look at it.

But why does it matter. After all, what's in a name?


问:
Should a method do one thing and be good at it?
"Extract Till You Drop" is someting I've read in Uncle Bob's blog, meaning that a method should do one thing alone be good at it.

What is that one thing? When should you stop extracting methods?

Let's say I have a login class with the following methods:

```<code> public string getAssistantsPassword()
 public string getAdministratorsPassword()
</code>```

These retrieve the respective accounts password in the database. Then:

```<code> public bool isLogInOk()
</code>```

The method compares the password that has been called or selected, and sees if the password the user provided is in the database.

Is this an example of "Extract Till You Drop"? When will you know when you are doing too much of extracting?

答:
The general idea is that you're done extracting when there is nothing else that you can extract and still get a logical lump of code. If there's part of a function that can be taken out, if it does something that you can describe and give a name to, and if you can imagine that you might need to call that from some other part of your code, then you should extract it.

Even if you never need to call it from another part of your code, the fact that it's a separate function means you can write unit tests for it alone, which improves your bug detection, and means you can profile it independently, which improves your ability to assess for performance losses in your code.

Extract code until there is no function that does more than one thing - if you can pull code out of a function into another function, if the new function performs some task, and if you can describe what that task is, then extract that code. If you're worried about performance, you can always inline it later.