问:
Dividing responsibilities between client and server
I'm working on a Web app that uses node.js on the server and AngularJS on the client. I'm new to Angular, but enables writing client-side applications that can be more self-contained than some other approaches.

Here is the scenario. On the server, I query a DB and then transform the results into a list of nodes and edge objects. These objects are sent to the client (browser), and the client displays them as a graph.

The code to parse the query results and build the graph is pretty generic and I expect to use it again subsequent apps. It can stay on the server. However, a lot of the code could be moved to the client because it is specific the sigma.js package that displays the graph.

Part of me wants to offload the processing the client. There is also talk of ditching sigma.js for the next application we build, so shoving it into the client sounds pretty appealing.

However, the client is already feels bloated and complicated. I could use something like the decorator pattern to keep the sigma.js specific code encapsulated while leaving room for more representations.

Which direction should I go? What should I taking into consideration?

答:
I can conceive of a few considerations to be juggled, in priorty order:

Performance

Doing the display processing on the client may be slower than on the server - will the user notice?

Doing the display processing on the server will increase load, possibly slowing or delaying other requests.

Will the data transmitted from server to client be more or less if processing is done on the server? By how much?

If the performance hit of processing on the client is acceptable, it may be the best choice.

Changing the graph display library

It's a good idea to decouple the modules in a software product so that changes can be made to one without affecting the others, but unless you have a high degree of certainty that you'll need to change a given module, introducing complexity to support it could impose an unnecessary price.

Would a different graph display library require a different input graph representation? Then the server side will likely need to change with a new library, so it may be best to do the processing on the server to insulate the client side.

Would a different graph display library produce output that needs to be consumed differently? Then the client side will likely need to change, so it may be best to do the processing on the client side to insulate the server side.

Changes to the server API

Doing the processing on the server will require a change to your server API, but it doesn't have to replace the ability to request the existing JSON representation that you have now. To provide different representations for the same resource, define a custom media type for the display representation, such as application/vnd.example.my-graph-display, then use that when your client requests the resource for display. When the client needs the JSON representation, use application/json.

Finally, the solution to planning for a future replacement of Sigma.js with some other graph display library is the same whether it's done on the client or server: create an interface to abstract the library and write an Adapter to translate your interface calls into the Sigma.js API. When you switch graph display implementations, write a new adapter for it, and you can replace your implementation without changing the code that uses the interface.


答:
Which direction should I go? What should I taking into consideration?

I cannot tell you which direction to go because that will require careful consideration of your problem domain, end users and some testing.  However, I can help you figure out what to take into consideration.

Load Balancing

Your application servers are fixed.  You might have 2, 3 or even 4, but whatever the number, you have a certain number.  You can scale horizontally by adding servers, but there is a direct linear cost to that.

On the other hand, you have N clients.  Each user who visits your site has their own CPU and memory.  In terms of executing your code, that is free CPU and memory :)  Hard to pass that up.

Your clients also provide a level of isolation.  The work of one client does not impact the work of another in regard to client-side code.  If everything executed on the server, one HTTP request going awry can bog down a server that is shared by many users.

Security

Don't trust the client to do computations that affect data that gets shared with other users unless that computation is derived from data they have entered anyway.  For example, it would be fine to use JavaScript in the browser to convert the user's entered "05-15-2014" into an ISO date, but if the server needs to record the time the client performed some action, don't ask the client to do supply the time.  Just capture the time on the server when that request occurs.

Performance

Browsers can be slow to do a lot of number crunching.  Until the recent JavaScript browser war, JavaScript in general was a slow language, not due to issues with the language, just the runtime implementations.  If the server can calculate something using a nice fast server-grade CPU and send it down, that may perform better than letting the client do it.

Predictability

Client machines vary.  There are users running Safari on a Mac, Chrome on a Windows 7 64-bit machine with 8 GB of RAM and users running IE8 on Windows XP 32-bit.  You can't predict how your client-side code will perform because there are major factors outside of your control.  Your servers on the other hand, are very much under your control.  You can monitor their performance and scale them up or down as needed to balance performance and costs.

Bandwidth

Calculating something on the server may be faster, but if you end up having to push a large data set down to the client over the Internet, not only is there a latency component to that, but you are likely billed by bandwidth usage.  Therefore, if you have a cheap calculation that results in a large data set (let's say an array of all even numbers up to 1 million), let the client do it.

Monitoring

Your servers are under your control and therefore you can monitor their performance.  If requests to a specific page are returning results to the client after 5 seconds, it is easier to detect and debug that on your servers.  There are tools and mechanisms to monitor client-side performance, but the trade-offs and complexities are usually higher (like how do you report the data back to a central place and report on it?), like:

How do you report the data back to a central place?

Performance hit of executing additional code

For clients where the performance is extremely bad, you may not even get the measurements, which biases your metrics because the worst performance is what you need to know the most about.

Server-side performance can be monitored via log files.

ContentLicense: CC BY-SA 3.0

Title: Dividing responsibilities between client and server

Body:
I'm working on a Web app that uses node.js on the server and AngularJS on the client. I'm new to Angular, but enables writing client-side applications that can be more self-contained than some other approaches.

Here is the scenario. On the server, I query a DB and then transform the results into a list of nodes and edge objects. These objects are sent to the client (browser), and the client displays them as a graph.

The code to parse the query results and build the graph is pretty generic and I expect to use it again subsequent apps. It can stay on the server. However, a lot of the code could be moved to the client because it is specific the sigma.js package that displays the graph.

Part of me wants to offload the processing the client. There is also talk of ditching sigma.js for the next application we build, so shoving it into the client sounds pretty appealing.

However, the client is already feels bloated and complicated. I could use something like the decorator pattern to keep the sigma.js specific code encapsulated while leaving room for more representations.

Which direction should I go? What should I taking into consideration?


问:
I am making 4-5x more story points than average, but producing bugs at half the rate. Graphs say it's 2x more bugs, how to deal with that?
So it is generally accepted that top tier programmers can produce an order of magnitude more/better code than their more average peers.

It's also generally accepted that the rate of errors made in code is relatively constant for programmers.

Instead, it tends to be impacted by the processes used when writing the code and after the code is written. (As I understand it) Humans tend to make mistakes at a fairly constant rate - better programmers just notice more of them and are quicker to fix them.

Note that both of above assertions come from Code Complete by Steve McConnell - so it's not a matter of differing perspectives.

So I've started to see this recently in my code. I can hammer out about 4-5x the amount of code as many of my peers (measured by story points estimated by the team), with higher quality (based on performance metrics and number of changes made after check-in). But I still make mistakes. Between better unit tests, a better understanding of what the code is doing, and a better eye for issues when doing code reviews I'm not producing 4-5x the number of bugs.

But I'm still producing about twice as many bugs found by QA as other developers on my team. As you might imagine, this causes some problems with non-technical folks doing metric measurements (read: my boss).

I've tried to point out that I'm producing bugs at half the rate of my peers (and fix twice as many), but it's a hard sell when there's graphs saying I produce twice as many bugs.

So, how to deal with the fact that increased productivity will lead to an increased number of bugs?

答:
If your boss wants you to improve the quality of your work, then improve the quality of your work.

You should be aiming at zero bugs, not aiming to produce only twice as many as the next best programmer.


问:
Coding: conciseness/efficiency vs readability
I am fairly new to c# and trying to learn best practices. I've been faced with many situations over the last week in which I need to make a choice between longer+simpler code, or shorter code that combines several actions into a single statement. What are some standards you veteran coders use when trying to write clear, concise code? Here is an example of code I'm writing with two options. Which is preferable?

A)

```<code>    if (ncPointType.StartsWith("A"))//analog points
    {
        string[] precisionString = Regex.Split(unitsParam.Last(), ", ");
        precision = int.Parse(precisionString[1]);
    }
    else
    {
        precision = null;
    }
</code>```

B)

```<code>    if (ncPointType.StartsWith("A"))//analog points
        precision = int.Parse(Regex.Split(unitsParam.Last(), ", ")[1]);
    else
        precision = null;
</code>```

C)

```<code>    precision = ncPointType.StartsWith("A") == true ?
            int.Parse(Regex.Split(unitsParam.Last(), ", ")[1]) :
            null;
</code>```

答:
It's just like writing in English. Concise is rarely a bad thing, as long as the reader can see all the information they need to understand the intent.

The reason option C isn't perfectly readable is not because it's TOO concise, it's because it's not concise enough. Look at it again:

```<code>precision = ncPointType.StartsWith("A") == true ?
            int.Parse(Regex.Split(unitsParam.Last(), ", ")[1]) :
            null;
</code>```

What if it said this?

```<code>precision = ncPointType.StartsWith("A") ? SecondToken(unitsParam.Last()) : null
</code>```

That seems pretty readable to me. It's very clear that if ncPointType starts with an A, we'll set the precision to the second token in the last parameter of unitsParam. Otherwise we'll set it to null.

The details of tokenization is irrelevant to the person reading this line of code. But if they want to know, they can look at the method, which will say.

```<code>public int SecondToken(string param)
{
    return int.Parse(GetTokens(param)[1]);
}
</code>```

Makes sense. Very clear. And then ...

```<code>public string[] GetTokens(string param)
{
    return Regex.Split(param, ", ");
}
</code>```

Now you're going to say that this is a lot more words than any of your options. And it is. But think of each method as part of a glossary of terms. You're creating a language as you go.

Not doing this is like trying to write a story about your pets, having removed the words dog and cat from the dictionary.

There are a lot of words in the definition of dog; even more in the dictionary as a whole. But not having that definition for dog means you have to say "domesticated carnivorous mammal" instead and your story becomes less readable.

That said, as I alluded at the beginning, there is a point at which you lose information. For example:

```<code>precision = ncPointType.IsOk() ? GetIt() : Dont();
</code>```

This is a step too far. To beat the last piece of usefulness out of an analogy: It's like writing a story about your pets, referring to them always as "it".

Body:
It's just like writing in English. Concise is rarely a bad thing, as long as the reader can see all the information they need to understand the intent.

The reason option C isn't perfectly readable is not because it's TOO concise, it's because it's not concise enough. Look at it again:

precision = ncPointType.StartsWith("A") == true ?
            int.Parse(Regex.Split(unitsParam.Last(), ", ")[1]) :
            null;

What if it said this?

precision = ncPointType.StartsWith("A") ? SecondToken(unitsParam.Last()) : null

That seems pretty readable to me. It's very clear that if ncPointType starts with an A, we'll set the precision to the second token in the last parameter of unitsParam. Otherwise we'll set it to null.

The details of tokenization is irrelevant to the person reading this line of code. But if they want to know, they can look at the method, which will say.

public int SecondToken(string param)
{
    return int.Parse(GetTokens(param)[1]);
}

Makes sense. Very clear. And then ...

public string[] GetTokens(string param)
{
    return Regex.Split(param, ", ");
}

Now you're going to say that this is a lot more words than any of your options. And it is. But think of each method as part of a glossary of terms. You're creating a language as you go.

Not doing this is like trying to write a story about your pets, having removed the words dog and cat from the dictionary.

There are a lot of words in the definition of dog; even more in the dictionary as a whole. But not having that definition for dog means you have to say "domesticated carnivorous mammal" instead and your story becomes less readable.

That said, as I alluded at the beginning, there is a point at which you lose information. For example:

precision = ncPointType.IsOk() ? GetIt() : Dont();

This is a step too far. To beat the last piece of usefulness out of an analogy: It's like writing a story about your pets, referring to them always as "it".


答:
Developers can be bright, even genius, with an aptitude for understanding and coding solo, without being GOOD developers. A good developer creates a quality piece of work, and makes the whole project better.

I'm not saying this is you, but one of the most frustrating programmers I ever worked with wrote more code than anyone on the team, and we had good people on the team. We tracked commits with a ranking software, so it was almost a competition for some people. He churned out swaths of code, leaving behind him ZERO documentation, impenetrable forests, and actually made some of my own code hard for me to understand (I can do that on my own, thank you very much!). Eventually he almost derailed the project, because he became a one man show. People could not follow him. We were not in synch as a team. We actually rewrote some of his features years later, just to regain maintainability.

The thing I wanted from him was to slow down, and spend more time:
1) Improving the quality of the codebase
2) Communicating with the team
3) Working on things that helped others as well as help him finish features / stories
4) Fixing bugs

I don't agree with measuring productivity by lines of code, but it is a key metric.
Does your code counter include comments? If so, there is an easy way to maintain your line output while reducing your "bug ratio"; simply increase the quality and quantity of comments you write. Comments rarely have bugs (though they can) and in general, we don't have enough quality comments. I am not condoning code-inflation, but the act of commenting is like a mini code review, it forces you think, refactor and improve.

Title: I am making 4-5x more story points than average, but producing bugs at half the rate. Graphs say it's 2x more bugs, how to deal with that?

Body:
So it is generally accepted that top tier programmers can produce an order of magnitude more/better code than their more average peers.

It's also generally accepted that the rate of errors made in code is relatively constant for programmers.

Instead, it tends to be impacted by the processes used when writing the code and after the code is written. (As I understand it) Humans tend to make mistakes at a fairly constant rate - better programmers just notice more of them and are quicker to fix them.

Note that both of above assertions come from Code Complete by Steve McConnell - so it's not a matter of differing perspectives.

So I've started to see this recently in my code. I can hammer out about 4-5x the amount of code as many of my peers (measured by story points estimated by the team), with higher quality (based on performance metrics and number of changes made after check-in). But I still make mistakes. Between better unit tests, a better understanding of what the code is doing, and a better eye for issues when doing code reviews I'm not producing 4-5x the number of bugs.

But I'm still producing about twice as many bugs found by QA as other developers on my team. As you might imagine, this causes some problems with non-technical folks doing metric measurements (read: my boss).

I've tried to point out that I'm producing bugs at half the rate of my peers (and fix twice as many), but it's a hard sell when there's graphs saying I produce twice as many bugs.

So, how to deal with the fact that increased productivity will lead to an increased number of bugs?


问:
How robust are Git commits when the power goes out?
One day I was using Git (I'm still using it) and the electricity went down while I was committing.

When I (actually, the electricity) came back, the git repo was corrupt. I don't remember the exact name, but it was something like "invalid refs" or something like that.

It's easy to guess that the commit was broken in the middle of the operation (I was committing through IntelliJ, which does the index additions automatically). It was also easy to guess that, actually, 'commit' is not as ACID as the DBMS operation with the same name.

Q: Is there a way to ensure repo-altering operations respect atomicity? i.e. if the electricity goes down again, and I'm committing, I'd like my filesystem to not be in a corrupt state.

答:
I don't know if there is a way to make Git commits survive perfectly timed power failures, but you might be able to fix your repository.

Git objects are supposed to be immutable, so all your older commits should still be valid. According to this answer, you can change the hash in .git/refs/heads/<branch-name> to change the head of the branch you were working on to the previous commit(you can see them in .git/logs/HEAD).

The comment to that answer says that this method "Still leaves repository in broken state, but this allows to recover it". I'm did not test this(no idea how to replicate your situation), but I assume the recovery is done via git gc, that will delete the corrupted commit.


问:
What was the worst piece of code you fixed that you are proud of?
I have had a few that I am proud of and some of them were written by myself few years ago. It doesn't have to be necessarily buggy, just bad code. </p>

答:
The worst I've seen was some Java code to extract key sentences from a text corpus.

The code had few comments (besides disabled code comments) and had poor names.

The algorithm state was stored in public static vectors.

Instead of storing values in the vectors, he stored their string representations.

The vectors were poor man's classes (they were parallel, each index being an 'instance')

The algorithm was sub-optimal (n^2 instead of an easier to understand n log n version)

To be fair, this is nothing compared to some of the stuff our there, but there is still a massive difference in quality before and after. Consider the following actual before and after code of one function:

Before (try to figure out what it does before looking at After!):

```<code>public static void getCluster() {
    count = new Vector();
    for (int i = 0; i < begin.size(); i ++)
        count.add("1");
    if (begin.size() > 1) {
        for (int i = 0; i < begin.size() - 1; i ++) {
            for (int j = i + 1; j < begin.size(); j ++) {
                int b1 = Integer.parseInt(begin.get(i).toString());
                int e1 = Integer.parseInt(end.get(i).toString());
                double w1 = Double.parseDouble(wght.get(i).toString());
                int c1 = Integer.parseInt(count.get(i).toString());
                int b2 = Integer.parseInt(begin.get(j).toString());
                int e2 = Integer.parseInt(end.get(j).toString());
                double w2 = Double.parseDouble(wght.get(j).toString());
                int c2 = Integer.parseInt(count.get(j).toString());
                int max = Math.max(e1, e2);
                boolean toRemove = true;
                if (b1 == b2) end.set(i, Integer.toString(max));
                if (b1 < b2) {
                    if (b2 < e1) end.set(i, Integer.toString(max));
                    else {
                        if ((b2 - e1) <= 3) end.set(i, Integer.toString(e2));
                        else toRemove = false;
                    }
                }
                if (b1 > b2) {
                    if (e2 >= b1) {
                        begin.set(i, Integer.toString(b2));
                        end.set(i, Integer.toString(max));
                    } else {
                        if ((b1 - e2) <= 3) {
                            begin.set(i, Integer.toString(b2));
                            end.set(i, Integer.toString(e1));
                        } else toRemove = false;
                    }
                }
                //System.out.println(b1 + ", " + e1 + ", " + b2 + ", " + e2 + " ---> " + begin.get(i).toString() + ", " + end.get(i).toString());
                if (toRemove) {
                    wght.set(i, Double.toString(w1 + w2));
                    count.set(i, Integer.toString(c1 + c2));
                    begin.removeElementAt(j);
                    end.removeElementAt(j);
                    wght.removeElementAt(j);
                    count.removeElementAt(j);
                    j --;
                } //end of if
            } //end of for j
        } //end of for i
    } //end of if
    //System.out.println(begin);
    //System.out.println(end);
    //System.out.println(wght);
    //System.out.println(count);
}
</code>```

After:

```<code>/** Returns the result of merging all overlapping-with-leeway clusters into single combined clusters.
 * @param leeway The minimum number of word-spaces which must separate two clusters in order for them to not be overlapping.
 * @requires clusters != null
 * @requires leeway >= 0
 * @ensures result != null */
private static List<TermCluster> combineOverlappingClusters(Iterable<TermCluster> clusters, int leeway) {
    if (clusters == null) throw new NullPointerException("clusters");
    if (leeway < 0) throw new IllegalArgumentException("leeway < 0");

    //Sort to allow linear folding
    List<TermCluster> sortedClusters = Iter.sort(clusters, new Comparator<TermCluster>() {
        @Override public int compare(TermCluster o1, TermCluster o2) {
            return new Integer(o1.begin).compareTo(o2.begin);
        }
    });
    if (sortedClusters.size() == 0)
        return sortedClusters;

    //Combine left-to-right
    List<TermCluster> result = new ArrayList<TermCluster>();
    TermCluster acc = sortedClusters.get(0);
    for (TermCluster cluster : sortedClusters.subList(1, sortedClusters.size())) {
        if (acc.isOverlappingWithLeeway(cluster, leeway)) {
            //combine
            acc = acc.combineWith(cluster);
        } else {
            //next
            result.add(acc);
            acc = cluster;
        }
    }
    result.add(acc); //leftovers

    return result;
}
</code>```

ContentLicense: CC BY-SA 2.5

Body:
The worst I've seen was some Java code to extract key sentences from a text corpus.

The code had few comments (besides disabled code comments) and had poor names.

The algorithm state was stored in public static vectors.

Instead of storing values in the vectors, he stored their string representations.

The vectors were poor man's classes (they were parallel, each index being an 'instance')

The algorithm was sub-optimal (n^2 instead of an easier to understand n log n version)

To be fair, this is nothing compared to some of the stuff our there, but there is still a massive difference in quality before and after. Consider the following actual before and after code of one function:

Before (try to figure out what it does before looking at After!):

public static void getCluster() {
    count = new Vector();
    for (int i = 0; i < begin.size(); i ++)
        count.add("1");
    if (begin.size() > 1) {
        for (int i = 0; i < begin.size() - 1; i ++) {
            for (int j = i + 1; j < begin.size(); j ++) {
                int b1 = Integer.parseInt(begin.get(i).toString());
                int e1 = Integer.parseInt(end.get(i).toString());
                double w1 = Double.parseDouble(wght.get(i).toString());
                int c1 = Integer.parseInt(count.get(i).toString());
                int b2 = Integer.parseInt(begin.get(j).toString());
                int e2 = Integer.parseInt(end.get(j).toString());
                double w2 = Double.parseDouble(wght.get(j).toString());
                int c2 = Integer.parseInt(count.get(j).toString());
                int max = Math.max(e1, e2);
                boolean toRemove = true;
                if (b1 == b2) end.set(i, Integer.toString(max));
                if (b1 < b2) {
                    if (b2 < e1) end.set(i, Integer.toString(max));
                    else {
                        if ((b2 - e1) <= 3) end.set(i, Integer.toString(e2));
                        else toRemove = false;
                    }
                }
                if (b1 > b2) {
                    if (e2 >= b1) {
                        begin.set(i, Integer.toString(b2));
                        end.set(i, Integer.toString(max));
                    } else {
                        if ((b1 - e2) <= 3) {
                            begin.set(i, Integer.toString(b2));
                            end.set(i, Integer.toString(e1));
                        } else toRemove = false;
                    }
                }
                //System.out.println(b1 + ", " + e1 + ", " + b2 + ", " + e2 + " ---> " + begin.get(i).toString() + ", " + end.get(i).toString());
                if (toRemove) {
                    wght.set(i, Double.toString(w1 + w2));
                    count.set(i, Integer.toString(c1 + c2));
                    begin.removeElementAt(j);
                    end.removeElementAt(j);
                    wght.removeElementAt(j);
                    count.removeElementAt(j);
                    j --;
                } //end of if
            } //end of for j
        } //end of for i
    } //end of if
    //System.out.println(begin);
    //System.out.println(end);
    //System.out.println(wght);
    //System.out.println(count);
}

After:

/** Returns the result of merging all overlapping-with-leeway clusters into single combined clusters.
 * @param leeway The minimum number of word-spaces which must separate two clusters in order for them to not be overlapping.
 * @requires clusters != null
 * @requires leeway >= 0
 * @ensures result != null */
private static List<TermCluster> combineOverlappingClusters(Iterable<TermCluster> clusters, int leeway) {
    if (clusters == null) throw new NullPointerException("clusters");
    if (leeway < 0) throw new IllegalArgumentException("leeway < 0");

    //Sort to allow linear folding
    List<TermCluster> sortedClusters = Iter.sort(clusters, new Comparator<TermCluster>() {
        @Override public int compare(TermCluster o1, TermCluster o2) {
            return new Integer(o1.begin).compareTo(o2.begin);
        }
    });
    if (sortedClusters.size() == 0)
        return sortedClusters;

    //Combine left-to-right
    List<TermCluster> result = new ArrayList<TermCluster>();
    TermCluster acc = sortedClusters.get(0);
    for (TermCluster cluster : sortedClusters.subList(1, sortedClusters.size())) {
        if (acc.isOverlappingWithLeeway(cluster, leeway)) {
            //combine
            acc = acc.combineWith(cluster);
        } else {
            //next
            result.add(acc);
            acc = cluster;
        }
    }
    result.add(acc); //leftovers

    return result;
}


答:
So, how to deal with the fact that increased productivity will lead to an increased number of bugs?

Your boss is the only person who can answer this in your case. Talk to him, point out your better ratio and let him decide. If his decission doesn't make sense, it is time to look for a company with your way of thinking.

As professional you should be able to work with any given client conditions, just make sure they understand the consequences. A nice bug/stories chart can help your boss understand how much your productivity will sink if you take the time to produce less bugs.

You also need to consider these points:

complexity of stories, for example simple getter/setter wrappers versus statistical calculations or real time programming or even real time statistical ...

severity of bugs, is it small typos on text fields or wrong calculation results, program crashes

cost to fix the bugs, both if you do it now, later or if someone else has to understand your code because you left


答:
More code. More lines of code does not translate into more instructions executed.

In all of your examples I would expect the compiler to produce identical code (barring some variation in the line numbers mappings for use in diagnostics). I would also expect any benchmark on the three variations to produce identical results.

Compilers are very clever pieces of software written by a large number of very clever people over several years.

Your program will be maintained by one person (probably yourself) who may not be that clever and may only have a few minutes to read your code and resolve a problem.

So your priority should be the poor sucker who has read your code, not the super clever optimizing compiler which will render any old garbage into reasonably efficient machine code.

The key here is readability and comprehension. Whatever makes your intention clearer is the better code. You can do this by splitting dense lines of code, or, conversely you can do this by reducing many lines of code to a single terse statement -- its all a matter of judgement.

Title: Coding: conciseness/efficiency vs readability

Body:
I am fairly new to c# and trying to learn best practices. I've been faced with many situations over the last week in which I need to make a choice between longer+simpler code, or shorter code that combines several actions into a single statement. What are some standards you veteran coders use when trying to write clear, concise code? Here is an example of code I'm writing with two options. Which is preferable?

A)

```<code>    if (ncPointType.StartsWith("A"))//analog points
    {
        string[] precisionString = Regex.Split(unitsParam.Last(), ", ");
        precision = int.Parse(precisionString[1]);
    }
    else
    {
        precision = null;
    }
</code>```

B)

```<code>    if (ncPointType.StartsWith("A"))//analog points
        precision = int.Parse(Regex.Split(unitsParam.Last(), ", ")[1]);
    else
        precision = null;
</code>```

C)

```<code>    precision = ncPointType.StartsWith("A") == true ?
            int.Parse(Regex.Split(unitsParam.Last(), ", ")[1]) :
            null;
</code>```


问:
Multiple sites with the same codebase in Python
I am trying to run a large amount of sites which share about 90% of their code. They are simply designed to query an API and return the results. They will have a common userbase / database but will be configured slightly different and will have different CSS (perhaps even different templating).

My initial idea was to run them as separate applications with a common library but I have read about the sites framework which would allow them to run from a single instance of Django which may help to reduce memory usage.

https://docs.djangoproject.com/en/dev/ref/contrib/sites/

Is the site framework the right approach to a problem like this, and does it have real benefits over running separate applications?

Initially I thought it was, but now I think otherwise. I have heard the following:

Your SITE_ID is set in settings.py, so in order to have multiple
  sites, you need multiple settings.py configurations, which means
  multiple distinct processes/instances. You can of course share the
  code base between them, but each site will need a dedicated worker /
  WSGIDaemon to serve the site.

This effectively removes  any benefit of running multiple sites under one hood, if each site needs a UWSGI instance running.

Alternative ideas of systems:

https://github.com/iivvoo/django_layers

https://github.com/shestera/django-multisite

I don't know what route to be taking with this.

答:
My suggestion would be to use nginx, uWSGI, and flask.  nginx is robust and works well with uWSGI in Emperor mode. Beyond that Flask is super flexible for python coders so you should be able to quickly make the modifications necessary to take advantage of your shared code base.

This blog entry should get you started.


问:
how can we have a person to allot and track tasks in agile development
I understand that Agile team should be self organized and self driven,

but is there a provision that I can have someone who will allot tasks to developers and ensure that all user stories will be completed on time??

For example if there are two persons in an agile team who are not self motivated to take up tasks and they will work only when task is assigned to them with a deadline, how can we deal this in Agile?

The problem I face is that no one is fixing the deadlines for the tasks and the team is under delivering for the last two sprints.
It will be better if we can have someone who can fix deadlines. IS there a provision for this in Agile

答:
One of the principles of an agile team is to
pull tasks, not assign them!

Sorry, but IMHO you do not have an agile team. You may throw the unwilling ones out of the team or drop agile.

The last try could be to let them decide: want you like to pull a task you that fits best to you or should I assign you the worst task I can find?

If that does not work, it's over.


问:
How to promote code reuse and documentation?
As a team lead of about 10+ developers, I would want to promote code reuse. We have written a lot of code-- a lot of them are repetitive over the past few years. The problem now is that a lot of these code are just duplicate of some other code or a slight variation of them.

I have started the movement ( discussion) on how to make code into components so that they can be reused for the future projects, but the problem is that I afraid the new developers or other developers who are ignorant of the components will just go forward and write their own thing.

Is there anyway to remind the developers to reuse the components/ improve the documentation/ contribute to the underlying component instead of duplicating the existing code and tweaking on it or just write their own?

How to make the components easily discover-able, easily usable so that everyone will use it?

I think every developer knows about the benefit of reusable components and wants to use them, it's just that we don't know how to make them discoverable. Also, the developers when they are writing code, they know they should write reusable code but lack of the motivation to do so.

答:
You need a tool that helps your developers to do it in a seamless way.
If your developers discover how much time they can save by reusing the code snippets (not only in terms of writing the code, but obviously for quality assurance, integration, etc.), helped by an efficient tool that is easy-to-use and directly integrated into development environment, they will PRAY you to adopt such a tool!

Be careful that a lot of times the realization of libraries for code reuse will not result in a huge advantage (they tend to become too much powerful and large...); instead, I would like to focus on simple snippets, i.e. few lines of code that solve a particular task in an effective way.

In this way you can force the usage of guidelines and best practices by giving real examples that can be directly used by programmers.

There are several tools for the snippet management, I recommend this one: http://www.snip2code.com.

(Disclaimer: I'm one of the founder of Snip2Code, and I was - together with my co-founders - in your very same mindset some time ago: this is why we decided to start this project, which collects all the features that I stated above, i.e. sharing snippets among a team, integration in IDEs like Visual Studio, Eclipse, IntelliJ, Notepad++, etc.)


答: Adopting Agile is supposed to be a team decision. It relies heavily on team members to make best-effort estimates about the scope/effort for a task. If you are having to force-assign tasks to developers in order to get things done, it kind of defeats the spirit of Agile development.</p>

Title: how can we have a person to allot and track tasks in agile development

Body:
I understand that Agile team should be self organized and self driven,

but is there a provision that I can have someone who will allot tasks to developers and ensure that all user stories will be completed on time??

For example if there are two persons in an agile team who are not self motivated to take up tasks and they will work only when task is assigned to them with a deadline, how can we deal this in Agile?

The problem I face is that no one is fixing the deadlines for the tasks and the team is under delivering for the last two sprints.
It will be better if we can have someone who can fix deadlines. IS there a provision for this in Agile


问:
How long does a Comp Sci degree last?
I keep hearing from people that if I don't become a programmer soon after graduation my degree will be a useless piece of paper, they claim it will become outdated.  I kind of find this hard to believe considering what I was taught at a fairly good school has been standard practice for some time.

So is this a true belief in industry?  That somehow I become less desirable after a year or two, even though the graduates who comes after me pretty much get the same identical education.

答:
Nothing Lasts Forever, that's how it operates here.

Having said that, computer science degrees in particular tend to run its course rather quickly these days. You need to continuously upgrade your skills. Open source, books, stackoverflow and stackexchange, mailing lists, programming contests, checking out new programming languages -- I could carry on forever.

In the end it's about how excited you are about technology and how quickly you can adapt.

Title: How long does a Comp Sci degree last?


问:
What's so bad about creative coding?
I was watching Bob Ross paint some "happy trees" tonight, and I've figured out what's been stressing me out about my code lately.

The community of folks here and on Stack Overflow seem to reject any whiff of imperfection.  My goal is to write respectable (and therefore maintainable and functioning) code, by improving my skills.  Yet, I code creatively.

Let me explain what I mean by "coding creatively":

My first steps in a project are often to sit down and bash out some code.  For bigger things, I plan a bit out here and there, but mostly I just dive in.

I don't diagram any of my classes, unless I'm working with others who are creating other pieces in the project.  Even then, it certainly isn't the first thing I do.  I don't typically work on huge projects, and I don't find the visual very useful.

The first round of code I write will get rewritten many, many times as I test, simplify, redo, and transform the original hack into something reusable, logical, and efficient.

During this process, I am always cleaning.  I remove unused code, and comment anything that isn't obvious.  I test constantly.

My process seems to go against the grain of what is acceptable in the professional developer community, and I would like to understand why.

I know that most of the griping about bad code is that someone got stuck with a former employee's mess, and it cost a lot of time and money to fix.  That I understand.  What I don't understand is how my process is wrong, given that the end result is similar to what you would get with planning everything from the start.  (Or at least, that's what I have found.)

My anxiety over the issue has been so bad lately that I have stopped coding until I know everything there is about every method for solving the particular problem I am working on.  In other words, I have mostly stopped coding altogether.

I sincerely appreciate your input, no matter what your opinions are on the issue.

Edit:  Thank you all for your answers.  I have learned something from each of them.  You have all been most helpful.

答:
I also use your approach. It works better for me, since it reduces the risk of overengineering.

What I do very often is solve a problem with probably the least code possible, which usually leads to evidently unneccessary dependencies or other design problems. Then I refactor working code into beautiful code.

For example I reduce the dependencies between different modules to concise interfaces and put thought into the question which data should be held where, until every modules only depends on very minimalistic abstractions of the other modules. You could say, I postpone the final decision, which module should have which responsibility. I postpone abstraction.

Putting too much thought into seperating a problem into distinct responsibilities, into distinct abstractions, is not good. It will force you to bend your implementation to fit the abstractions you made. Code works, if it produces the results you want and if it is maintainable. A design works, if you can implement it through good code. If code doesn't work, you change it. Ergo, if a design doesn't work, you will need to change it as well. You can only see if a design works, once you implemented it.

Thus having a simple sketch in mind is just about enough as a design, before you start bringing it to life. Redesign, abstract and refactor as needed.

Title: What's so bad about creative coding?


答:
I think if you're going to be good at programming, at least sometimes it has to be fun, and that means being creative.

Surely when programming in groups there are at least minimal standards that should be followed, not for "moral" reasons, but for practical ones, when they apply.

Outside of that, it's interesting and fun to probe the boundaries to see what can be found there. Once when working on a Mini in assembly language, I discovered that you could make co-routines that could switch from one to the other with 1 instruction. Then I figured out how to make a self-co-routine that could go two steps forward, one step back, etc. Was it useful? I doubt it. That's not the point.

Once I heard a talk by Edsger Dijkstra, talking about creativity in programming. He mentioned how a student found a way to do an n-bit rotate of an n+m-bit word. It was done with 3 bitswaps. First you swap the n bits, then you swap the m bits, then you swap the whole n+m bits. Useful? No. Clever? Yes.

It's good to feel free to try things that nobody in their right mind would do.

Title: What's so bad about creative coding?

Body:
I was watching Bob Ross paint some "happy trees" tonight, and I've figured out what's been stressing me out about my code lately.

The community of folks here and on Stack Overflow seem to reject any whiff of imperfection.  My goal is to write respectable (and therefore maintainable and functioning) code, by improving my skills.  Yet, I code creatively.

Let me explain what I mean by "coding creatively":

My first steps in a project are often to sit down and bash out some code.  For bigger things, I plan a bit out here and there, but mostly I just dive in.

I don't diagram any of my classes, unless I'm working with others who are creating other pieces in the project.  Even then, it certainly isn't the first thing I do.  I don't typically work on huge projects, and I don't find the visual very useful.

The first round of code I write will get rewritten many, many times as I test, simplify, redo, and transform the original hack into something reusable, logical, and efficient.

During this process, I am always cleaning.  I remove unused code, and comment anything that isn't obvious.  I test constantly.

My process seems to go against the grain of what is acceptable in the professional developer community, and I would like to understand why.

I know that most of the griping about bad code is that someone got stuck with a former employee's mess, and it cost a lot of time and money to fix.  That I understand.  What I don't understand is how my process is wrong, given that the end result is similar to what you would get with planning everything from the start.  (Or at least, that's what I have found.)

My anxiety over the issue has been so bad lately that I have stopped coding until I know everything there is about every method for solving the particular problem I am working on.  In other words, I have mostly stopped coding altogether.

I sincerely appreciate your input, no matter what your opinions are on the issue.

Edit:  Thank you all for your answers.  I have learned something from each of them.  You have all been most helpful.


问:
How can I promote clean coding at my workplace?
I work with a lot of legacy Java and RPG code on an internal company application. As you might expect, a lot of the code is written in many different styles, and often is difficult to read because of poorly named variables, inconsistent formatting, and contradictory comments (if they're there at all).

Also, a good amount of code is not robust. Many times code is pushed to production quickly by the more experienced programmers, while code by newer programmers is held back by "code reviews" that IMO are unsatisfactory. (They usually take the form of, "It works, must be ok," than a serious critique of the code.) We have a fair number of production issues, which I feel could be lessened by giving more thought to the original design and testing.

I have been working for this company for about 4 months, and have been complimented on my coding style a couple of times. My manager is also a fan of cleaner coding than is the norm. Is it my place to try to push for better style and better defensive coding, or should I simply code in the best way I can, and hope that my example will help others see how cleaner, more robust code (as well as aggressive refactoring) will result in less debugging and change time?

答:
What does clean code mean for you?

I'm sure your definition is great, but the other guys in your workplace probably have their own definition. They are not wrong, only different from yours.

You should create coding guidelines which everyone in your workplace can agree on, and you should do it together with your fellow programmers. Don't try forcing this on people, it will backfire if you do.

So get the team together and start working on a common definition of "clean code"! There are no hard rules to this. You are trying to bringing several minds together and that can result in conflicts, so you may want to set the stage with a positive note that you all should be respectful and keep an open mind (code writing is personal...).

The Clean Code book may come in handy. You could use examples from that book to talk about and see if you find some common ground in there?


问:
What is the (craziest, stupidest, silliest) thing a client/boss asked you to do?
See title, but I am asking from a technical perspective, not

Take my 40 year old virgin niece on a date or you're fired.

答:
To market Neal Stephenson's sci-fi thriller Snow Crash, I was asked to write a "benign" computer virus. It would "benignly" pretend to take over the user's computer and replace the screen with snow, a.k.a., a "snow crash." After a minute or so of snow, the snow would fade out and be replaced by an advertisement for the book. This would be "benign," you see. The virus would spread through normal means, but nobody would mind because after taking over their computer "you'd just get a fun ad and then be relieved that nothing bad happened to your computer."

I was actually told to do this at a major worldwide corporation. I had to write a memo explaining all the laws this would break and all 17 bad things that could happen if they really made me implement this.


问:
How would you design a programming language?
If you were to design a programming language, how would you do it? What features would you put in? What would you leave out? Statically or dynamically typed? Strongly or weakly typed? Compiled or interpreted? Justify your answers.</p>

答:
This is how my dream programming language would look like:

A powerful static type system with some support for dependent typing.

Optional dynamic typing.

Numeric Tower a la Lisp but statically typed.

Macros a la Lisp.

Primarily a Functional Programming language with basic support for imperative programming (like ML family).

Garbage collection.

Type inference.

Continuations.

Optional lazy semantics.

All the control constructs would be provided in the form of library functions. (This can be made possible using last two features.)

Minimal syntax (not as little as Lisps, but something of the sort of Ioke/Seph.)


问:
Drag-n-drop programming - would it fly?
All programming languages I know of are written - i.e. typed out as lengths of text one way or another. But I wonder if there's any programming language where you can just drag-n-drop the whole program; to get a loop, you select this box over here and drag it to that section of the "code" over there, and so on. And if there isn't one like this, would it fly if one was invented?

Personally I don't believe it would be such a good idea, but I'd like to hear what you think.

答:
LabVIEW is pretty graphical.

From the LabVIEW website:

Title: Drag-n-drop programming - would it fly?


答:
Lots of outfits have done drag-and-drop programming systems.

National Instruments "Labview" is probably the best-known, and the best.

The fundamental problem they all encounter is that there is no known way to convert a Flying Code Monkey into an expert programmer and engineer.  As ONE example, there is no difference to a Flying Code Monkey between an O(N^2) or O(N^3) process and an O(N log N) process, which means that they must be supplied with canned routines for the O(N log N) algorithms, that can be custom-fit into the quickie graphic kludges they will build.

The second problem they all encounter is that, when you supply the special-purpose blocks required by the first problem, overhead imposed by moving the data between the blocks starts to get expensive.  I worked with one very nice such system called Rippen.  When I profiled, to see where we were hurting on a HIGH!-required-performance sensor processing application, I was rather disturbed to see that some 20% of my CPU time was going to data-moving.  (Since I was doing LADAR image processing, doing a fair chunk of floating-point processing on every pixel of an input image, 20% of CPU was a LOT of data-moving overhead.)

You could probably get around part 2 by going to a compiler-based system: you feed it your picture, and it compiles to a heavily-optimized executable program, but I'm not certain that would really fix the issues, and it might hurt the interactive nature of the tool.

Title: Drag-n-drop programming - would it fly?

Body:
All programming languages I know of are written - i.e. typed out as lengths of text one way or another. But I wonder if there's any programming language where you can just drag-n-drop the whole program; to get a loop, you select this box over here and drag it to that section of the "code" over there, and so on. And if there isn't one like this, would it fly if one was invented?

Personally I don't believe it would be such a good idea, but I'd like to hear what you think.


问:
Best books on the theory and practice of software architecture?
I have a couple of developers at my company who wish to move from programming into architecture. What are the best books out there on the theory and practice of software architecture? Include a cover picture if you can.

Feel free to include general books, and also books that relate to a specific technology.

答:
Refactoring, Martin Fowler

One of the best programming books overall.


答:
The simple answer is no.

When it comes to programming, textual input far exceeds in terms of specified information than its visual counter part.

Title: Drag-n-drop programming - would it fly?


答:
The best drag and drop programming system i've seen is for the Lego Mindstorms NXT robots.

This allows you to do some quite amazing things, controlling some quite intricate functionality.

However at some point it does break down, and you need to revert to another system.

See this article: http://www.wired.com/geekdad/2007/11/the-best-progra/

It's possible though, that if this was improved, and different scenarios where catered for, the need for this would become less and less.

Title: Drag-n-drop programming - would it fly?


答:
There are quite a few visual programming languages. A phone system I managed for a large call center was programmed using drag and drop modules. My uncle developed a Just-In-Time system for designing manufacturing lines that was completely drag and drop and that was 20 years ago.

I've even played a robot combat game on the PS1 that used a drag and drop programming language.

Title: Drag-n-drop programming - would it fly?

OwnerDisplayName: Pickle Pumper


问:
How is quality important to the programmer, the person?
I didn't ask how the quality of the software is important to the product itself, the customers/users, the manager or the company. I want to know how it is important to the programmer that build it.

I'll be interested in any books (please specify the chapter), articles, blog post, and of course your personal opinion on the subject regardless your experience.

答: Actually, Peopleware chapter 4 discusses this.  People put their pride into things that they build.  The authors argue that it is important to let builders create things up to their standards of excellence even if the market will allow for less quality.  The reason being that forcing people to put out a product that's below their standard of quality undermines their motivation, which ultimately has a bigger impact on their ability to work quickly than anything else.


答:
This may be a case of "one size does not fit all". You've made your style work for the projects you've been on, so who's to argue with that? However, the critics you are reading here and on SO may be working on bigger projects, or on projects that require complex coordination between the team members.

Your development style could become a problem if you were ever involved in larger projects involving cooperation between multiple developers. It's hard to schedule it, it's hard to track your progress, and there's no way for you fellow programmers to plan the bit of their work that depend on knowing what your bit of work is doing.

You may be interested in reading Dreaming in Code to see what can happen when a large project adopts a development style similar to yours.

Title: What's so bad about creative coding?


答:
Plenty of reassurance that your method isn't wrong, but let me add some personal experience. I started off your way, but in the meantime I learnt the benefit of planning beforehand at least part of the general structure, and this for a number of reasons:

biggest extra is that it's easier to see which code can be reused if worked around a bit. I often write a piece of code that, while writing, suddenly seems useful for another part in the general scheme I have hanging next to my screen (drawn on paper in a only-readible-for-me-style).

Having a scheme allows you to refactor not only the code, but the scheme as well. Sometimes I'm busy writing a class that suddenly appears useful for some other part in the scheme as well. As a result the scheme becomes simpler when the project runs on

Every time I update that scheme as well with required input and given output of functions/methods, and available slots in classes. This goes faster for reusing bits: I don't have to dive in the code every time to check what exactly goes in and out. Even if it's in the comments, I still have to browse to get the comments up

So actually, I use your method as well. I just start, try out, refactor, try out again, change another bit and so on, but my cycle includes the scheme as well. And when that's done, I add the information for the next one that works on that code.

Mind you, this is for projects where I work on alone. If you work with more people on the same code, planning ahead is not only logic, it's essential. But I guess you know that already.

And as others said: this is my  way, your mileage may vary.

Title: What's so bad about creative coding?


答:
It's hard to give a general answer to these sorts of questions because everyone has a specific example where it doesn't apply. However, from an employer perspective:

Not all degrees are created equal, so when you're job hunting as a new graduate, the name of the school and the quality of your grades are important;

This is tempered by the fact that all a degree really proves is that you've got the ability to learn. Sure you picked up some specific CS-related knowledge and skills (so I hopefully don't need to teach you about B-trees), and the stop sign recognition code you wrote for the engineering department's new autonomous car is interesting, but I want you to be able to write code for us, in our way, in our team.

So from my perspective, the value of the degree on your CV diminishes over time, not because of its content, but because it's been overtaken by more (hopefully) valuable work experience.

Title: How long does a Comp Sci degree last?

Body:
I keep hearing from people that if I don't become a programmer soon after graduation my degree will be a useless piece of paper, they claim it will become outdated.  I kind of find this hard to believe considering what I was taught at a fairly good school has been standard practice for some time.

So is this a true belief in industry?  That somehow I become less desirable after a year or two, even though the graduates who comes after me pretty much get the same identical education.


答:
Every now and then someone comes up with a drag and drop programming language or design tool that is going to "put an end to programming as we know it" and make everyone who uses it into a programmer.

The reason that none of them have actually done the job as yet and put us all out of work is that actually, no matter how much drag and drop functionality you create and no matter how user friendly you make it, the simple fact is that programming is hard.

The real disciplines of programming are as much about knowing how to solve problems, understanding how to model processes and organise data to be usable. Even understanding what is possible with a computer at all.

There is evidence (if controversial) to suggest that some people can't be taught to think this way which leads me to a couple of interesting and relevant thoughts. To start with, if you can't think this way then there are lots of programmers around, so you can always hire someone to implement an idea if you have one and you think it's worth paying for. If you can work with programming logic well enough then you might as well learn a real language rather than mess around with a relatively simple drag and drop environment.

I'm thinking of general programming here. The same thing doesn't necessarily apply in a more limited DSL type scenario where drag-and-drop might be a really useful process users who are specialists within that domain rather than IT specialists.

Title: Drag-n-drop programming - would it fly?


答: Programming is my craft, and I care about my craft. Code done poorly is an insult.</p>

Title: How is quality important to the programmer, the person?

Body:
I didn't ask how the quality of the software is important to the product itself, the customers/users, the manager or the company. I want to know how it is important to the programmer that build it.

I'll be interested in any books (please specify the chapter), articles, blog post, and of course your personal opinion on the subject regardless your experience.


答: Zen and the Art of Motorcycle Maintenance - Best book on Quality and the search for it in life...seriously, every dev should have a copy (and read it)</p>


答:
MIT's Scratch programming system is almost entirely drag-and-drop.

Google's App Inventor seems to be similar (and credits Scratch).

I wouldn't want to code anything big in either myself, but for teaching "programmer thinking", Scratch is superb.  It's Real Programming, but with instant visual gratification and the snap-together blocks avoid much of the "syntax error" frustration which puts off newcomers (a view I see echoed in this article).  Trying to enthuse young kids with a python commandline doesn't cut it these days.

Title: Drag-n-drop programming - would it fly?


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

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

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

答: The possibility to work from home!</p>

Body: The possibility to work from home!


问:
A programmer should concentrate on at least how many languages?
For me I am C# and Java person. I find these 2 languages are quite similar so its easier for me to crossover each other. I'm not sure if its good idea to pick up other different languages. Any thoughts?</p>

答:
A programmer needs to know three languages: C, English, and Something Else.

C is very much a core language, it's close to the machine and has syntax rules that are common to several high level languages. C forces you to think about things like data structures in a very different way than Java. Also, the Python and Ruby vms are both built in C, and you can inline C into both languages when you want to boost your speed.

English is the common language of programming. Most books, technical reports, technical websites, and journal papers come out in English first, and sometimes English exclusively. Furthermore, if English isn't your first language, learning English will expand your toolkit for manipulating concepts (this goes for English speakers learning some other language as well, of course).

The Something Else should be a language that isn't procedural, or isn't statically typed, or is strongly object oriented, or in some way is just fundamentally different from C. Haskell, Scala, Python, Ruby, some Lisp dialect, whatever.

After that, you can learn whatever your specific situation calls for, likely C# or Java.


答:
Dataflow programming (a.k.a. flow-based programming) can be kind of. Altough, dataflow programming is not Turing-complete.

Dataflow programming is the method of creating applications, when you put component instances on the scene and connect their ports, so they form a message processing network. The components can be choosen from a library, they have consumer (input) and producer (output) ports, which are ready to connect with other components' ports.

Here's a nice example, where not even a mouse used to build a synth app, but bare hands and little cubes: http://www.youtube.com/watch?v=0h-RhyopUmc

Wikipedia articles are a good start point:
http://en.wikipedia.org/wiki/Flow-based_programming
http://en.wikipedia.org/wiki/Dataflow_programming

Sound generation is a typical area of dataflow programming. There are some open source synth systems:
http://www.synthedit.com/
http://alsamodular.sourceforge.net/

If you have Mac, you may have a factory pre-installed Quartz Composer: http://developer.apple.com/graphicsimaging/quartz/quartzcomposer.html

I've also made a DF system with a friend of mine, but we have no visual editor yet, only script visualizer.

Title: Drag-n-drop programming - would it fly?


答:
This already exists, albeit possibly not in the form that you are thinking about.  Two examples are Simulink and Alice.

Simulink is a graphical means of assembling dynamic system simulations.  While most of the constructs are more complex than what you would usually think of as programming, things like for and if statements still can be graphically constructed.  Simulink is kinda a big deal in Aerospace applications as the government and many of the big companies do their initial designs in Simulink and then apply some type of theorem prover to the Simulink "code".

Alice, is a drag and drop, programming training tool for kids.  It allows kids to have fun building stories by dragging and dropping actions and objects on a sort of programming story board.

Title: Drag-n-drop programming - would it fly?


问:
Error handling, creating time line, need help defining what aspects of the environment need tracking
For my final year project, I'm working on a script that will run your python program and provide a time line of events(so far working on assignments) and create a story of what happened(the changes in the variables). Based on what Exception is thrown, you can choose to use the library made available by me to help figure out what happened and how it happened. (Hopefully I explained this much better than I did on stack overflow)

My question to you, besides the variables, when an error occurs/exception you cant handle occurs, what would you look through in order to try and fix the problem?

Many thanks.

答:
The Call Stack With Arguments

This might be a little obvious, but a lot of my error logs just consist of functions announcing they're beginning with a listing of the args passed. As you're creating your "story," make it obvious every time a function is called and display the args passed to the function.


答:
Yahoo! Pipes is probably a perfect example of a graphical language of the type you're describing; you drag-and-drop primitives (everything from data sources that you act on, to loops and conditionals) to produce a flow of information through the system.

It's highly domain-specific, but that's mostly the point; Pipes is data-centric, making visualization (rather than expression) paramount. Similarly, tutorial environments like Scratch or Sprog! emphasize the visualization of what you're working on as a learning aid; data-entry efficiency is a much lower priority in that domain.

Title: Drag-n-drop programming - would it fly?


问:
How do I get into R&D?
I'm beginning to think that I might be best suited for a job in R&D.  The reason being that I like jobs that allow me to be creative and I generally am more interested in solving puzzles than building things.  I really dislike jobs that just boil down to translating requirements into code.

Here's the kicker though:  I don't have a bachelor's much less a masters or phd.  Is it possible for me to land a job like this?

答:
At my second development job there was a guy who, to this day, I think had the best job on the planet.

He spent all day messing around with new technology and techniques and evaluating them to see if they had value for the business. He presented his research to the developers - who would then do the grunt work. He did a bit of architecture, but 90% analysis and problem solving.

He joined the company as an intern, and never left. So he had no formal qualifications at all and he made a ton of money.

If you haven't got a degree then you're going to have trouble getting your foot in the door at an interview. So maybe do what this guy did. Identify some companies that will contain research opportunities and get a developer job there. Then once you've proved yourself and you have some reputation make the transition.

If you have aspirations like this, then bring them up at your Review(s). As long as you are worth keeping, then your boss will try to keep you happy and fulfilled. And the more value that you add, the more they will be willing to appease you.

Title: How do I get into R&D?


问:
How much time a week do you spend on extracurricular programming?
Background: I'm a microsoft DBA/IT type person by day, an iOS and Mac developer by night. I have one app in the App Store and another one in the works. I try to spend as much time as possible working on my two apps, but with a new daughter and other (non computer) hobbies, I find it hard to spend more than a few hours every week programming.

I'm wondering how this compares to other developers. I see a lot of apps out there written by single developers who don't do iOS development as their main job. Are they spending 4 hours a night working on their projects, or do they just plug away for a year or two before releasing anything?

答:
It all depends on your goals.

If you want to spend more time with your spouse/kids/family, then you need to put that first. I hope you're aware that the time spent with babies is unlike when they're older/bigger and therefore less dependent, so it's worth treasuring. Once they go to nursery/daycare/school, you have a lot less influence and quality time.

If you've got a great idea for an iOS app that could potentially earn enough to make a difference to your life, that sounds like a candidate for vacation time off work to get it done and perhaps several evenings a week where you negotiate with your spouse that you're left alone to have interrupted project time.

Finding a balance between these is hard, but it can be done. For example, after dropping the kids off and then going to work, do a full day with a short lunch, you could then come back to do evening routine with them. After they're in bed, you could have some time to be able to crack on with various programming projects. Obviously, your wife won't get a whole lot of your attention with this arrangement, so weekends should be reserved for quality family time, and a decent proportion of any money you make on the projects should be spent treating the family.

Whatever you do though, I'd advise against giving up the day job unless your iOS app has paid off the mortgage already and you have a year's worth of savings, as the market is a rapid-moving target.


问:
What is a good way to brainstorm algorithms on a computer?
I'm looking for something that allows me to work out an algorithm on a computer similar to how I would do it on a whiteboard. At work, I have a huge whiteboard that I can use for this, but at home, I don't (and can't). This makes it difficult to design algorithms when I'm working on hobby projects. I think better when I use drawings as opposed to text, so pseudocode is no good. I guess what I'm looking for is something like a flowchart program, but that allows a less rigid approach to designing algorithms.

I'd like the program to be cross-platform (Mac, Linux), but I'll be happy even if it just runs on Macs. Free is preferred, but reasonably priced programs are good too. I would prefer programs that people have used and had experiences with, rather than whatever turned up on Google, as I know of some flowchart and mind-mapping software, but haven't really been satisfied with either. I realise that a computer isn't the best platform for doing this kind of stuff, but assume for a moment that it's the only medium I possess.

答: Livescribe might be a solution for you, aside from picking up a Bamboo or Intuous.  Even though it is pen and paper, it can create PDFs of your writings/diagrams on the computer. </p>


问:
How do I explain to non-programers what .NET is?
I don't work at a software company, and I'm one of a small handful of people in the company that know anything about programming. I spend a lot of time automating other programs that are used in the office through public APIs, and I've also created a few stand alone applications. I work almost entirely in C#.NET as every application we seem to use in the office seems to have some form of .NET API.

I've had a few people here ask me about learning "how to program", and where they should start. I think it makes a lot more sense to learn a .NET language as nearly all the programs they would want to automate have a .NET API, and it sounds like VBA is on it's way out and being replaced by VSTA.

However, I'm trying to figure out how to explain what .NET is and why they should learn it to a someone that doesn't know anything about programming. It's not really a language, as there are a number of languages that are considered .NET languages. Plus I think there is a distinction between ".NET" and "The .NET framework" as the latter is more about the libraries provided by Microsoft.

答:
This looks like an opportunity for you within this company.

As you are becoming known as someone proficient with programming, and people are coming to you for advice/input, it seems like there's a business need for programming in this company in general.

I'd recommend talking to someone in a position of authority that may be able to establish that this becomes part of your role - e.g. you head up the software development efforts, and are recognised accordingly.

If this is possible, you could start the educational ball rolling with a chalk-and-talk session on what is programming, why you program these office apps, etc, and introduce C#  as you do this. If this goes well, you probly want to progress to Version Control, leveraging frameworks and nUnit (or similar) soon after.

If there's no opportunity available, a chalk-and-talk session is still a good option as you can disseminate the same information to a number of people, aiming for the average case, and they can then support each other going forwards.


答: Textual programming has had a nice 50 year run, but software engineering must move into the graphical realm to deal with the next level of complexity.  For example, the emergence of manycore processors and the challenges of parallel programming are pushing the threading model to its limit.  Frankly, I think that the software community is just arrogant thinking that there is something fundamentally different and special about programming that it would not be amenable to visualization like every other domain.  Like telephone operators and many other professions, the right automation technology will enable domain experts to soon collaborate in rich simulation spaces of knowledge-based systems.  The software industry is long overdue for a paradigm shift.</p>

Title: Drag-n-drop programming - would it fly?


问:
What security practices should you be aware of when writing software?
What different types of security do there exist? Why and when should they be implemented?

Example: SQL Injection Prevention

答:
I am no expert, but in my experience, there are several well-known attack vectors for systems:

Unvalidated user data

This is the classic buffer-overrun, SQL injection, drive-by-download mechanism and is caused by insufficient planning or education on secure coding practices. It is important to ensure developers understand how any insecure code can be leveraged to exploit a zero-day attack on a computer. Just because your website doesn't do anything particularly secret/important, doesn't mean that getting root access on your webserver can't harm the other parts of the organisation.

Weak security

This can be a blend of poor security infrastructure, policy or just bad passwords. The worlds most popular password is 'password1' since most email providers started insisting on alpha-numeric passwords - previously it was 'password'. If a dictionary-based attack can guess a users' password, the policy was insufficient.

Backdoors

Some enterprising programmers leave quick-access backdoors in code in case they need to jump in and 'fix' the system. If you have any of these, deliberate or otherwise, your system is a ticking time-bomb.

What to do about it

Here's a useful selection of podcast episodes that discuss the topic: http://www.se-radio.net/?s=security&submit=Find

Read up on some best-practices, for example http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=writing+secure+code&x=0&y=0

Get your code security/penetration tested.

Keep up-to-date with current threats and mitigation strategies through blogs and online articles: http://www.cert.org/sse/


答:
Always relate it to something the person can understand. If they do not understand programming then:

.NET is a collection of pre-made stuff. So its like:

a whole lot of bricks already put together

a pre-written agreement where you just fill in some fields

buying a car instead of the individual parts that make up a car

Title: How do I explain to non-programers what .NET is?

Body:
I don't work at a software company, and I'm one of a small handful of people in the company that know anything about programming. I spend a lot of time automating other programs that are used in the office through public APIs, and I've also created a few stand alone applications. I work almost entirely in C#.NET as every application we seem to use in the office seems to have some form of .NET API.

I've had a few people here ask me about learning "how to program", and where they should start. I think it makes a lot more sense to learn a .NET language as nearly all the programs they would want to automate have a .NET API, and it sounds like VBA is on it's way out and being replaced by VSTA.

However, I'm trying to figure out how to explain what .NET is and why they should learn it to a someone that doesn't know anything about programming. It's not really a language, as there are a number of languages that are considered .NET languages. Plus I think there is a distinction between ".NET" and "The .NET framework" as the latter is more about the libraries provided by Microsoft.


答:
If you work on something just to earn money, it's meaningless to discuss about quality, maintenance or design patterns...

But no one want to work on the fields they don't like. We are all developers. And good developers take good quality, delivery time and easy maintenance as his happiness. It's not the problem about money & customers anymore, it's professional pride.


问:
how can we have a person to allot and track tasks in agile development
I understand that Agile team should be self organized and self driven,

but is there a provision that I can have someone who will allot tasks to developers and ensure that all user stories will be completed on time??

For example if there are two persons in an agile team who are not self motivated to take up tasks and they will work only when task is assigned to them with a deadline, how can we deal this in Agile?

The problem I face is that no one is fixing the deadlines for the tasks and the team is under delivering for the last two sprints.
It will be better if we can have someone who can fix deadlines. IS there a provision for this in Agile

答:
Address this issue with the following techniques:

Daily scrum to review progress.  If people aren't making progress at a reasonable pace it will become more obvious to everyone day by day.

If a problem is suspected the product manager or line manager can review recent stories and their points and see if there is an issue that persists over time.

Continual retrospectives to uncover the deeper issue and team dynamics that are impeding progress.  There are frequently hidden issue which slow progress.

Put a low performing member on review and if they can't deliver what is consider to be the minimum, after several reviews let them go.  Never a pleasant option but it should be considered an option in extreme cases.


问:
What is the responsibility or benefit of a Tokenizer?
Suppose I had a grammar like:

```<code>object
    { members }
members
    pair
pair
    string : value
value
    number
    string
string
    " chars "
chars
    char
    char chars
number
    digit
    digit number
</code>```

I could parse the following example: { "one" : 1234 }

As far as I understand, I should have the tokens object, members, pair, value, string and chars.

Tokenizing the example should produce

```<code>object
    ->members
        ->pair
            ->"one"
            ->"1234"
</code>```

Parsing the tokens should produce

```<code>object
    ->pair
        ->"one"
        ->1234
</code>```

It seems to me like the tokenizer is either useless or I don't fully understand what a it should do.

What is the responsibility of a tokenizer?
What is the benefit of a tokenizer over parsing the original string?

答:
You don't seem to understand what a tokenizer should do. In this example, I'd make the tokenizer recognize six tokens: {, }, :, string, number. The tokenizer produces a string/sequence of tokens, not a tree. And instead of the grammar being written in terms of individual characters (char, digit), it is now written in terms of tokens.

The benefit is that this simplifies the grammar and parser: You no longer need to describe how to parse strings and numbers (note that real languages' string and numeric literals are far more complicated, which boosts this benefit). As far as the parser is concerned, the grammar becomes

```<code>object
    '{' members '}'
members
    pair
pair
    string ':' value
value
    number
    string
</code>```

Which is not only simpler to write a parser for, but also more useful for comprehending the syntactic structure of programs. I know what a string literal is, the interesting part is how I can combine string literals and other atomic units to form programs.

Body:
You don't seem to understand what a tokenizer should do. In this example, I'd make the tokenizer recognize six tokens: {, }, :, string, number. The tokenizer produces a string/sequence of tokens, not a tree. And instead of the grammar being written in terms of individual characters (char, digit), it is now written in terms of tokens.

The benefit is that this simplifies the grammar and parser: You no longer need to describe how to parse strings and numbers (note that real languages' string and numeric literals are far more complicated, which boosts this benefit). As far as the parser is concerned, the grammar becomes

object
    '{' members '}'
members
    pair
pair
    string ':' value
value
    number
    string

Which is not only simpler to write a parser for, but also more useful for comprehending the syntactic structure of programs. I know what a string literal is, the interesting part is how I can combine string literals and other atomic units to form programs.


答:
The original source file, in whatever programming or markup language you're parsing, is just a long sequence of characters.  The "words" that make up the language may be conveniently separated by spaces, or they may not.

For instance in C, the character sequences "foo = bar << 2;" and "foo=bar<<2;" should be considered to be equivalent.  The first step in parsing a document is therefore to analyse the sequence of characters and work out where one token ("word") ends and the next one begins.

In my little C example, the tokens are "foo", "=", "bar", "<<", "2" and ";" in both cases.  Note the subtlety in this case that it's "<<" and not "<" followed by "<".  Tokenisers need to know about the language's syntax, but not it's meaning.

Only once you've tokenised the string can you start to think about what the document means.

Title: What is the responsibility or benefit of a Tokenizer?

Body:
Suppose I had a grammar like:

```<code>object
    { members }
members
    pair
pair
    string : value
value
    number
    string
string
    " chars "
chars
    char
    char chars
number
    digit
    digit number
</code>```

I could parse the following example: { "one" : 1234 }

As far as I understand, I should have the tokens object, members, pair, value, string and chars.

Tokenizing the example should produce

```<code>object
    ->members
        ->pair
            ->"one"
            ->"1234"
</code>```

Parsing the tokens should produce

```<code>object
    ->pair
        ->"one"
        ->1234
</code>```

It seems to me like the tokenizer is either useless or I don't fully understand what a it should do.

What is the responsibility of a tokenizer?
What is the benefit of a tokenizer over parsing the original string?


问:
pattern to share objects between API and application
I'm having serious doubts about the design for my Web application.

I wanted to separate the business logic from the interface so I made a Web API that handles all the requests to the database.

It's an ASP.NET Web API with Entity framework and a unit of work and generic repository pattern. So far, everything is good.

PROBLEM

Where I need help is I can't figure out an efficient way of sharing objects between the API and the application.

I don't want to serialize directly the entity object, I thought it would be a bad practice because if the entity model changes, I could end up with serializing large objects for no reason.

How it's implemented now

Because my interface is ASP.NET Web application in C# and my API is in C#, I made a common library  with the definition of all my classes I want to share between them.

I know that solution won't work when I will develop an android app, I will have to create my classes again in Java but that's not my biggest problem.

The problem is I feel like I'm always converting my objects.

EXAMPLE

Here's an example of my work flow :

I start with a model with all the objects and the data annotations for my form then user would POST that model to a controller.

In the controller I have to convert this model to a class in my common library then send that object to my API.

Then a controller in my API catch the call and convert that object to an entity object to update the database.

So I have 3 classes

The model for the view with all the data annotation for the validation (Client)

The common library classes to share the objects (DLL)

The Entity classes (API)

I have a feeling that I do something really wrong. Is there something more elegant? I would like to make sure that I have a good solution for this problem before the project gets too big.

答:
I know it may seem like you are converting objects back and forth all the time between your database objects, your data transfer objects, your client objects with validation logic and so on but I'd say that no, you're not doing anything wrong.

Each of these objects may represent the same unit of information, but they have very different responsibilities. The database object is your communication interface with the database and should be kept in the database layer since it may or may not have different database metadata annotations and/or unnecessary details about the database implementation in it.

Your data transfer object is the communication interface with your API consumers. These should be as clean as possible to facilitate easy consumption from different languages/platforms. This might impose certain restrictions on how these look and behave depending on what API consumers you wish to support.

Your client objects with validation logic is really not a part of your API project, they're part of your consumer project. These cannot be the same as the data transfer objects in this case since you are adding extra client-specific logic (in this case validation attributes) on them which the server knows nothing about (and should not know anything about!) You shouldn't count these objects as part of your API, because they're really not. They're highly consumer application specific and some applications that consume your API might actually not even need to create these object and could just as well survive on just your data transfer objects. For example, if you didn't have any need of validation you wouldn't need an extra layer of objects that are completely identical to your data transfer objects. Generally my strategy here is to evolve the project in stages, I start off by plainly using the data transfer objects as my consumer application objects and when I see the need for application specific handling of data (validation, implementing INotifyPropertyChanged, etc..) I do a quick refactoring and add in the new layer as needed.

To me, it seems like each of the three object types map very nicely to a single responsibility which is clean coding and good practice. Sadly, clean code and good practices sometimes means that you are writing a lot of extra code and jumping through extra hoops "just because". And while coding, it may be hard to appreciate the value that this is giving you - but as soon as you release your application and begin supporting it or adding new features for the next version then you will probably start appreciating that you took the time to separate these concerns properly in the first place. (Not to mention that you'll avoid certain problems that might occur due to improper separation of concerns - and since you have avoided these problems it might be hard to appreciate the mess that you can find yourself in when you have not separated your concerns.)

I also hate writing conversion code between different object types like this, but my solution is usually one of the following:

Use a library that does most of the object conversion heavy lifting for you - for example, if you use C# you can use the fantastic AutoMapper library (http://automapper.org/). I believe that there's a couple of other libraries like this, but AutoMapper is the most powerful one I've seen so far.

If you can't find a library help you with your object conversions, write a set of utility methods for converting between them. This might suck, but it's worth it in the long run, write the conversion method the first time you need to convert something - don't wait.


问:
Benefits of Java in education?
I hope this isn't too off-topic and/or opinion based.

I'm looking for examples and reasons why Java is an acceptable language for education purposes.

Here's why: I learned programming on my own in C at the age of about 15. In school we used Pascal (which I think is quite OK, especially in educational context). In University, Java was used and I was disgusted. Examples:

Verbosity:

```<code>RenderingHints rh = new RenderingHints(
     RenderingHints.KEY_ANTIALIASING,
     RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHints(rh);
</code>```

Listener classes instead of functions.

No overloading (resulting in ugly .equals() and .get() instead of == and []).

When I was able to pick a programming language on my own again, I chose Python and everything "felt just right".

Now the problem is that I'm going to become a teacher for computer science in german secondary schools (grade 5-13), where I will be forced to teach Java.

So I'm looking for the pretty parts of Java. What is especially easy/readable/... to implement in Java?

Preferably in an educational context, but also from a professional programmer's point of view.

答:
The usual reasons for teaching Java are:

Object Oriented Design

Cross-platform development

Popularity

As a long time programmer, and former Java Developer, I've grown to hate Java. I was taught it in college (like everyone else), and I left college and went straight into Java development. Over time though, I was given more leeway on what platforms I could develop on, and I moved away from Java with some relief.

It's slow to develop in, it doesn't result in notably less buggy code, it doesn't result in faster code, and it doesn't result in better designed or more readable code. On top of that Oracle is more than a little evil, and I'd be more than a little leery of wedding myself to a technology they control.

Still, knowing Java will get you a job. The shit's everywhere.

Title: Benefits of Java in education?


答:
I think java is a great language for education purposes because it teaches some very important computer science / software engineering concepts such as

strong typing - the most important of all. For those who are learning, I think this is the most important thing in a language. Students don't have to struggle trying to guess what's the return type.

OO - Java has many influences from Eiffel and C++, it was being designed having OO concepts from the scratch (main() is a method from a class)

I18n - it may be seem silly, but I think it's one less barrier to learn a language

JVM - another thing that may be silly, but again, one less barrier to learn a language. No core dumps. You can always (almost always) get a reasonable error message. The same for garbage collection.

Distributed / Parallel - Java had some nice features about serialization and, in the newer versions, some very very nice features for algorithm parallelization

Last but not least, lots of free industrial-strength IDEs and libraries around there.

Title: Benefits of Java in education?

Body:
I hope this isn't too off-topic and/or opinion based.

I'm looking for examples and reasons why Java is an acceptable language for education purposes.

Here's why: I learned programming on my own in C at the age of about 15. In school we used Pascal (which I think is quite OK, especially in educational context). In University, Java was used and I was disgusted. Examples:

Verbosity:

```<code>RenderingHints rh = new RenderingHints(
     RenderingHints.KEY_ANTIALIASING,
     RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHints(rh);
</code>```

Listener classes instead of functions.

No overloading (resulting in ugly .equals() and .get() instead of == and []).

When I was able to pick a programming language on my own again, I chose Python and everything "felt just right".

Now the problem is that I'm going to become a teacher for computer science in german secondary schools (grade 5-13), where I will be forced to teach Java.

So I'm looking for the pretty parts of Java. What is especially easy/readable/... to implement in Java?

Preferably in an educational context, but also from a professional programmer's point of view.


问:
Android proprietary app including Apache-2.0 licensed code from Google
My Android app contains some Apache-2.0 licensed code from Google (in-app billing example) and links to com.android.vending.billing library in the form of a InAppBillingFile.aidl file (same license?).

I would like to know what I have to do for my app to be license compliant, i.e. what to show in the About section, what files to include and so on?

答:
As your app merely links to the library, it is not considered a derived work by the Apache 2.0 license. This means that you are completely free in the choice of license for your own code.

For distributing an Apache 2.0 licensed library, the main condition is that you inform your users about the license. The easiest way to do that without risk of confusion is to mention in the About section that you use this library and that it is available under the Apache 2.0 license, with a human readable link to the license text.

If you have the full text of your own license/EULA in there, then you should also reproduce the complete text of the Apache 2.0 license.


问:
Theoretically bug-free programs
I have read lot of articles which state that code can't be bug-free, and they are talking about these theorems:

Halting problem

Gödel's incompleteness theorem

Rice's theorem

Actually Rice's theorem looks like an implication of the halting problem
and the halting problem is in close relationship with Gödel's incompleteness theorem.

Does this imply that every program will have at least one unintended behavior?
Or does it mean that it's not possible to write code to verify it?
What about recursive checking? Let's assume that I have two programs. Both of them have bugs, but they don't share the same bug. What will happen if I run them concurrently?

And of course most of discussions talked about Turing machines. What about linear-bounded automation (real computers)?

答:
I want to ask, does it imply that every code will get at least one unintended behaviour?

No. Correct programs can be and are written. Mind you, a program can be correct, but it's execution may fail due to, eg, physical circumstances (as the user Robert Harvey wrote in his answer here), but this is a distinct matter: that program's code is still correct. To be more precise, the failure is not caused by a fault or error in the program itself, but in the underlying machine that executes it (*).

(*) I am borrowing definitions for fault, error and failure from the dependability field as, respectively, a static defect, an incorrect internal state, and an incorrect external observed behavior according to its specification (see <any paper from that field>).

Or, does it mean that I am not able to write code, which will check it?

Refer to the general case in the statement above and you are correct.

You may be able to write a program that checks if a specific X program is correct. For example, if you define a "hello world" program as one with two instructions in sequence, namely print("hello world") and exit, you can write a program that checks if its input is a program composed of these two instructions in sequence, thus reporting if it is a correct "hello world" program or not.

What you can't do using current formulations is to write a program to check if any arbitrary program halts, which implies the impossibility of testing for correctness in the general cases.

Title: Theoretically bug-free programs