答:
The view that the software engineers can be pigeon-holed into the same classification as medical professionals or accountants is an ignorant view of the "problem" that they are trying to solve. Before I give my opinion on this, lets break down some of the arguments of Mr. Thornton, who is Vice Chair of the regulatory body proposing this legislation.

“Just as practicing professionals such as doctors, accountants, and
  nurses are licensed, so should software engineers,” Thornton says.
  “The public needs to be able to rely on some sort of credential when
  choosing a contractor to write software.”

- Mitch Thornton, Vice Chair of the IEEE Licensure and Registration

This sounds very reasonable on the surface. After all, there are other industries that might be considered "successfully regulated". By successfully regulated I mean that if you look a doctor up in the yellow pages you can be reasonably certain that he or she has had a thorough education at an accredited university and has passed a number of exams and completed a residency. Here are some "successfully regulated" industries (in terms of professional personnel).

Lawyers

Doctors

Accountants

Nuclear engineers

Barbers (not kidding)

After all, you don't want just anyone removing that tumor from your pancreas or working on the centrifuges of that nuclear power plant just outside of town. Why shouldn't similar restrictions exist for software engineers?

Only those whose programs might “endanger the public health or safety,
  security, property, or the economy will need to be tested,”

This is a vague statement and open to liberal interpretation and application. I could make the argument that Apple Inc. or Facebook are integral parts of the American economy - do I need a special license from the government to write code for them now, since if I bring down the site with my incompetence I might damage the American economy? At my last job I accidentally shut down a grain elevator with a faulty cron job - possibly endangering food supply.

I realize that I'm avoiding the actual intent of this proposal. The idea behind it is to ensure that the person writing the code for the Anti-Lock Braking System on your new Jetta is competent and properly licensed to write code for an Anti-Lock Braking System. On your Jetta.

Here's the problem: software engineering in this day and age encompasses everything and you can't possibly test for every discipline. The business rules are too specific, and too varied from discipline to discipline. Our hypothetical engineer writing code for the ABS system on a Jetta might be writing something entirely different for the ABS system on an Elantra. Does he have to get re-certified?

And what if you do test for all of these derivative disciplines? Suppose for a moment that every programmer who works on an e-commerce web site gets certified as an e-commerce capable programmer. So? Does this suddenly mean that these programmers and companies will actually do the necessary validation and build to PCI compliance? Even if they do - glitches will still happen.

The exam will test for basic knowledge, not mastery of subject matter,
  according to Mitch Thornton, vice chair of the IEEE Licensure and
  Registration Committee.

Here's the kicker. A lack of basic knowledge is never the problem. My anti-lock brakes didn't stop working because Chuck was struggling with the concepts of a control structure. They failed because there was glitch where the ABS turned off due to an electrical short in the tail lights and power wasn't properly rerouted. Or something.

The insulin pump software I wrote didn't stop working because I lack basic skills; it stopped because there was a bug in how I measured the dispensure of insulin when my European teammate used the metric system and I didn't.

That's something you can account for in development, but you could never test for with a certification.

Here's what will happen if this "certification" goes into effect: the number of incidents will stay exactly the same. Why? Because it doesn't do anything to eliminate the actual problem of an ABS or insulin pump failing.

Title: Regulation of the software industry


问:
Regulation of the software industry
Every few years someone proposes tighter regulation for the software industry.

This IEEE article has been getting some attention lately on the subject.

If software engineers who write programs for systems that expose the public to physical or financial risk knew they would be tested on their competence, the thinking goes, it would reduce the flaws and failures in code—and maybe save a few lives in the bargain.

I'm skeptical about the value and merit of this. To my mind it looks like a land grab by those that proposed it.

The quote that clinches that for me is:

The exam will test for basic knowledge, not mastery of subject matter

because the big failures (e.g. THERAC-25) seem to be complex, subtle issues that "basic knowledge" would never be sufficient to prevent.

Ignoring any local issues (such as existing protections of the title Engineer in some jurisdictions):

The aims are noble - avoid the quacks/charlatans1 and make that distinction more obvious to those that buy their software. Can tighter regulation of the software industry ever achieve it's original goal?

1 Exactly as regulation of the medical profession was intended to do.

答:
I haven't read the article, but if the question is about whether software industry regulation can benefit humanity, I think it depends on circumstance:

The industry as a whole encompasses a wide variety of domains, some of which are life critical (e.g. controlling radiation dosage in a medical device), and some of which aren't (the "Which Muppet Are You?" Facebook app). I can't see any argument for regulation for applications where the stakes are low.

One shouldn't start with legal regulation. Rather, one should start with a certification program for developers. Only if the certification program produces some measurable benefit should there be a question of legal regulation.

Even if a certification program produces measurable results, it's likely that industry would standardize on requiring this certification for strictly business reasons, and we wouldn't need legal regulation. (This is why delegations like MCSE exist - companies prefer to hire MCSEs for the domains in which MCSEs are trained.)

That all said, there still remain domains in which it makes business sense to cause harm (often these are negative externalities, sometimes they're the result of market power for some institutions). For example, an area may have a single local hospital; in this case, the quality of the back-end software can make a huge difference to the level of care a patient receives, but does not make that much difference in which hospital the patient chooses. The hospital then does not necessarily have much business case for investing in higher-quality developers. In this case, there may be a public-health case for regulating the developers that the hospital is allowed to hire.

IMHO.

ContentLicense: CC BY-SA 3.0

Title: Regulation of the software industry


问:
Problems (such as maintenance) in development with unpopular language
I'm developing some application with clojure(lisp) alone in my team. It starts as small application. No problem. But as it's having features and extending the area, it's becoming important program.

I worried about maintenance or something. No one in my team knows clojure or lisp nor is interested in languages such as them.

So, isn't it wrong to do programming in unpopular languages? (for my own fun?) Should I use more popular languages? (at least such as python)

I'm sure if I leave the team, --not saying I'm leaving. :)-- no one would maintain it. This program will be destroyed and some will develop with other language.

I'm very enjoying developing with clojure though, I came across with that this might be not for my team.

What do you think about this? I think many programmers loving unpopular languages have been concerning similar issue.

答:
I would recommend to start rewriting your program in different (more convenient) language when you start feeling that maintenance has high chances to be dominating issue.

If you managed to write it in closure (which you didn't know when you started creating your app, as I understood), then it will be no problem to rewrite it using more familiar/convenient language. Closure uses completely different concepts and therefore implementation might be difficult to transfer into another language. But the thing is that if you had fun with writing new app in closure, then you might find it interesting to transfer concepts and ideas you used into another convenient language. It might be fun to compare different languages and their capabilities. I think your case is perfect for such experiments.

OwnerDisplayName: Hybrid


答:
Software is already tightly regulated in the aircraft industry. See DO-178B.

I'm sure other subsets of the industry have their norms.

"Software" encompasses so much these days. I think it would be absurd to have any mandatory all-encompassing regulation.

Title: Regulation of the software industry

Body:
Every few years someone proposes tighter regulation for the software industry.

This IEEE article has been getting some attention lately on the subject.

If software engineers who write programs for systems that expose the public to physical or financial risk knew they would be tested on their competence, the thinking goes, it would reduce the flaws and failures in code—and maybe save a few lives in the bargain.

I'm skeptical about the value and merit of this. To my mind it looks like a land grab by those that proposed it.

The quote that clinches that for me is:

The exam will test for basic knowledge, not mastery of subject matter

because the big failures (e.g. THERAC-25) seem to be complex, subtle issues that "basic knowledge" would never be sufficient to prevent.

Ignoring any local issues (such as existing protections of the title Engineer in some jurisdictions):

The aims are noble - avoid the quacks/charlatans1 and make that distinction more obvious to those that buy their software. Can tighter regulation of the software industry ever achieve it's original goal?

1 Exactly as regulation of the medical profession was intended to do.


问:
How can I extract words from a sentence and determine what part of speech each is?
I want to write something that takes a sentence and identifies each word it contains and defines what part of speech each word is.

For example

Hello World, I am a sentence

would return this

```<code>verb noun, pronoun verb adjective noun
</code>```

Ideally, I'd like to eventually take it one step further and take a sentence and programmatically have it understand what it is trying to interpret and maybe do something about it.

So my question is, has someone heard of something like this?

答:
This is called Natural Language Processing and it's a huge, complex field.  Something like you describe is a monumental achievement, and even the best solutions, like Watson, are nowhere near perfect.

Things like this make it challenging: "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo"

a grammatically correct sentence in American English, used as an example of how homonyms and homophones can be used to create complicated linguistic constructs. It has been discussed in literature since 1972... It was also featured in Steven Pinker's 1994 book The Language Instinct as an example of a sentence that is "seemingly nonsensical" but grammatical...

The sentence's meaning becomes clearer when it's understood that it uses the city of Buffalo, New York and the somewhat-uncommon verb "to buffalo" (meaning "to bully or intimidate"), and when the punctuation and grammar is expanded so that the sentence reads as follows: "Buffalo buffalo that Buffalo buffalo buffalo, buffalo Buffalo buffalo." The meaning becomes even clearer when synonyms are used: "Buffalo bison that other Buffalo bison bully, themselves bully Buffalo bison."


答:
I think you should start reading this Wikipedia article:

http://en.wikipedia.org/wiki/Part-of-speech_tagging

(it is a research field, don't expect any easy solution for it.)

Title: How can I extract words from a sentence and determine what part of speech each is?

Body:
I want to write something that takes a sentence and identifies each word it contains and defines what part of speech each word is.

For example

Hello World, I am a sentence

would return this

```<code>verb noun, pronoun verb adjective noun
</code>```

Ideally, I'd like to eventually take it one step further and take a sentence and programmatically have it understand what it is trying to interpret and maybe do something about it.

So my question is, has someone heard of something like this?


答:
Though splitting a sentence and determining the grammatical correctness along with solving your first problem is easier than your second problem, many complexities like verb-nouns or gerunds like swimming, programming, etc and other such intricacies, it still is a challenge - See Morons' answer.

But your second problem - people have put in huge efforts to find a perfect solution, but a really perfect "interpretation" algorithm is not realizable practically for any natural language like English - there are variations that will screw up your algorithm. This field - a hybrid between AI, Computer Science and Linguistics is known as NLP. Consider this: Even Google Translate is not perfect when "interpreting" sentences.

But nevertheless, this is a very interesting field to dabble with.


问:
Where should I locate the cache in a WCF service?
I am going to build a Windows Communication Foundation (WCF) service using Microsoft Enterprise Library for caching. I am wondering whether or not I should put the cache in the service layer. If I do this, do I have to use InstanceContextMode = Single for this to work? Are there better alternatives, because I prefer using InstanceContextMode = PerSession. Where could I put the cache?

答:
Perhaps not the ideal answer but static variables will still be persisted throughout the life of the application in either InstanceContextMode.

Singeltons are usually lauded for classes, but for large data structures, unless you use a distributed caching solution, there isn't a lot of choice.  Besides, the very nature of a cache entails that there will only be 1 on a given server.

InstanceContextMode Single is far worse (in most scenarios--Only one request per service can process at a time; not desirable)


答:
How fortunate that no one dies thanks to medical regulation, no one is hurt by fraud thanks to financial regulation, no one has their house foreclosed thanks to housing regulation, no one ever gets a bad haircut thanks to barber regulation, and no plane ever crashes thanks to aircraft regulation.

Obviously, the presence of regulation does not imply an absence of flaws or failures.  Conversely, the presence of flaws or failures does not imply regulation would prevent those flaws or failures.  Software engineers are already highly regulated as members of respective safety-critical industries, and outside of those industries there is little need.

Title: Regulation of the software industry


问:
What is the best way to allow a client to contribute to a project?
We've been building a CRM for a client. Now that the first major phase has been finished, and a second one agreed upon, the client would like to pick up some of the work, making minor amendments to the database schema and business processes the first phase while we build the second.

I'm undecided whether this is at all practical, but assuming it is, I'd like some pointers on which measures can be taken to make this at all workable. Here's what I've got so far:

Until now, the client has mostly seen the project from a user's point of view; clearly, a two-part seminar ought to take place where we introduce him to the inner workings:

first, showing the existing database schema and, by way of example, extending it,

then, showing some sample code, and writing a new business process for the schema enhancement.

The code currently resides in an internal Subversion repository. While we could set up a public one or one on his network (which we can VPN to), I feel a distributed system would work better. I appear to be the only one who feels that way, however, so I could use some good convincing arguments.

I'm not sure how to mandate/ensure that code that runs in production is committed. Seems like "x made a critical, undocumented change right before going on vacation; now y's trying to figure out this bug that's been occurring ever since" disasters are inevitable. Ideally, all changes, before deployment, would:

be documented in an issue tracking system,

occur on a separate testing environment first, and

have to pass automated tests.

Alas, I doubt the discipline for any of those will prevail.

Assume that a plug-in architecture or separate project aren't viable options, because 1) the former doesn't exist, and 2) the latter would prohibit the client from looking at and possibly modifying existing code, an ability I believe he would insist on.

答:
From a legal perspective, you're basically asking "What's the best way to ride a donkey blindfolded through a mine field?"

From a programming perspective, I would ask for more information - can what the client is asking for be implemented using some sort of user defined EAV system or with hooks that can be added to the system? Ideally, I'd want to keep the client's code as separate from yours as possible for various reasons.


问:
What's the best way to build a factory using NInject?
I am pretty comfortable with dependency injection using NInject in MVC3. While working in an MVC3 application, I developed a custom Controller Creation Factory using NInject, so any controller that is created will have dependencies injected in it through this Controller Factory.

Now I am starting to develop a windows application, I want to use Application wide Dependency Injection. i.e. Every object must be created through NInject, so as to ease Unit Testing. Please guide me to ensure that every object created must be though the NInject Factory only.

For example, if on any windows form on Button_Click event I write:

```<code>TestClass testClass = new TestClass()
</code>```

and TestClass has any dependency on, say, ITest then it must be automatically resolved. I know I can use:

```<code>Ikernel kernel = new StandardKenel()
//AddBinding()
TestClass testClass = kenel.get<TestClass>();
</code>```

But I find it tedious to do this every time I want to create an object. It also the forces developer to create the object in a particular way. Can it be made better?

Can I have a central repository for object creation and then every object creation will automatically use that repository?

答:
Windows Forms applications typically have a point of entry that looks like this:

```<code>    // Program.cs
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new MainForm());
    }
</code>```

If you make this point in code your composition root, you can vastly reduce the number of places where you have code explicitly invoking Ninject as if it were a Service Locator.

```<code>    // Program.cs
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        var kernel = InitializeNinjectKernel();
        Application.Run(kernel.Get<MainForm>());
    }
</code>```

From this point, you inject all your dependencies via constructor injection.

```<code>public MainForm(TestClass testClass) {
    _testClass = testClass;
}
</code>```

If your "dependency" is something you need to be able to produce multiple times, then what you really need is a factory:

```<code>public MainForm(IFactory<TestClass> testClassFactory) {
    _testClassFactory = testClassFactory;
}

...
var testClass = _testClassFactory.Get();
</code>```

You can implement the IFactory interface this way to avoid having to create a ton of one-off implementations:

```<code>public class InjectionFactory<T> : IFactory<T>, IObjectFactory<T>, IDependencyInjector<T>
{
    private readonly IKernel _kernel;
    private readonly IParameter[] _contextParameters;

    public InjectionFactory(IContext injectionContext)
    {
        _contextParameters = injectionContext.Parameters
            .Where(p => p.ShouldInherit).ToArray();
        _kernel = injectionContext.Kernel;
    }

    public T Get()
    {
        try
        {
            return _kernel.Get<T>(_contextParameters.ToArray());
        }
        catch (Exception e)
        {
            throw new Exception(
                string.Format("An error occurred while attempting to instantiate an object of type <{0}>",
                typeof(T)));
        }
    }

...
Bind(typeof (IFactory<>)).To(typeof (InjectionFactory<>));
Bind(typeof (IContext)).ToMethod(c => c.Request.ParentContext);
</code>```

Body:
Windows Forms applications typically have a point of entry that looks like this:

    // Program.cs
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new MainForm());
    }

If you make this point in code your composition root, you can vastly reduce the number of places where you have code explicitly invoking Ninject as if it were a Service Locator.

    // Program.cs
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        var kernel = InitializeNinjectKernel();
        Application.Run(kernel.Get<MainForm>());
    }

From this point, you inject all your dependencies via constructor injection.

public MainForm(TestClass testClass) {
    _testClass = testClass;
}

If your "dependency" is something you need to be able to produce multiple times, then what you really need is a factory:

public MainForm(IFactory<TestClass> testClassFactory) {
    _testClassFactory = testClassFactory;
}

...
var testClass = _testClassFactory.Get();

You can implement the IFactory interface this way to avoid having to create a ton of one-off implementations:

public class InjectionFactory<T> : IFactory<T>, IObjectFactory<T>, IDependencyInjector<T>
{
    private readonly IKernel _kernel;
    private readonly IParameter[] _contextParameters;

    public InjectionFactory(IContext injectionContext)
    {
        _contextParameters = injectionContext.Parameters
            .Where(p => p.ShouldInherit).ToArray();
        _kernel = injectionContext.Kernel;
    }

    public T Get()
    {
        try
        {
            return _kernel.Get<T>(_contextParameters.ToArray());
        }
        catch (Exception e)
        {
            throw new Exception(
                string.Format("An error occurred while attempting to instantiate an object of type <{0}>",
                typeof(T)));
        }
    }

...
Bind(typeof (IFactory<>)).To(typeof (InjectionFactory<>));
Bind(typeof (IContext)).ToMethod(c => c.Request.ParentContext);


答:
Ouch... You have the right idea but I have seen how messy this can turn out, and both parties suffer considerably.  I am maintaining such an application currently.

Find out the real reasons why the client finds it necessary to contribute directly to the project.  Is it that they now want the project done faster than you can realistically turn it out?  Do they want changes already but are afraid of incurring additional costs from you for making spec changes or requesting additional features?  Is there a political struggle in their organization where internal development resources want more control and input in the project or where they are looking for busy work for internal developers? (this last one hits close to home for me)

Find what their true motivations and address them if at all possible.  The fact that they even suggest it is a huge warning sign that trouble is coming down the road.  Try to alleviate their real concerns before agreeing to such a thing because more than likely what will happen is that they will strongarm control of the project and phase you out, or they will cause massive chaos and a failed project.

EDIT: Unfortunately that ship has sailed for you, but don't despair just yet.  There are still things you can do to greatly minimize the pain that will come.  No matter what, make absolute sure that their is ONE AND ONLY ONE PROJECT MANAGER and PRODUCT OWNER and that this person is associated with your organization/company.  This person must have the ability to plan sprints, include or remove user stories and assign tasks to resources in your company as well as your client's company.  Whatever happens, please make sure that development resources at your company do not work seperately from your clients resources and even more importantly DO NOT allow developers in your company to report to their project managers or product owners!  They will either take complete advantage of free work not covered by the contract or they will snub you out of your own project.  It is a certainty.

Title: What is the best way to allow a client to contribute to a project?

Body:
We've been building a CRM for a client. Now that the first major phase has been finished, and a second one agreed upon, the client would like to pick up some of the work, making minor amendments to the database schema and business processes the first phase while we build the second.

I'm undecided whether this is at all practical, but assuming it is, I'd like some pointers on which measures can be taken to make this at all workable. Here's what I've got so far:

Until now, the client has mostly seen the project from a user's point of view; clearly, a two-part seminar ought to take place where we introduce him to the inner workings:

first, showing the existing database schema and, by way of example, extending it,

then, showing some sample code, and writing a new business process for the schema enhancement.

The code currently resides in an internal Subversion repository. While we could set up a public one or one on his network (which we can VPN to), I feel a distributed system would work better. I appear to be the only one who feels that way, however, so I could use some good convincing arguments.

I'm not sure how to mandate/ensure that code that runs in production is committed. Seems like "x made a critical, undocumented change right before going on vacation; now y's trying to figure out this bug that's been occurring ever since" disasters are inevitable. Ideally, all changes, before deployment, would:

be documented in an issue tracking system,

occur on a separate testing environment first, and

have to pass automated tests.

Alas, I doubt the discipline for any of those will prevail.

Assume that a plug-in architecture or separate project aren't viable options, because 1) the former doesn't exist, and 2) the latter would prohibit the client from looking at and possibly modifying existing code, an ability I believe he would insist on.


答: Your client should definitely be given a walk-through of how everything is set up, it should have been a requirement for sign off on the first phase. You should push back on allowing your client to edit anything directly, he should fill out a change request that is entered into your issue tracking system and prioritized with the rest of the work.  It will be up to you and your client to decide which requests are out of the scope of the contract. How this happens should be designed in some sort of change management workflow/document, if one doesn't exist I highly suggest you create one and get your client to agree that this is the process through which he can change things, and get this in writing. Otherwise there isn't much you can do other than pray nothing goes wrong.</p>


答:
I'm in exactly the spot you envision your successor being in. I was tasked with adding features to a legacy program that used Clojure and Erlang to do asynchronous searching and turn it into a program that does distributed asynchronous searching. When I came into this job, all I knew was Python and Java.

My advice to you: use the best tool for the job. If that tool is Clojure, then so be it. Programming languages aren't that hard to learn. Well written code in a language that's appropriate to the task at hand is always easier to read than code that attempts to do something that the language wasn't designed to do. It'll be easier for your successor to read clean Clojure than mangled Java.

Title: Problems (such as maintenance) in development with unpopular language

Body:
I'm developing some application with clojure(lisp) alone in my team. It starts as small application. No problem. But as it's having features and extending the area, it's becoming important program.

I worried about maintenance or something. No one in my team knows clojure or lisp nor is interested in languages such as them.

So, isn't it wrong to do programming in unpopular languages? (for my own fun?) Should I use more popular languages? (at least such as python)

I'm sure if I leave the team, --not saying I'm leaving. :)-- no one would maintain it. This program will be destroyed and some will develop with other language.

I'm very enjoying developing with clojure though, I came across with that this might be not for my team.

What do you think about this? I think many programmers loving unpopular languages have been concerning similar issue.


问:
What is the origin of sessions, by whom and when were they created?
I know sessions are in PHP, ASP, ASP.NET and probably in many other languages. In most cases session solve a problem which the language itself fails to solve. I am wondering

Who created sessions and when were they first introduced?

Was it a feature of a particular language first?

Is the use of sessions limited to web browsers only? Or are they used in desktop applications  as well?

答: Sessions are an answer to HTTP being a terrible protocol for most internet traffic. Sessions are a means of maintaining state, which has to be managed this way because HTTP is a stateless protocol, unlike most other commonly used protocols. Its the result of a poor choice made a long time ago, that worked well for what the internet was at that time, but has since caused a lot more problems, but its too late to change.</p>


问:
What function or method can I use to equally distribute a workload
This is more of mathematical question than an algorithmic one; nevertheless it will be implemented in php.

I have an array of N tasks. Each task has taken t time to complete(e.g. task 1 has taken 5 hours to complete.) Now, in order to review that these tasks were completed correctly, I have to assign a certain number of users U to review each of them. Each user will be assigned a certain number of tasks, ideally, with each user having roughly the same amount of hours assigned as the other.

E.G.  There are 10 tasks. task 1 took 4 hours, task 2 took 18 hours, task 3 took 6 hours...etc... totaling 80 hours.

There are 8 users.  If each of the 8 users is to ideally have the same amount of hours (some users get more, yet less lengthier tasks, some users get less, yet lengthier tasks), what is a good way to automatically sort assign the tasks?

答: This is an instance of the open shop scheduling problem. The problem is NP-complete, so you'll want to apply some heuristic, such as the one described in the Wikipedia or perhaps one of the genetic algorithms in this paper.</p>

OwnerDisplayName: John


问:
When there are multiple scrum teams, how often should the 'scrum of scrums' meet and who should attend?
When there is too much work for one scrum team to manage, multiple teams are created. A scrum team has a stand up meeting everyday. How often should the intra-scrum team meeting occur and who should attend? What should they talk about?</p>

答:
Initially, I would plan to have a "Scrum of Scrums" once a week, preferably on a similar schedule to your planning sessions and retrospectives.  As far as who should be in attendance, I would advise you to have each team elect a member that will participate and speak on behalf of the team, but leave the door open for any team member to attend should they want to.

The beauty of Scrum and Agile methods as a whole is that there is no single magic recipe.  The advice that I gave about the schedule and attendees should be fluid and easily modified.  The best kind of agile, at least in my experience, is organic agile.  It's difficult to be truly agile when you're dogmatic about your processes. ;)

ContentLicense: CC BY-SA 2.5


问:
When making a website. How do you keep track of an ever growing set of url parameters and expected values?
A website I'm making has been growing larger and larger feature wise. Which means there's more URL parameters that get passed from page A to B or B to C, etc.

Does anyone have any tips for how to keep track of and use parameter keys and expected values?

Ex. Say a url I need to build is www.example.com?type=this&mode=a

Is there some kind of a system that will let me easily keep track of the fact that the "type" parameter key is in fact "type"?

I tried to keep them all in a constants class, but that class quickly grew out of hand.

```<code>public class URLParameters {

  public static final String TYPE = "type" ;
  public static final String MODE = "mode" ;

  //more "keys"

  public static class Values {

    public static final String TYPE_THIS = "this" ;
    public static final String TYPE_THAT = "that" ;

    public static final String MODE_PRIMARY = "a" ;
    public static final String MODE_SECONDARY = "b" ;

    //more expected values
  }

}
</code>```

答:
I've always used globally accessible objects that are responsible for managing all variables in and out. This prevents duplication of code by having a singular method such CreateQueryString() and properties on the object that are instructed to look for specific keys. This allows you to put in extra data scrubbing if you need, etc. It also allows you to discard invalid keys that might have unintended consequences if the structure you're using is vulnerable to it.

I always try to keep my query strings short, but I recall a job I did in FuseBox a ways back that we had to employ this method. When you get right down to it, that's basically what FuseBox is. It's an object structure that uses structured query strings to control the presentation of the site. Our implementation, however, was geared towards specific global functionality.

The drawback to this method is that it then becomes a requirement that any page which expects to use a query string variable will have to register that variable as a property in the global object. While this will help prevent the duplication or reusage of specific keys, it will still be a little tedious and possibly even cumbersome.


答:
Web clients (browsers) communicate with web servers using a protocol called HTTP. HTTP was deliberately designed to be a stateless protocol., that is each request and response stands on its own, the server doesn't retain any record of completed responses, and doesn't link together the series of requests from a single user. Why was HTTP designed to be stateless? Primarily because it makes HTTP servers much easier to design and code, and makes them much less demanding of memory. HTTP was designed primarily as an information retreival system and there was almost no notion of using it as an application programming platform. Even today most HTTP traffic consists of simple requests and responses with no need for state.

Around 1992-93 folks started writing web applications (as opposed to simple web pages). They immediately ran into a need to store the state of the application over multiple pages. They began writing extensions to the web server that could store and manage state using cookies and url rewriting to associate HTTP requests with particular sessions. As awkward as this is, it has the virtue of flexibility. If folks designing HTTP had tried to specify a general purpose state mechanism, they probably would have gotten it wrong, and we'd be stuck with it as part of the standard. ASP, PHP, JSP, and the other server side scripting languages are the offspring of those old web server extensions.

Many other network applications use the notion of a session (SSH and SMTP for example), but the contents of the session are hardwired to the details of that application.

Title: What is the origin of sessions, by whom and when were they created?

Body:
I know sessions are in PHP, ASP, ASP.NET and probably in many other languages. In most cases session solve a problem which the language itself fails to solve. I am wondering

Who created sessions and when were they first introduced?

Was it a feature of a particular language first?

Is the use of sessions limited to web browsers only? Or are they used in desktop applications  as well?


答:
There are a few different ways to apply regulation to any profession - a well-defined body of knowledge, a code of ethics, accreditation of education programs, certification and licensing, and professional societies that support professional development as well as the other aspects of a profession. Software engineering has most of the characteristics of a profession.

I like to think of it as starting with the Software Engineering Body of Knowledge (SWEBOK) and the Software Engineering Code of Ethics and Professional Practice. Although common acceptance of these is still fairly limited, I think that they serve as a good base to identify the types of things that someone identifying themselves as a software engineer should have a knowledge of and how such a person should act in a professional capacity. That doesn't mean these are hard rules, but rather these documents guide professional software engineers as to what is typically relevant to the work that they might be asked to do. The SWEBOK is revised from time to time to ensure that it stays relevant.

The next characteristic is the accreditation of education programs. In the US, accreditation of software engineering programs is handled by ABET. They also accredit computer science, information technology, computer engineering, and other computing-related professions. ABET posts their requirements of accredited programs on their website - software engineering is considered an Engineering Program. The purpose of accreditation is to ensure consistency among graduates of different engineering programs, at least in terms of the subject matter taught in the classroom. It says nothing about the quality of the education.

After graduation, certification and licensing are used to assess knowledge learned in the classroom (and, in some cases, on the job) against the standard bodies of knowledge. Although the accredited schools have a defined body of material to be taught, there isn't a measure of how well this material is taught and how much students learn at the completion of the program. Certification and licensing provide methods to do that - everyone takes the same exams and demonstrates a knowledge in the various bodies of knowledge that the profession is rooted in. In software engineering, the IEEE offers certifications that are rooted in the SWEBOK - the Certified Software Development Associate for seniors and recent graduates and the Certified Software Development Professional for those with industry experience. For these to add value, it requires the acceptance of the SWEBOK as a good definition of what software engineering is.

Finally, professional societies maintain the guiding documents for the profession, facilitate conferences and publications for the exchange of knowledge and ideas, bridge gaps between academia and industry, and so on. The two leading societies are the IEEE Computer Society and the ACM, but there are other societies around the world. These wrap up everything into a nice little bundle and help deliver information to the right people.

From here, there are other questions to ask. Is the development of software an engineering discipline? Does certification or licensing add any value to software engineers? Is certification useful?

I don't think that all software development needs the rigor of an engineering discipline. That's not to say that an empirical, scientific study of the science and engineering of building software doesn't help everyone - it does. However, there's a is a big difference between developing the latest video game, developing the embedded software for a pacemaker, or building the next space craft. The emphasis is different on all of them - two of the three deserve the attention of a skilled engineer. The other can learn from engineering practices, but doesn't need to rely on them to successfully complete the project.

Certification and licensing requires an accepted body of knowledge. The SWEBOK is a good document that provides a solid foundation, but it isn't widely accepted. Unless you can base your academic programs and certification/licensing exams on something concrete that would be accepted by practitioners, then there's really no point. If the SWEBOK or alternative document becomes widely accepted (at least in those fields that require the rigor of engineering), then certification or licensing exams can be used to gauge the understanding of required knowledge.

However, there is one glaring problem with certification - it's a test on a book. Some people are good at reading, learning, memorizing, and taking a test. However, that doesn't mean they are a good engineer. People slip through the cracks all the time. A certification or license is only a single step. On the job training and mentoring by other experienced engineers is mandatory to groom a good practitioner. In addition, the ability to prevent people from practicing in critical environments can also help to mitigate the risks to society and businesses.

A good book with a fairly in-depth discussion of this is Steve McConnell's Professional Software Development: Shorter Schedules, Higher Quality Products, More Successful Projects, and Enhanced Careers.

Title: Regulation of the software industry


答:
It's certainly not wrong to do programming in "unpopular" languages. Why do you actually care if they are popular or not? I fully agree with @quanticle on this. If Clojure or another non mainstream language is the best tool for the problem you are solving, you should pick it.

I don't see why maintenance will be a problem. If you apply Unit, Integration, etc. Testing and document your code any programmer with interest in functional programming will be able to maintain your program. IMHO the fact that your colleagues don't care about Clojure isn't a good argument for not using it, except if it's a company's policy that you need to respect.


问:
Is it significantly costlier to fix a bug at the end of the project?
In a blog post by Andrew Hay, the following axiom was posited:

It costs significantly more to fix a bug at the end of the project that it does to fix the same bug earlier in the project.

However, this doesn't seem certain, especially after reading a blog post on Less Wrong, and the data I've seen to back it up is extremely old.

Is this still axiom accurate today?

答:
While I'm not aware of any hard data or other evidence to support this claim, at a bare minimum, I'd figure it's common sense.

Think about it this way.. If you have a complex system with inter-dependent subsystems (as most non-trivial applications do), think about knock-on issues that may be a result of changes made to any one of the systems. If subsystems are proven to be correct (via unit tests and the like) and fixed early, the number of bugs that will be caused due to knock-ons alone are mitigated simply by fixing early.

Also, if you're fixing bugs early, the implementation is still fresh in the developer's mind. Depending on the length of any given project, if you're fixing bugs at the end, the developer will need to spend time figuring out what they wrote and (perhaps) how the subsystems that their code depends on works. Time spent re-learning this = $.


答:
Early bugs will propagate to other parts of the system so when you fix the bug you may be forced to rewrite some parts of the system that relied on the bug itself.

Beside over time you'll foget how some parts of the program are built and you'll need to remind yourself. It's some form of technical debt (if you rush the project in early stage you'll have problems with finishing it because of shortcuts you have taken).

It's as simple as that and there's nothing to proof.

I think you're trying to rush the project as fast as possible to present some working solution to your employee. Good news is that you'll have it very fast, bad news is that you probably will never finish it without complete rewrite if you just keep writing crap as fast as possible and plan to fix everything in a couple of months. You probably won't even be able to refactor this.

Title: Is it significantly costlier to fix a bug at the end of the project?

Body:
In a blog post by Andrew Hay, the following axiom was posited:

It costs significantly more to fix a bug at the end of the project that it does to fix the same bug earlier in the project.

However, this doesn't seem certain, especially after reading a blog post on Less Wrong, and the data I've seen to back it up is extremely old.

Is this still axiom accurate today?


答:
In some cases, a language like Lisp can make it faster or easier to implement functionality that would be very difficult in a different language. It also influences the way you look at problems, giving you a perspective that others on your team may not have. Having a wider array of capabilities and a broader view of what's possible can be very valuable to a company that's able to understand and use them. The price for those capabilities, though, is a lack of standardization.

Many companies try to standardize on one or two languages because it gives them more organizational flexibility: they can move developers from one project to another without having to retrain them, they have a built-in reserve of knowledge about the languages that they do use, and managers don't have to consider the strengths and weaknesses of using one language or another for a given project. When all you've got is a hammer, everything looks like a nail.

As I've outlined, both approaches have certain benefits and drawbacks. As is so often the case, there's not a right or wrong approach. You're just trading one set of benefits and drawbacks for another. A company doesn't have to go entirely in one direction or the other, either. It's perfectly reasonable to do most work in C++ or Java, but dip a toe into Lisp or Python from time to time to try them out and see what works. It sounds like that might be what your company is doing.

So go forth (but not Forth), learn as much as you can, and become the Clojure expert that your manager can rely on for insight that your colleagues might not have. And don't feel bad about it... worrying about the organizational stuff is your managers job.


答:
Silicon Valley News - June 31, 2015

Horror: Uncertified programmer made program abort

"I'll never be able to run again", outputs the victim. Police is investigating.

Criminal: License of Dr H. Acker Jr. revoked for incorrect use of pointer and attempts to read from system file

Advocate says there is going to be appeal to Supreme Court.

Announcements: Cobol programmers certified in 1975 should recertify no later than 2025

IEEE confirmed certification did not change since.

Ads: Certification guaranteed with Magic Knowledge Stuffers, Inc

Teach yourself programming in 21 days.

Title: Regulation of the software industry


答:
Well, I probably can't give you the definitive proof you're asking for, but I can relate a fairly recent incident from my work.

We added a feature that provided workflow management capabilities to our product. Typical BDUF stuff, specs signed off and approved by the client. Implemented to spec. Complaints from Day 1 on deployment.

We hadn't done a real usability walkthrough with the client, just taken their word for what they wanted. Result: hundreds of hours of rework - analysis, design, implementation, and QA had to be redone.  All because the spec missed particular use cases.  A bug in the specification, if you will.

I've seen similar things in prior jobs when someone in the chain makes assumptions that are different from the end-user assumptions. Straight-up coding bugs are relatively easy to deal with if caught close to when they happen, but design bugs can kill entire systems.


答:
I doubt that it's at all possible to come up with a scientifically rigid way of measuring this - there's just too many other factors involved, and no two projects are comparable enough to serve as more than case studies. Logical thinking should get you a long way though. A few arguments:

The total amount of code in a project tends to grow toward the end. The longer you wait fixing a bug, the larger the codebase that you have to touch.

The quality of new code added to a project decreases toward the end, at least if there is pressure (which is usually a given): a looming deadline makes people throw best practices overboard just to ship on time. This means that the later you fix a bug, the more bad code you have to sift through.

Even though code duplication is generally frowned upon, it happens all the time, and since it is easy to copy-paste, but hard to re-merge duplicate code sections, the amount of once copy-pasted code typically increases over the lifetime of a project. More copy-pasted code means a higher chance that your bug is going to be duplicated and needs to be found and fixed several times (and consequently, a higher chance that some of its occurrences go unnoticed).

Fixing a bug is a change to a codebase; you hope to make things better, but a change always carries a risk. A change that causes a serious problems in a project with months to go should leave plenty of headroom for damage management, but two days before shipping, you're in for serious trouble.

The longer the bug itself exists, the more likely it becomes that other parts of the application start relying on its misbehavior. Then when you fix it, you suddenly unleash a bunch of secondary bugs in code that doesn't expect your function to actually provide the correct documented results.


问:
What are the advantages and Disadvantages of Using an Aspect Orientated Programming Paradigm
Ok so here is the question: What are the advantages and Disadvantages of Using an Aspect Orientated Programming Paradigm.

My advantages and disadvantages thus far:

Advantages:

Complements object orientation.

Modularizes cross-cutting concerns improving code maintainability and understandability.

Disadvantage:

Not the easiest of concepts to grasp - not as well documented as O-O

O-O goes far enough in the separation of concerns...

Would anyone like to challenge any of these/ add their own?

Many Thanks,
J

答:
Additional Advantages (not all of them)

Reuse of classes and aspects, thanks to modularity

Reduced cost of coding thanks to modularity and reuse

Shorter code thanks to the ability to have an aspect with the code that would otherwise be implemented (scattered) into several classes

Ability to add behavior to a class without introducing in it code unrelated with its main responsibility

Ability to redefine the semantic of methods/classes without letting client classes know about it

Disadvantages

Runtime overhead when using some constructs, e.g. cflow


问:
How do I "hand over the keys" to a webserver I'm hosting?
I only have a verbal hosting agreement in place with a customer.  Unfortunately the relationship has deteriorated to the point of no return, and I'd like to end the hosting agreement and hand them over the root password.  This is a virtual dedicated server I pay for, and then they pay me.

They are fine with this, but the problem is I don't trust this client even a little bit.  Can I get them to sign something saying they release me from liability to changes made on the server once I give them the password?  How is the root password usually given to clients who request it while making sure they don't come back later on and blame you for breaking the server?  Does simply the act of giving them the root password infer that you are handing over complete control and thus complete responsibility?

答:
When you give him the password, at the very moment, tell him to change it and give him instructions on how to do that.

(If you can force it be changed on next log in, all the better)

Honestly, I think you are worrying over nothing, If he accuses you of tampering, ask him to produce the server logs proving it, or STFU.

Lastly,
If you don't have a written contract simply telling him "we are done" is enough to rid yourself of the "responsibility.". If you do, you will need some other document amending the original contract releasing you both of your obligations. (Here consult a lawyer)


问:
Which tools to use for Embedded Linux C++ development with a fast compiler and possibly cross platform
I'm not happy with our build environment for our Linux based (Ubuntu 10.04) equipment. It is embedded software we are developing. What I would like is to have the optimal mix of these wishes:

Use proven tools and libraries

Be able to develop on both Linux and Windows

Ideally: use the same tooling on both platforms

Have a fast development cycles, especially on Windows

Note that paying for good stuff is definitely an option. Note also that C++ and Linux are the only two hard requirements, everything else is open for debate.

We currently use Boost and STL libraries for obtaining as much platform independence as possible. CodeBlocks is our cross-platform IDE and we use the gcc tool-chain (compiler, linker, debugger, not make). All are excellent open source projects but they have their limitations.

Biggest problems with the current environment:

Compared with MS Visual C++, I feel gcc is very slow. A lot of time is spent compiling and especially linking. gcc's pre-compiled header support gives you no way near the same performance gain as with VC and with boost you really need it. Also, statically linking a few boost libraries takes forever. (Would using dynamic linking change much?)

CodeBlocks has no support for what in VC are property files. This makes it difficult to enforce that build options are the same for all projects in the workspace.

Related to build speed: CodeBlocks has no "compile this project only" support like VC has. When changing a single source file, CodeBlocks spends too much time checking for the need to compile files I know haven't changed.

Some of my own thoughts so far:

Biggest issue is having a fast, reliable compiler and linker on all platforms we develop on. If this is solved what about doing development on multiple platforms? Are Intel C++ compilers an option (we don't really need the performance optimization of those compilers)? Should we consider doing cross compilation?

Should we use a make based build? It seems a solution when it proves difficult to use the same IDE/build tooling on windows and Linux. I find make difficult so that is holding me back.

Is there a single product of equivalent maturity as Visual Studio (IDE and tool chain) available for Windows and Linux? Or for that matter, for Linux only?

How much simpler would life be if we decided develop only on Linux? Right now we all use Windows as it is supported by IT, our non-development software is all windows and we have limited Linux expertise in our company.

Your thoughts please.

答:
You could use MinGW to get the same tools you use in the Linux/Unix environment into the windows environment.  You could also use cygwin on windows to accomplish the same.  I would write my own makefiles and use gcc (but it looks like you don't like gcc).  I'm not sure of a better, free alternative to gcc.  Personally, I would just use VIM or Emacs, GDB and use these tools on all environments (or learn to love Code::Blocks).

The idea with *nix and C development is that the whole environment is your build/development environment... windows, not so much.


答:
Contact the hosting company, ask them how to transfer the VPS to your client. Add a statement that you want them to reset the password on behalf on the client when the transfer is completed. There may be a service fee but your client can pay for it.

That way the ownership (and billing) is transferred to your client so the hosting company can easily support them in the future, plus you go on the record for requesting the password change.

Or, download the site files/configuration etc and send them to client for them to install on their own new server.

Title: How do I "hand over the keys" to a webserver I'm hosting?

Body:
I only have a verbal hosting agreement in place with a customer.  Unfortunately the relationship has deteriorated to the point of no return, and I'd like to end the hosting agreement and hand them over the root password.  This is a virtual dedicated server I pay for, and then they pay me.

They are fine with this, but the problem is I don't trust this client even a little bit.  Can I get them to sign something saying they release me from liability to changes made on the server once I give them the password?  How is the root password usually given to clients who request it while making sure they don't come back later on and blame you for breaking the server?  Does simply the act of giving them the root password infer that you are handing over complete control and thus complete responsibility?


问:
Using XML field Vs. creating a table for unstable organization
I am in the middle of design an application to issue and store invoices for an organization. The problem is the organization is not stable at all. There are many types of invoices and they may increase and change.

First, I tried to use tables in my DAL, one table to store invoices, one for invoice fields, and one for invoice field values. The problem was, this way needs Reflection to detect fields later, and this may slow the application when invoice contains plenty items.

Second, I tried to keep core of invoice data as two tables: invoices and invoice items. Other fields are fully catchable from other tables. I mean, Business Layer should provide different results per invoice type. It should choose the right queries, and process the results according to the type of invoice. Two problems with this solution are:

I still have lots of join between other tables when I want to show
an invoice, for per invoice item. I should recalculate everything
every time for every invoice item.

What if the invoice items table doesn’t support a new type of
invoice? Then I probably should add a new table to store that kind of invoices items.

My client asked me to keep all data related to an invoice, they do
not want me to recalculate it every time. They want something like a
snapshot of related data at the time invoice is creating.

Now, what I’m think can I use the benefit of XML in table? I can save the invoice, with whatever fields as xml.

I can save the different version of their invoices.

On changes, I only update my Business.dll and no DAL change required.

Linq to XML is not slow.

What do you suggest?

答:
I have tried something similar and been caught out!

In my case the system proved a little too successful, and now stores 2.5 million transactions each with a blob of Xml data. The size of the database is now around 25Gb, and backups are starting to take a long time.

The main problem is that Xml in databases doesn't compress well.

I'm thinking of a redesign now, where the Xml documents are stored on the file system. They're transactional in nature, e.g. write-once, read-many and never update.

Xml files on the file system can be compressed or archived as needed.

There are some considerations. My servers use NTFS, so even the smallest file occupies 4kB of diskspace (compression will help with that). Security and backups also need to be considered.


问:
When do you know it's time to move on from your current job?
Have you ever reached a point at your job when you just know it's time to move on?

When do you move to the point that you're willing to let go of the demons you know for the ones you don't know?

What was your deciding factor final straw so to speak when you finally faced the decision to find a new job?

答: I have a mathematical formula that I apply in my head on about a monthly basis.  I call it the pay-to-crap ratio  It works thusly: does the amount of pay I receive seem to offset the amount of crap I have deal with, crap being defined as the things outside of my core job responsibilities of software architecture and development (i.e. corporate mandates, re-organizations, bungee bosses, seagull management, budget reductions, benefits changes, etc.).  If I feel that the crap quantity is overpowering my pay quantity, I'll talk to my boss about increasing my pay and/or reducing the crap.  If neither of those are possible: sayonara, job.


答:
Perhaps you may be over-thinking this. Arrange tasks in a simple queue and order according to priority. Having each user take the first task available should be enough.  Longer tasks might take longer to review, and short ones less time, therefore the order in which users appear to collect the next task will change as they finish the previous task and come forward for the next.  This doesn't really need to be too complicated.

Pre-allocating tasks can have some serious drawbacks.  This is basically a push system, and it  tends to result in "waste" more often than not.  Implementing a pull system would be much more efficient, and less wasteful in terms of scheduling and resources, as you won't end up needing to manage synchronization issues if work estimates are either wrong, or become interrupted by changing circumstances within the team.

Title: What function or method can I use to equally distribute a workload

Body:
This is more of mathematical question than an algorithmic one; nevertheless it will be implemented in php.

I have an array of N tasks. Each task has taken t time to complete(e.g. task 1 has taken 5 hours to complete.) Now, in order to review that these tasks were completed correctly, I have to assign a certain number of users U to review each of them. Each user will be assigned a certain number of tasks, ideally, with each user having roughly the same amount of hours assigned as the other.

E.G.  There are 10 tasks. task 1 took 4 hours, task 2 took 18 hours, task 3 took 6 hours...etc... totaling 80 hours.

There are 8 users.  If each of the 8 users is to ideally have the same amount of hours (some users get more, yet less lengthier tasks, some users get less, yet lengthier tasks), what is a good way to automatically sort assign the tasks?


答:
The only hard data I've ever seen is Boehm and Papaccio, Understanding and Controlling Software Costs.

This stems back to 1988 and was a study of around 80 software projects. They concluded that a decision made early and corrected late could cost 50-200 times what it would have if it had been corrected early. But the kind of very early decisions they're talking about are which OS to run on and which language and database to use.

So those figures may be overwrought with respect to today's software development. However, now we have a lot of experience in the field and we know instinctively that it still holds true to a point.

In the extreme, we know that if a failure in requirements is caught just before we go to production, this causes a lot of rework and get the project delayed or indeed cancelled, where if it had been caught before any work had been done, we'd have been fine.

Edit: Doc Brown makes a good point in his comment.

Boehm's research was done on COBOL and FORTRAN projects in a time when compile and run times were ridiculously slow. I started my career in the early 90s on COBOL and the compile and test cycle used to take so long that it was worth the effort to dry-test the code before going through the cycle (or at least during the build phase, just in case you could catch something and cancel it early, saving yourself an hour or so).

In turn, our bosses used to laugh at our complaints because it wasn't so long ago they used to have to carry a box of hand-sorted punch cards to the server room and leave it there for a day.

So it was definitely more true then than it is now.

And yet, very recently, I've seen blogs reusing Steve McConnell's visualisation of this problem (ref, dated 1996) as if that graph was actually based on hard numbers. It isn't. It's a visualisation, to explain his point simply.

I think that Morendil's premise, in the article the OP quoted, is a good one. The science we have on this subject is poor and outdated and yet treated as canon. But I also think that it holds up well and sounds true because we know from bitter experience that it is still true, at least to a point. And I think his dramatic "diseased discipline" phrasing does him no favours.


问:
HTML5 video sprites
I'm currently working on a project where there is a requirement to dynamically composite multiple synchronised video sources onto a single canvas. The initial prototype I put together loaded the video into HTMLVideoElements and then used requestAnimFrame (via Paul Irish's shim) to draw these onto a single canvas and maintain sync between the different elements.

Although this is functional and the system can hold sync fairly well (+/- 80ms tolerance) it is somewhat inefficient to say the least. I've been thinking about optimisations and one approach that seems pretty straight forward is to combine all the media into a single larger 'video sprite' and serve this. This would allow it to be load into a single video element which could then be used extract and render the areas of interest client side using drawImage() and remove the need to manage sync between sources.

Has anyone else implemented something similar in the past? If so what approach worked well for you?

答:
Have you checked out popcorn.js?

Popcorn.js is an HTML5 media framework written in JavaScript for filmmakers, web developers, and anyone who wants to create time-based interactive media on the web. Popcorn.js is part of Mozilla's Popcorn project.

http://popcornjs.org/

Title: HTML5 video sprites


问:
How do you assign error codes?
How, when developing a medium sized project, do you identify, create and maintain error codes?

I for the life of me can't think of a simple and clean method of doing so. Some of my ideas convert class names and method name into an integer string, but that is way to long to display to the user on top of the fact that method names and class names may change (hopefully not!). Others are just using an incrementing log system (ie. when ever I create a new error message, just add 1 to the last error message id). But that is just completely unorganized.

To be more specific I am talking about error code such as:

Error 401 Unauthorized.

答:
I'm going to assume a procedural context (C). If you have objects an error object is usually better, whether exception or not.

You should use error codes local to each module. For a library you can have a special header listing the error codes, with number 1, 2 etc (or -1, -2 if you prefer). Make sure to always return one of these codes, e.g. translate errno into your own codes. If you have multiple layers of modules, translate at each step (or predefine a range for the deeper error, e.g. values 1001 - 1050 is from that other module).

It is also important that you provide a means for translating the code into a string. You should never report only the code, that only leads to frustration. Actually pretty much any code in your application should come with a string translation function. For example libc typically has strerror and strsignal, but sadly lacks strwaitstatus.

Title: How do you assign error codes?


问:
What is the best way to handle product versioning and branching of long term projects?
In a general sense, for long term projects that may have multiple releases during the products life cycle and require support of previous products, what is the best way to handle product versions and branching of the code base?

In a more specific sense, assume that proper distributed version control is in place (i.e. git) and that the teams are small to large in size and that developer may be working on multiple projects at once. The major issue that is being faced is that there is a contractual obligation to support old versions as they existed at the time which means that new development can not patch old code (Microsoft Office products could be an example of this, you only get patches for the feature year you own).

As a result the current product versioning is a touch convoluted as each main product has multiple dependencies, each with their own versions which may change between annual releases. Likewise, while each product has its own repository, most of the work is not done on the main source trunk but rather on a branch for that years product release with a new branch being made when the product is released so that it may be supported. This in turn means that getting a product's code base isn't a simple matter as one might think when using version control.

答:
This question seems to be very similar to another question that I answered recently.

In short, this sounds more like a product design and distribution problem more than a version control/branching problem.  Of course, it's easy for me to say that and harder for you to fix if you are already neck deep in the problem.

Without knowing in greater detail the specifics of your particular problem.  In general however, if I had multiple versions of products based on a code base that had a large amount of shared code between products, If it was feasible I'd look to refactoring products in a way that would make them more modular, and to ensure that the modules themselves would not require additional branching of code. I'd also look at my deployment model, to see if there was a better means to support my customers while still keeping much of the code base unified. Where specific customer customization is required, greater granularity of the modules might be needed to reduce the amount of duplicated code in the system.

It's not an easy task, but fixable in stages if you manage the job well, and if you can schedule the work so that you don't need to "upgrade" everything all at once.


答:
Overall this is a good plan. Implemented a few things that are remarkably similar in my day. If I were starting design of something like this today I would strongly consider using a document database rather than SQL but that die may already be cast.

If you are using SQL, I would advise pushing as much data outside of the invoice and into the table -- it is loads easier to query on and understand on the fly. Stuff inside XML is a bit trickier to get at.

One thing you posted deserves a bit of discussion:

On changes, I only update my Business.dll and no DAL change required.

Data format or schema changes within the invoice are probably the hardest thing to deal with here. Presuming you are using XmlSerialization, changes to the underlying object can result in crashes at best or silent data corruption at worst. You really need to build in an invoice schema versioning plan from day zero. Exactly what to do depends in requirements, and with XML it is pretty easy to modify the underlying data without hydrating objects, but you will need to do something at some point if this system is expected to live for any significant length of time.

Title: Using XML field Vs. creating a table for unstable organization

Body:
I am in the middle of design an application to issue and store invoices for an organization. The problem is the organization is not stable at all. There are many types of invoices and they may increase and change.

First, I tried to use tables in my DAL, one table to store invoices, one for invoice fields, and one for invoice field values. The problem was, this way needs Reflection to detect fields later, and this may slow the application when invoice contains plenty items.

Second, I tried to keep core of invoice data as two tables: invoices and invoice items. Other fields are fully catchable from other tables. I mean, Business Layer should provide different results per invoice type. It should choose the right queries, and process the results according to the type of invoice. Two problems with this solution are:

I still have lots of join between other tables when I want to show
an invoice, for per invoice item. I should recalculate everything
every time for every invoice item.

What if the invoice items table doesn’t support a new type of
invoice? Then I probably should add a new table to store that kind of invoices items.

My client asked me to keep all data related to an invoice, they do
not want me to recalculate it every time. They want something like a
snapshot of related data at the time invoice is creating.

Now, what I’m think can I use the benefit of XML in table? I can save the invoice, with whatever fields as xml.

I can save the different version of their invoices.

On changes, I only update my Business.dll and no DAL change required.

Linq to XML is not slow.

What do you suggest?


答:
If you fix the bug after release, then you have the cost of finding and fixing the bug - which may or may not take more time/cost to do post release. However you have a round of Integration testing, regression testing, UA testing, release activities, etc that will need to be accounted for. Unless the bug fix goes in with a number of other fixes or a version update you will have additional expense for the testing and release activities that would be avoided by including the fix in the initial release - because these costs would be shared over a number of fixes/updates/features.

Also consider the cost that the bug will cause in use, if is just cosmetic, then it probably does not matter, but a function or performance bug could create a cost with support activities or reduced productivity or incorrect calculations.


问:
Exceptions as asserts or as errors?
I'm a professional C programmer and a hobbyist Obj-C programmer (OS X). Recently I've been tempted to expand into C++, because of its very rich syntax.

So far coding I haven't dealt much with exceptions. Objective-C has them, but Apple's policy is quite strict:

Important You should reserve the use of exceptions for programming or unexpected runtime errors such as out-of-bounds collection access, attempts to mutate immutable objects, sending an invalid message, and losing the connection to the window server.

C++ seems to prefer using exceptions more often. For example the wikipedia example on RAII throws an exception if a file can't be opened. Objective-C would return nil with an error sent by a out param. Notably, it seems std::ofstream can be set either way.

Here on programmers I've found several answers either proclaiming to use exceptions instead of error codes or to not use exceptions at all. The former seem more prevalent.

I haven't found anyone doing an objective study for C++. It seems to me that since pointers are rare, I'd have to go with internal error flags if I choose to avoid exceptions. Will it be too much bother to handle, or will it perhaps work even better than exceptions? A comparison of both cases would be the best answer.

Edit: Though not completely relevant, I probably should clarify what nil is. Technically it's the same as NULL, but the thing is, it's ok to send a message to nil. So you can do something like

```<code>NSError *err = nil;
id obj = [NSFileHandle fileHandleForReadingFromURL:myurl error:&err];

[obj retain];
</code>```

even if the first call returned nil. And as you never do *obj in Obj-C, there's no risk of a NULL pointer dereference.

答:
Here's the thing: Because of C++'s unique history and flexibility, you can find someone proclaiming virtually any opinion about any feature that you'd like. However, in general, the more that what you're doing looks like C, the worse an idea it is.

One of the reasons that C++ is much looser when it comes to exceptions is that you can't exactly return nil whenever you feel like it. There's no such thing as nil in the vast majority of cases and types.

But here's the simple fact. Exceptions do their work automatically. When you throw an exception, RAII takes over and everything is handled by the compiler. When you use error codes, you have to remember to check them. This inherently makes exceptions significantly safer than error codes- they check themselves, as it were. In addition, they're more expressive. Throw an exception and you can get out a string telling you what the error is, and can even contain specific information, like "Bad parameter X which had value Y instead of Z". Get an error code of 0xDEADBEEF and what, exactly, went wrong? I sure hope the documentation is complete and up-to-date, and even if you get "Bad parameter", it's never going to tell you which parameter, what value it had, and what value it should have had. If you catch by reference, as well, they can be polymorphic. Finally, exceptions can be thrown from places where error codes never can, like constructors. And how about generic algorithms? How is std::for_each going to handle your error code? Pro-tip: It isn't.

Exceptions are vastly superior to error codes in every respect. The real question is in exceptions vs assertions.

Here's the thing. Nobody can know in advance what pre-conditions your program has for operating, what failure conditions are unusual, which can be checked for beforehand, and which are bugs. This generally means that you cannot decide beforehand whether a given failure should be an assertion or an exception without knowing the program logic. In addition, an operation which can continue when one of it's sub-operations fail is the exception, not the rule.

In my opinion, exceptions are there to be caught. Not necessarily immediately, but eventually. An exception is a problem that you expect the program to be able to recover from at some point. But the operation in question can never recover from a problem which warrants an exception.

Assertion failures are always fatal, unrecoverable errors. Memory corruption, that sort of thing.

So when you can't open a file, is it an assertion or exception? Well, in a generic library, then there are plenty of scenarios where the error can be handled, for example, loading a configuration file, you might simply use a pre-built default instead, so I'd say exception.

As a footnote, I'd like to mention there's some "Null Object Pattern" thing going around. This pattern is terrible. In ten years, it will be the next Singleton. The number of cases in which you can produce a suitable null object is miniscule.

Title: Exceptions as asserts or as errors?


答:
Exceptions were invented for a reason, which is to avoid having all your code look like this:

```<code>bool success = function1(&result1, &err);
if (!success) {
    error_handler(err);
    return;
}

success = function2(&result2, &err);
if (!success) {
    error_handler(err);
    return;
}
</code>```

Instead, you get something that looks more like the following, with one exception handler way up in main or otherwise conveniently located:

```<code>result1 = function1();
result2 = function2();
</code>```

Some people claim performance benefits to the no exception approach, but in my opinion readability concerns outweigh minor performance gains, especially when you include execution time for all the if (!success) boilerplate you have to sprinkle everywhere, or the risk of harder to debug segfaults if you don't include it, and considering the chances of exceptions happening are relatively rare.

I don't know why Apple discourages the use of exceptions.  If they are trying to avoid propagating unhandled exceptions, all you really accomplish is people using null pointers to indicate exceptions instead, so a programmer mistake results in a null pointer exception instead of a much more useful file not found exception or whatever.

Title: Exceptions as asserts or as errors?

Body:
I'm a professional C programmer and a hobbyist Obj-C programmer (OS X). Recently I've been tempted to expand into C++, because of its very rich syntax.

So far coding I haven't dealt much with exceptions. Objective-C has them, but Apple's policy is quite strict:

Important You should reserve the use of exceptions for programming or unexpected runtime errors such as out-of-bounds collection access, attempts to mutate immutable objects, sending an invalid message, and losing the connection to the window server.

C++ seems to prefer using exceptions more often. For example the wikipedia example on RAII throws an exception if a file can't be opened. Objective-C would return nil with an error sent by a out param. Notably, it seems std::ofstream can be set either way.

Here on programmers I've found several answers either proclaiming to use exceptions instead of error codes or to not use exceptions at all. The former seem more prevalent.

I haven't found anyone doing an objective study for C++. It seems to me that since pointers are rare, I'd have to go with internal error flags if I choose to avoid exceptions. Will it be too much bother to handle, or will it perhaps work even better than exceptions? A comparison of both cases would be the best answer.

Edit: Though not completely relevant, I probably should clarify what nil is. Technically it's the same as NULL, but the thing is, it's ok to send a message to nil. So you can do something like

```<code>NSError *err = nil;
id obj = [NSFileHandle fileHandleForReadingFromURL:myurl error:&err];

[obj retain];
</code>```

even if the first call returned nil. And as you never do *obj in Obj-C, there's no risk of a NULL pointer dereference.

Body:
Exceptions were invented for a reason, which is to avoid having all your code look like this:

bool success = function1(&result1, &err);
if (!success) {
    error_handler(err);
    return;
}

success = function2(&result2, &err);
if (!success) {
    error_handler(err);
    return;
}

Instead, you get something that looks more like the following, with one exception handler way up in main or otherwise conveniently located:

result1 = function1();
result2 = function2();

Some people claim performance benefits to the no exception approach, but in my opinion readability concerns outweigh minor performance gains, especially when you include execution time for all the if (!success) boilerplate you have to sprinkle everywhere, or the risk of harder to debug segfaults if you don't include it, and considering the chances of exceptions happening are relatively rare.

I don't know why Apple discourages the use of exceptions.  If they are trying to avoid propagating unhandled exceptions, all you really accomplish is people using null pointers to indicate exceptions instead, so a programmer mistake results in a null pointer exception instead of a much more useful file not found exception or whatever.


答:
In the post that you reference, (exceptions vs error codes), I think there is a subtly different discussion going on.  The question there seems to be whether you have some global list of #define error codes, probably complete with names like ERR001_FILE_NOT_WRITEABLE (or abbreviated, if you're unlucky).  And, I think the main point in that thread is that if you're programming in a polymporphic language, using object instances, such a procedural construct is not necessary.  Exceptions can express what error is occurring simply by virtue of their type, and they can encapsulate information like what message to print out (and other things as well).  So, I'd take that conversation as one about whether you should program procedurally in an object oriented language or not.

But, the conversation of when and how much to rely on exceptions for handling situations that arise in code is a different one.  When exceptions are thrown and caught, you are introducing a completely different control flow paradigm from the traditional call stack.  Exception throwing is basically a goto statement that wrenches you out of your call stack and sends you to some indeterminate location (wherever your client code decides to handle your exception).  This makes exception logic very hard to reason about.

And so, there is a sentiment like that expressed by jheriko that these should be minimized.  That is, let's say that you're reading a file that may or may not exist on disk.  Jheriko and Apple and those who think as they do (myself included) would argue that throwing an exception is not appropriate - the absence of that file is not exceptional, it's expected.  Exceptions shouldn't substitute for normal control flow.  It's just as easy to have your ReadFile() method return, say, a boolean, and to have client code see from the return value false that the file was not found.  Client code can then tell the user file was not found, or quietly handle that case, or whatever it wants to do.

When you throw an exception, you're forcing a burden on your clients.  You're giving them code that will, sometimes, wrench them out of the normal call stack and force them to write additional code to prevent their application from crashing.  Such a powerful and jarring burden should only be forced on them if absolutely necessary at runtime, or in the interests of the "fail early" philosophy.  So, in the former case, you can throw exceptions if the purpose of your application is to monitor some network operation and someone unplugs the network cable (you're signalling a catastrophic failure).  In the latter case, you may throw an exception if your method expects a non-null parameter and you're handed null (you're signaling that you're being used inappropriately).

As for what to do instead of exceptions in the object-oriented world, you have options beyond the procedural error code construct.  One that spring immediately to mind is that you can create objects called OperationResult or some such thing.  A method can return an OperationResult and that object can have information about whether the operation succeeded or not, and whatever other information you want it to have (a status message, for example, but also, more subtly, it can encapsulate strategies for error recovery).  Returning this instead of throwing an exception allows for polymorphism, preserves control flow, and makes debugging much simpler.

Title: Exceptions as asserts or as errors?


问:
Why don't mobile platforms support generational garbage collection?
Both Windows Phone/Xbox and Android lack support for generational garbage collection. This is frustrating for a lot of programmers. There seems to be a legitimate engineering reason to it, but I can't figure it out.

Current phones have more memory and probably better CPUs than the desktops/laptops running .NET 1.1 with generational GC back in 2001, and I can't think of any reasons that ARM processors would be worse at generational GC than x86 would. There's also less need for multitasking on phones and consoles, so there's relatively more free heap space.

So what gives?

Edit: A few points to clarify:

These platforms use garbage collection for apps exclusively, so my question isn't about why GC isn't supported; my question is about why generational garbage collection isn't.

The reason that people are frustrated about the lack of generational GC is that non-genrational GC is extremely inefficient. (That means that battery life isn't the reason.)

I do believe that there's an honest technical reason for the lack of generational GC support. This isn't a rhetorical question.

答:
I think the biggest problem is the battery life. Garbage collection is a developer convenience bought at the price of additional CPU cycles on user's computer. When your CPU is plugged in (desktop) or has a relatively large battery (laptop), your users are more willing to pay for developers' convenience with the additional energy consumed by CPU while doing garbage collection. When the battery is relatively small, the users may not be as generous. They may want that additional bar for themselves - perhaps to talk to their friends, or to kill a few extra pigs in a deadly encounter with angry birds.

No matter what users' reasons are, OS developers do not want to form a perception that the devices running their OS drain battery faster than ones running their competitor's OS. So they buy better perception of their devices' expected battery life time at the price of developers' convenience: to them, your pain is no big deal, as long as the users are happy with the devices.


问:
What should a tester (Quality Assurance) person do on a scrum team?
Coming from a scrum environment with no integrated testing support and an independent minded QA staff, how is a tester (QA person) best integrated with a scrum team? What should they do?

For reference some test functions are:

Unit Testing

Integration Testing

Functional Testing

Performance Testing

Acceptance Testing

答:
Scrum Master

Because the team must have people with cross-funcional skills.

Scrum is facilitated by a Scrum Master, who is accountable for removing impediments to the ability of the team to deliver the sprint goal/deliverables. The Scrum Master is not the team leader, but acts as a buffer between the team and any distracting influences. The Scrum Master ensures that the Scrum process is used as intended. The Scrum Master is the enforcer of the rules of Scrum, often chairs key meetings, and challenges the team to improve. The role has also been referred to as a servant-leader to reinforce these dual perspectives. The Scrum Master differs from a Project Manager in that the latter may have people management responsibilities unrelated to the role of Scrum Master. The Scrum Master role excludes any such additional people responsibilities...


答:
The algorithm shown below provides a solution. I have not tested it throughly, but it should give you an idea. It could only be used only if the sum(resources available time) >= sum(required task review time).

The process starts by examining Task1's required review time and resource 1 availalble time. If the available time is less than or equal the time required by the task, the intersection cell of T1, U1 is filled with the the number of hours that would either fulfill the required review time or the available time for user 1.

Next, we go to task 2 and repeat the process.

If the allocation exhausts a given resource's available time, logic moves to the next resource.

The iterations should stop when this condition is violated or when all resources have been allocated.

In the image below, step 0 is the initial step. I have used an Orange color to show the changes at each step, hoping you can discover the process.

Note:

This process is biased to the way users are listed from left to right and does not distribute work evenly across users. That is, one user may work harder than the rest just because he/she appears before the others.


答:
There is a lovely couple of chapters in Clean Code which talks about this very subject - minus the Apple point of view.

The basic idea is that you never return nil from your functions, because it:

Adds a lot of duplicated code

Makes a mess of your code - I.e.: It becomes harder to read

Can often result in nil-pointer errors - or access violations depending on your particular programming "religion"

The other accompanying idea is that you use exceptions because it helps to further reduce the clutter in your code, and rather than needing to create a series of error codes that eventually become difficult to track manage and maintain (particularly across multiple modules and platforms) and are a pain for your customers to decipher, you instead create meaningful messages that identify the exact nature of the problem, make debugging simpler, and can reduce your error handling code to something as simple as a basic try..catch statement.

Back in my COM development days, I had a project where every failure raised an exception, and each exception needed to use a unique error code id based on extending windows standard COM exceptions.  It was a hold-over from an earlier project where error codes had been previously used, but the company wanted to go all object-oriented and jump on the COM-bandwagon without changing the way they did things too much. It only took 4 months for them to run out of error code numbers and fell to me to refactor large tracts of code to use exceptions instead.  Better to save yourself the effort up front and just use exceptions judiciously.

Title: Exceptions as asserts or as errors?


问:
Why is CS taught to be memorized?
I have been taking Advanced Placement Computer Science for this past year in high school. It seems as though we are taught simply to memorize code and functions and not how to be resourceful and efficient in using documentation and the like.

Practically, I imagine many (if not all) programming jobs would allow you to flip through documentation, review past code and the code of others, essentially doing what my teacher would consider "cheating."

While I do agree core concepts are essential to memorize (in any subject matter), it seems superfluous and impractical to me to give a pen-and-paper exam for a CS class, especially when practically you would have a compiler, debugger, reference manuals, and the entire internet to refer to in any real-world work situation.

Why is CS taught focusing on the memorization of code and functions as opposed to teaching useful skills including how to use and interpret documentation, sample code, the debugger and such?

答:
In a high school class, you're in the most basic level of your path to mastery. Things that are covered in your class are the kind of things that a professional programmer are expected to know cold.  In a lot of ways, this is akin to learning your "times tables". Of course you'll always be able to grab a calculator in a "real-world" setting, but this memorization not only increases your speed in more complex tasks, but also promotes a more thorough understanding of the basic principles.

For example, you should know several sorting algorithms, how they're implemented, how they work, when they're best used, and when not to use them.  This could always be looked up, but shouldn't have to be - anymore than a mathematician should have to look up 6 times 8.

Title: Why is CS taught to be memorized?


答:
It depends on what you are trying to memorize...

In order to study math, for example, you have to be familiar with algebra and you frequently have to be rather creative in how you go about performing algebraic manipulations in order to simplify equations.  But you have to have memorized certain building blocks in order to be able to focus on those interesting bits.  You have to, for example, know your multiplication tables by heart and you have to know some identities so that you can recognize how to manipulate the equations in order to use those identities.

In order to study computer science, you similarly need to be familiar with basic building block data structures and algorithms because you're going to need to apply them to higher level problems.  It's highly unlikely that you'd ever, for example, write your own linked list implementation in the real world, you'd simply use the one provided by your library.  But knowing how a linked list is implemented and how to implement your own, you'd be able to reason about where and whether to use a linked list when you start working on higher-level problems.  Similarly, you'd never write your own binary search function but it's important to understand how it works so that you can reason about things like where a database could use an index and where it couldn't.

Once you have some basic building blocks memorized, it's much easier to do things like interpret documentation.  Documentation might indicate that a list is being used and assume that the programmer implicitly knows that this means that inserts are O(1) and searches are O(n).  The building blocks are also vastly more stable over time-- you're very likely to use new debuggers every few years, you're likely to use the same binary search your entire career.

Title: Why is CS taught to be memorized?

Body:
I have been taking Advanced Placement Computer Science for this past year in high school. It seems as though we are taught simply to memorize code and functions and not how to be resourceful and efficient in using documentation and the like.

Practically, I imagine many (if not all) programming jobs would allow you to flip through documentation, review past code and the code of others, essentially doing what my teacher would consider "cheating."

While I do agree core concepts are essential to memorize (in any subject matter), it seems superfluous and impractical to me to give a pen-and-paper exam for a CS class, especially when practically you would have a compiler, debugger, reference manuals, and the entire internet to refer to in any real-world work situation.

Why is CS taught focusing on the memorization of code and functions as opposed to teaching useful skills including how to use and interpret documentation, sample code, the debugger and such?


答:
It is often taught this way because teachers generally don't know any other way of testing understanding.  Your feelings are completely correct in that it is worthless to be taught like this.  The way people are educated in general is in need for reform desperately!

Life gets better though, at least at UIUC I have found that the higher you go in your CS classes the less the exams are oriented as you are describing and in the majority of my courses we have been allowed a cheat sheet for the all the crap that you would likely have googled if you were actually sitting at a computer.

That being said, the higher up I have gone in my classes the less they actually teach you about languages or how to implement something.  In fact I have only had one class where they have actually taught us anything about programming, it's mostly been abstract mathematical concepts and we have been expected to just figure out the programming part on our own (provided they were always happy to help but this was never something on an exam).

Title: Why is CS taught to be memorized?