答:
"2. Go with it"

This is the only reasonable answer.  You have a great opportunity here.

Use the senior programmer's comments to encourage your company to pay for time and/or a course and/or certification to learn the new language. Worst case scenario: the certification and the language will both improve your resume, you may get a good recommendation for being a team player, and you can laugh all the way to a better job somewhere else.

I have gained valuable insights about programming from every language I learned. Even the least practical language (cough XSLT cough) had its sweet spot and was chock full of interesting learning opportunities (and paid my bills for several years).  Constant learning is one of the great benefits of being a programmer.

All the cool projects probably use the senior developer's favorite language. Knowing that language puts you in the pool of talent who can work on those projects.

Someone is presumably paying you to do certain work a certain way.  Any other response is probably insubordination and is likely to end badly.

The senior developer/architect normally chooses the primary language used at a shop and ensures that everyone uses that language.  This way, a company builds a knowledge base in certain technologies so that one employee (you) can take vacation and someone else can pick up your code and fix it while you're gone. Also the company can bring in relevant training talent and the HR department will know which buzzwords to look for on resumes.

By learning his language and using it for work, you accumulate the political capital you need to effectively advocate for your favorite language.  Many companies have an official infrastructure language and an official scripting language for reports.  Prepare a pros and cons list showing where his language excels and where yours does, also where each falls short. You need to keep this list in the context of a specific application, such as the reports you are writing. Plan a time with him to privately and respectfully show him the list and discuss it with him. Write down his objections, research them after the meeting, and if you have good counter-arguments, plan a follow-up meeting.

Good luck!

Title: Dealing with Fanboys


问:
When to use abstract classes instead of interfaces with extension methods in C#?
"Abstract class" and "interface" are similar concepts, with interface being the more abstract of the two. One differentiating factor is that abstract classes provide method implementations for derived classes when needed. In C#, however, this differentiating factor has been reduced by the recent introduction of extension methods, which enable implementations to be provided for interface methods. Another differentiating factor is that a class can inherit only one abstract class (i.e., there is no multiple inheritance), but it can implement multiple interfaces. This makes interfaces less restrictive and more flexible. So, in C#, when should we use abstract classes instead of interfaces with extension methods?

A notable example of the interface + extension method model is LINQ, where query functionality is provided for any type that implements IEnumerable via a multitude of extension methods.

答:
IMHO, I think that there is a mixing of concepts here.

Classes use a certain kind of inheritance, while interfaces use a different kind of inheritance.

Both kinds of inheritance are important and useful, and each one has its pros and cons.

Let's start at the beginning.

The story with interfaces starts a long while back with C++. In the mid-1980s, when C++ was developed, the idea of interfaces as a different kind of type was not yet realized (it would come in time).

C++ only had one kind of inheritance, the kind of inheritance used by classes, called implementation inheritance.

To be able to apply the GoF Book recommendation: "To program for the interface, and not for the implementation", C++ supported abstract classes and multiple implementation inheritance to be able to do what interfaces in C# are capable (and useful!) of doing.

C# introduces a new kind of type, interfaces, and a new kind of inheritance, interface inheritance, to offer at least two different ways to support "To program for the interface, and not for the implementation", with one important caveat: C# only supports multiple inheritance with interface inheritance (and not with implementation inheritance).

So, the architectural reasons behind interfaces in C# is the GoF recommendation.

I hope this can be of help.

Kind regards, Gastón

ContentLicense: CC BY-SA 3.0


问:
Why does java.util.ArrayList allow to add null?
I wonder why java.util.ArrayList allows to add null.  Is there any case where I would want to add null to an ArrayList?

I am asking this question because in a project we had a bug where some code was adding null to the ArrayList and it was hard to spot where the bug was. Obviously a NullPointerException was thrown but not until other code tried to access the element. The problem was how to locate the code that added the null object. It would have been easier if ArrayList threw an exception in the code where the elements was being added.

答:
It is easier to accept everything, than to be to be restrictive and then try opening up your design after the fact.

For example, what if they oracle/sun provided only NonNullableArrayList, but you wanted to be able to add a Null to your list.  How would you do it?  You would probably have to create an entirely different object, you couldn't use extend the NonNullableArrayList.  Instead if you have a ArrayList that takes everything, you could easily extend it, and override the add, where it doesn't accept null values.


问:
How to use DI and DI containers
I am building a small PHP mvc framework (yes, yet another one), mostly for learning purposes, and I am trying to do it the right way, so I'd like to use a DI container, but I am not asking which one to use but rather how to use one.

Without going into too much detail, the mvc is divided into modules which have controllers which render views for actions. This is how a request is processed:

a Main object instantiates a Request object, and a Router, and injects the Request into the Router to figure out which module was called.

then it instantiates the Module object and sends the Request to that

the Module creates a ModuleRouter and sends the Request to figure out the controller and action

it then creates the Controller and the ViewRenderer, and injects the ViewRenderer into the Controller (so that the controller can send data to the view)

the ViewRenderer needs to know which module, controller and action were called to figure out the path to the view scripts, so the Module has to figure out this and inject it to the ViewRenderer

the Module then calls the action method on the controller and calls the render method on the ViewRenderer

For now, I do not have any DI container set up, but what I do have are a bunch of initX() methods that create the required component if it is not already there.
For instance, the Module has the initViewRenderer() method.
These init methods get called right before that component is needed, not before, and if the component was already set it will not initialize it. This allows for the components to be switched, but it does not require manually setting them if they are not there.

Now, I'd like to do this by implementing a DI container, but still keep the manual configuration to a bare minimum, so if the directory structure and naming convention is followed, everything should work, without even touching the config.

If I use the DI container, do I then inject it into everything (the container would inject itself when creating a component), so that other components can use it?
When do I register components with the DI?
Can a component register other components with the DI during run-time?
Do I create a 'common' config and use that?
How do I then figure out on the fly which components I need and how they need to be set up?

If Main uses Router which uses Request,
Main then needs to use the container to get Module (or does the module need to be found and set beforehand? How?)
Module uses Router but needs to figure out the settings for the ViewRenderer and the Controller on the fly, not in advance, so my DI container can't be setting those on the Module before the module figures out the controller and action...

What if the controller needs some other service? Do I inject the container into every controller? If I start doing that, I might just inject it into everything...

Basically I am looking for the best practices when dealing with stuff like this. I know what DI is and what DI containers do, but I am looking for guidance to using them in real life, and not some isolated examples on the net.

Sorry for the lengthy post and many thanks in advance.

EDIT: after reading a bit more, it seems that injection the container itself into objects and making them use the container to find stuff is actually service location, not dependency injection. So my latest idea is to use factories for the stuff that should be dynamically acquired based on something (like getting controllers based on what the router says), and the container would be injected into the factories where it would be used more like a service locator. The non dynamic components would be registered beforehand, and those components would be built by the container and returned fully operational, with all their dependencies filled.

So the flow would look like this:

get Main from the container, Main is injected with Request, Router and ModuleFactory which uses the container to find modules. This is all pre-configured

Main uses ModuleFactory to create the Module, injected with ModuleRouter, Request, ControllerFactory and ViewRenderer.

Module uses ControllerFactory to create a Controller, injected with any service that it depends on, and then the Module calls the action on the controller, and sends the result to the ViewRenderer to render the view.

Am I getting anywhere with this?

答:
As there is no right or wrong in this question, I could give an example about how I like to use Dependency Injection in PHP.

I'm using the Dependency Injection Component from Symfony with the LosoDiAnnotationsBundle and extracted everything from the Bundle to use it as standalone as the Dependency Injection Component. I'm not using the rest of the Symfony Framework.

There are two functions in my system which use the Dependency Injection Container. The main function and the dispatcher. The main function (application entry point) retrieves the configured Dispatcher like this:

```<code>$dispatcher = $service_container->get('Dispatcher');
$response = $dispatcher->route( $request );
</code>```

The service called "Dispatcher" is either defined in the global dependency config or annotated in the class itself like this:

```<code> /*
 * @Service
 */
 class Dispatcher {
    /**
     * @Inject({"@service_container"})
     */
    public function __construct($serviceContainer) {
        $this->serviceContainer  = $serviceContainer;
    }
 }
</code>```

The Dispatcher needs this service locator because thats how my routing works. If you use some extra mapping between routes and called methods, you could avoid this.

To inject something into other services I use the @inject annotation:

```<code>/** @Inject({"@SomeLogic", "@SomeGateway"}) */
public function setDependencies(SomeLogic $someLogic, SomeGateway $someGateway) {
    $this->someLogic = $someLogic;
    $this->someGateway = $someGateway;
}
</code>```

I like this approach because the configuration of a Service Class is done in the class itself and not in a separate file. Refactoring doesn't involve messing around with lengthy XML or YAML files.

To not harm the performance I run a script everytime I change some annotations and at build time (or in general on every vagrant up). It uses Symfony's ContainerBuilder and PHP Dumper to generate a PHP Lookup file which extends the Base ServiceContainer Class.

The lookup for the example dispatcher would look like this:

```<code>protected function getDispatcherService()
{
    return $this->services['dispatcher'] = new \Some\Dispatcher($this);
}
</code>```

This looks like a lot of work upfront, but it clearly separates concerns later on, especially in bigger projects. Classes do what they are supposed to do and need little to no non-domain-logic code at all.

And I try to keep factories to an absolutely minimum. The DI Container itself is one big factory and repository but it is not manually maintained.

EDIT:

My Routing Function looks like this, request_uri is something like Controller/action/...

```<code>    $path = explode( self::ACTION_SEPARATOR, $request_uri );

    if( empty( $path[1] ))
        throw new RoutingException( 'Invalid Action' );

    $method = ucfirst( $path[1] );
    $className = $path[0].'Controller';
    $qualifiedClassName = 'Some\\Namespace\\'.$className;

    if( !class_exists( $qualifiedClassName ))
        throw new RoutingException(sprintf('Invalid controller "%s" for route "%s"', $qualifiedClassName, $route));
    if( !is_callable( array( $qualifiedClassName, $method ) ))
        throw new RoutingException(sprintf('Invalid Action "%s"', $method));

    $controller = $this->serviceContainer->get( $className );
    call_user_func( array( $controller, $method ), $message );
</code>```

Title: How to use DI and DI containers

Body:
As there is no right or wrong in this question, I could give an example about how I like to use Dependency Injection in PHP.

I'm using the Dependency Injection Component from Symfony with the LosoDiAnnotationsBundle and extracted everything from the Bundle to use it as standalone as the Dependency Injection Component. I'm not using the rest of the Symfony Framework.

There are two functions in my system which use the Dependency Injection Container. The main function and the dispatcher. The main function (application entry point) retrieves the configured Dispatcher like this:

$dispatcher = $service_container->get('Dispatcher');
$response = $dispatcher->route( $request );

The service called "Dispatcher" is either defined in the global dependency config or annotated in the class itself like this:

 /*
 * @Service
 */
 class Dispatcher {
    /**
     * @Inject({"@service_container"})
     */
    public function __construct($serviceContainer) {
        $this->serviceContainer  = $serviceContainer;
    }
 }

The Dispatcher needs this service locator because thats how my routing works. If you use some extra mapping between routes and called methods, you could avoid this.

To inject something into other services I use the @inject annotation:

/** @Inject({"@SomeLogic", "@SomeGateway"}) */
public function setDependencies(SomeLogic $someLogic, SomeGateway $someGateway) {
    $this->someLogic = $someLogic;
    $this->someGateway = $someGateway;
}

I like this approach because the configuration of a Service Class is done in the class itself and not in a separate file. Refactoring doesn't involve messing around with lengthy XML or YAML files.

To not harm the performance I run a script everytime I change some annotations and at build time (or in general on every vagrant up). It uses Symfony's ContainerBuilder and PHP Dumper to generate a PHP Lookup file which extends the Base ServiceContainer Class.

The lookup for the example dispatcher would look like this:

protected function getDispatcherService()
{
    return $this->services['dispatcher'] = new \Some\Dispatcher($this);
}

This looks like a lot of work upfront, but it clearly separates concerns later on, especially in bigger projects. Classes do what they are supposed to do and need little to no non-domain-logic code at all.

And I try to keep factories to an absolutely minimum. The DI Container itself is one big factory and repository but it is not manually maintained.

EDIT:

My Routing Function looks like this, request_uri is something like Controller/action/...

    $path = explode( self::ACTION_SEPARATOR, $request_uri );

    if( empty( $path[1] ))
        throw new RoutingException( 'Invalid Action' );

    $method = ucfirst( $path[1] );
    $className = $path[0].'Controller';
    $qualifiedClassName = 'Some\\Namespace\\'.$className;

    if( !class_exists( $qualifiedClassName ))
        throw new RoutingException(sprintf('Invalid controller "%s" for route "%s"', $qualifiedClassName, $route));
    if( !is_callable( array( $qualifiedClassName, $method ) ))
        throw new RoutingException(sprintf('Invalid Action "%s"', $method));

    $controller = $this->serviceContainer->get( $className );
    call_user_func( array( $controller, $method ), $message );

ContentLicense: CC BY-SA 4.0


答:
Is there any case where I would want to add null to an ArrayList?

Sure, what about pre-allocation? You want an ArrayList of things you can't create yet because you don't have enough info. Just because you can't think of a reason why someone may want to do something doesn't make it a bad idea. Whatever. (Now, I'm sure someone will come along and say you should instead have empty objects that fulfill some pattern they read about on some obscure blog and that programmers should really be able to write programs without ever using if statements, blah blah.)

If you guys have a contract that there never should be nulls in a container then it's up to you lot to make sure that contract is upheld, probably most appropriately by asserting. It would probably have taken you max 10 lines of code. Java makes it incredibly easy for you to do this sort of thing. The JDK cannot read your mind.

Title: Why does java.util.ArrayList allow to add null?

Body:
I wonder why java.util.ArrayList allows to add null.  Is there any case where I would want to add null to an ArrayList?

I am asking this question because in a project we had a bug where some code was adding null to the ArrayList and it was hard to spot where the bug was. Obviously a NullPointerException was thrown but not until other code tried to access the element. The problem was how to locate the code that added the null object. It would have been easier if ArrayList threw an exception in the code where the elements was being added.


问:
Grading an algorithm: Readability vs. Compactness
Consider the following exam / interview question:

Implement the strcpy() function in C: void strcpy(char *destination, char *source);

The strcpy function copies the C string pointed by source into the array pointed by destination, including the terminating null character. Assume that the size of the array pointed by destination is long enough to contain the same C string as source, and does not overlap in memory with source.

Say you were the interviewer \ examiner, how would you grade the following answers to this question?

1)

```<code>void strcpy(char *destination, char *source)
{
  while (*source != '\0')
    {
      *destination = *source;
       source++;
       destination++;
    }
    *destination = *source;
}
</code>```

2)

```<code>void strcpy(char *destination, char *source)
    {
       while (*(destination++) = *(source++)) ;
    }
</code>```

The first implementation is straightforward - it is readable and programmer-friendly.

The second implementation is shorter (one line of code) but less programmer-friendly; it's not so easy to understand the way this code is working, and if you're not familiar with the priorities in this code then it's a problem.

I'm wondering if the first answer would show more complexity and more advanced thinking, in the interviewer's \ examiner's eyes, even though both algorithms behave the same, and although code readability is considered to be more important than code compactness.
It seems to me that since making an algorithm this compact is more difficult to implement, it will show a higher level of thinking as an answer in an exam. However, it is also possible that an interviewer \ examiner would consider the second answer not good because it's not readable.

I would also like to mention that this is not specific to this example, but general for code readability vs. compactness when implementing an algorithm, specifically in exams \ interviews.

答:
The first implementation is straightforward - it is readable and
  programmer-friendly.

The second implementation is shorter (one line of code) but less
  programmer-friendly; it's not so easy to understand the way this code
  is working, and if you're not familiar with the priorities in this
  code then it's a problem.

You have your answer there.

When interviewers look at your code, they will also see your coding style. Readability is important for production code, so try to show them you can write such code.

For an exam you should aim for understandability as well, so your code is not wrongfully determined to be faulty.


问:
Are there any OS which are simple enough for learning?
I would really like to understand how an operating  system works behind the scenes. However, I think that the kernel of most open-source OSs out there are too complex for learning purposes, even for a full-time programmer to learn. Are there any "simple" OSs made for learning purposes only out there?</p>

答: People can understand all of CP/M and early DOS versions. After that things got out of control and nobody knows everything anymore. They weren't designed for learning how an OS works but many people did learn that from those OS.


问:
Port numbers in Visual Studio projects and IIS
I have a few questions about localhost and port numbers as this is an area where I do not have a lot of knowledge, and because I recently had to work with setting up Visual Studio projects and IIS and there are things I'm not clear on.

I have the following questions on the things I find confusing. I thought it made more sense to include them all in one question instead of making separate questions.

I have noticed a random port number is generated with projects I have worked on in the past, but I recently saw a project where the port number was fixed. What is the purpose of having a fixed/default localhost port number? i.e is it particularly useful on projects that have many programmers working on the project?

If a solution contains multiple projects (for example, WCF services, Domain, MVC/Web pages), is it possible to setup a different localhost port for each of them? If so, what is the benefit of this?

If a solution contains multiple projects and has different localhost urls/port numbers, must there be a corresponding website (and application pool) for each project in IIS? Or just for the project that contains the actual web pages?

答:
The usual pattern is IIS generates a random port number but once generated said port number is fixed. The main advantage is when you've got parts of a project that communicate. For example, if you are building a WPF front-end to a web service you'd need to know where the web service is. And it is very convenient for it to live in a fixed place development-wise, especially when other developers enter the fray.

The default behavior is a different port per project. In fact, depending on local setups, making them all use the same port can be difficult if not impossible.

Not necessarily. Visual Studio 2008 and 2010 ship with something called Cassini, a self-hosted development web server. This is the default server which spins up. In 2010 Microsoft released IIS Express which is a much better option -- it is a full blown local version of IIS which means it behaves almost exactly like your production environment. IIS express does have app pools, but they are all running in the context of the logged in user not as APPLICATION POOL IDENTITY. Developers generally need not worry about managing their app pools.


问:
What is the point of having every service class have an interface?
At the company I work at, every service class has a corresponding interface.

Is this necessary?

Notes:

Most of these interfaces are only used by a single class

We are not creating any sort of public API

With modern mocking libraries able to mock concrete classes and IDEs able to extract an interface from a class with two or so clicks, is this just a holdover from earlier times?

答:
Here is how Adam Bien think about this question: Service s = new ServiceImpl() - Why You Are Doing That?

That is not only bloat (and the opposite of "Convention Over Configuration" idea), but it causes real damage:

Imagine you get another implementation (thats the whole point of an interface) - how would you name it?

It doubles the amount of artifacts - and significantly increases the "complexity"

It is really funny to read the javadocs on the interface and the impl - another redundancy

The navigation in the IDE is less fluent

and I agree with him.

Maybe your co-workers are still stuck in time with J2EE, because this was necessary when working with J2EE, maybe you can find on the internet old tutorials about hard times in J2EE.


问:
In centralized version control, is it always good to update often?
Assuming that:

Your team is using centralized version control.

You are working on a larger feature which will take several days to complete, and you won't be able to commit before that because it would break the build.

Your team members commit something every day that might change some of files you're working on.

Since this is centralized version control,
you will have to update your local checkout at some point:
at least once right before committing the new feature.

If you update only once right before your commit, then there might be a lot of conflicts due to the many other changes by your teammates, which could be a world of pain to resolve all at once.

Or, you could update often, and even if there are a few conflicts to resolve day by day, it should be easier to do, little by little.

Would you stay it's always a good idea to update often?

答:
Personally, I update my local versions daily.

In the scenario you describe, I would go the extra mile by

Creating a branch for the new, lengthy feature.

Merge often from the mainline to this new branch.

This way,

You can check-in daily to preserve your code on the server

You don't have to worry about breaking the build by checking-in.

You can use the repository to undo some work or diff when necessary with earlier check-ins.

You are certain to be working on the latest codebase and detect possible conflicting code changes early on.

The drawbacks as I see them are

Merging from main has to be done manually (or scripted)

It takes more "administration"


答:
If you are adding a new feature, could you create a new single source file (and a matching external interface header file)?

I am concerned that a "new feature" is having widespread implications?  Object orientation may no longer be the buzzword it once was, but there is merit in that paradigm.

That way you could create the framework (external interface, plus stub functions) and commit that then there should be minimal third party effects, whilst you finish the rest of your development?

In the situation you describe I feel it is better to have more smaller source files than fewer, bigger files.

Title: In centralized version control, is it always good to update often?

Body:
Assuming that:

Your team is using centralized version control.

You are working on a larger feature which will take several days to complete, and you won't be able to commit before that because it would break the build.

Your team members commit something every day that might change some of files you're working on.

Since this is centralized version control,
you will have to update your local checkout at some point:
at least once right before committing the new feature.

If you update only once right before your commit, then there might be a lot of conflicts due to the many other changes by your teammates, which could be a world of pain to resolve all at once.

Or, you could update often, and even if there are a few conflicts to resolve day by day, it should be easier to do, little by little.

Would you stay it's always a good idea to update often?


问:
Can I use my company name instead of using ofbiz logo and name
Sorry this is not a programming questions. My company is looking to do some work on ofbiz. I read the license of apache and I am not sure if its legal to change the logo to our company logo.

http://www.apache.org/foundation/license-faq.html#WhatDoesItMEAN

答:
first paragraph = IANAL.disclaimer()

Apache has a page devoted to how to do branding with Apache.


答:
Why can't you give both answers?

I once had someone tell me I had the wrong answer in an interview and deny me the job because of it, even though my procedure worked.  He wanted the quick way instead of the readable way (it was a game company).  He explained his clever shortcut, but it was still a big disappointment for me.  I sulked around feeling cheated for a couple weeks before looking up and trying out his solution.  It turned out to have a serious bug that would have prevented it from working!

In hindsight, I should have continued working on the problem immediately after leaving the interview (or at least the next day when I cooled off).  That way I could have contacted him and continued the discussion about the problem, maybe emailed him a test case to demonstrate where his preferred solution failed, and suggested a correction that solved the problem closer to his way, but without the bug.

Most of the candidates I've asked questions of in interviews have gotten them wrong.  I finally gave up and just asked candidates to describe a recent project they felt excited about.  That's probably a better interview question any way.  Because it's open-ended, you get a feel for someone's style and perspective as well as their knowledge and ability.  If anyone had ever given me two correct answers to a question and discussed the relative strengths and weaknesses, I think I would have passed out.  Someone like that would have to be a convicted serial killer AND a sex offender to not get the job!  Maybe I wasn't hiring from the best talent pool, but there you have it.

Title: Grading an algorithm: Readability vs. Compactness

Body:
Consider the following exam / interview question:

Implement the strcpy() function in C: void strcpy(char *destination, char *source);

The strcpy function copies the C string pointed by source into the array pointed by destination, including the terminating null character. Assume that the size of the array pointed by destination is long enough to contain the same C string as source, and does not overlap in memory with source.

Say you were the interviewer \ examiner, how would you grade the following answers to this question?

1)

```<code>void strcpy(char *destination, char *source)
{
  while (*source != '\0')
    {
      *destination = *source;
       source++;
       destination++;
    }
    *destination = *source;
}
</code>```

2)

```<code>void strcpy(char *destination, char *source)
    {
       while (*(destination++) = *(source++)) ;
    }
</code>```

The first implementation is straightforward - it is readable and programmer-friendly.

The second implementation is shorter (one line of code) but less programmer-friendly; it's not so easy to understand the way this code is working, and if you're not familiar with the priorities in this code then it's a problem.

I'm wondering if the first answer would show more complexity and more advanced thinking, in the interviewer's \ examiner's eyes, even though both algorithms behave the same, and although code readability is considered to be more important than code compactness.
It seems to me that since making an algorithm this compact is more difficult to implement, it will show a higher level of thinking as an answer in an exam. However, it is also possible that an interviewer \ examiner would consider the second answer not good because it's not readable.

I would also like to mention that this is not specific to this example, but general for code readability vs. compactness when implementing an algorithm, specifically in exams \ interviews.


答:
How is it different for a centralised version control than for a distributed one?

In both case you'll have to check in in a place whose content will have moved compared to what you have started. I don't see any difference in the frequency of merge from the central repository to you working place (and your project branch is your working place).

I tend to be for the merge often way (at least once a day, I may also merge at some other convenient time for me, or when I know someone has checked in something which impact what I'm working on). It's far easier to absorb small changes and if you have a problem, people are more helpful when you ask them about what they have just checked in than about what they have checked in one week ago.

BTW, I don't know what you call "break the build". I tend to work in relatively small increment, so that I keep a compilable state, even if it breaks some features. And I run the tests so that I know that the merge hasn't broken something which should have work. Again, it is easier to fix a problem when it is detected early.


问:
Severity and relation to occurence - priority?
I have been browsing through some webpages related to testing and found one dealing with the metrics of testing. It says:

The severity level of a defect indicates the potential business impact
  for the end user (business impact = effect on the end user x frequency
  of occurrence).

I do not think think this is correct or what am I missing? Usually it is the priority which is the result of such a calculation (severe bug that occurs rarely is still severe but does not have to be fixed immediately).
Also from this description, what is the difference between the effect on the end user and business impact?

答: That document doesn't seem to mention priority anywhere.  I assume they're just assigning a severity level to each defect.  It should be understood that a higher severity leads to higher priority.  Since the document is only considering defects I think that's appropriate.  You might have other new features that are higher priority, but those can be considered separate from defects.


问:
C: What is a good source to teach standard/basic code conventions to someone newly learning the language?
I'm tutoring someone who can be described as a rank newcomer in C. Understandably, she does not know much about coding conventions generally practiced, and hence all her programs tend to use single letter vars, mismatched spacing/indentation and the like, making it very difficult to read/debug her endeavors.

My question is, is there a link/set of guidelines  and examples which she can use for adopting basic code conventions ? It should not be too arcane as to scare her off, yet inclusive enough to have the basics covered (so that no one woulc wince looking at the code).

Any suggestions ?

答:
When learning anything, I think a wide variety of activities and paradigms are needed.  You will soon get past the indentation and formatting issues, and can embark on a deeper level of training that will be more interesting to both of you.

I think it is cool sometimes to borrow from other areas of endeavor (like sports or classical music) where the kind of coaching and mentoring you describe are extremely common, as opposed to our own field where it is either one extreme or the other (self-taught vs. taught to the syllabus/tests as sometimes happens at universities).

Kindergartens and public elementary school education was designed with the idea that several subjects need to be taught: reading, writing, penmanship, history, math, civics, physical education.  As your mentoring progresses, to play with the analogy a little, I think you need a portfolio of topics that goes beyond programming languages (writing) and coding standards / coding conventions (penmanship).  Many kids burn out on music in a hurry because playing scales and goofy little exercises don't click with them.

A very famous music teacher, Dorthy Delay had hundreds or thousands of students, including some of the most famous musicians in the world, during her long career at Julliard.  She had a program for her students that included five hours per day of individual practice.  Added onto class work and performing with ensembles (think working in teams), she required a heavy workload.  And so should you.

The following chart summarizes what she recommended / required:

http://gallagherclarinets.blogspot.com/2012/01/dorothy-delays-practice-mindmap.html

Having had some musical training when I was younger, I'll try to translate the analogy.

Exercises - API Tutorials: Find a programming feature you haven't done and learn to do it.  Another parallel might be scripting and writing small programs to increase fluency in a programming language.

Scales - Refactoring: Take a piece of code and smooth it out to eliminate code smells.  Scales are considered important because they help musicians focus on playing in tune and on moving their fingers efficiently so they can play faster.  Perhaps this could also correspond to use of valgrind, lint, static and dynamic analysis tools that look very closely at the per statement / per function aspects of programs.

Studies - Like exercises, but bigger scope.  Maybe learn a new tool or framework.

Pieces - Applications.  Pieces are like concertos or sonatas, they are what gets delivered to audiences / customers and required iterative / incremental improvements that may span years of work.

Other - These are not obscure references to particular lesson books or composers.  Playing for fun / coding for fun line up.  So does listening to music / reading other people's code.  Mental rehearsal refers to running through a memorized musical piece in your head.  For developers this role might be taken my thinking about an app, note taking or sketching on paper or a white board separate from the work of coding or documenting formally.

If we take the musician analogy further, try to make opportunities for your protege to pair program with you and others, and to work in small, medium, and large teams, particularly those that perform frequently.


问:
How safe is it to rely on thirdparty Python libs in a production product?
I'm new to Python and come from the write-everything-yourself world of PHP (at least this is how I always approached it).

I'm using Flask, WTForms, Jinja2, and I've just discovered Flask-Login which I want to use. My question is about the reliability of using thirdparty libraries for core functionality in a project that is planned to be around for several years.

I've installed these libraries (via pip) into a virtualenv environment. What happens if these libraries stop being distributed? Should I back up these libraries (are they eggs)? Can I store these libraries in my project itself, instead of relying on pip to install them in a virtualenv? And should I store these separately?

I'm worried that I'll rely on a library for core functionality, and then one day I'll download an incompatible version through pip, or the author or maintainer will stop distributing it and it'll no longer be available.

How can I protect against this, and ensure that any thirdparty libraries that I use in my projects will always be available as they are now?

答:
I've been deploying python web applications for years now, and this has rarely been a problem.

Note that what you describe and fear could happen to any open source project, including to PHP, Apache, or even Linux. What happens if any OSS project goes AWOL? If there has been any number of people relying on it, backups of distributions can always be found somewhere on the world wide internet.

Also note that if you use a reliable, reproduceable distribution method, where you pin dependency versions to one version only, you should never run into the accidental 'incompatible version' scenario you describe. pip has the freeze command to give you a re-usable list of versions, for example.

Using a tool like buildout gives you another avenue to build a fully re-playable deployment configuration, and not only can you pin your library versions with it, you can instruct buildout to never install a python package unless you configured an explicit version for that package (allow-picked-versions = false). Buildout caches downloaded package distribution files, giving me easy access to those backups I mentioned earlier.

Last, but not least, you create such a backup cache automatically with a sufficiently smart, local PyPI mirror such as collective.eggproxy. Both PyPI and buildout can be instructed to use your mirror instead of the central PyPI repository, and it'll build up a cache of packages as you go along, fully automatic.


问:
Dealing with Fanboys
We've all probably met someone like this, that developer who just knows that his language is the one true language and won't shut up about it. How do you deal like someone like this? I don't want to offend anyone (especially since the fanboy in my workplace is the senior developer). But I want to be able to use my own choice of scripting language when I have to write a throwaway script that never makes it to the repository and no one else need know existed.

Thoughts that I had to dealing with this:

Laugh it off - "Haha yeah maybe language X is a bit easier, I guess I'm a masochist!"

Go with it - I'd really prefer to avoid this as I can't afford the drop in productivity associated with picking up a new language.

Hide my language - Become a closet programmer and hide my monitor whenever I'm scripting or automating something.

What would you suggest for this situation?

答:
Passive-aggressive options 1,3 lead to more emotional distress, so give me a 2) take it on the chin.

Some general advice for the road: 4) If you don't get any smarter listening to your senior, do your own study in language/compiler design. Pick a language and learn what thoughts went into it. What the tradeoff is between features, performance, and expressive power. What other options are there. This alone will grant you inhuman programming superpowers. Learn NBL even, it's going to be huge.

Asserting oneself by pushing opinions on others inhibits productivity and communication. People may think giving up to the emotional urge is helpful, but it's a mere band-aid on their insecurity.

Being humble and kind with advice, and improving yourself will do wonders to express your gut feelings on a technical level. You'll feel better and see things for what they are, because you'll be able to reason. Hard to get mad when you externalize criticism to a technical context.

Title: Dealing with Fanboys


问:
Is there a difference between multi-tasking and time-sharing?
Just going over my school notes, my teacher identifies multi-tasking OS, and time-sharing OS as two different things.

I really don't see a difference between the two.

MULTI-TASKING: You load a number of programs in the memory and execute them. You execute another program if the time quantum allocated to the current program expires OR if it goes on to do I/O and leaves the CPU OR if it finishes execution.

TIME-SHARING: the same,again.

The same applies in case of serial processing and batch processing. Although they are the same, I guess the only difference would be the way in which control information is passed to the CPU. Maybe, and again MAYBE, in serial processing you need to provide the punch cards with all the processes while in batch, the entire batch uses the same set of control information.

Like all the print jobs would have the same control information.

答:
Multi-tasking usually implies multiple threads. With multicore systems that means each thread will run in it's own core or with multi-processor systems on it's own processor.

Time-sharing clearly implies one single thread that serves several task as you defined.

However, there may not be such a clear definition anywhere ... this is just what usually is understood about this 2 different expressions.

Also, I imagine that multi-tasking is from a higher point of view, it refers to a user being capable of running several applications simultaneously. The user doesn't know the underlying technology. It can be real multi-threading or time-sharing or something different.

Time-sharing is more of a technical term which refers to the functioning of a system. This is usually more used by programmers or sysadmins and less by users, who actually don't care about how their computer works.


答:
In computing TIME-SHARING is described as being the sharing of computing resource among many users by means of multiprogramming and multi-tasking. So in effect by allowing many users to interact concurrently with a single computer. There are many systems like this already built Stanford PDP-1, Univac, IBM TSO and so on.

MULTI-TASKING on the other hand is the method where multiple tasks(processes) are performed during the same period of time. This can be achieved on single CPU by creating the proper scheduling strategy for context switching. On multi-cpu they can run each on an individual CPU or again use a strategy to run more tasks than the number of CPU's.

In time sharing systems the scheduling strategy for context switching is done by interrupts usually. Time sharing systems basically where first introduced to name computers shared among multiple users through terminals.

Title: Is there a difference between multi-tasking and time-sharing?

Body:
Just going over my school notes, my teacher identifies multi-tasking OS, and time-sharing OS as two different things.

I really don't see a difference between the two.

MULTI-TASKING: You load a number of programs in the memory and execute them. You execute another program if the time quantum allocated to the current program expires OR if it goes on to do I/O and leaves the CPU OR if it finishes execution.

TIME-SHARING: the same,again.

The same applies in case of serial processing and batch processing. Although they are the same, I guess the only difference would be the way in which control information is passed to the CPU. Maybe, and again MAYBE, in serial processing you need to provide the punch cards with all the processes while in batch, the entire batch uses the same set of control information.

Like all the print jobs would have the same control information.


答:
Time-sharing and batch processing implies for me serving multiple users. (And are more dated. It looks like speak of the 70's or the 80's)

Multi-tasking and serial processing haven't that implication.

But if someone makes a nuance between the two, I'd expect them to explicit it.


问:
Is functional programming a superset of object oriented?
The more functional programming I do, the more I feel like it adds an extra layer of abstraction that seems like how an onion's layer is- all encompassing of the previous layers.

I don't know if this is true so going off the OOP principles I've worked with for years, can anyone explain how functional does or doesn't accurately depict any of them: Encapsulation, Abstraction, Inheritance, Polymorphism

I think we can all say, yes it has encapsulation via tuples, or do tuples count technically as fact of "functional programming" or are they just a utility of the language?

I know Haskell can meet the "interfaces" requirement, but again not certain if it's method is a fact of functional? I'm guessing that the fact that functors have a mathematical basis you could say those are a definite built in expectation of functional, perhaps?

Please, detail how you think functional does or does not fulfill the 4 principles of OOP.

Edit:
I understand the differences between the functional paradigm and object oriented paradigm just fine and realize there are plenty of multiparadigm languages these days which can do both. I am really just looking for definitions of how outright fp (think purist, like haskell) can do any of the 4 things listed, or why it cannot do any of them. i.e. "Encapsulation can be done with closures" (or if I am wrong in this belief, please state why).

答:
Answer:

Wikipedia has a great article on Functional Programming  with some of the examples you ask for.  @Konrad Rudolph already provided the link to the OOP article.

I don't think one paradigm is a super-set of the other.  They are different perspectives on programming and some problems are better solved from one perspective and some from another.

Your question is further complicated by all the implementations of FP and OOP.  Each language has its own quirks that are relevant to any good answer to your question.

Increasingly Tangential Rambling:

I like the idea that a language like Scala tries to give you the best of both worlds.  I worry that it gives you the complications of both worlds as well.

Java is an OO language, but version 7 added a "try-with-resources" feature which can be used to imitate a kind of closure.  Here it imitates updating a local variable "a" in the middle of another function, without making it visible to that function.  In this case the first half of the other function is the ClosureTry() constructor and the second half is the close() method.

```<code>public class ClosureTry implements AutoCloseable {

    public static void main(String[] args) {
        int a = 1;
        try(ClosureTry ct = new ClosureTry()) {
            System.out.println("Middle Stuff...");
            a = 2;
        }
        System.out.println("a: " + a);
    }

    public ClosureTry() {
        System.out.println("Start Stuff Goes Here...");
    }

    /** Interface throws exception, but we don't have to. */
    public void close() {
        System.out.println("End Stuff Goes Here...");
    }
}
</code>```

Output:

```<code>Start Stuff Goes Here...
Middle Stuff...
End Stuff Goes Here...
a: 2
</code>```

This is could be useful for its intended purpose of opening a stream, writing to the stream, and closing it reliably, or for simply pairing two functions in a way that you don't forget to call the second one after doing some work between them.  Of course, it's so new and unusual that another programmer might remove the try block without realizing they are breaking something, so it's currently kind of an anti-pattern, but interesting that it can be done.

You can express any loop in most imperative languages as a recursion.  Objects and variables can be made immutable.  Procecures can be written to minimize side effects (though I would argue that a true function is not possible on a computer - the time it takes to execute and the processor/disk/system resources it consumes are unavoidable side effects).  Some functional languages can be made to do many if not all object-oriented operations as well.  They don't have to be mutually exclusive, though some languages have limitations (like not allowing any updating of variables) that prevent certain patterns (like mutable fields).

To me, the most useful parts of object oriented programming are data hiding (encapsulation), treating similar-enough objects as the same (polymorphism), and collecting your data and methods that operate on that data together (objects/classes).  Inheritance may be the flagship of OOP, but to me it is the least important and least used part.

The most useful parts of functional programming are immutability (tokens/values instead of variables), functions (no side effects), and closures.

I don't think it's object-oriented, but I have to say that one of the most useful things in computer science is the ability to declare an interface, then have various pieces of functionality and data implement that interface.  I also like to have a few mutable pieces of data to work with, so I guess I'm not totally comfortable in exclusively functional languages, even though I try to limit mutability and side effects in all my program designs.

Body:
Answer:

Wikipedia has a great article on Functional Programming  with some of the examples you ask for.  @Konrad Rudolph already provided the link to the OOP article.

I don't think one paradigm is a super-set of the other.  They are different perspectives on programming and some problems are better solved from one perspective and some from another.

Your question is further complicated by all the implementations of FP and OOP.  Each language has its own quirks that are relevant to any good answer to your question.

Increasingly Tangential Rambling:

I like the idea that a language like Scala tries to give you the best of both worlds.  I worry that it gives you the complications of both worlds as well.

Java is an OO language, but version 7 added a "try-with-resources" feature which can be used to imitate a kind of closure.  Here it imitates updating a local variable "a" in the middle of another function, without making it visible to that function.  In this case the first half of the other function is the ClosureTry() constructor and the second half is the close() method.

public class ClosureTry implements AutoCloseable {

    public static void main(String[] args) {
        int a = 1;
        try(ClosureTry ct = new ClosureTry()) {
            System.out.println("Middle Stuff...");
            a = 2;
        }
        System.out.println("a: " + a);
    }

    public ClosureTry() {
        System.out.println("Start Stuff Goes Here...");
    }

    /** Interface throws exception, but we don't have to. */
    public void close() {
        System.out.println("End Stuff Goes Here...");
    }
}

Output:

Start Stuff Goes Here...
Middle Stuff...
End Stuff Goes Here...
a: 2

This is could be useful for its intended purpose of opening a stream, writing to the stream, and closing it reliably, or for simply pairing two functions in a way that you don't forget to call the second one after doing some work between them.  Of course, it's so new and unusual that another programmer might remove the try block without realizing they are breaking something, so it's currently kind of an anti-pattern, but interesting that it can be done.

You can express any loop in most imperative languages as a recursion.  Objects and variables can be made immutable.  Procecures can be written to minimize side effects (though I would argue that a true function is not possible on a computer - the time it takes to execute and the processor/disk/system resources it consumes are unavoidable side effects).  Some functional languages can be made to do many if not all object-oriented operations as well.  They don't have to be mutually exclusive, though some languages have limitations (like not allowing any updating of variables) that prevent certain patterns (like mutable fields).

To me, the most useful parts of object oriented programming are data hiding (encapsulation), treating similar-enough objects as the same (polymorphism), and collecting your data and methods that operate on that data together (objects/classes).  Inheritance may be the flagship of OOP, but to me it is the least important and least used part.

The most useful parts of functional programming are immutability (tokens/values instead of variables), functions (no side effects), and closures.

I don't think it's object-oriented, but I have to say that one of the most useful things in computer science is the ability to declare an interface, then have various pieces of functionality and data implement that interface.  I also like to have a few mutable pieces of data to work with, so I guess I'm not totally comfortable in exclusively functional languages, even though I try to limit mutability and side effects in all my program designs.


问:
Efficient way to find unique elements in a vector compared against multiple vectors
I am trying find the number of unique elements in a vector compared against multiple vectors using C++. The vectors are in sorted order and it can be of size 2,000,000.

Suppose I have,

```<code>v1: 5, 8, 13, 16, 20
v2: 2, 4, 6, 8
v3: 20
v4: 1, 2, 3, 4, 5, 6, 7
v5: 1, 3, 5, 7, 11, 13, 15
</code>```

The number of unique elements in v1 is 1 (i.e. number 16).

I tried two approaches.

Added vectors v2,v3,v4 and v5 into a vector of vector. For each element in v1, checked if the element is present in any of the other vectors.

Combined all the vectors v2,v3,v4 and v5 using merge sort into a single vector and compared it against v1 to find the unique elements.

Note: sample_vector = v1 and all_vectors_merged  contains v2,v3,v4,v5

```<code>//Method 1
unsigned int compute_unique_elements_1(vector<unsigned int> sample_vector,vector<vector<unsigned int> > all_vectors_merged)
{
    unsigned int duplicate = 0;
    for (unsigned int i = 0; i < sample_vector.size(); i++)
    {
        for (unsigned int j = 0; j < all_vectors_merged.size(); j++)
        {
            if (std::find(all_vectors_merged.at(j).begin(), all_vectors_merged.at(j).end(), sample_vector.at(i)) != all_vectors_merged.at(j).end())
            {
                duplicate++;
            }
        }
    }
    return sample_vector.size()-duplicate;
}

// Method 2
unsigned int compute_unique_elements_2(vector<unsigned int> sample_vector, vector<unsigned int> all_vectors_merged)
{
    unsigned int unique = 0;
    unsigned int i = 0, j = 0;
    while (i < sample_vector.size() && j < all_vectors_merged.size())
    {
        if (sample_vector.at(i) > all_vectors_merged.at(j))
        {
            j++;
        }
        else if (sample_vector.at(i) < all_vectors_merged.at(j))
        {
            i++;
            unique ++;
        }
        else
        {
            i++;
            j++;
        }
    }
    if (i < sample_vector.size())
    {
        unique += sample_vector.size() - i;
    }
    return unique;
}
</code>```

Of these two techniques, I see that Method 2 gives faster results.

1) Method 1: Is there a more efficient way to find the elements than running std::find on all the vectors for all the elements in v1.

2) Method 2: Extra overhead in comparing vectors v2,v3,v4,v5 and sorting them.

How can I do this in a better way?

[edit]
Vectors are in sorted order.

答: Use hash tables.  Elements are the key, number of occurrences are the values.</p>


答:
The answer is 2) Go with it.

The only way to shut the fanboy up is to become fluent (to some degree) in his language of choice.

The loss of productivity is not an issue. You are doing as requested by your senior, so productivity changes must be accommodated by the project.

Learning a new language will make your brain function better.

Learning to be open about learning new languages will do you even more good.

It's win-win-win-win. Enjoy!

Title: Dealing with Fanboys

Body:
We've all probably met someone like this, that developer who just knows that his language is the one true language and won't shut up about it. How do you deal like someone like this? I don't want to offend anyone (especially since the fanboy in my workplace is the senior developer). But I want to be able to use my own choice of scripting language when I have to write a throwaway script that never makes it to the repository and no one else need know existed.

Thoughts that I had to dealing with this:

Laugh it off - "Haha yeah maybe language X is a bit easier, I guess I'm a masochist!"

Go with it - I'd really prefer to avoid this as I can't afford the drop in productivity associated with picking up a new language.

Hide my language - Become a closet programmer and hide my monitor whenever I'm scripting or automating something.

What would you suggest for this situation?


问:
How can a non-technical person learn to write a spec for small projects?
How can a non-technical person learn to write specs for small projects?

A friend of mine is trying to outsource some development on a statistics project.

In particular, he does a lot of work in excel, and wants to outsource the creation of scripts to do what he now does by hand.

However, my friend is extremely non-technical. He is poor at writing technical specs.

When he does write a spec, it is written the way you would describe doing something in excel (go to this cell and then copy the value to that cell). It is also overly verbose, and does examples several times. I'm not sure if he properly describes corner cases.

The first project he outsourced was a failure. I think he overdescribed some details, but underdescribed corner cases. That and/or the coder he hired didn't think through the corner cases and ask appropriate questions. I'm not sure. I got on IM with him and it took me half an hour to dig out a description that should have taken five minutes or less to describe. I wrote the scripts for him at the end, but didn't examine why his process with the coder failed.

He has asked me for help. However, I refuse to get involved, because taking his spec and translating it into clear requirements is 10x more work than executing on a clearly written spec.

What is the right way for him to learn? Are there resources he could use? Are there ways he can learn from small, low-pressure practice projects with coders?

Most of his scripts are statistical and data processing oriented. e.g. take this column and run an average over it. Remove these rows under these conditions. So the challenge is different than spec'ing a web app.

答:
He can try using the storyboard approach.

Have him write down a list of things (stories) the application is going to have to do and within that list, further elaborate on the functionality of each story.

He can use a tool like Asana to flesh out the project scope and functionality, and even interact with his developer.


答:
I see two good possible approaches to to this problem. However, it's important to realize two things. First, requirements engineering is hard work - turning an idea into a formal specification that is enough to build a system takes a lot of time, effort, and practice. Second, if you have good requirements (in any format, from a formal specification to less formal user stories and use cases), it will be significantly easier, cheaper, and faster to actually build the software (and build it right earlier).

If your friend is either going to be asking for numerous software tools to be built or intends on contracting them out, he should learn how to write software requirements, at least at the level of business objectives and concept of operations. The two leading books on software requirements engineering are by Karl Wiegers - Software Requirements (2nd Edition) and More About Software Requirements: Thorny Issues and Practical Advice. I would expect that most people he would hire would want some kind of document describing the system, at least at a level of business objectives or concept of operations, and these books go into that. They also go into the how and why of other aspects of requirements engineering that I would suspect a good developer would go through early in the project.

The second option would be to either hire someone with experience in software development and requirements engineering (and perhaps even some kind of systems engineering or system architecture) to understand the problem space and determine where software solutions are needed and where software solutions wouldn't be beneficial, write the documents, and perhaps even oversee or carry out the development effort. However, this would probably be more expensive and amount to hiring a full-time software developer for an extended period of time to develop not only the system requested, but the requirements and architecture needed as well.

Honestly, I don't think what your friend is experiencing is that uncommon for someone who doesn't understand the software development process. I also don't think the blame lies entirely on him, either. If the first software project didn't have good requirements, the developer(s) that it was outsourced to should have clarified, refined, and documented the requirements. Frankly, I'm not sure that you are the right person to get involved, either, if you aren't willing to put in the time or the effort to work with the non-technical user/customer and develop good technical specifications (this is a key role of anyone performing requirements engineering in any engineering discipline).

I think the optimal solution is really a combination of my two options. I think that your friend (and perhaps you, as well) should learn about what is involved in requirements engineering and the benefits that having solid requirements can bring to a project. You, as a software developer, should also become more familiar with requirements engineering and how to elicit, document, analyze, and manage requirements as appropriate for software projects - it's really a valuable skill for anyone doing work at any part in the software lifecycle.

Title: How can a non-technical person learn to write a spec for small projects?

Body:
How can a non-technical person learn to write specs for small projects?

A friend of mine is trying to outsource some development on a statistics project.

In particular, he does a lot of work in excel, and wants to outsource the creation of scripts to do what he now does by hand.

However, my friend is extremely non-technical. He is poor at writing technical specs.

When he does write a spec, it is written the way you would describe doing something in excel (go to this cell and then copy the value to that cell). It is also overly verbose, and does examples several times. I'm not sure if he properly describes corner cases.

The first project he outsourced was a failure. I think he overdescribed some details, but underdescribed corner cases. That and/or the coder he hired didn't think through the corner cases and ask appropriate questions. I'm not sure. I got on IM with him and it took me half an hour to dig out a description that should have taken five minutes or less to describe. I wrote the scripts for him at the end, but didn't examine why his process with the coder failed.

He has asked me for help. However, I refuse to get involved, because taking his spec and translating it into clear requirements is 10x more work than executing on a clearly written spec.

What is the right way for him to learn? Are there resources he could use? Are there ways he can learn from small, low-pressure practice projects with coders?

Most of his scripts are statistical and data processing oriented. e.g. take this column and run an average over it. Remove these rows under these conditions. So the challenge is different than spec'ing a web app.


答:
Translating it into clear requirements is 10x more work than executing
  on a clearly written spec.

Amen.  That also explains why:

the coder he hired didn't think through the corner cases and ask appropriate
  questions.

Understanding requirements is the hardest (and most expensive) part of most programming projects.  When a non-technical person writes requirements they often only document the work-around they want to replace ("open Excel, click on cell B3...").  The best they can hope for is an exact duplicate of their current difficulty!

The most productive way I know to work around this is to encourage this person to write Use Cases ("use" rhymes with "loose").  Instead of writing requirements, describe how the system will be used.  This leaves the developer some wiggle-room to suggest a better solution than what the user is doing now.

It sounds like this problem is exacerbated by poor written communication skills on the part of your friend.  He/She either has to put the work into effectively communicating their ideas, or pay the programmer to fish the information out of them.  Either process is painful and time consuming, but doing it yourself is less expensive than paying someone to do it with you.

In any case, this is a common and frustrating difficulty where creative people either have an incomplete idea, or are incapable of describing it in less than a million words.  This person should try to find an extremely patient and insightful programmer who is willing to get to the bottom of what they are really trying to do and make it happen.


答:
It depends on how good you are at "unupdating" when someone else breaks the build.  On the one hand, you want to update in as small chunks as possible.  Personally, I update almost every time I notice updates are available.  On the other hand, if the build breaks and it's going to take a day for someone else to fix it, you still want to be able to work on your new feature in the mean time.

I've worked with version control systems that are very difficult to back up once an update is done.  On those, I tend to update only just before I need to check in.  With better version control systems, there's little reason not to update several times per day.


答:
Test Metrics and Priorities

Many metrics help understand impact of defects missed in testing when they fail in the field.

One common technique in risk management is to rank the top 10 risks on a project based on the following formula:

risk exposure = cost of failure * probability of failure

I think this works because the units can be dollars and ROI for corrective action may also be estimated using dollars.

Mindlance lists many metrics for their tools.  The one you suspect, reminded me of the risk ranking equation.  But it describes business impact as a priority times a frequency.  Elsewhere, the priority seems to be enumerated 1 to 4.  Their equation is qualitative but not good math for quantitative methods.

When they mention frequency of failure, a useful testing technique comes to mind.  The article Operational Profiles asserts that we should test most those features the customer uses most.  It demonstrates simple steps to build a profile by observing usage, uses tallies to rank most frequently used features highest.

Title: Severity and relation to occurence - priority?

Body:
I have been browsing through some webpages related to testing and found one dealing with the metrics of testing. It says:

The severity level of a defect indicates the potential business impact
  for the end user (business impact = effect on the end user x frequency
  of occurrence).

I do not think think this is correct or what am I missing? Usually it is the priority which is the result of such a calculation (severe bug that occurs rarely is still severe but does not have to be fixed immediately).
Also from this description, what is the difference between the effect on the end user and business impact?


答:
When I need specs from a non-techical client, I usually ask them to write in plain language what exactly it is they want to accomplish. As in "the app should do A to B when I press C, but only if D". Extra bonus for "because D means that...".

In fact "take this column and run an average over it." is a step in the right direction. A better explanation would be "The table contains this and that" (if the structure is predefined); "Get an average of X". Basically, the least technical way possible without losing the details.

In other words, describe the idea, not the implementation.

Then a caring programmer should be able to understand the actual purpose of what's he commissioned to do and choose the right steps himself, asking questions for anything non-obvious.

If there isn't anyone who cares enough and understands the process, the project will fail in any case.


问:
What to put in a Stored Procedure documentation?
I was tasked to document our stored procedures.

Target audience: Technical

Purpose: To have a good documentation in preparation for
migration.

I'm assuming someone has already done it.

答:
At a minimum, you document it like you would a function or method in source code. For example:

What does the stored procedure do? Does it update or modify any tables or just read values?

What are the arguments? What are their allowed values? Can they be NULL?

What is returned? Is it a scalar value? Is it a table? If so, what are the fields and what do their values mean? Is there a single row or multiple rows?

Give an example of its use

Are there related or similar stored procedures? For example, is it normally used in conjunction with another stored procedure?

Depending on your environment, the following may or may not apply:

Should it be called within a transaction or not?

Are there any special security requirements? For example, does the caller need access to particular tables?

Are there any known bugs that are not fixed due to backwards compatibility reasons?

Does this stored procedure supersede other stored procedures? Is it obsolete or deprecated?

Is the stored procedure written by hand or auto generated? If it is auto generated, what tool generated it?

Does the procedure deal with sensitive information like credit card details, hashed passwords or Personally Identifiable Information (PII)?

For the actual documentation, the best experience I had was using a Wiki. Each stored proc had its own page and so the documentation was versioned independently with an easily accessible history and change list. Users could subscribe to changes via E-mail and the documentation was always in an easily accessible location.


答:
I think you should commit more often. If you are going to work for a long time like few days, you should branch your code and work in your branch rather than working directly in the trunk. I know it's convenient to start working without branches, but it's not really flexible as you cannot be sure that your update/commit would break your code or not, which ends up to the situation that you will hold your update/commit until you've done your job. "Feature branching" is better in the way that you can always commit your code, and just merge back later when you finish.

In the branching strategy, the update is replaced with merging from trunk. From my experience, you don't need to merge from trunk that often, as the code in something like five days time span would not change much and it's easier to resolve the conflict once only when you've finished.


问:
Specific reasons for still using Subversion?
I want to choose a version control system for my company. So far I know I have Git, Subversion and Mercurial.

These days I see that Git is the most used, so I'm left wondering: would there be any specific reason to still use Subversion, or should I go directly to Git?

答:
With SVN you can easily checkout parts of a repository down to the folder level, whereas with git, you get the whole repository, including all the history.

Depending on the situation this may have some advantages for SVN

(this also has some big drawbacks such as the hidden ".svn" garbage all the way up your folder tree).


问:
How does one handle sensitive data when using Github and Heroku?
I am not yet accustomed with the way Git works (And wonder if someone besides Linus is ;)).

If you use Heroku to host you application, you need to have your code checked in a Git repo. If you work on an open-source project, you are more likely going to share this repo on Github or other Git hosts.

Some things should not be checked in the public repo; database passwords, API keys, certificates, etc...
But these things still need to be part of the Git repo since you use it to push your code to Heroku.

How to work with this use case?

Note: I know that Heroku or PHPFog can use server variables to circumvent this problem. My question is more about how to "hide" parts of the code.

答:
If you want to run your code on Heroku, you have to give it to them - you can't keep it "secret" from your hosting provider.

So far as public git repositories go, if your project is open source but you don't want to share hosting details, you would need to maintain a private fork of your project for the purposes of deployment.


问:
LINQ Style preference
I have come to use LINQ in my every day programming a lot. In fact, I rarely, if ever, use an explicit loop.  I have, however, found that I don't use the SQL like syntax anymore.  I just use the extension functions.  So rather then saying:

```<code>from x in y select datatransform where filter
</code>```

I use:

```<code>x.Where(c => filter).Select(c => datatransform)
</code>```

Which style of LINQ do you prefer and what are others on your team are comfortable with?

答:
Is it ever too late to add another answer?

I've written a ton of LINQ-to-objects code and I contend that at least in that domain that it's good to understand both syntaxes in order to use whichever makes for simpler code -- which isn't always dot-syntax.

Of course there are times when dot-syntax IS the way to go - others have provided several of these cases; however, I think comprehensions have been short-changed - given a bad rap, if you will. So I'll provide a sample where I believe comprehensions are useful.

Here's a solution to a digit substitution puzzle:
(solution written using LINQPad, but can stand-alone in a console app)

```<code>// NO
// NO
// NO
//+NO
//===
// OK

var solutions =
    from O in Enumerable.Range(1, 8) // 1-9
                    //.AsQueryable()
    from N in Enumerable.Range(1, 8) // 1-9
    where O != N
    let NO = 10 * N + O
    let product = 4 * NO
    where product < 100
    let K = product % 10
    where K != O && K != N && product / 10 == O
    select new { N, O, K };

foreach(var i in solutions)
{
    Console.WriteLine("N = {0}, O = {1}, K = {2}", i.N, i.O, i.K);
}

//Console.WriteLine("\nsolution expression tree\n" + solutions.Expression);
</code>```

...which outputs:

N = 1, O = 6, K = 4

Not too bad, the logic flows linearly and we can see that it comes up with a single correct solution. This puzzle is easy enough to solve by hand: reasoning that 3 > N > 0, and O > 4 * N implies 8 >= O >= 4. That means there's a maximum of 10 cases to test by hand (2 for N -by- 5 for O). I've strayed enough - this puzzle is offered for LINQ illustration purposes.

Compiler Transformations

There's a lot the compiler does to translate this into equivalent dot-syntax. Besides the usual second and subsequent from clauses get turned into SelectMany calls we have let clauses that become Select calls with projections, both of which use transparent-identifiers. As I am about to show, having to name these identifiers in the dot-syntax takes away from the readability of that approach.

I have a trick for exposing what the compiler does in translating this code to dot syntax. If you uncomment the two commented lines above and run it again, you'll get the following output:

N = 1, O = 6, K = 4

solution expression tree
  System.Linq.Enumerable+d_b8.SelectMany(O => Range(1, 8), (O, N) => new <>f_AnonymousType02(O = O, N = N)).Where(<>h__TransparentIdentifier0 => (<>h__TransparentIdentifier0.O != <>h__TransparentIdentifier0.N)).Select(<>h__TransparentIdentifier0 => new <>f__AnonymousType12(<>h_TransparentIdentifier0 = <>h_TransparentIdentifier0, NO = ((10 * <>h_TransparentIdentifier0.N) + <>h_TransparentIdentifier0.O))).Select(<>h_TransparentIdentifier1 => new <>f_AnonymousType22(<>h__TransparentIdentifier1 = <>h__TransparentIdentifier1, product = (4 * <>h__TransparentIdentifier1.NO))).Where(<>h__TransparentIdentifier2 => (<>h__TransparentIdentifier2.product < 100)).Select(<>h__TransparentIdentifier2 => new <>f__AnonymousType32(<>h_TransparentIdentifier2 = <>h_TransparentIdentifier2, K = (<>h_TransparentIdentifier2.product % 10))).Where(<>h_TransparentIdentifier3 => (((<>h_TransparentIdentifier3.K != <>h_TransparentIdentifier3.<>h_TransparentIdentifier2.<>h_TransparentIdentifier1.<>h_TransparentIdentifier0.O) AndAlso (<>h_TransparentIdentifier3.K != <>h_TransparentIdentifier3.<>h_TransparentIdentifier2.<>h_TransparentIdentifier1.<>h_TransparentIdentifier0.N)) AndAlso ((<>h_TransparentIdentifier3.<>h_TransparentIdentifier2.product / 10) == <>h_TransparentIdentifier3.<>h_TransparentIdentifier2.<>h_TransparentIdentifier1.<>h_TransparentIdentifier0.O))).Select(<>h_TransparentIdentifier3 => new <>f_AnonymousType4`3(N = <>h_TransparentIdentifier3.<>h_TransparentIdentifier2.<>h_TransparentIdentifier1.<>h_TransparentIdentifier0.N, O = <>h_TransparentIdentifier3.<>h_TransparentIdentifier2.<>h_TransparentIdentifier1.<>h_TransparentIdentifier0.O, K = <>h__TransparentIdentifier3.K))

Putting each LINQ operator on a new line, translating the "unspeakable" identifiers to ones we can "speak", changing the anonymous types to their familiar form and changing the AndAlso expression-tree lingo to && exposes the transformations the compiler does to arrive at an equivalent in dot-syntax:

```<code>var solutions =
    Enumerable.Range(1,8) // from O in Enumerable.Range(1,8)
        .SelectMany(O => Enumerable.Range(1, 8), (O, N) => new { O = O, N = N }) // from N in Enumerable.Range(1,8)
        .Where(temp0 => temp0.O != temp0.N) // where O != N
        .Select(temp0 => new { temp0 = temp0, NO = 10 * temp0.N + temp0.O }) // let NO = 10 * N + O
        .Select(temp1 => new { temp1 = temp1, product = 4 * temp1.NO }) // let product = 4 * NO
        .Where(temp2 => temp2.product < 100) // where product < 100
        .Select(temp2 => new { temp2 = temp2, K = temp2.product % 10 }) // let K = product % 10
        .Where(temp3 => temp3.K != temp3.temp2.temp1.temp0.O && temp3.K != temp3.temp2.temp1.temp0.N && temp3.temp2.product / 10 == temp3.temp2.temp1.temp0.O)
        // where K != O && K != N && product / 10 == O
        .Select(temp3 => new { N = temp3.temp2.temp1.temp0.N, O = temp3.temp2.temp1.temp0.O, K = temp3.K });
        // select new { N, O, K };

foreach(var i in solutions)
{
    Console.WriteLine("N = {0}, O = {1}, K = {2}", i.N, i.O, i.K);
}
</code>```

Which if you run you can verify that it again outputs:

N = 1, O = 6, K = 4

...but would you ever write code like this?

I'd wager the answer is NONBHN (Not Only No, But Hell No!) - because it's just too complex. Sure you can come up with some more meaningful identifier names than "temp0" .. "temp3", but the point is that they don't add anything to the code - they don't make the code perform better, they don't make the code read better, they only ugly-up the code, and if you were doing it by hand, no doubt you would mess it up a time or three before getting it right. Also, playing "the name game" is hard enough for meaningful identifiers, so I welcome the break from the name-game that the compiler provides me in query comprehensions.

This puzzle sample may not be real-world enough for you to take seriously; however, other scenarios do exist where query comprehensions shine:

The complexity of Join and GroupJoin: the scoping of range variables in query comprehension join clauses turn mistakes that might otherwise compile in dot-syntax into compile-time errors in comprehension syntax.

Any time the compiler would introduce a transparent-identifier in the comprehension transform, comprehensions become worthwhile. This includes the use of any of the following: multiple from clauses, join & join..into clauses and let clauses.

I know of more than one engineering shop in my hometown that has outlawed comprehension syntax. I think this is a pity as comprehension syntax is but a tool and a useful one at that. I think it's a lot like saying, "There are things you can do with a screwdriver that you can't do with a chisel. Because you can use a screwdriver as a chisel, chisels are banned henceforth under decree of the king."

Title: LINQ Style preference

Body:
Is it ever too late to add another answer?

I've written a ton of LINQ-to-objects code and I contend that at least in that domain that it's good to understand both syntaxes in order to use whichever makes for simpler code -- which isn't always dot-syntax.

Of course there are times when dot-syntax IS the way to go - others have provided several of these cases; however, I think comprehensions have been short-changed - given a bad rap, if you will. So I'll provide a sample where I believe comprehensions are useful.

Here's a solution to a digit substitution puzzle:
(solution written using LINQPad, but can stand-alone in a console app)

// NO
// NO
// NO
//+NO
//===
// OK

var solutions =
    from O in Enumerable.Range(1, 8) // 1-9
                    //.AsQueryable()
    from N in Enumerable.Range(1, 8) // 1-9
    where O != N
    let NO = 10 * N + O
    let product = 4 * NO
    where product < 100
    let K = product % 10
    where K != O && K != N && product / 10 == O
    select new { N, O, K };

foreach(var i in solutions)
{
    Console.WriteLine("N = {0}, O = {1}, K = {2}", i.N, i.O, i.K);
}

//Console.WriteLine("\nsolution expression tree\n" + solutions.Expression);

...which outputs:

N = 1, O = 6, K = 4

Not too bad, the logic flows linearly and we can see that it comes up with a single correct solution. This puzzle is easy enough to solve by hand: reasoning that 3 > N > 0, and O > 4 * N implies 8 >= O >= 4. That means there's a maximum of 10 cases to test by hand (2 for N -by- 5 for O). I've strayed enough - this puzzle is offered for LINQ illustration purposes.

Compiler Transformations

There's a lot the compiler does to translate this into equivalent dot-syntax. Besides the usual second and subsequent from clauses get turned into SelectMany calls we have let clauses that become Select calls with projections, both of which use transparent-identifiers. As I am about to show, having to name these identifiers in the dot-syntax takes away from the readability of that approach.

I have a trick for exposing what the compiler does in translating this code to dot syntax. If you uncomment the two commented lines above and run it again, you'll get the following output:

N = 1, O = 6, K = 4

solution expression tree
  System.Linq.Enumerable+d_b8.SelectMany(O => Range(1, 8), (O, N) => new <>f_AnonymousType02(O = O, N = N)).Where(<>h__TransparentIdentifier0 => (<>h__TransparentIdentifier0.O != <>h__TransparentIdentifier0.N)).Select(<>h__TransparentIdentifier0 => new <>f__AnonymousType12(<>h_TransparentIdentifier0 = <>h_TransparentIdentifier0, NO = ((10 * <>h_TransparentIdentifier0.N) + <>h_TransparentIdentifier0.O))).Select(<>h_TransparentIdentifier1 => new <>f_AnonymousType22(<>h__TransparentIdentifier1 = <>h__TransparentIdentifier1, product = (4 * <>h__TransparentIdentifier1.NO))).Where(<>h__TransparentIdentifier2 => (<>h__TransparentIdentifier2.product < 100)).Select(<>h__TransparentIdentifier2 => new <>f__AnonymousType32(<>h_TransparentIdentifier2 = <>h_TransparentIdentifier2, K = (<>h_TransparentIdentifier2.product % 10))).Where(<>h_TransparentIdentifier3 => (((<>h_TransparentIdentifier3.K != <>h_TransparentIdentifier3.<>h_TransparentIdentifier2.<>h_TransparentIdentifier1.<>h_TransparentIdentifier0.O) AndAlso (<>h_TransparentIdentifier3.K != <>h_TransparentIdentifier3.<>h_TransparentIdentifier2.<>h_TransparentIdentifier1.<>h_TransparentIdentifier0.N)) AndAlso ((<>h_TransparentIdentifier3.<>h_TransparentIdentifier2.product / 10) == <>h_TransparentIdentifier3.<>h_TransparentIdentifier2.<>h_TransparentIdentifier1.<>h_TransparentIdentifier0.O))).Select(<>h_TransparentIdentifier3 => new <>f_AnonymousType4`3(N = <>h_TransparentIdentifier3.<>h_TransparentIdentifier2.<>h_TransparentIdentifier1.<>h_TransparentIdentifier0.N, O = <>h_TransparentIdentifier3.<>h_TransparentIdentifier2.<>h_TransparentIdentifier1.<>h_TransparentIdentifier0.O, K = <>h__TransparentIdentifier3.K))

Putting each LINQ operator on a new line, translating the "unspeakable" identifiers to ones we can "speak", changing the anonymous types to their familiar form and changing the AndAlso expression-tree lingo to && exposes the transformations the compiler does to arrive at an equivalent in dot-syntax:

var solutions =
    Enumerable.Range(1,8) // from O in Enumerable.Range(1,8)
        .SelectMany(O => Enumerable.Range(1, 8), (O, N) => new { O = O, N = N }) // from N in Enumerable.Range(1,8)
        .Where(temp0 => temp0.O != temp0.N) // where O != N
        .Select(temp0 => new { temp0 = temp0, NO = 10 * temp0.N + temp0.O }) // let NO = 10 * N + O
        .Select(temp1 => new { temp1 = temp1, product = 4 * temp1.NO }) // let product = 4 * NO
        .Where(temp2 => temp2.product < 100) // where product < 100
        .Select(temp2 => new { temp2 = temp2, K = temp2.product % 10 }) // let K = product % 10
        .Where(temp3 => temp3.K != temp3.temp2.temp1.temp0.O && temp3.K != temp3.temp2.temp1.temp0.N && temp3.temp2.product / 10 == temp3.temp2.temp1.temp0.O)
        // where K != O && K != N && product / 10 == O
        .Select(temp3 => new { N = temp3.temp2.temp1.temp0.N, O = temp3.temp2.temp1.temp0.O, K = temp3.K });
        // select new { N, O, K };

foreach(var i in solutions)
{
    Console.WriteLine("N = {0}, O = {1}, K = {2}", i.N, i.O, i.K);
}

Which if you run you can verify that it again outputs:

N = 1, O = 6, K = 4

...but would you ever write code like this?

I'd wager the answer is NONBHN (Not Only No, But Hell No!) - because it's just too complex. Sure you can come up with some more meaningful identifier names than "temp0" .. "temp3", but the point is that they don't add anything to the code - they don't make the code perform better, they don't make the code read better, they only ugly-up the code, and if you were doing it by hand, no doubt you would mess it up a time or three before getting it right. Also, playing "the name game" is hard enough for meaningful identifiers, so I welcome the break from the name-game that the compiler provides me in query comprehensions.

This puzzle sample may not be real-world enough for you to take seriously; however, other scenarios do exist where query comprehensions shine:

The complexity of Join and GroupJoin: the scoping of range variables in query comprehension join clauses turn mistakes that might otherwise compile in dot-syntax into compile-time errors in comprehension syntax.

Any time the compiler would introduce a transparent-identifier in the comprehension transform, comprehensions become worthwhile. This includes the use of any of the following: multiple from clauses, join & join..into clauses and let clauses.

I know of more than one engineering shop in my hometown that has outlawed comprehension syntax. I think this is a pity as comprehension syntax is but a tool and a useful one at that. I think it's a lot like saying, "There are things you can do with a screwdriver that you can't do with a chisel. Because you can use a screwdriver as a chisel, chisels are banned henceforth under decree of the king."


问:
Are there any OS which are simple enough for learning?
I would really like to understand how an operating  system works behind the scenes. However, I think that the kernel of most open-source OSs out there are too complex for learning purposes, even for a full-time programmer to learn. Are there any "simple" OSs made for learning purposes only out there?</p>

答:
Minix is a great choice and is described in one of the other responses.

Xinu

Also consider XINU - XINU Is Not Unix.

Is is also UNIX spelled backward.

There is a book by Douglas Comer that I thought was well written, well illustrated, and well scoped.

There is an Embedded Xinu and a website about teaching with Xinu.

http://xinu.mscs.mu.edu/Teaching_With_Xinu

FreeRTOS

Another smallish OS that gets a lot of love these days is FreeRTOS.  It runs on almost everything.  If you came from Mars and had a processor or eval board where it doesn't run, you could read about 10 pages of documentation, modify about five files related to interrupts, timers, and UARTs and you would be running.

http://www.freertos.org/

They claim it supports 31 architectures and 18 tool chains.  My experience in late 2009 was good, and I hear it has been improved a lot since then.

Other Links

A similar questions on that might have helpful information for you is located here:

https://stackoverflow.com/questions/254149/how-do-you-write-a-basic-operating-system

Linux and a lot of other operating system design is influenced by UNIX, so this video where the original designers (Kernigan, Richie, and Thompson and others) is both informative and gets the design ideas right from the source.

http://techchannel.att.com/play-video.cfm/2012/2/22/AT&T-Archives-The-UNIX-System

There is a classic but often revised operating systems text book:

Silberschatz, Galvin, Gagne: Operating System Concepts, 7th Edition

There may be newer editions too.  I seldom link to a book through a book seller, but the preview is very generous, so to learn more about operating systems, please check out:

http://www.amazon.com/Operating-System-Concepts-Abraham-Silberschatz/dp/0470128720


答:
Here's the heuristic that I follow:

Favor LINQ expressions over lambdas when you have joins.

I think that lambdas with joins look messy and are difficult to read.

Title: LINQ Style preference

Body:
I have come to use LINQ in my every day programming a lot. In fact, I rarely, if ever, use an explicit loop.  I have, however, found that I don't use the SQL like syntax anymore.  I just use the extension functions.  So rather then saying:

```<code>from x in y select datatransform where filter
</code>```

I use:

```<code>x.Where(c => filter).Select(c => datatransform)
</code>```

Which style of LINQ do you prefer and what are others on your team are comfortable with?


问:
Most appropriate OSS license for infrastructure code
I'm looking into potentially releasing some infrastructure code (related to automated builds and deployments) as OSS and I'm curious about how the various OSS licenses effect it.

Specifically, LGPL prevents the code itself (part/whole) being modified into a commercial product (which is what I'm after), but allows it to be "linked to" in the creation of commercial products (also ok).

How does the "linked to" clause relate to infrastructure code, which is not deployed with the product itself? Would the application still be required to provide "appropriate legal notices" (which I'm not fussed over)?

Would I be better off looking at the Eclipse Public License?

答:
Disclaimer: I am not a lawyer. I would strongly recommend you speak to one if you are considering licensing software, particularly if you want to use it in a commercial product now or in the future.

If you want your software to be freely used by all, the best licenses are ones like BSD and MIT. These claim no responsibility for the code except for copyright and allow modification. People and organizations can use it in their products will relatively little concern other than including an attribution and the license text. This will get your code maximum coverage but gives you the least rights.

Licenses like the Apache, Eclipse and the Common Distribution and Development License (CDDL) are a middle ground. They are more detailed and stricter that the MIT and BSD licenses but place fewer restrictions on what the user can do than GPU license.

Lastly, you have licenses like Gnu Public License (GPL) and Lesser Gnu Public License. The GPL is particularly onerous because it requires any modifications to also be open source. If you want to prevent your product being used in commercial software, use GNU.

Before choosing a license consider:

Do I own the source code? This may be harder to answer than it first appears. Have you copied an example from a web site? Are you using other open source software? If you do not own the code, open sourcing it could violate copyright or other agreements.

Does the source code contain patents, trade secrets or protectable   intellectual property? If yes, open sourcing it may reduce or eliminate the protection offered.

Am I ever going to want to sell this source code? If yes, open sourcing it means others can too. Open sourcing software can be a great way to get assistance from the wider community, educate others and help customers find bugs. It can also shut down a revenue stream and expose any security flaws in the product. Depending on the license, open sourcing a component may be  effectively saying "I going to make money from services or something else other than selling this software".

Am I happy with other selling or modifying the source code? If not, a more restrictive license such as GNU may be in order. Alternatively, you can always provide the source code to paying customers with a license that prevents them from distributing it. Maybe a custom license is on order.

Whether your code is infrastructure or not is incidental. This is as much a business decision as ideological.

Remember that licenses are written by lawyers and certain terms may have specific or ambiguous definitions. Take the term "distribution". I create a web site and the code is housed on the web servers only does that count as distribution? Another legal concern surrounds the term "use" or "integrate" because the boundaries of some modules are unclear.


问:
What software do you use to help plan your team work, and why?
Planning is very difficult. We are not naturally good at estimating our own future, and many cognitive biases exacerbate the problem. Group planning is even harder. Incomplete information, inconsistent views of a situation, and communication problems compound the difficulty.

Agile methods provide one framework for organizing group planning--making planning visible to everyone (user stories), breaking it into smaller chunks (sprints), and providing retrospective analysis so you get better at planning. But finding good tools to support these practices is proving tricky.

What software tools do you use to achieve these goals? Why are you using that tool? What successes have you had with a particular tool?

答:
OmniPlan

Mac OS X planning tool.

Pivotal Tracker

Useful even if you aren't doing "agile" development.

FogBugz

Incredibly useful and featured issue tracking.

I use these in conjunction. OmniPlan is great to lay out all the tasks that need to be completed and divide them among your team. You can setup critical paths (things that must happen for completion) and breakdown overall effort. Also great visually for management.

Pivotal is excellent for keeping up your development pace. If you fully subscribe to agile methodology it's excellent, but still very useful to track features, dependent components, and currently active status.

FogBugz provides an easy to use interface for non-programmers to submit bugs or feature requests and monitor progress. Issues that come in are evaluated and logged in Pivotal. Then they get moved into OmniPlan if it becomes a larger task with multiple components.

ContentLicense: CC BY-SA 2.5


问:
How to test the render speed of my solution in a web browser?
Ok, I need to test the speed of my solution in a web browser, but I have some problems, there are 2 versions of the web solution, the original one that is on server A and the "fixed" version that is on server B.

I have VS2010 Ultimate, so I can make a web and load test on solution B, but I can't load the A solution on my IDE.

I was trying to use fiddle2 and jmeter, but they only gave me the times of the request and response of the browsers with the server, I also want the time it takes to the browser to render the whole page.

Maybe I'm misusing some of this tools...

I don't know if this could be usefull but:

Solution A is on VB 6.0

Solution B is on VB.Net

Thanks in advance!

答: The best answer I can suggest is: Selenium. It is available for Chrome, Firefox, and IE. It can even generate test cases that can be automated by VSTS. You can also create a farm of browser test automation machines to execute the tests.</p>