问:
Which metric/list should be used to evaluate whole software development team?
The title might be seem vague, so let me tell you a little bit history what i am trying to clarify question.

I have been hired as a consultant for a corporate's small development division.  The company also owns a couple of software development companies.  My ex-manager runs a BI team, with reports, analyst and developers.  He asked me to evaluate overall design, software development process and code quality.

Here what I found:

Lots of copy/paste code everywhere ( no reuse ).

Even though they have everything TFS, VS Ultimate etc, they have no build process.

No Cruise Control.net / Teamcity...

No unit tests.

Web Pages with 3700 lines of code, Lots of huge functions ( which can be divided into smaller functions).

No naming convention both db and c# code

No 3rd party or open source projects.

No IoC.

No Separation Of Concerns.

No Code Quality Check ( NDepend or FxCope or anything ).

No Code Review.

No communication within the team.

They claim they wrote an application framework ( 6 months, 3 persons), but I would hardly call a framework ( of course no unit test, there are some but all commented out). The framework contains 14 projects, but there are some projects with only one file with twenty lines of code.

Honestly, what people are doing fixing bug all the day( which will provide more bugs eventually), they are kind of isolated from community, some team members even don't know github or stack Overflow they probably went there with google but they don't know about it.

So here is question, Is This list  ok? Or am I being picky? Since I don't have any grudge against them, I just want to be fair, honest and I would like to hear you suggestions, before I would submit this list.

And since this list also will be review by software  division's manager, I don't want any heart break or something like this. http://www.hanselman.com/altnetgeekcode/ For example I would love to such lists, I can't make references.

Here what I think after this question

Since sorf of list wanted I will submit it. But I will definetly reference this question and great answers to make my intention clear ( I dont want to be picky a***e, I respect what they do, but I believe they can do better) . I will recommend them to take it slowly, use their time wisely, and if they let me I will try to investigate the real problem and try to solve it with them. Not as an enemy or a person who didnt like what they do,  as a friend, a person who likes building things.

答:
Start by being constructive and look for things they are doing right. If you don't you are going to make enemies and you job will be very hard. Make friends, find out what they want, what will motivate (and demotivate) them, before talking metrics.

Have you even tried to find out why they do what they are doing?

This is most likely a people problem - lack of teamwork, lack of leadership, wrong focus (bug fix over bug prevention) etc. There may be a lack of ability, skills, training etc, but in my experience that is a symptom, not a route cause.

One word of caution about metrics: Be very careful what you measure. What you measure becomes all important. What you don't measure becomes unimportant. If you measure the wrong things, you drive towards the wrong results.

Edit - This question might be helpful - although closed as Of Topic for Programmers its almost certainly relevant to your situation. Particularly read the works of Steve McConnel.


问:
Is there an effective way to test XSL transforms/BizTalk maps?
Creating repeatable tests for BizTalk maps is frustrating. I can't find a way to handle testing them like I'd do unit testing, because I can't find ways to break them into logical chunks. They tend to be one big monolithic unit, and any change has the potential to ripple through the map and break a lot of unit tests. Even if I could break it up, creating XML test inputs is painful and error prone.

Is there any effective way of testing these? I'd settle for recommendations for testing XSL transforms in general, but I specifically mention BizTalk maps primarily for the reason that when using the mapper, there really isn't any way to break your XSLT into templates (which I'd imagine you could use to break up your logic into testable chunks, but I've honestly never gotten that far with XSLT).

答:
I'm not an expert on BizTalk, but I made some unit tests for XSLT. I found several ways to do it.

Creating some XML that represent the usual data.

Developing a reverse tool (from XSLT output to significant XML data) and then testing XSLT over a big amount of XML (e.g. monthly invoicing, integration messaging, etc.). If you can obtain the significant part of the XML you are in the good way. This test can be presented to a customer to ensure that the XSLT was made correctly.

We use the way 1 to develop XSLT and the way 2 to test XSLT.

ContentLicense: CC BY-SA 3.0


问:
Is it legal to modify MIT licensed code and sell it?
I have a project and I want to use a ready-made script that is licensed under MIT in it. But using this script separately will be redundant.

So I've decided to merge my code and the MIT licensed script in the same file. (Let's say I'll modify, improve and/or add new features to it.)

I'm planning to sell this work on a market, but is it fair (legally)?

NOTE: Meanwhile, I'll put (refer) the MIT licensed script's copyright already in the final file.

答:
Short Answer: Yes

From the MIT License:

Permission is hereby granted, free of charge, to any person obtaining
  a copy of this software and associated documentation files (the
  "Software"), to deal in the Software without restriction, including
  without limitation the rights to use, copy, modify, merge, publish,
  distribute, sublicense, and/or sell copies of the Software, and to
  permit persons to whom the Software is furnished to do so, subject to
  the following conditions:

The above copyright notice and this permission notice shall be
  included in all copies or substantial portions of the Software.

Make sure you include the license in your source code and you should be fine. It would probably be good of you to at some point fully open source your project but I don't believe that's a requirement.

Long Answer: Talk to a Lawyer/Barrister/Legal Professional in your jurisdiction.


问:
Should comments say WHY the program is doing what it is doing? (opinion on a dictum by the inventor of Forth)
The often provocative Chuck Moore (inventor of the Forth language) gave the following advice[1]:

Use comments sparingly! (I bet that's welcome.) Remember that program
  you looked through - the one with all the comments? How helpful were
  all those comments? How soon did you quit reading them? Programs are
  self-documenting, even assembler programs, with a modicum of help from
  mnemonics. It does no good to say:

LA B . Load A with B

In fact it does positive bad: if I see comments
  like that I'll quit reading them - and miss the helpful ones. What
  comments should say is what the program is doing. I have to figure out
  how it's doing it from the instructions anyway. A comment like this is
  welcome:

COMMENT SEARCH FOR DAMAGED SHIPMENTS

Should comments say why the program is doing what it is doing?

In addition to the answers below, these two Programmers posts provide additional insight:

Beginner's guide to writing comments?

An answer to Why would a company develop an atmosphere which discourage code comments?

References

1. Programming a problem-oriented-language, end of section 2.4. Charles H. Moore. Written ~June 1970.

答:
Depends on what you mean by "why".

If you mean information like high level requirements, user stories, etc, then no, comments are not a good place to explain "why". A far better place would be your commit/push messages, which ideally should point to fuller explanations in tickets in your issue tracker. And obviously you can always have a comment in code pointing to the ticket.

If, on the other hand, you mean very short explanations of small but not obvious decisions you've made in your code, then such comments would be appropriate. But that's more or less the same as what Chuck Moore means by "WHAT the program is doing" (the "why" is implied).

Related questions:

Beginner's guide to writing comments?

Best practices in comment writing and documentation

Style and recommendations of commenting code

Are More Comments Better in High-Turnover Environments?

What should I put in comments while commiting to the Source Control?

https://softwareengineering.stackexchange.com/questions/89871/reasons-to-not-add-comments-to-source-control-check-ins

Why would a company develop an atmosphere which discourage code comments?


问:
How do you use blank lines in your code?
There has been a few remarks about white space already in discussion about curly braces placements.

I myself tend to sprinkle my code with blank lines in an attempt to segregate things that go together in "logical" groups and hopefully make it easier for the next person to come by to read the code I just produced.

In fact, I would say I structure my code like I write: I make paragraphs, no longer than a few lines (definitely shorter than 10), and try to make each paragraph self-contained.

For example:

in a class, I will group methods that go together, while separating them by a blank line from the next group.

if I need to write a comment I'll usually put a blank line before the comment

in a method, I make one paragraph per step of the process

All in all, I rarely have more than 4/5 lines clustered together, meaning a very sparse code.

I don't consider all this white space a waste because I actually use it to structure the code (as I use the indentation in fact), and therefore I feel it worth the screen estate it takes.

For example:

```<code>for (int i = 0; i < 10; ++i)
{
    if (i % 3 == 0) continue;

    array[i] += 2;
}
</code>```

I consider than the two statements have clear distinct purposes and thus deserve to be separated to make it obvious.

So, how do you actually use (or not) blank lines in code ?

答:
Yes, but I don't abuse it.

I've seen code where every line of code inside a method is separated by a blank line, and two blank lines are used where a logical separation occurs. That just makes it even less readable in my opinion. I've also seen whitespace used to make crazy alignments, such as this:

```<code>//Prot.   Return type                    Name                 Arg1        Arg2
//=====   ============================== ==================== =========== ========

private   int                            AMethodWithALongName(string s,   object o)
{
    ...
}

private   IDictionary<MyLongObject, int> SomethingCrazy      (string s)
{
    ...
}

protected void                           Foo                 (string str, object o)
{
    ...
}
</code>```

The same misuse of horizontal whitespace can be applied to vertical whitespace. Like any tool, use it wisely.

Body:
Yes, but I don't abuse it.

I've seen code where every line of code inside a method is separated by a blank line, and two blank lines are used where a logical separation occurs. That just makes it even less readable in my opinion. I've also seen whitespace used to make crazy alignments, such as this:

//Prot.   Return type                    Name                 Arg1        Arg2
//=====   ============================== ==================== =========== ========

private   int                            AMethodWithALongName(string s,   object o)
{
    ...
}

private   IDictionary<MyLongObject, int> SomethingCrazy      (string s)
{
    ...
}

protected void                           Foo                 (string str, object o)
{
    ...
}

The same misuse of horizontal whitespace can be applied to vertical whitespace. Like any tool, use it wisely.

ContentLicense: CC BY-SA 2.5


答:
Should comments say WHY the program is doing what it is doing?

Unequivocally yes. There don't necessarily need to be many comments, mind you, but if you have them, WHY is the only question worth answering outside of a few bizarre fringe scenarios. The reasoning is simple. If I read your code, good or bad, I can see what the program is doing. I have no idea why. HOW seldom has anything I don't know. WHY is frequently based on history, weird portions of the problem domain, or hacks around third party dependencies.

Title: Should comments say WHY the program is doing what it is doing? (opinion on a dictum by the inventor of Forth)

Body:
The often provocative Chuck Moore (inventor of the Forth language) gave the following advice[1]:

Use comments sparingly! (I bet that's welcome.) Remember that program
  you looked through - the one with all the comments? How helpful were
  all those comments? How soon did you quit reading them? Programs are
  self-documenting, even assembler programs, with a modicum of help from
  mnemonics. It does no good to say:

LA B . Load A with B

In fact it does positive bad: if I see comments
  like that I'll quit reading them - and miss the helpful ones. What
  comments should say is what the program is doing. I have to figure out
  how it's doing it from the instructions anyway. A comment like this is
  welcome:

COMMENT SEARCH FOR DAMAGED SHIPMENTS

Should comments say why the program is doing what it is doing?

In addition to the answers below, these two Programmers posts provide additional insight:

Beginner's guide to writing comments?

An answer to Why would a company develop an atmosphere which discourage code comments?

References

1. Programming a problem-oriented-language, end of section 2.4. Charles H. Moore. Written ~June 1970.


问:
Did I Inadvertently Create a Mediator in my MVC?
I'm currently working on my first biggish project. It's a frontend facebook application that has, since last Tuesday, spanned some 6000-8000 LOC.

I say this because I'm using the MVC, an architecture I have never rigidly enforced in any of my hobby projects. I read part of the PureMVC book, but I didn't quite grasp the concept of the Mediator. Since I didn't understand and didn't see the need for it, my project has yet to use a single mediator.

Yesterday I went back to the design board because of some requirement changes and noticed that I could move all UI elements out of the View and into its own class. The View essentially only managed the lifetime of the UI and all events from the UI or Model.

Technically, the View has now become a 'Mediator' between the Model and UI. Therefore, I realized today, I could just move all my UI stuff back into the View and create a mediator class that handles all events from the view and model.

Is my understanding correct in thinking that I have devolved my View as it currently is (handling events from the Model and UI) into a Mediator and that the UI class is what should be the View?

答:
In ASP.NET MVC, the view creates HTML code which send messages to controller. That is, a View may send a "modelled request" to a controller.
The controller usually responds with a typed view, this type is a "ViewModel".
This "ViewModel" is filled with data provided by the controller.

A typical MVVM is a web page (View) that has JavaScript that gets view information (JSON, XML, etc), or another new View, from a "ViewModel". Examples are: Gmail and Telerik Kendo UI.


答:
I totally agree with the points that mattnz makes and offer this aside.

I have seen this a lot. the Prototype Model becomes the Production Model.

Time and time again a "Proof of Concept" gets whipped up in a frenzy to get buy in from certain people and then... someone decides to put the "PoC" into production because a potential customer saw it an offered to buy it today. Then the next day three customers say they want it and the day after, seven customers say they want to buy it.

Once it's sold, you have to deliver and the focus is shifted from building a real scalable application to rolling out features that are on high demand because the PoC didn't include them.

Get some history on the evolution of the system before making recommendations.

Title: Which metric/list should be used to evaluate whole software development team?

Body:
The title might be seem vague, so let me tell you a little bit history what i am trying to clarify question.

I have been hired as a consultant for a corporate's small development division.  The company also owns a couple of software development companies.  My ex-manager runs a BI team, with reports, analyst and developers.  He asked me to evaluate overall design, software development process and code quality.

Here what I found:

Lots of copy/paste code everywhere ( no reuse ).

Even though they have everything TFS, VS Ultimate etc, they have no build process.

No Cruise Control.net / Teamcity...

No unit tests.

Web Pages with 3700 lines of code, Lots of huge functions ( which can be divided into smaller functions).

No naming convention both db and c# code

No 3rd party or open source projects.

No IoC.

No Separation Of Concerns.

No Code Quality Check ( NDepend or FxCope or anything ).

No Code Review.

No communication within the team.

They claim they wrote an application framework ( 6 months, 3 persons), but I would hardly call a framework ( of course no unit test, there are some but all commented out). The framework contains 14 projects, but there are some projects with only one file with twenty lines of code.

Honestly, what people are doing fixing bug all the day( which will provide more bugs eventually), they are kind of isolated from community, some team members even don't know github or stack Overflow they probably went there with google but they don't know about it.

So here is question, Is This list  ok? Or am I being picky? Since I don't have any grudge against them, I just want to be fair, honest and I would like to hear you suggestions, before I would submit this list.

And since this list also will be review by software  division's manager, I don't want any heart break or something like this. http://www.hanselman.com/altnetgeekcode/ For example I would love to such lists, I can't make references.

Here what I think after this question

Since sorf of list wanted I will submit it. But I will definetly reference this question and great answers to make my intention clear ( I dont want to be picky a***e, I respect what they do, but I believe they can do better) . I will recommend them to take it slowly, use their time wisely, and if they let me I will try to investigate the real problem and try to solve it with them. Not as an enemy or a person who didnt like what they do,  as a friend, a person who likes building things.


问:
what receives an ajax call?
I'm making a site which should (a) take information from the user in the form of files and forms, (b) take that data to the server to be run on a C application, and (c) take the result back and show it to the user. I was told to look for AJAX for the communication with the server. BTW, I'm using rails.

I'm trying to understand how AJAX works. From what I understand so far, with rails is pretty easy to make the call.

What I can't figure out is, what waits for that call? what process the call?

If I understand correctly, with rails I could make a function in ruby and make it so it's called through AJAX, which means -or so I understand- that it gets executed on the server. If I were using PHP, would I need to make an http server to wait for the AJAX calls?

I just don't find information about what waits for the call, and that information is processed. Any links, comments or books are welcome!

答:
This is an oversimplified answer, based on what I think your current understanding is. If it's too trivial or too complex, feel free to tell me about it and I'll expand or clarify.

An AJAX request is a normal HTTP request. You are essentially requesting a resource from the web server, and technically it's exactly the same request as if you'd type the URL of the resource in the address bar of your browser.

What's different with AJAX requests is than they can be executed asynchronously. A trivial explanation of what that means is that you don't need to reload the page for the requests to happen.

So, the difference is solely on the client side. On the server side, the HTTP Server doesn't treat them any differently than normal HTTP requests, it listens for requests, and serves resources when asked. These resources can be anything, an HTML script, a PHP script, a Ruby script, any kind of media, etc.

Lastly, your choice of server side language doesn't really matter, the architecture is the same.

Title: what receives an ajax call?


问:
Rewriting software using Agile methodologies
Suppose you have to rewrite an entire application using Agile methodologies, how would you do it?

I guess you could write a big bunch of user stories based in the behavior of your current system. And then implement them in small iterations.
But this wouldn't mean that we have the requirements UP FRONT??

Also, when would you start releasing? Agile says we should release early and often, but it doesn't make much sense to release before the complete rewrite has been completed.

答:
Break it down into high-level epics. Take each functional area of the application, one step at a time.

Break one epic down into a group of stories (usable chunks -- anything that improves the application) and manage those as you would if you didn't have an existing application, with one exception: If it is possible, make it so that you can implement that one piece of functionality as part of, or alongside, the original application.

When Agilists say "release early and often", that doesn't necessarily mean to production. If you're going to replace an existing application, you should use a staging area to release often, and make sure your users are testing the system there. This will still give them room to prioritise the next piece of work and to make sure that nothing you release to production depreciates the product.

Once you've released one component to production, move onto the next.


答:
we just got through such an experience (me as scrum product owner). It took us two years to get to something releasable. But still, agile brought us many benefits.

First: A total rewrite is by nature not agile at all. You should instead consider refactoring the existing product piece by piece. That has been discussed in another question. So let's assume it has to be a rewrite.

Then indeed, you start with a back log that covers all the relevant use cases of the existing product. But please don't approach it as writing specs. That would be too much detail. It should be complete (otherwise you can't do release planning). And it shouldn't be too elaborate (otherwise you're writing specs upfront). Here's how we approached that:

categorize the users of the old product. Identify the users that only need a small part of the old product and still get something useful out of it. They define your first epics.

Then add epics that would allow another category of users to move to the new product. Etc.  until you have a back log that covers all users.

most likely, these epics will need further splitting. If possible, try to split so that each part still has some value. If that's not feasible, then at least make sure each part can be demonstrated.

when you have 20-50 epics, have the team estimate them.

split the top most epics into User Stories that the team believes to be feasible within a sprint. Don't do that for all epics yet, only the ones on top. You'll have plenty of time for splitting the rest.

When to release externally! That is a business decision. At least this approach gives you the opportunity to release earlier to certain user categories. That can be handy if management gets nervous about this seemingly never ending project.

Title: Rewriting software using Agile methodologies

Body:
Suppose you have to rewrite an entire application using Agile methodologies, how would you do it?

I guess you could write a big bunch of user stories based in the behavior of your current system. And then implement them in small iterations.
But this wouldn't mean that we have the requirements UP FRONT??

Also, when would you start releasing? Agile says we should release early and often, but it doesn't make much sense to release before the complete rewrite has been completed.


问:
Are flag variables an absolute evil?
Are flag variables evil? Are the following kind of variables profoundly immoral and is it wicked to use them?

"boolean or integer variables that you assign a value in certain places then down below you check then in orther to do something or not, like, for example using newItem = true then some lines below if (newItem ) then"

I remember doing a couple of projects where I totally neglected using flags and ended up with better architecture/code; however, it is a common practice in other projects I work at, and when code grows and flags are added, IMHO code-spaghetti also grows.

Would you say there are any cases where using flags is a good practice or even necessary?, or would you agree that using flags in code are... red flags and should be avoided/refactored; me, I just get by with doing functions/methods that check for states in real time instead.

答: A huge function block is the smell, not the flags. If you set the flag on line 5, then only check for the flag on line 354, then that's bad. If you set the flag on line 8 and check for the flag on line 10, that's fine. Also, one or two flags per block of code is fine, 300 flags in a function is bad.</p>

Title: Are flag variables an absolute evil?

ContentLicense: CC BY-SA 4.0


答:
Don't confuse symptomatic concerns based on personal bias (preference) with big picture problems.

Are they shipping software?

If they are shipping software, there are some things in their process that are working.  If they are aren't, then work on who, why, how, and when they can get on a release schedule they can meet.

For the software they are shipping, are the sponsers/customers/users generally happy with it?  Are they creating mutual value for both their employer and the customer?  Are the things the customer needs being built?  Is what is being delivered honestly making the sponser/customer/user job easier, or is it another layer of complication or difficulty?

Everything will have bugs.  'Bug Free' is some ideal that really only applies to software of very limited complexity, with a very static environment.  It is something to aim for, but sometimes certain bugs are just not worth investing in.  Simply because no one has identified a bug in 'bug free' software doesnt mean it's not there, it simply means it hasn't surfaced or been reported.  Additionally, it is ok to occassionally say no to the customer, especially when it is a pie-in-the-sky feature that needlessly pushes the release and ship dates: deliver the things that are fixed, or fixable, and defer the others till another ship date when there is time to do those other things.  Worry about it later, as later may never come: you may never have to fix or add that feature.


答: I think maybe the point that your missing is that your browser is effectively multi-threaded.  When you make an AJAX call, a new thread is spawned which waits for the call to return; while an existing thread sits around performing business as usual (such as responding to user actions).</p>

Title: what receives an ajax call?

Body:
I'm making a site which should (a) take information from the user in the form of files and forms, (b) take that data to the server to be run on a C application, and (c) take the result back and show it to the user. I was told to look for AJAX for the communication with the server. BTW, I'm using rails.

I'm trying to understand how AJAX works. From what I understand so far, with rails is pretty easy to make the call.

What I can't figure out is, what waits for that call? what process the call?

If I understand correctly, with rails I could make a function in ruby and make it so it's called through AJAX, which means -or so I understand- that it gets executed on the server. If I were using PHP, would I need to make an http server to wait for the AJAX calls?

I just don't find information about what waits for the call, and that information is processed. Any links, comments or books are welcome!


答:
Release Now If You Can

Your question about when do you start releasing the code is a great one.  I think that two provisos apply.  First, that you have "good enough quality", and second that that you meet the requirements for an MVP (minimum viable product).

Rome (and Agile) Weren't Built in a Day

Maybe you are ready with a turnkey agile team to take over on day one.  For most organizations, there is the work and expense of training, retooling, and the usual forming, storming, norming, performing cycle of building a team.  Be up front about the risks and costs, be careful to set realistic expectations, and be up beat and prepared to advocate your approach.

Be a Reuse Bootstrapper

Like fusion power, code reuse is and always will be the future solution to our economic problems.  My feeling is that developers often say they believe in reuse, but only the kind of reuse that starts after they build a new framework, rather than the kind where they build on what someone else has already done.  How can that work until someone is willing to chose to build on someone else's foundation?  At best, it means a rewrite every few years when team leadership changes.

Why Release Early And Often?

Release early and often is a mantra for many reasons.  It gives life to our discussions about what the product should become, it makes real where we are, and it gives us a base for iterative/incremental changes.  The pace of releases is pretty much an invariant for agile, with the difference being who receives the releases (customer surrogates or end users).  Before agile, maintenance was estimated to account for 60% of the cost of software systems.  This is a source of much consternation for managers and others, some who feel the product release is where software goes to die.  For them, everything after the release is rework and paying to fix a product that they paid for once already.

Pre-release is Unnatural

Kent Beck writes that pre-release is an unnatural state for software products.  It is certainly an inconvenient time because it is a time when you have no customers and you are paying for the product rather than the product paying for you.

Don't Criticize the Previous Team

While it might setup the developers who take over the rewrite as the heros and salvation of the project, I think there is a cost to criticizing the previous team's accomplishments.

First, if you let people make up their own mind about the previous team, you have more time and energy for your real mission.

It will be awkward if you need to work with members of the previous team, both developers as well as stakeholders like product managers, project managers, or customers.

If you can get it working, you may find yourself receiving (or worse yet taking) credit for what the previous team did.

On average, the previous team was probably average.  On average, you might be average.  You have more work than the previous team because you have a new methodology to put in place in addition to a project.

If the old team was horrible, unless you are horrible too, you will eventually get credit for being better than horrible.  If they were better than horrible, and you aren't noticeably better, saying they were horrible may invite unpleasant comparisons.

If the old team was better than you thought they were, and you get into trouble because the organization is broken or the problem is ill defined or very difficult, things will go better for you if you haven't significantly raised expectations.

If they expect what they were getting, but you do better, it is a win for you.

To refrain from criticism is both good manners, and shows that you have class.


答: I'm a strong proponent of the Single Responsibility Principle which lends itself well to method names that reveal WHAT they are doing. WHY is a little tougher. If the implementation is convoluted enough to the point that comments are needed to justify what's going on then it'll be difficult to contextualize, in the midst of subsequent execution calls, why a given piece of code is running. My preference is to leave the WHY to the user stories and keep the code granular enough that it can effectively comment itself.</p>


答:
The essence of the advice is to write code for both the compiler and for people, and to not explain things that are expressed by the code.

Redundancy between the code and comments creates problems.  When the two disagree, both are probably wrong.  If you have to write it twice and read it twice, someone probably paid for it twice.

Among the answers, we have down votes for explaining how, and up votes for explaining what and why.  I agree.  Where comments that relate parts of the code, or perhaps explain rationale that can be used to make minimal, cohesive, and coherent classes would be a benefit.  The who and when of code can be found in the source control system.  Source control commit comments give us an understanding and correlation of the systems evolution toward its goals.  Linked with a bug tracker can answer many why questions.

Scope and applicability are good topics for comments.  If we are separating concerns the way we should, we should use naming and comments to guide future maintainers.  Programming by contract, using assertions, and unit tests are all in the mix of clarifying the meaning and expected behavior of our software.


问:
Do support sites like Stack Overflow upset the paid-support open source model?
In order to stay relevant in the marketplace, I'm researching new business models for my software company.  The open source model with paid support seems like a good fit for our product, but I have concerns about whether or not a paid support model is viable in an era where top-notch help is readily available for free on sites like those in the Stack Exchange network.

Case in point -- I moved my employees to Ubuntu last year because I didn't want to pay for Win 7 licenses and new hardware (plus, the mono platform was highly attractive).  My staff had no Linux experience, but were able to achieve relative competency in about 120 days with the help of AskUbuntu, Stack Overflow, and a few "For Dummies" books.  We did employ an Ubuntu consultant for 7 days to provide training and support, but beyond that spent $0.00 on any kind of paid expertise.

In regards to my due diligence, I ran a 3 month beta of the freemium-paid-support model with one of our smaller customers, and achieved mediocre results.  I'd like to think its because our software is so stable and easy to use that the customer didn't need much paid support, but I suspect that they circumvented the terms of our SLA in the same manner that we did with the move to Ubuntu.

Does anyone out there has any thoughts, advice, or experience relevant to the move I'm considering?  What worked, what didn't, etc?

答:
Paid support really works best for those things that are specific to your product that will benefit from your expertise.  If you are a domain expert in your own product, you are the one best qualified to be a top-notch consultant for your users.

Nobody wants to pay good money for run-of-the-mill customer service or for things that I would call "common knowledge" (at least within the developer community), nor would you as a company want to support such things.

Example: Telerik has a reputation for having very good technical support.  There are a number of companies that do what Telerik does (provide custom, high-quality user-interface controls for  business applications), and they're all very good at it.  There's a market for these products because nobody wants to spend man-years writing a control suite before they begin providing value in their own software application.  Since many companies can provide this product, Telerik sets themselves apart by offering better customer support.

Telerik is more than happy to provide domain-specific support for their own product.  But they're not going to teach you Model-View-Controller or how to write a SQL statement (even though their customer service must know these things).  For that, there are a raft of other (and arguably better) resources.  Nor do I necessarily want to call Telerik for MVC or SQL support.  In fact, I don't want to call Telerik at all, if I don't have to.  It's very expensive for both me and Telerik to sit on the phone trying to solve a problem.

So I view a support contract as "insurance."  I buy it, hoping I never need to use it, but feeling more secure knowing that I have an expert support team that's available to back me up if I have a problem.

This philosophy extends to Stack Overflow, to a substantial degree.  Stack Overflow (and sites like it) do not want to substitute for other companies' paid support.  When folks ask questions over there that are very specific to Telerik controls, I always ask them, "What did Telerik say?"  "Well, I never called them."  People ask on SO first because most companies have crappy customer service, and I guess they're hoping that some random employee from Telerik will wander in and answer their question.

I believe the key is, if you are going to offer support as a service, it has to be the kind and quality of support that people will say, "I won't use anyone else's product, because I know I can count on your staff's expertise in your product to help get me through the rough patches."


答:
Why can be a very powerful question to answer.

If you have trouble answering it yourself, then you are probably not thinking through your code design properly, and might need to rethink the motivation for your class/function/whatever. If you can answer the question why clearly and concisely, then your class will also probably be clear and concise.


答:
Several years ago I heard a definition for consultant as:

A guy who can tell you a thousand ways to make love to a woman, but
  can't get a date.

I think you don't have to be that guy, provided you have the hands-on skills to go down the list you made here and decide which you will solve through doing once or multiple times for the customer, by training that you provide or purchase for the staff, and by staff changes that you recommend and help execute.

Perhaps you can ask to not be a consultant, but to instead be an interim manager for software.  You will want and need decision authority over policy, and will need to act directly, not from a distance to make the needed changes.  I think Machiavelli advised that when the Prince conquerors a city, he must go and live there to exert his ruling power.  I believe if you want to make lasting changes, there is no other way than to go there and direct the change you advocate.

Your list seems pretty sound, but can be augmented.  Follow the money!  Start with the customer, learn how features, prices, and payments work between the company and its clients.  Evaluate requirements management, estimation, integrated planning and tracking, and quality.  As with SEI CMM, it is good to start with management where the highest leverage changes will occur, then work your way down to the developers.  Scrum and agile methods are great, but there is a significant selling task at every step to keep executives, managers, and professionals on task making the changes that will fix the problems.


问:
Start with open source desktop application and move to iPhone/Android app
I'm a high schooler and I am competing in an open source software development competition. It must be a desktop application that runs on either Windows or Linux. I have a great idea for the open source desktop app, and I wanted to know if I could take it farther and port it to the iPhone or Android platform and make money (preferably through $.99 cost, not ads)

I read somewhere that certain open source licenses allow me to do this... am I correct?

答: This is an app you are creating, correct?  If so, you can port it to whatever OS you'd like.  </p>


答:
It will entirely depend on the competition rules. There is nothing stopping me releasing my software under open source rules and also selling it (QT is a good example) under a commercial license.  If I own the rights to it, I determine who by, where and when it can be used. </p>

<p>The rules of the competition will (should) clearly state who owns the rights to the source after the competition ends - is it the author or the competition organizers (The cynic in me says look out for someone looking for some cheap IP). </p>

Title: Start with open source desktop application and move to iPhone/Android app

Body:
I'm a high schooler and I am competing in an open source software development competition. It must be a desktop application that runs on either Windows or Linux. I have a great idea for the open source desktop app, and I wanted to know if I could take it farther and port it to the iPhone or Android platform and make money (preferably through $.99 cost, not ads)

I read somewhere that certain open source licenses allow me to do this... am I correct?

Body:
It will entirely depend on the competition rules. There is nothing stopping me releasing my software under open source rules and also selling it (QT is a good example) under a commercial license.  If I own the rights to it, I determine who by, where and when it can be used.

The rules of the competition will (should) clearly state who owns the rights to the source after the competition ends - is it the author or the competition organizers (The cynic in me says look out for someone looking for some cheap IP).


答:
Prompted by the comments by @Chuck and references to Netscape essentially saying don't rewrite, and valid responses retorting that he OP is not asking if he should. - A truly agile software development cycle precludes rewriting. Rewriting almost always breaks many of the principles behind Agile.
Using the current software as a base-line these Agile principles (from Agile Manifesto) cannot be met with a rewrite.

Early and continuous delivery of valuable software. - the customer will not get early value when measured against what they already have

Deliver working software frequently - weeks to months - how big is the project, can you honestly say the customer will get anything more useful to them anytime soon.

Working software is the primary measure of progress - working compared to the baseline won't happen in a hurry

Agile processes promote sustainable development. - Given the customer has a working baseline, the pressure will be on to deliver improved functionality. This is unlikely to be done at a pace that sustainable

Simplicity--the art of maximizing the amount of work not done--is essential. this Says it all really...

"Suppose you have to rewrite an entire application using Agile
  methodologies, how would you do it?"

The question is based on a false premise - That a rewrite can be considered Agile.


答: The code itself is partly for computer, partly for humans (the names of methods and variables). But comments are exclusively for humans, either other person or yourself in the future (who will be a little different person then you currently due to properties of our memory). Any message for humans is valuable if it consists helpful information. If you explain WHY you're using a sorted list and not the hash then it is less likely that you rush into replacing ineffective code two years later just because you instantly see this opportunity </p>


问:
How can I improve my skills while working on actual projects, in the absence of more experienced developers?
I'm the lead developer at a small company, working with C# and ASP.Net. Our team is small, 2-3 people, without much experience in development and design. I don't have the opportunity to learn from more senior developers, there is no one in my team to guide me and help me choose the best approaches, as I take care most of the projects myself.

How can I improve my software development skills while working on actual projects, in the absence of more experienced developers?

答:
Software development is a team sport.  Like a sport, to play at a very high level, you need to be with and compete against others who do the same.  Look for opportunities to move around.

Remember that practice makes permanent, so if you are not constantly working toward better technique and knowledge, if you work in isolation with no critic or role model, you may find that your skills don't grow.

Worldwide, things are getting more competitive, so expect your niche to be temporary, and prepare for the kind of opportunity that meets your criteria for satisfying work, while at the same time, takes you outside your comfort zone to work with a superior team.


问:
Is modern C++ replacing C#? Is Microsoft pushing developers to adopt C++?
I hear about modern C++ popularity and some talks about migrating back to C++ from C# or other C-like languages.

I know about C++11 features but I would like to hear your experiences, especially from developers who migrated from C# to C++.

More importantly, does Microsoft push developers to use C++? If yes, why?

答:
No, Windows 8 is all about using whatever language you need to (or know) get the job done. JavaScript, .Net languages (C#) and C/C++ are all supported equally.

Nothing is being replaced and it's up to developers in the end anyway. There is however a push for better battery life which WinRT makes easier.

The exception is games where C++ is getting more support, especially on Windows Phone 8 while the managed languages have no native support (aka no xna).


问:
What are the differences between programming languages?
Once upon a time, I heard from someone

the only difference between programming languages is the syntax

I wanted to deny it - to say that there are other fundamental aspects that truly set a language apart from others than just syntax.

But I couldn't... So, can you?

Whenever I search Google for something like "differences between programming languages", the results tend to be debates between two specific languages (I'd like something more general) - however, some of the aspects that people seemed to debate the most were:

Object-Oriented

Method/Operator overloading (I actually see this rather related to syntax)

Garbage-Collection (While it seems like a good difference, for some reason it doesn't seem that "fundamental")

What important aspects other than syntax can you think of?

答:
There are many things that differentiate programming languages. However, any result can be obtained by using any general purpose programming language. The difference, however, is in the efficiency, both of runtime (more compiler-dependent) and development time.

For example, programming distributed applications in Erlang is much easier than in Assembly, or even C.

Mutability is another criterion that separates languages. It's essentially about making "pure functions", i.e functions that always return the same value for a certain input, just like mathematical functions. This belongs in (and in a way defines) the functional programming paradigm.

The list could go on forever. Anyone who says that the only difference between any X programming languages is the syntax, is saying that only because probably the only thing they know about the languages is their syntax.

Some programming languages only differ in syntax (for example, Javascript and Coffeescript); but more often, different programming languages suggest different ways to think about a problem. That's usually the major difference between them.


问:
Sort algorithms that work on large amount of data
I am looking for sorting algorithms that can work on a large amount of data, i.e. that can work even when the whole data set cannot be held in main memory at once.

The only candidate that I have found up to now is merge sort: you can implement the algorithm in such a way that it scans your data set at each merge without holding all the data in main memory at once. The variation of merge sort I have in mind is described in this article in section Use with tape drives.

I think this is a good solution (with complexity O(n x log(n)) but I am curious to know if there are other (possibly faster) sorting algorithms that can work on large data sets that do not fit in main memory.

EDIT

Here are some more details, as required by the answers:

The data needs to be sorted periodically, e.g. once in a month. I do not need to insert a few records and have the data sorted incrementally.

My example text file is about 1 GB UTF-8 text, but I wanted to solve the problem in general, even if the file were, say, 20 GB.

It is not in a database and, due to other constraints, it cannot be.

The data is dumped by others as a text file, I have my own code to read this text file.

The format of the data is a text file: new line characters are record separators.

One possible improvement I had in mind was to split the file into files that are small enough to be sorted in memory, and finally merge all these files using the algorithm I have described above.

答: If you really want a scalable solution you should take a look at TeraSort, the standard sort implementation with map-reduce; more details on StackOverflow.</p>


答:
Computer scientists have long time been thinking about the ways to describe and compare programming languages. You might be interested in the field of formal semantics.

A description by John Longley from the University of Edinburgh:

A formal semantics for a programming language is a mathematically precise description of the intended meaning of each construct in the language. In contrast to a formal syntax for a language, which tells us which sequences of symbols are correctly formed programs, a formal semantics tells us what programs will actually do when we run them. The ideas of semantics are of importance for language designers, compiler writers, and programmers; they also provide a basis for mathematical proofs of the correctness of programs.

Several approaches to the definition of formal semantics exist. The most known are:

Denotational semantics;

Operational semantics;

Axiomatic semantics.

I recommend you the book "The Formal Semantics of Programming Languages" by Glynn Winskel. It's a bit outdated, but still relevant and suitable for beginners.

Title: What are the differences between programming languages?

Body:
Once upon a time, I heard from someone

the only difference between programming languages is the syntax

I wanted to deny it - to say that there are other fundamental aspects that truly set a language apart from others than just syntax.

But I couldn't... So, can you?

Whenever I search Google for something like "differences between programming languages", the results tend to be debates between two specific languages (I'd like something more general) - however, some of the aspects that people seemed to debate the most were:

Object-Oriented

Method/Operator overloading (I actually see this rather related to syntax)

Garbage-Collection (While it seems like a good difference, for some reason it doesn't seem that "fundamental")

What important aspects other than syntax can you think of?


答:
If you need only a counter argument to some kind of manager person, tell him that the most important difference between programming languages (besides syntactical differences) are the means of abstraction provided by each language.

That is surely not the whole truth, but easy enough to understand for a lot of people even when they are no formally educated programmers.


答:
When we talk about flags we should know that they are going to get modified over the time of program execution and that they are going to effect the behavior of program based on  their states. As long as we have neat control over these two things, they will work great.

Flags can work great if

You have defined them in an appropriate scope. By appropriate I mean the scope should not contain any code that need-not/should-not modify them. Or at least the code is secure (for example it may not be called directly from outside)

If there is need to handle flags from outside and if there are many flags we can code flag handler as a only way to safely modify flags. This flag handler may itself encapsulate flags and methods to modify them. It can be then made singleton and can be then shared among classes that needs access to flags.

And finally for maintainability, if there are too many flags:

No need to say they should follow sensible naming

Should be documented with what are valid values (may be with enumerations)

Should be documented with WHICH CODE WILL MODIFY each of them, and also with WHICH CONDITION will result in assignment of a particular value to the flag.

WHICH CODE WILL CONSUME them and WHAT BEHAVIOR will result for a particular value

If there are hell lot of flags good design work should precede since flags then start playing key-role in program behavior. You can go for State diagrams for modeling. Such diagrams also work as documentation and visual guidance while dealing with them.

As long as these things are in place I think it will not lead to the mess.

Title: Are flag variables an absolute evil?

Body:
Are flag variables evil? Are the following kind of variables profoundly immoral and is it wicked to use them?

"boolean or integer variables that you assign a value in certain places then down below you check then in orther to do something or not, like, for example using newItem = true then some lines below if (newItem ) then"

I remember doing a couple of projects where I totally neglected using flags and ended up with better architecture/code; however, it is a common practice in other projects I work at, and when code grows and flags are added, IMHO code-spaghetti also grows.

Would you say there are any cases where using flags is a good practice or even necessary?, or would you agree that using flags in code are... red flags and should be avoided/refactored; me, I just get by with doing functions/methods that check for states in real time instead.


答:
Consider whether you can release the rewritten application a piece at a time, and have it in production side by side with the old one.

For web applications in particular, it may be fairly easy to move a single part of the application to a new platform, and have your load balancer route requests to the appropriate system. Then write up the stories that will let you get your first page into production, and deliver those in an agile way.

Desktop applications can be more complicated, but it will often be possible.

You're looking for seams – places where it is possible for the old system to have its responsibilities taken over by the new, without needing a full rewrite.

Perhaps there is some self-contained business logic that can be moved into a new web service or framework, and the old app can be modified use that instead of its old code. Just keep carving off chunks at the seams until what is left is manageable all in one bite.

If you can't find any seams, then you may indeed need to look for the kind of big bang approach suggested in some of the other answers. But be prepared for a long march before you reach your destination, especially if you are expected to keep developing the old system in parallel...


问:
What is the difference in a developer's years of experience with a language?
As stated by the title, what is the difference in years of experience in given language in terms of developers? For example, if one developer has had five years working with language A and the other developer has had two years working with language B followed by three years working with language A, would there be perceivable difference between them?</p>

答:
Yes, Programmer 1 has no syntax knowledge of language B.

Programming concepts are programming concepts. The language is merely syntax.


问:
C++ Building Static Library Project with a Folder Structure
I'm working on some static libraries using visual studio 2012, and after building I copy .lib and .h files to respective directories to match a desired hierarchy such as:

```<code>drive:/libraries/libname/includes/libname/framework

drive:/libraries/libname/includes/libname/utitlies

drive:/libraries/libname/lib/...
</code>```

etc

I'm thinking something similar to the boost folder layout.

I have been doing this manually so far. My library solution contains projects, and when I update and recompile I simply recopy files where they need to be. Is there a simpler way to do this? Perhaps a way to compile the project with certain rules per project as to where the projects .h and .lib files should go?

答:
I would suggest creating a deployment MSBuild file that copies your files to the various destination directories. This will keep all your deployment rules in one place, and allow you to change both source and destination without impacting your other projects.

MSBuild has globbing features that will allow you to group your framework and utility features together and talk about them as a group. Since Visual Studio projects are MSBuild projects, you could probably find a way to include the deployment project in your solution.

Is there a reason you would like to deploy from the IDE? I would suggest you have a stand alone deployment step. Including deployment in the normal compile process can lead to confusion when there are build errors or copy errors. Mismatched versions end up in a library directory and people forget and waste time.


问:
As per IEEE 12207, who has to perform SW integration testing?
As per IEEE 12207, who has to perform Software integration testing (SOIPL): SW Testing team or SW Development team?</p>

答:
The TL;DR; answer is "It depends..."

ISO/IEEE 12207 doesn't specify teams as such, simply the processes to be followed.  Depending on the nature of the activity (and other requirements, eg DO-178, IEC61508) which introduce requirements for independence at the higher levels, then a single person can be responsible for the whole life-cycle.

In simple terms, the Software Integration Process (of which integration testing is a part) builds all the (unit tested) modules into a single executable. The stages of the process will be as follows:

Build manager (or automated process, eg Jenkins) fetches files from Configuration Control tool, and builds the build

Integration tester(s) then test that build

In a small project, the integration tester(s) may well be the same software engineer(s) who wrote the code... if you have separate teams, I suggest that start of the Software Integration Process is probably a good handover point, because thereafter you are testing a full build, probably on target hardware. But that is a local decision to be made.


答:
Agile says we should release early and often, but it doesn't make much sense to release
  before the complete rewrite has been completed.

Actually, IMHO this is the key point - the earlier you get parts of the rewritten application in production (and ideally replacing functionality of the old system), the bigger the chances are that your project will be sucesssful. If you think this does not much sense, think harder about it - there are almost always possibilities to release parts.

It will probably mean someone has to change something in the old application, for example, add some new interfaces to interact with the rewritten application during the time the rewrite is not complete. But to my experience, such additional work always pays for itself.

Once the first parts of the new application is in production, the agile, iterative approach will become obvious. Requirements will change, your user stories will change or get new priorities, and hopefully you will replace more and more functionality of the old system in small steps.


答:
I assumed from the question that the QA was meaning flag (global) variables, and not bits of a function parameter.

There are situations where you don't have much other possibilities. For example, without an operating system you have to evaluate interrupts. If an interrupt comes very frequently and you don't have time to do a lengthy evaluation in the ISR, it is not only allowed but sometimes even best practice to only set some global flags in the ISR (you should spend as little time as possible in the ISR), and to evaluate those flags in your main loop.

Title: Are flag variables an absolute evil?


答: Comments should explain aspects of the code that will not be immediately apparent to a programmer that is familiar with the language.  The facilities provided by the language should then be used to minimise the number of comments that remain necessary.</p>


问:
How to go about designing an intermediate routing filter program to accept input and forward accordingly?
My predicament:

I designed an app, written in Python, to read my mail and check for messages that contain a certain digital signature. It opens these and looks for keywords. If the message contains these keywords, certain related functions area executed on the computer. It is a way I can control my computer from my cell phone without being there. I am still in the beginning stages and it can only currently remotely open and close applications/processes.

The obvious issue is security risks. I hoped to spearhead that by requiring and checking for that digital signature. However, my issue comes when I'd like to make this program usable by multiple users. The idea is that the user will send keywords: username and password, for instance, to log into their personal email account and send messages to it to be parsed.

Please ignore the security implications of sending non-encoded passwords through email. (Though if you could help me on that part I'd much appreciate it as well, but currently, that is not the scope of my question.)

My issue is designing an intermediary process that will take an email/password to read an email and scan for those keywords. The issue is, that the program has to be accessing an email to read the email for the username/password! I have got myself into a loop and cannot figure out how to have this required intermediary program. I could just create an arbitrary email account and have that check for login-creds, but is there a better way of doing this than that?

Also, is there a better way of communicating with a computer remotely than this? Especially if the computer is not a server and is behind a router with only a subnet ip?

If I am asking this question in the wrong place, I deeply apologize. Any help would be much appreciated!

答:
Using emails is one of possible solutions. It seems you need to create a special mail account on some public mail server and make a service(daemon) which will login on server and receive mail messages from server and execute commands which they contain. Good tool for creating such services in Python is twisted, they also have a rather good tutorial for creating SMTP client. For sending commands to your computer you could use your favourite mail client.
Some knowledge of SMTP, POP3 or IMAP protocols is essential.

Another option is to create IRC bot or Jabber bot. In this case you have to study some internals of appropriate protocol(IRC and XMPP) and register some closed room on a public IRC or Jabber server. This bot also could be easy implemented as twisted service, because twisted has a built-in support of these protocols. There are many IRC/Jabber clients, which helps you to send commands to your bot, e.g. Pidgin.


答:
There are open-source licenses that allow you to sell, and there are ways to license your open-source project for non-commercial use. mattnz's question about the competition rules is an important one. The question about who owns the rights to the submitted source code is important. You also need to be aware if there is a specific open-source license the competition requires you to use. Some will make it hard for you to sell that code later.

If this is your first attempt at deploying a commercial product, I advise you to keep it as separate as possible from your open source work. There are many surprises ahead of you in creating and releasing a product on a mobile platform. You don't want extra surprises around your licensing.

I would suggest deciding on a different project for the open source competition. If you can use any open-source license, choose a related project that allows you to develop an underlying library you can use later. License it with something like BSD. That will allow you to make use of your library code later. Be careful though. If you have to use GPL, you may not be able to use that library later on, and you will be better off choosing an unrelated project. Also, if you lose ownership rights to the code, definitely do not submit something you want to build on later.

You can always open-source something at any time. You can't usually undo that.


答:
"it depends"

Experience <> knowledge or understanding.

Programmer 1 could be very good, a guru even, or they could be someone fumbling around with the language for the last 5 years.

Programmer 2 could be someone who understands concepts independently of language they're using. Or someone who found language B too difficult and hopes A is easier.

Coding Horror's "The Years of Experience Myth" is worth reading

Title: What is the difference in a developer's years of experience with a language?

Body: As stated by the title, what is the difference in years of experience in given language in terms of developers? For example, if one developer has had five years working with language A and the other developer has had two years working with language B followed by three years working with language A, would there be perceivable difference between them?</p>


问:
How have Guava unit tests been generated automatically?
Guava has unit test cases automatically generated:

Guava has staggering numbers of unit tests: as of July 2012, the
  guava-tests package includes over 286,000 individual test cases. Most
  of these are automatically generated, not written by hand, but Guava's
  test coverage is extremely thorough, especially for
  com.google.common.collect.

How they were generated? What techniques and technologies were used to design and generate them?

答:
There are unit test generators. For example, in the .NET world, something like Microsoft Pex could do this.

For example, Microsoft Pex tries based on code analysis all possible values as arguments for a method. Some arguments are expected to let the method throw an exception. Such things can automatically tests created for. Static values like an empty string that is returned in certain cases can also be automatically be tested.


问:
JavaScript objects and Crockford's The Good Parts
I've been thinking quite a bit about how to do OOP in JS, especially when it comes to encapsulation and inheritance, recently.

According to Crockford, classical is harmful because of new(), and both prototypal and classical are limited because their use of constructor.prototype means you can't use closures for encapsulation.

Recently, I've considered the following couple of points about encapsulation:

Encapsulation kills performance. It makes you add functions to EACH member object rather than to the prototype, because each object's methods have different closures (each object has different private members).

Encapsulation forces the ugly "var that = this" workaround, to get private helper functions to have access to the instance they're attached to. Either that or make sure you call them with privateFunction.apply(this) everytime.

Are there workarounds for either of two issues I mentioned? if not, do you still consider encapsulation to be worth it?

Sidenote: The functional pattern Crockford describes doesn't even let you add public methods that only touch public members, since it completely forgoes the use of new() and constructor.prototype. Wouldn't a hybrid approach where you use classical inheritance and new(), but also call Super.apply(this, arguments) to initialize private members and privileged methods, be superior?

答:
Encapsulation is really tricky, and probably not worth the effort in JavaScript. A method that works, and does everything you would wish (private fields, access to the superclass and private methods) would be this (probably very ugly and improvable) solution:

```<code>function SomeClass() {

    var parent = SomeSuperClass(),
        somePrivateVar;

    return Object.create(parent, {
        somePrivateVar: {
            get: function() {
                return somePrivateVar;
            },
            set: function(value) {
                somePrivateVar = value;
            }
        },
        doSomething: {
            value: function(data) {
                someHelperFunction.call(this, data);
            }
        }
    });
}

function someHelperFunction(data) {
    this.someMethod(data);
}
</code>```

This sort of works, allows you to have private fields and methods and inheritance as one would expect it. However, I don't like it - but I like it the best of all possibilities you have in pure JavaScript.

If I had to start a new project with a lot of JavaScript, I probably would have a closer look at TypeScript. It improves JavaScript where necessary (IMHO), gives you static typing, inheritance, encapsulation and everything.. But is just JavaScript, after all.

Now, is it worth it? I think there are two important things to consider. Encapsulation probably helps you at development time, but certainly doesn't at runtime. I think you have to decide; Either no encapsulation and better performance, or encapsulation, not-so-beautiful code, probably a better design but some overhead at runtime.

Body:
Encapsulation is really tricky, and probably not worth the effort in JavaScript. A method that works, and does everything you would wish (private fields, access to the superclass and private methods) would be this (probably very ugly and improvable) solution:

function SomeClass() {

    var parent = SomeSuperClass(),
        somePrivateVar;

    return Object.create(parent, {
        somePrivateVar: {
            get: function() {
                return somePrivateVar;
            },
            set: function(value) {
                somePrivateVar = value;
            }
        },
        doSomething: {
            value: function(data) {
                someHelperFunction.call(this, data);
            }
        }
    });
}

function someHelperFunction(data) {
    this.someMethod(data);
}

This sort of works, allows you to have private fields and methods and inheritance as one would expect it. However, I don't like it - but I like it the best of all possibilities you have in pure JavaScript.

If I had to start a new project with a lot of JavaScript, I probably would have a closer look at TypeScript. It improves JavaScript where necessary (IMHO), gives you static typing, inheritance, encapsulation and everything.. But is just JavaScript, after all.

Now, is it worth it? I think there are two important things to consider. Encapsulation probably helps you at development time, but certainly doesn't at runtime. I think you have to decide; Either no encapsulation and better performance, or encapsulation, not-so-beautiful code, probably a better design but some overhead at runtime.


问:
Is there a limit on the number of threads that can be spawned simultaneously?
Yesterday I came across this question: How can i call robocopy within a python script to bulk copy multiple folders?, and I though it might be a good exercise for multithreading.

I though of spawning as many threads as files needed to be copied, each routine having an exception handling system to prevent the whole copying process from crashing (and log -using mutex on the log file - if there was an error).

My question: Is there a limit on the number of thread you can spawn almost simultaneously? If yes, what is the limiting factor?

My question is focused on PC desktop, but I welcome any answer on different hardware (embedded systems, calculus clusters, etc.).

答:
A quick google query revealed this article about limits of processes and threads in Windows. It seems pretty thorough, and there are other articles about pushing the limits in the same series.

I didn't read it, but from what I glanced, on a 32-bit system you will only be able to create a little over 2000 threads, and then you'll run out of memory (or rather, address space, because a 32-bit process has a 2GB address limit). And that's only for empty threads, which don't do anything.

Also, for a copy routine spawning such a huge number of threads would devastate performance. Not only would there be a huge amount of context switching going on, but also the source disk would get thrashed as all the threads tried to read from it at the same time. It might be better for an SSD, but it would still mean a huge IO queue for the system to maintain.

All in all I'm not saying that a file copy operation can't benefit from multithreading, but blindly creating a thread for each file doesn't solve anything. Because in a copy operation it's not the CPU that's the bottleneck - it's the disk (or the network, if you're copying over the network). So any optimization would need to address these problems first.


答:
Of course, the developer who has more years of experience in one language will have a better understanding of the core libraries and idiosyncrasies of that language. If the languages embrace the same paradigm (imperative vs functional) then they should not have any more trouble picking up that language other than learning that.

My greatest difficulty picking up a new language came from trying to switch from C# to Erlang, because it represented not only a new syntax but a new way of thinking about programming as well.


问:
Is comparing an OO compiler to a SQL compiler/optimizer valid?
I'm now doing a lot of SQL development at my new job where as before I was doing Object Oriented desktop app stuff. I keep running across very large scripts (thousands of lines) and wanting to refactor in some way. I am seeing that SQL is a different sort of beast and it's probably fine to have these big scripts for the most part but while explaining this to me people are also insisting that the whole idea of refactoring is bad. That stuff like the .NET compiler are actually burdened by refactored code and that a big wall of code is more efficient and better design than code designed for reuse, readability and scalability.

The other argument is that OO compilers are almost dangerously inefficient and don't have efficient memory management or runs too many CPU instructions compared to older "simpler" compilers and compared to SQL.

Are these valid complaints? Even if some compiler like a C compiler is modestly more "efficient" (whatever that means on this high of a level without seeing code) would you want to write applications in C over C# or Java? Is comparing an OO compiler to a SQL compiler/optimizer even valid?

答:
You say this is your new job? Almost every word they say is utterly wrong.

Running across thousand-line SQL scripts -- This is hardly ever "good"

Refactoring is bad -- That's like getting a few scratches on the paint job of your car and insisting you must buy a new car

Big wall of code is better -- Hardly ever. The biggest thing about refactoring is usually it helps you remove both redundant code and operations(ie, making it faster)

OO compilers are not inefficient. Sure, you can write faster code in C in some cases, but a 1% performance impact isn't going to matter if you can't see that your Algorithm is O(n^2) instead of O(n)

SQL is not a "fast" language. Doing things in SQL other than what it is designed for is a bad idea.

Basically, you write C over C#/Java when you have to. Good cases are when dealing with low-level details(drivers, embedded), or when you really know that you need every bit of speed you can get from a piece of code. Comparing an OO compiler to a SQL compiler doesn't make sense at all. Sure, you can write complex (non-data oriented) algorithms in SQL, but it's going to be slow, have horrible code quality, and generally suck because SQL was NOT designed for this. It was designed to get your data from a set of tables and transfer it to a more competent language.

Why SQL isn't fast:

For one, it's not actually a fair comparison. SQL by itself isn't Turing Complete. I'm assuming you're talking about T-SQL or similar

It enforces heavy structures for simple data types. What do you do if your algorithm needs the equivalent of a hash-table or dictionary? Temporary tables are quite heavy, particularly for older versions of SQL servers

SQL is just designed in a way that certain optimizations can not be done because it's designed for fetching and updating data

Good comparison, SQL Server versus C# for the very simple operation of getting the length of a string: comparison. Also, this is not even a true comparison. This uses the SQL-CLR bridge, which of course has overhead, but you get the point. Using pure SQL is over 30 times slower than calling a C# function from SQL for this operation


问:
Open source library, can the project owner change the license to be more restrictive?
A company releases a library with an open source MIT license.

If they wanted to, could they change the license to be very restrictive so competitors cannot use it?

What impact would this have on previous versions?

Meaning if on Nov. 1st they make it very restrictive to some other license, would all versions prior to Nov 1st be still on MIT?

答:
They can IF they own it.

If they have accepted contributions from other users - then they would need the agreement of those other users. This is the point of GPL, you force other people to play nicely with your code, just as you did with theirs.

Since the license covers distribution the terms you agreed to when they distributed it to you still apply, they can't suddenly revoke an MIT library that has been in use for years.


答:
There are a couple things going on here, so it's back to basics time. As a rule of thumb, when you are implementing you want to make things:

Complete

Correct

Optimized

Optimizing before making things complete or correct will have a negative impact on schedule and, likely, quality. If you are being told to do this without concrete technical reasons and examples, you are dealing with superstition and not science. As for the refactoring issue, refactoring is a tool of optimization - you refactor to optimize. Objecting to that just means the developers have a poor understanding of what refactoring is.

The steps of optimization are:

Profile

Analyze

Optimize

Repeat

Anyone maintaining a large database who is not operating by those rules either is not maintaining a large database in working order, or has inherited a good system that they haven't messed up yet.

It sounds like you have fallen into a culture that is a little superstitious about why they are successful and how the system works. Possibly they have inherited a lot of code and lost the architect? Or there is one 'genius' who keeps everything working through force of will? Anyway, you can't fight religion on a large scale. Pick small things and do what you know is best. Be rigorous, provide data, and be successful. That will win you converts over time. At least, as long as it works, they won't mess with your mojo. ;)

Title: Is comparing an OO compiler to a SQL compiler/optimizer valid?

Body:
I'm now doing a lot of SQL development at my new job where as before I was doing Object Oriented desktop app stuff. I keep running across very large scripts (thousands of lines) and wanting to refactor in some way. I am seeing that SQL is a different sort of beast and it's probably fine to have these big scripts for the most part but while explaining this to me people are also insisting that the whole idea of refactoring is bad. That stuff like the .NET compiler are actually burdened by refactored code and that a big wall of code is more efficient and better design than code designed for reuse, readability and scalability.

The other argument is that OO compilers are almost dangerously inefficient and don't have efficient memory management or runs too many CPU instructions compared to older "simpler" compilers and compared to SQL.

Are these valid complaints? Even if some compiler like a C compiler is modestly more "efficient" (whatever that means on this high of a level without seeing code) would you want to write applications in C over C# or Java? Is comparing an OO compiler to a SQL compiler/optimizer even valid?


问:
Is there a way to add unique items to an array without doing a ton of comparisons?
Please bare with me, I want this to be as language agnostic as possible becuase of the languages I am working with (One of which is a language called PowerOn).  However, most languanges support for loops and arrays.

Say I have the following list in an aray:

```<code>0x  0  Foo
1x  1  Bar
2x  0  Widget
3x  1  Whatsit
4x  0  Foo
5x  1  Bar
</code>```

Anything with a 1 should be uniqely added to another array with the following result:

```<code>0x  1  Bar
1x  1  Whatsit
</code>```

Keep in mind this is a very elementry example.  In reality, I am dealing with 10's of thousands of elements on the old list.  Here is what I have so far.

Pseudo Code:

```<code>For each element in oldlist
 For each element in newlist
  Compare
  If values oldlist.element equals newlist.element, break new list loop
  If reached end of newlist with with nothing equal from oldlist, add value from old list to new list
 End
End
</code>```

Is there a better way of doing this?  Algorithmicly, is there any room for improvement?  And as a bonus qeustion, what is the O notation for this type of algorithm (if there is one)?

答:
Yes, it's called a hash table or map - don't know if your language has them builtin but it's easy to code. This allows you to check if an entry is already there in the same time no matter how big the list (almost).

If you need to preserve the order then you would use a sorted linked-list. Then it's easy to find (by searching) if the entry is new and a linked list lets you insert it without moving all the other entries.


答:
The copyright owner of a work determines what license to use when distributing their own property (code in this case); so the company can decide to switch to a more restrictive license at any time if they so wish.

Note that that does mean they must own all of the work, or have obtained licenses for the code from whomever does own it that grants them the right to re-license the work under a restrictive license.

However, code previously licensed under a permissive license, gives others the right to distribute that code to anyone they wish to. So, old code, once distributed under a permissive license, can be re-distributed under that same license. In theory that means the old code remains available to everyone as Open Source software, provided someone continues to distribute it.

The owner can decide to stop distributing the code under the permissive license, but as the older versions have already been distributed with a permissive license granting the right to re-distribute without restrictions, they cannot prevent others from doing so.

Title: Open source library, can the project owner change the license to be more restrictive?

Body:
A company releases a library with an open source MIT license.

If they wanted to, could they change the license to be very restrictive so competitors cannot use it?

What impact would this have on previous versions?

Meaning if on Nov. 1st they make it very restrictive to some other license, would all versions prior to Nov 1st be still on MIT?


问:
Do people in non-English-speaking countries code in English?
I've heard it said (by coworkers) that everyone "codes in English" regardless of where they're from. I find that difficult to believe, however I wouldn't be surprised if, for most programming languages, the supported character set is relatively narrow.

Have you ever worked in a country where English is not the primary language?

If so, what did their code look like?

答:
I'm from Belarus, but I'm always use English for comments. And as I know a lot of Belarus programmers use English as primary language for coding. </p>

```<code>    /// <summary>
    /// Get item quantity
    /// </summary>
    /// <param name="itemCode">Item code</param>
    /// <param name="grade">Grade</param>
    /// <param name="lpn">LPN</param>
    /// <returns>Returns item quantity</returns>
    private int GetQuantity(string itemCode, string grade, int lpn)
    {
        using (var db = new MappingDataContext(_connection))
        {
            db.ObjectTrackingEnabled = false;
            return (from i in db.INVENTORs
                    where i.ITEM_NO == itemCode
                    where i.CUSTCHAR12 == grade
                    select i.ITEM_NO).Count();
        }
    }
</code>```

Body:
I'm from Belarus, but I'm always use English for comments. And as I know a lot of Belarus programmers use English as primary language for coding.

    /// <summary>
    /// Get item quantity
    /// </summary>
    /// <param name="itemCode">Item code</param>
    /// <param name="grade">Grade</param>
    /// <param name="lpn">LPN</param>
    /// <returns>Returns item quantity</returns>
    private int GetQuantity(string itemCode, string grade, int lpn)
    {
        using (var db = new MappingDataContext(_connection))
        {
            db.ObjectTrackingEnabled = false;
            return (from i in db.INVENTORs
                    where i.ITEM_NO == itemCode
                    where i.CUSTCHAR12 == grade
                    select i.ITEM_NO).Count();
        }
    }


问:
How do you use blank lines in your code?
There has been a few remarks about white space already in discussion about curly braces placements.

I myself tend to sprinkle my code with blank lines in an attempt to segregate things that go together in "logical" groups and hopefully make it easier for the next person to come by to read the code I just produced.

In fact, I would say I structure my code like I write: I make paragraphs, no longer than a few lines (definitely shorter than 10), and try to make each paragraph self-contained.

For example:

in a class, I will group methods that go together, while separating them by a blank line from the next group.

if I need to write a comment I'll usually put a blank line before the comment

in a method, I make one paragraph per step of the process

All in all, I rarely have more than 4/5 lines clustered together, meaning a very sparse code.

I don't consider all this white space a waste because I actually use it to structure the code (as I use the indentation in fact), and therefore I feel it worth the screen estate it takes.

For example:

```<code>for (int i = 0; i < 10; ++i)
{
    if (i % 3 == 0) continue;

    array[i] += 2;
}
</code>```

I consider than the two statements have clear distinct purposes and thus deserve to be separated to make it obvious.

So, how do you actually use (or not) blank lines in code ?

答:
White space is extremely valuable.

Here's the deal... nerds that write complicated code like E=MC2 are great at showing off thier programming skills.

Now let's jump ahead six months, and it's 2:00 AM in the morning and the system that hasn't been looked at in six months has broken on the very line of E=MC2. This is nearly impossible to debug... everyone is freaking out.

Suppose the code looked more like this...

```<code>See Dick
See Jane
See Dick and Jan
</code>```

If it's 2:00 AM and the code is broken. A quick glance will show you that line three should have been

```<code>See Dick and Jane
</code>```

Problem solved.

Bottom Line... use whitespace.

Body:
White space is extremely valuable.

Here's the deal... nerds that write complicated code like E=MC2 are great at showing off thier programming skills.

Now let's jump ahead six months, and it's 2:00 AM in the morning and the system that hasn't been looked at in six months has broken on the very line of E=MC2. This is nearly impossible to debug... everyone is freaking out.

Suppose the code looked more like this...

See Dick
See Jane
See Dick and Jan

If it's 2:00 AM and the code is broken. A quick glance will show you that line three should have been

See Dick and Jane

Problem solved.

Bottom Line... use whitespace.


答:
Do not compare anything to do with the best way to write SQL with what you learned in object-oriented programming. It is a different beast entirely.

In database work we are mainly concerned with the code accomplishing three things:

Preserving data integrity

Database performance

Security of the data

All code should be evaluated based on these three factors above everything else.

Database people are inherently conservative about refactoring becasue it can drastically affect data integrity or cause huge performance slowdowns on production machines if done incorrectly. There are ways to refactor successfully, but a system for it needs to be set up and you have to have buy in from the dbas. I can suggest a book to give you ammunition to help get a refactoring system in place:

http://www.amazon.com/Refactoring-Databases-Evolutionary-Addison-Wesley-ebook/dp/B001QAP36E/ref=sr_1_1?s=digital-text&ie=UTF8&qid=1351782765&sr=1-1&keywords=refactoring+databases


问:
Solutions for Project management

The team consists of 3 people.

The method of development is Scrum.

The language of the project is C++.

The project will be under the control of the git system.

The start up budget is 0.

The following things have to be chosen:

Build and Version Numbering

Project documentation ( file with the most common info for current stage of the project, which will be changed every time the new version or subversion of the project emerges )

Project management tool ( like Trac or Redmine, I cannot use them, because there is no hosting )

Code documentation ( I consider Doxygen )

The following questions have arisen:

What can you add to the above list of the main solutions for project management in the described project?

One of three project participants has linux os (No MS Office), one has Windows and MS Office (does not want to use Libre or Open Office), one has Windows, but does not have MS Office. What formats, tools can u suggest using for project documentation? The variant of using online wiki does not fit, it must be files.

OneNote mb is a good tool for project management, but because of the reason mentioned above it is not possible. What can you advise?

Offer a system for Build and Version Numbering.

答: Rally for the project management, Tiddlywiki for the documentation and not Doxygen which I find tends to be write-only. Perforce is good for source control but you have already chosen git.</p>

Title: Solutions for Project management


问:
Suggestions for connecting .NET WPF GUI with Java SE Server
BACKGROUND

We are building a Java (SE) trading application which will be monitoring market data and sending trade messages based on the market data, and also on user defined configuration parameters.

We are planning to provide the user with a thin client, built in .NET (WPF) for managing the parameters, controlling the server behavior, and viewing the current state of the trading. The client doesn't need real-time updates; it will instead update the view once every few seconds (or whatever interval is configured by the user).

The client has about 6 different operations it needs to perform with the server, for example:

CRUD with configuration parameters

query subset of the data

receive updates of current positions from server

It is possible that most of the different operations (except for receiving data) are just different flavors of managing the configuration parameters, but it's too early in our analysis for us to be sure.

To connect the client with the server, we have been considering using:

SOAP Web Service

RESTful service

building a custom TCP/IP based API (text or xml) (least preferred - but we use this approach with other applications we have)

As best as I understand, pros and cons of the different web service flavors are:

SOAP

pro: totally automated in .NET (and Java), modifying server side interface require no code changes in communication layer, just running refresh on Web Service reference to regenerate the classes.

con: more overhead in the communication layer sending more text, etc. We're not using J2EE container so maybe doesn't work so well with J2SE

REST

pro: lighter weight, less data. Has good .NET and Java support. (I don't have any real experience with this, so don't know what other benefits it has.)

con: client will not be automatically aware if there are any new operations or properties added (?), so communication layer needs to be updated by developer if server interface changes.

con: (both approaches) Server cannot really push updates to the client at regular intervals (?)  (However, we won't mind if client polls the server to get updates.)

QUESTION

What are your opinions on the above options or suggestions for other ways to connect the 2 parts?  (Ideally, we don't want to put much work into the communication layer, because it's not the significant part of the application so the more off-the-shelf and automated the better.)

答:
I compared REST + JSON for interchanging data between .NET client and Java server against traditional SOAP client/server approach.  In all both cases, the Java server app is running as a standalone process, and not inside J2EE container.

For .NET client, I tested RestSharp to send the REST requests and handle responses.  I found RestSharp to be elegant, easy, and light-weight solution.  On the Java server side, I tested Restlet, which was also fairly easy to set up, and also tested Gson for serializing and deserializing objects.  After a bunch of fumbling around with Restlet, I was able to test serializing .NET objects to JSON and receiving with Java server. (I found Restlet's documentation and object model to be confusing, especially in comparison with RestSharp.  This is also why I ended up using Gson for serializing/deserializing).

The significant disadvantage I found (but not the only one), is that the Gson deserialization is case-sensitive (as I imagine probably most if not all the Json libraries are), and there was a mismatch between the casing on the .NET side and the Java side.  (As an aside, I think whoever decided that variable/property names should be case-sensitive introduced a lot of unnecessary complexity into interoperability. It would be a lot better if all text matching was case-insensitive by default, but globally configurable turn on case-sensitivity.  I think that would be far more useful.)

I then compared this with SOAP WS, using VS 2010 to generate the proxy classes, and jSoapServer to run on the Java side.  It was up and running with a bunch of operations in minutes (only 1 minor glitch to get prototypes to work).

I have to say that, for simplicity with this tool set (VS 2010 and Eclipse) and set of components (.NET WPF and Java), the SOAP Web Service wins hands down.  It is so much easier to manage the coupling between server and client with the WSDL and .NET web service client generation, than it was with JSON (and REST).  While I can see the huge benefits of JSON + REST for Ajax and web apps (where you don't have the SOAP framework easily built in), for a rapid development mode, SOAP was the way to go in this case.

UPDATE

Someone on StackOverflow pointed me to a Gson setting to specify the field naming policy.  This resolved the problem between differences between the client and server casing of names. However, it still seems that SOAP offers faster development of new methods and updates to objects between GUI and server (though I may revise opinion in future).

UPDATE

In the end, I selected Apache CXF, which is working awesomely well.  Setting up the service in Java was a breeze, and Visual Studio generated all the service classes and web service client without any hitches. Any changes to server interface are very easily propagated to the GUI by having VS update the Service Reference. This turned out to be the appropriate RAD solution for us, given our toolset.


问:
Ways of Gathering Event Information From the Internet
What are the best ways of gathering information on events (any type) from the internet ?

Keeping in mind that different websites will present information in different ways.

I was thinking 'smart' web crawlers, but that can turn out to be extremely challenging, simply because of the hugely varied ways that different sites present their information.

Then I was thinking of sifting through the official twitter feeds of organisations, people with knowledge of events .. etc and look for the event hash tag, grab the tweet and dissect it to grab the relevant information about the event.

Information I am interested in gathering is: Date and Time of Event, Address where Event is being held, and any Celebrities (or any famous people) attending the event (if any).

The reason to ask here is my hope that experienced folk will open my eyes to things I've missed, which I am sure I have.

答:
I would approach this as a program that would screen scrape certain sites. So if your looking for celebrities then you would want to find some site to use as a source and then start with their home page and download the HTML. Then you would have to teach your program to parse out the HTML to pull down only the information you want.

You will also want to look for URLs as most sites will have both internal and exteranal links. This will probably be the hardest part to filter out as you will not know what is on the other end of that URL until your program gets there.

The basic concept of this is a web crawler and believe me you will need to have a way to either throttle back the application or have a very beefy server to handle the information flow. It has been several years at least since I have written a crawler and I was actually after very specific information on a very specific site.