答:
Refactoring does have immediate benefits. When programming in a Red-Green-Refactor mode, when you are transitioning from Red to Green, you are in "draft" mode: you don't worry about duplication necessarily, you don't worry about naming, you don't worry about the quality of your solution. This state produces user-value rapidly. When you switch to transitioning between Green and Refactored, you switch into "polish" mode: you don't worry about the domain and users, you worry about the code quality. This is when you express your craftsmanship. </p>

<p>Both modes provide real immediate benefits. (If for no other reason, checking in un-crafted code will harm your reputation on your team.) By explicitly alternating modes, you can achieve higher "flow" / overall productivity. </p>

Body:
Refactoring does have immediate benefits. When programming in a Red-Green-Refactor mode, when you are transitioning from Red to Green, you are in "draft" mode: you don't worry about duplication necessarily, you don't worry about naming, you don't worry about the quality of your solution. This state produces user-value rapidly. When you switch to transitioning between Green and Refactored, you switch into "polish" mode: you don't worry about the domain and users, you worry about the code quality. This is when you express your craftsmanship.

Both modes provide real immediate benefits. (If for no other reason, checking in un-crafted code will harm your reputation on your team.) By explicitly alternating modes, you can achieve higher "flow" / overall productivity.


问:
What is the economic rationale for focusing on free, open source projects?

Possible Duplicate:

  Why programming open source?

I'm having trouble understanding why people dedicate their time to an open source project that's free as in beer instead of focusing on a closed source, paid project.

Closed source projects seem to be more commercially viable, so why do programmers open source their code and make it free when there are commercial opportunities for it?

答:
Even as a purely economic decision (which it isn't, as several others pointed out), the rational function to optimize is your cumulative future value, not your immediate future value. By working on a non-paid project, you may increase:

Your competence

Your reputation

Your devotion to the profession (i.e, to a hiring manager)

Your mastery of a potentially profitable domain (e.g., a new language, hardware platform, or domain)

Your association with a product for which people will pay support

All of which may maximize long-term economic benefits.

ContentLicense: CC BY-SA 3.0


问:
How to write manageable code with functional programming?
I just started with functional programming (with JavaScript and Node.js) and from the look of things it looks as if the code I am writing would grow to be one hell of a code base to manage, when compared to programming languages that have a sort of object oriented paradigm.

With OOP I am familiar with practices that would ensure your code is easily managed and extensible. But am nore sure of similar convention with functional programming.

答:
Functional programming languages enjoy a lot of powerful concepts to build high quality code, for example:
Partial applied functions, functions compositions (this one is really powerful and my favorite), macros, higher order functions. And not to forget immutable data structures.</p>


问:
Is duck typing a subset of polymorphism
From Polymorphism on WIkipedia

In computer science, polymorphism is a programming language feature that allows values of different data types to be handled using a uniform interface.

From duck typing on Wikipedia

In computer programming with object-oriented programming languages, duck typing is a style of dynamic typing in which an object's current set of methods and properties determines the valid semantics, rather than its inheritance from a particular class or implementation of a specific interface.

My interpretation is that based on duck typing, the objects methods/properties determine the valid semantics. Meaning that the objects current shape determines the interface it upholds.

From polymorphism you can say a function is polymorphic if it accepts multiple different data types as long as they uphold an interface.

So if a function can duck type, it can accept multiple different data types and operate on them as long as those data types have the correct methods/properties and thus uphold the interface.

(Usage of the term interface is meant not as a code construct but more as a descriptive, documenting construct)

What is the correct relationship between ducktyping and polymorphism ?

If a language can duck type, does it mean it can do polymorphism ?

答:
It feels almost natural to say "Yes, if foo has duck typing, foo has polymorphism". But I can't say this 100% sure, in a sense that maybe it is possible to come up with an artificial examples of such system which has duck typing ("can it quack && can it float on water ==> it is a Duck") while not having polymorphism ("foo, quack!" fails), but they would really be artificial and in a real world, I'd say "Yes, if duck typing is present, polymorphism must also be present".

Personally I see duck typing as "polymorphism done right". What I mean by that, thing that exist in a duck typing world do not need to have any explicit types and their (polymorphic = "same access, different outcome") behaviour is the only thing that counts. In other implementations of polymorphism, it is constrained to types/interfaces/inheritance, so it is "implemented and constrained polymorphism" not a "polymorphism per se".

Title: Is duck typing a subset of polymorphism


问:
What made you contribute to that open source project?
I'm interested in real experience and personal answers not just those standard worn out "benefits of contributing to open source" that we all memorized by heart by now.

I've met many people who contribute to open source project and almost never did this topic come up: why did they contribute to this open source project. So, if you've contributed to an open source project before in any way, can you please pause for a second and try to remember what really made you decide to contribute to that particular project.

Was it a random decision, was it because you were bored, was it because the company you worked for was already using it and you contributed as part of your job, was it because the project was too big you wanted to get contracts, or the project was too small you wanted to build it, or because your prof or co-worker asked you to help with his open source project, or.....

To substantiate your reasons, please mention the project name and rate your involvement (heavy, occasional, light, once).

答:
We frequently do small contributions to various open source projects.  This is primarily done because a particular piece of code done to achieve some functionality "logically" belongs to the projects and not our own code, and by contributing them back upstream they get part of the official distribution instead of us having to keep close track of new updates ensuring the code still works.

This is a good thing, as it lowers the risk of things breaking when deciding to upgrade to the newest version of libraries.

ContentLicense: CC BY-SA 2.5


问:
Is there a correlation between complexity and reachability?
I've been studying cyclomatic complexity (McCabe) and reachability of software at uni recently. Today my lecturer said that there's no correlation between the two metrics, but is this really the case?

I'd think there would definitely be some correlation, as less complex programs (from the scant few we've looked at) seem to have 'better' results in terms of reachability.

Does anyone know of any attempt to look at the two metrics together, and if not, what would be a good place to find data on both complexity and reachability for a large(ish) number of programs?

答:
I've been studying cyclomatic complexity (McCabe) and reachability of
  software at uni recently. Today my lecturer said that there's no
  correlation between the two metrics, but is this really the case?

Actually both yes and no.

First of all, just to remind you, McCabe metric for cyclomatic complexity is calculated on control flow graph where you abstract your source code to a directed graph with basic blocks or statements being the nodes and the transitions between them (either by normal control flow downward or in case of conditioned jumps and loops) being edges. The cyclomatic complexity here can be roughly (if you consider your whole program to have no isolated code, i.e. your graph is connected) seen as the difference between the number of edges and number of nodes.

```<code>CC = E - N
</code>```

Reachability problem is a common problem in graph theory that can be expressed in the way: given two nodes A and B, is the node B reachable from node A, i.e. can one reach B starting from A and following the edges of the graph in correct direction? So, it is again the metric that is applicable to the control flow graph and not on the code.

There are several ways to apply this problem to the control flow graph. One way is so-called "variable reachability analysis", meaning that for the given variable the analysis determines whether its value is still available at certain program point (this technique is also called slicing in software analysis). I also found only some articles that use this term (and generally the reachability problem) for multi-threaded applications.

Basically one can see some sort of correlation between the CC and reachability: with the increase of CC the ratio of edges over nodes also increases and even in case of a directed graph where the direction of the edge is also important, one can speculate that increasing the number of edges eventually leads to the increase of available paths in the graph and thus to increases reachability either via direct or indirect connections between the nodes. So, the answer is Yes here.

On the other side, the notion of reachability in multi-threaded environment requires the analysis of so-called supergraph -- and this is not so trivial. Increase of CC (called here "synchronisation complexity") might lead to the higher probability of deadlocking in software and thereby decrease the reachability of certain nodes / code segments. Therefore "No" is a valid answer here too.

Body:
I've been studying cyclomatic complexity (McCabe) and reachability of
  software at uni recently. Today my lecturer said that there's no
  correlation between the two metrics, but is this really the case?

Actually both yes and no.

First of all, just to remind you, McCabe metric for cyclomatic complexity is calculated on control flow graph where you abstract your source code to a directed graph with basic blocks or statements being the nodes and the transitions between them (either by normal control flow downward or in case of conditioned jumps and loops) being edges. The cyclomatic complexity here can be roughly (if you consider your whole program to have no isolated code, i.e. your graph is connected) seen as the difference between the number of edges and number of nodes.

CC = E - N

Reachability problem is a common problem in graph theory that can be expressed in the way: given two nodes A and B, is the node B reachable from node A, i.e. can one reach B starting from A and following the edges of the graph in correct direction? So, it is again the metric that is applicable to the control flow graph and not on the code.

There are several ways to apply this problem to the control flow graph. One way is so-called "variable reachability analysis", meaning that for the given variable the analysis determines whether its value is still available at certain program point (this technique is also called slicing in software analysis). I also found only some articles that use this term (and generally the reachability problem) for multi-threaded applications.

Basically one can see some sort of correlation between the CC and reachability: with the increase of CC the ratio of edges over nodes also increases and even in case of a directed graph where the direction of the edge is also important, one can speculate that increasing the number of edges eventually leads to the increase of available paths in the graph and thus to increases reachability either via direct or indirect connections between the nodes. So, the answer is Yes here.

On the other side, the notion of reachability in multi-threaded environment requires the analysis of so-called supergraph -- and this is not so trivial. Increase of CC (called here "synchronisation complexity") might lead to the higher probability of deadlocking in software and thereby decrease the reachability of certain nodes / code segments. Therefore "No" is a valid answer here too.


问:
How much data validation is too much?

Possible Duplicate:

  Data input validation - Where? How much?

I'm a new PHP developer and am into Powershell quite a bit but this question is language agnostic. I've been questioning my code quite a bit lately thinking about how many nets I should setup to catch exceptions, verify results, etc.   I realize that I could go crazy trying to verify each and every line of code but at the same time I want the code as resilient as possible. I'm not talking about user input but verifying output from methods.

Is there some standard or rule of thumb to go by when deciding when and where to do data validation?

答:
In general, you are correct about the anticipation of problems. However, everything is good in moderation. Too much and unnecessary checking makes the code hard to write, read and test.

During application testing, you should catch many errors that you could analyze and determine if they fit into your plan of error management (see below for the details).

If you are working in a team, the team should have this plan communicated so that code is built in a consistent manner.

I classify execution results of a piece of code according to their nature using the phrase: "the Good, the Bad and the Ugly".

The good is your normal processing. That is when the method executes the sweet case.

The Bad category is when the method can't do its job because the data passed is bad or not enough. Catching this kind of errors is important since these would arise from your intentionally built checks.

For example, you can verify the validity of passed arguments to a method before processing them, as another example is when you request a method to Add Customer but you don't provide a name for that customer.

Another type of rules that falls under this category is regarding arithmetic overflow and null values. These are slightly different than regular user-data validation. For example, a complex equation may result in a large number that you are not sure whether it would fit in your target data type. Such problems should worth coding for only when in-doubt. By the end of your testing, such checks may not be necessary.

The ugly category is when the problem is outside of your code. This is an error in either the system, the logic, or whatever. For example, in the Add Customer, if during the insert, the database gets full. This is not your program's or your logic fault. You must identify, log and catch such errors but only in a generic way. A common approach for this is the Catch clause (I am not sure how PHP provides for that).

If you follow the above classification of types of errors, you will not have to check every statement.

Also, you should build your code with the above in mind. So, don't validate business rules in the middle of processing I/O. Structured programming concepts help here. To get cleaner code, you may want to separate methods for data validation from I/O processing.

In languages such as Java and .Net, the languages allow exceptions to bubble up, if PHP allows that, then this will greatly reduce the need for detailed checks since your actions can be protected from errors when you place your code within the Try block's scope.

Another important rule is you should avoid repeating coding the rules at different levels when you can. For example, leave the Ref. Integrity (RI) checks and database constraints to the database and don't repeat them in your code. I have seen developers coding the delete manually even though the Database is doing that for them.

The way you define your method interfaces affect your ability to check results greatly. Sometimes people don't even return primitive types and use classes as a way to communicate detailed feedback from method calls.

Title: How much data validation is too much?


问:
Role of "Refactoring" in good programming pratices?
I have learned in Agile Development that:

Refactoring is the process of clarifying and simplifying the design of
  existing code, without changing its behavior.

I have heard about some GUI refactoring tools like ReSharper and DevExpress Refactor Pro!

Here are my questions:

How does it takes place in the Software development process and how far it effects the system?

Does Refactoring using these tools really speed up the process of development/maintenance?

答:
How does it takes place in the Software development process and how far it effects the system?

Merciless refactoring is a standard practice in all teams I work with. The emphasis is on 'merciless'. If code doesn't 'feel' right it probably isn't. Typically this is called a 'code smell'.

In general we refactor as soon as possible, typically at a time when all tests pass. We stop refactoring once we cannot think of any further way to simplify the code.

Sometime we refactor towards a particular design pattern, e.g. when we have identified the need for a particular interface. Sometimes we change the implementation to address a performance issue. In that sense there are cases when refactoring affects the system. In general however, our refactorings do not change the systems behavior.

Does Refactoring using these tools really speed up the process of development/maintenance?

The best option would be to have data to answer this question. I don't. However, based on observation in my experience fully refactored code is much easier to work with. It is easier to extend. It is easier to locate the source of a bug. By removing code duplicates you not only follow the DRY principle (Don't Repeat Yourself) but you also avoid having to fix the same bug more than once.

Using tools is mandatory. Manual refactoring is possible but tools can take care of most of the cases and are a real time saver.

Based on my observations and my experience working with a number of teams and systems refactoring supported by tools speeds up both development and maintenance of source code.


问:
Exposing business logic as WCF service
I'm working on a middle-tier project which encapsulates the business logic (uses a DAL layer, and serves a web application server [ASP.net]) of a product deployed in a LAN. The BL serves as a bunch of services and data objects that are invoked upon user action.

At present times, the DAL acts as a separate application whereas the BL uses it, but is consumed by the web application as a DLL. Both the DAL and the web application are deployed on different servers inside organization, and since the BL DLL is consumed by the web application, it resides in the same server.

The worst thing about exposing the BL as a DLL is that we lost track with what we expose. Deployment is not such a big issue since mostly, product versions are deployed together.

Would you recommend migrating from DLL to WCF service? If so, why? Do you know anyone who had a similar experience?

答:
My recommendation would be to move the business logic onto the same server that has the data access layer, then exposed the business logic as web services using WCF. The web user interface would then make use of the business logic by interacting with the services.

Therefore my answer is yes to your question, I would recommend to migrated from DLL to WCF service.

In some sense you can look at the web application as the presentation layer. The presentation layer and the business logic are two different layers. Of course you can deploy both on the same host. However, in most cases you are better off to deploy business logic and data access on the same host.

I would go even one step further and recommend assessing whether you have a need to expose the data access layer (DAL) via services. If you don't then combining both the data access layer and the business logic into a set of services may be beneficial.

Conceptually a service encapsulates its data and therefore the data access would be an internal detail of a particular service. Equally a service offers pieces of business logic. Therefore creating vertical slices of functionality covering both the business logic and the data access for each slice in a separate service often gives a good level of granularity and modularization.

Of course you may have additional factors that may influence your choices.

Title: Exposing business logic as WCF service


问:
How do you quantify competency in terms of time (years)?
While looking for a job via agencies some time ago, I kept having questions from the recuitment agents or in the application forms like:

How many years of experience do you have in:

Oracle

ASP.NET

J2EE etc etc etc....

At first I answered faithfully... 5yrs, 7yrs, 2 yrs, none, few months etc etc..

Then I thought; I can be doing something shallow for 7 years and not being competent at it simply because I am just doing a minor support for a legacy system running SQL2000 which requires 10 days of my time for the past 7 years. Eventualy I declined to answers such questions.

I wonder why do they ask these questions anymore. Anyone who just graduated with a computer science can claim 3 to 4 years experience in anything they 'touched' in the cirriculum, which to me can be equivalent to zero or 10 years depending how you look at it.

It might hold true decades ago where programmers and IT skills are of very different nature. I might be wrong but I really doubt 'time' or 'years' are a good gauge of competency or experience anymore.

Any opinion/rebuttal are welcome!

答:
These are good questions for recruiters:

They know when the technologies became available, and can use it to detect if your numbers are bogus

They can also sum them together, and compare it with your age, and gives them another way to check it

It also indicates if you're good match for the position requiring those skills. Probably few of the techs listed are useless, and they'll see if you choose them.

Also experience is always measured in years. A project with less than half year time is probably useless.

But on the other hand, such questions also cannot explain what other skills you have


问:
Process arbitrarily large lists without explicit recursion or abstract list functions?
This is one of the bonus questions in my assignment.

The specific questions is to see the input list as a set and output all subsets of it in a list. We can only use cons, first, rest, empty?, empty, lambda, and cond. And we can only define exactly once.

But after a night's thinking I don't see it possible to go through the arbitrarily long list without map or foldr.

Is there a way to perform recursion or alternative of recursion with only these functions?

答:
How much theory have you studied? If you've had classes about the lambda calculus, now is the time to put them to good use.

At this point, pause and think back to what you've studied. Do you remember anything about recursion in the lambda calculus?

The specification cannot be met by a constant-time program. (Proof: the size of the output is superlinear in the size of the input.) Yet all the primitives you list operate in constant time. You can't make a non-constant time program out of constant-time primitive constructs.

Ok, what I've written is true, but confusing in this context: the primitive constructs provided by the language include more than the functions you have at your disposal. Recursion obviously allows you to write any computable program out of constant-time functions. You don't have recursion here, however. But you have function application. That's not a constant-time operation — it can reach any complexity, depending on the function you're applying. And you can build recursion out of function application.

Does this trigger any memories yet?

 It's called a fixpoint combinator. I'll refer you to your lecture notes or the Wikipedia article for an explanation of how they work. For completeness, here's a definition of a fixpoint combinator in Scheme, for a function that takes one argument:

```<code>(define (fix1 phi)
  ((lambda (rec) (phi (lambda (x) ((rec rec) x))))
   (lambda (rec) (phi (lambda (x) ((rec rec) x))))))
</code>```

Now you can define a list iterator (using here a three-argument variant of the fixpoint combinator for clarity).

```<code>(define foldr
  (fix3 (lambda (foldr)
          (lambda (f l a)
            (if (empty? l) a (f (first l) (foldr f a (rest l))))))))
</code>```

And I guess you know how to go on from there already.

One last point: we've used define more than once. But that's for convenience only. You can make fix3, foldr and any other auxiliary function you may need local definitions. And then write your single function as an application:

```<code>(define subsets
  ((lambda (fix3)
     ((lambda (foldr it)
        (lambda (l) (foldr it '() l)))
      (fix3 …)
      (lambda (x sets) …)))
   (lambda (phi) …)))
</code>```

Body:
How much theory have you studied? If you've had classes about the lambda calculus, now is the time to put them to good use.

At this point, pause and think back to what you've studied. Do you remember anything about recursion in the lambda calculus?

The specification cannot be met by a constant-time program. (Proof: the size of the output is superlinear in the size of the input.) Yet all the primitives you list operate in constant time. You can't make a non-constant time program out of constant-time primitive constructs.

Ok, what I've written is true, but confusing in this context: the primitive constructs provided by the language include more than the functions you have at your disposal. Recursion obviously allows you to write any computable program out of constant-time functions. You don't have recursion here, however. But you have function application. That's not a constant-time operation — it can reach any complexity, depending on the function you're applying. And you can build recursion out of function application.

Does this trigger any memories yet?

 It's called a fixpoint combinator. I'll refer you to your lecture notes or the Wikipedia article for an explanation of how they work. For completeness, here's a definition of a fixpoint combinator in Scheme, for a function that takes one argument:

(define (fix1 phi)
  ((lambda (rec) (phi (lambda (x) ((rec rec) x))))
   (lambda (rec) (phi (lambda (x) ((rec rec) x))))))

Now you can define a list iterator (using here a three-argument variant of the fixpoint combinator for clarity).

(define foldr
  (fix3 (lambda (foldr)
          (lambda (f l a)
            (if (empty? l) a (f (first l) (foldr f a (rest l))))))))

And I guess you know how to go on from there already.

One last point: we've used define more than once. But that's for convenience only. You can make fix3, foldr and any other auxiliary function you may need local definitions. And then write your single function as an application:

(define subsets
  ((lambda (fix3)
     ((lambda (foldr it)
        (lambda (l) (foldr it '() l)))
      (fix3 …)
      (lambda (x sets) …)))
   (lambda (phi) …)))


问:
What does 'opinionated software' really mean?
I've seen a lot of other framework/library developers throw the phrase 'we write opinionated software' around, but in practical terms, what does that really mean? Does it mean that the author of the 'Opinionated Framework X' says that because they write code a certain way, you should be writing the same type of code that they write?

Isn't that a bit pretentious?

答:
The framework imposes a certain way of working on you. Put another way, there's clearly one right way of using the framework which is nice and easy, and any other way of using the framework makes your life difficult.

I'm no Rails expert, but I'm told that it's opinionated because it's awesome for simple CRUD stuff, but when you try deviate from the "Rails way" things get tough. (This isn't necessarily a bad thing; I don't mean it as criticism.)


答:
The main question to ask yourself is Why Should I (as in what would I gain by) adding WCF to my project.  You would gain scalability, but at the cost of increase complexity.  Do you need scalability?  Flexibility in deployments (different layers can more easily be on different development schedules) is another benefit, but you mentioned that it was a low priority.

I am currently working in an environment with C# WebParts hitting Java WebServices,  We have fought back and forth about versioning, tight and loose coupling, APIs, and more, but we always focus on ROI.  How much will this architecture change cost over the life cycle of the project, versus how much will we save in maintenance and development cost.

I would say do it.  You can add your WCF Service on the same machine that is currently running your web.  I believe separation of concerns, flexibility, and scalability would be worth it, as the change should be minimally invasive.

Title: Exposing business logic as WCF service

Body:
I'm working on a middle-tier project which encapsulates the business logic (uses a DAL layer, and serves a web application server [ASP.net]) of a product deployed in a LAN. The BL serves as a bunch of services and data objects that are invoked upon user action.

At present times, the DAL acts as a separate application whereas the BL uses it, but is consumed by the web application as a DLL. Both the DAL and the web application are deployed on different servers inside organization, and since the BL DLL is consumed by the web application, it resides in the same server.

The worst thing about exposing the BL as a DLL is that we lost track with what we expose. Deployment is not such a big issue since mostly, product versions are deployed together.

Would you recommend migrating from DLL to WCF service? If so, why? Do you know anyone who had a similar experience?


问:
What are the essential things one needs to know about UML?
I want my scribbles of a program's design and behaviour to become more streamlined and have a common language with other developers.

I looked at UML and in principle it seems to be what I'm looking for, but it seems to be overkill. The information I found online also seems very bloated and academic.

How can I understand UML in plain-English way, enough to be able to explain it to my colleagues? What are the canonical resources for understanding UML at a ground level?

答:
There are three parts to this:

Get a formal UML reference

Anytime you're learning a new "language", get a reference that you can pull out and use anytime, whether it's a book or an online resource. UML Distilled is small, has great explanations, and plenty of clear diagrams.  Even if you don't use all of the features, you can always go back and look at the "right" way to express something.

Use UML to model things

Now that you have a reference, start using it to model some small existing systems or systems you're starting to use.  You'll probably want to stick with with Class Diagrams, Sequence Diagrams, and State Diagrams for most situations.  If there's something you're not sure about, go to your reference and look up the "correct" usage - if that doesn't help, try some Googling or ask on Stack Overflow.  Just like programming, practice is key.

Use some UML in real projects

When you start using UML with your team, remember that it's just a tool for understanding the system you built or will build.  You should still check your reference while diagramming, but focus on conveying the information, not strictly following the rules.

Think back to your high school writing classes.  Your teacher probably considered it a cardinal sin to start sentences with "and," "but," or "or."  As you did more writing and gained more control over the English language, you learned how to bend the rules for greater effect - you made the transition from following the proper approach to the one that conveyed what you wanted to say the best.  UML should be used in the industry the exact same way.


答: To me it's just a starting point to lead to other questions. Obviously if you have zero experience, there's no need to go further, but if you claim 7 years, get ready for several in-depth questions. I doubt anyone got a job based on this blunt question alone.</p>

Title: How do you quantify competency in terms of time (years)?

Body:
While looking for a job via agencies some time ago, I kept having questions from the recuitment agents or in the application forms like:

How many years of experience do you have in:

Oracle

ASP.NET

J2EE etc etc etc....

At first I answered faithfully... 5yrs, 7yrs, 2 yrs, none, few months etc etc..

Then I thought; I can be doing something shallow for 7 years and not being competent at it simply because I am just doing a minor support for a legacy system running SQL2000 which requires 10 days of my time for the past 7 years. Eventualy I declined to answers such questions.

I wonder why do they ask these questions anymore. Anyone who just graduated with a computer science can claim 3 to 4 years experience in anything they 'touched' in the cirriculum, which to me can be equivalent to zero or 10 years depending how you look at it.

It might hold true decades ago where programmers and IT skills are of very different nature. I might be wrong but I really doubt 'time' or 'years' are a good gauge of competency or experience anymore.

Any opinion/rebuttal are welcome!


问:
Understanding and developing web services
This question is in conjuction with How would you approach developing a Hotel Reservation System?

The solution to a system with different interfaces (or clients I should say) is to go with developing a Web service and have other systems interact with it.

I never had the requirement for developing a Web service so I am bit short on it. All I understand is that A web service is a system or application that performs some operations which may include modifying, sending or receiving data over a network using HTTP protocol. (Let me know if the understanding is wrong)

Now, from the other question it's clearly understood that I need to develop a web service but I have no idea as to how should I go about it. My language of choice is C# and .NET Framework.

Question: How do we develop a webservice and which tools, technology and framework should I use for the same using C# language?

Question: How can I interact with this from a desktop WPF application, website and mobile app.

答:
"Web Services" are a fairly generic term to describe a data interchange mechanism that usually operates over HTTP (although not restricted to). There are many types of ways to implement web services and in particular, ways to exchange data.

SOAP Web Services

The type of "Web Service" most (.NET) developers are probably familiar with are SOAP web services. SOAP web services are pretty mature, well defined and have a whole bunch of w3.org standards and specifications. SOAP web service support is burned into most development frameworks, .NET has had SOAP web service support since its inception and the Visual Studio tooling makes it really easy to start building SOAP web services out of the box.

The problem with SOAP web services is that they aren't lightweight. You need to publish a WSDL document that describes the service and the XML interchanged between systems can be quite heavy due to the constructs used to assemble a SOAP message - Envelope, Header and Body.

The problem with SOAP messages is that they aren't easily or naturally consumed by web browsers (Javascript), you need to do a lot of work to make that happen or use something like Microsoft's AJAX client side script libraries that aren't exactly pretty or lightweight either.

XML-RPC

Another, but older, type of "web service" protocol is XML-RPC. It's probably the daddy of HTTP web services and provided the groundwork for SOAP. XML-RPC is not well supported in .NET and as with SOAP has a fairly large metadata overhead in the XML payload just to send even small amounts of data. XML-RPC is also not easily or naturally consumed by web browsers.

Custom XML or other interchange formats

It's entirely possible to construct a web service that exchanges data using custom XML messages. In fact webservices don't even need to use XML (see below), you can even exchange data over HTTP using plain old CSV. However the disadvantage of using non-standard formats is that when you come to serialise or deserialise the interchange format then you're committing to writing your own custom code to do that. SOAP and JSON have built in support in many frameworks to serialise and deserialise your objects to and from these formats. Ideally you want to be using a format that your framework can understand and do the heavy lifting for you out of the box.

JSON

If you're going to be making calls to a "web service" endpoint and the consumers of these services are going to be varied (such as in your case), for example a .NET WPF application, AJAX calls from the browser or pulling data into a mobile application (iPhone, Android etc), then the one data interchange format to put at the top of your list is JSON.

JSON is a very lightweight data interchange format and has a multitude of libraries available for many different programming languages and platforms.

For .NET applications there is built-in support for serialising and deserialising JSON and there are also excellent third party libraries such as James Newton King's Json.NET library (which is my own preference).

For mobile applications, whilst there is fairly solid support for SOAP on most mobile platforms, JSON would be a better choice due to it being more compact, and compact has great advantages if your mobile application is pulling data over a low speed 2G or 3G connection.

JSON is also easily consumed by Javascript in the browser, Javascript will rehydrate JSON formatted data into objects you can use directly in your browser side script. jQuery makes transmitting and receiving JSON data between the browser and a web service a fairly pain free affair. In fact JSON is probably the de-facto way to consume web service data in the browser.

So, in conclusion and to answer your two questions -

How do we develop a webservice and which tools, technology and framework should I use for the same using C# language?

To build the web service itself - web service endpoints built using ASP.NET MVC is probably the path of least resistance. You can use WCF but the learning curve can be fairly high and there's a fair bit of configuration and infrastructure code that comes along with the territory. However, there is a MS project on CodePlex called WCF Web API aimed at simplifying using WCF over HTTP, however it's still at the preview stage.

My advice would be to start by getting the hang of sending and receiving JSON over HTTP using ASP.MVC. Either use the built-in .NET JSON support or use something like Json.NET.

How can I interact with this from a desktop WPF application, website and mobile app?

To allow the WCF application to communicate with the web service above I'd certainly go with Json.NET to serialise and deserialise the JSON data and make your requests to the web service endpoint just using simple HttpWebRequest's

Browser based clients can make AJAX calls to push and pull JSON data between the web service and the browser. The path of least resistance here is to use jQuery

For mobile applications (iPhone, Android or Windows Phone 7) there are numerous ways to send, receive and consume JSON. For example, here, here and here

To REST or not to REST

A decision you may want to take at some point is whether to make your web services RESTful. The principles of REST are well documented but often misunderstood (some developers claim their web services are RESTful simply because they use "clean" urls). There isn't enough space here to begin explaining the philosophy of REST, I couldn't do the subject any justice and I'd likely get it wrong, however I do recommend obtaining a copy of RESTful Web Services published by O'Reilly Media. There are few questions on REST on this site that you may find worthwhile perusing.

Hopefully this answer will give you a jumping of point to get you started.


问:
Object-Oriented Operating System
As I thought about writing an operating system, I came across a point that I really couldn't figure out on my own:

Can an operating system truly be written in an Object-Oriented Programming (OOP) Language?

Being that these types of languages do not allow for direct accessing of memory, wouldn't this make it impossible for a developer to write an entire operating system using only an OOP Language?

Take, for example, the Android Operating System that runs many phones and some tablets in use around the world. I believe that this operating system uses only Java, an Object-Oriented language. In Java, I have been unsuccessful in trying to point at and manipulate a specific memory address that the run-time environment (JRE) has not assigned to my program implicitly. In C, C++, and other non-OOP languages, I can do this in a few lines.

So this makes me question whether or not an operating system can be written in an OOP, especially Java.

Any counterexamples or other information is appreciated.

答:
The android backbone is written on top of linux so not really. It is possible to write an Operating System in C++ and there are many ones out there albeit not popular. C++ gives you the OOP concepts you want while still allowing you to do the low level stuff that you need in order to communicate with hardware. C still is the language that most operating systems are written in (with some assembly backbone required) and this is because C is lightweight and personally I find it better just because it removes a lot of the OOP stuff that I find isn't needed to write an operating system (that's just my opinion though).

Technically it is possible to write an operating system in Java in a sense you would need to hook into C/C++ code (I can't remember how to do it in Java but I believe you can) which would in turn call on the assembly required to talk to some of the hardware. The java code would also have to compile directly to machine language instead of the current bytecode scheme that runs on the Java Virtual Machine.

The high level concept of the OS could be done in java but the problem is that a lot of the functionality would have to exist in another form as doing some of the required things for handling data from devices and such cannot easily be accomplished in Java if at all.

OwnerDisplayName: nmagerko

Title: Object-Oriented Operating System

OwnerDisplayName: Jesus Ramos


答:
You can't write an entire operating system in C either.  A small amount of it must be written in assembly for things like bootstrapping, entering supervisor modes, etc.  Add a little more assembly wrapped with a small peek/poke class and an interrupt handler class, and you're pretty much good to go in any OO language.  There will be obvious inefficiencies without direct pointer manipulation, but that just makes the language ill-suited.

The main problem with Java is not its object-orientation, but the fact that it doesn't compile to native bytecode, so you require a JVM that has to be written and bootstrapped via some other means.

Title: Object-Oriented Operating System

Body:
As I thought about writing an operating system, I came across a point that I really couldn't figure out on my own:

Can an operating system truly be written in an Object-Oriented Programming (OOP) Language?

Being that these types of languages do not allow for direct accessing of memory, wouldn't this make it impossible for a developer to write an entire operating system using only an OOP Language?

Take, for example, the Android Operating System that runs many phones and some tablets in use around the world. I believe that this operating system uses only Java, an Object-Oriented language. In Java, I have been unsuccessful in trying to point at and manipulate a specific memory address that the run-time environment (JRE) has not assigned to my program implicitly. In C, C++, and other non-OOP languages, I can do this in a few lines.

So this makes me question whether or not an operating system can be written in an OOP, especially Java.

Any counterexamples or other information is appreciated.


问:
Is Java a good choice for cross-platform games?
I'm looking to create a game in Java and would like it to work on Windows, Linux, and Mac. I'm pretty sure C# is a bad choice for this, and I don't have enough experience in C or C++. I want to stay away from Flash. Therefore, is Java a good choice for me? Mostly, I use C#, and think that Java is similar, so I assume it won't be that hard to learn. But is it fast enough? Is there a language more suited for my needs than Java?</p>

答:
Minecraft and Blocks that Matter are both built in Java, so yes it's plenty good for making games. The main issue you're going to run into while using Java is porting to mobile platforms if you choose to go that route and write a native app. Android is a kind of frankensteined Java SE with a separate library. RIM's Blackberry uses Java ME. iOS can in theory be programmed with Java though Objective-C would likely be a better choice for that platform.

Java is quite similar to C#. I often find C# code understandable despite only knowing Java. They do have a different design philosophy but as far as being widely deployable with minimal hassle both fit the bill. C# isn't a terrible choice for games by any stretch either though your mobile deployment will be harder and deploying to non-windows platforms will be more time consuming or difficult depending on what specific external libraries and so forth you wind up using.


答:
Java is extremely suitable for writing cross-platform games. Main advantages:

Portability - In general, you can write a Java game and expect it to run unchanged on most platforms. It's probably the most portable option of any language - C/C++ is the other highly portable option but needs to be recompiled for each platform and in many cases libraries have platform specific features that limit portability.

Performance - Java code, if written well, will perform pretty much as well as any other language, including C/C++. The JVM JIT compiler is extremely good. You can write a top quality, successful game in Java (Minecraft, for example).

Libraries - there are a huge range of libraries available for Java that cover almost every feature you could want in games, from networking to graphics to sound to AI. Most Java libraries are open source.

The main decision you will have to take is what GUI framework you are going to use. There are quite a few different options but the most prominent ones are:

jMonkeyEngine - fully fledged 3D engine. If you want to make a 3D game this is probably your best choice - contains lots of game engine features such as scene graphs, terrain generation etc.

LWJGL - a more low-level library with direct access to OpenGL. Likely to appeal to you if you want maximum performance and don't mind writing a lot of your engine from scratch.

Swing - has the advantage of being extremely portable and is included in the Java runtime so doesn't need an extra dependency. It's good for non-graphically-intensive 2D games (strategy games, card games etc.)

Slick - a 2D game library based on LWJGL. Probably good if you want to write a 2D  game but still need good graphics performance (shoot-em-ups, scrolling platform games etc.)

JavaFX - designed for rich internet applications, roughly like Flash. Has a lot of neat features that would be good for games although I haven't seen it used much yet. JavaFX 2.0 in particular is looking quite promising.

The main disadvantages for Java for gaming are really around the "edge cases" that probably won't affect you but are relevant for some classes of game:

3D engine availability - although the tools and engines listed above are good, they still aren't quite up to the level of C/C++ engines like the Unreal Engine used by professional game companies. So Java is possibly not goingto be your first choice if you are are trying to develop a major FPS with a multi-million budget - C/C++ still wins out here.

GC latency Java garbage collection is overall a huge benefit, but it can cause slight pauses when GC cycles happen. This is getting much better with new low-latency JVMs, but still can be an issue for games with very low latency requirements (first person shooters perhaps). A workaround is to use low latency libraries like http://javolution.org/, however these seem to be targetted more at high frequency trading or realtime systems rather than games.

Lack of ability to exploit low level optimisations - while the Java JIT compiler is incredibly good, it still enforces some constraints that you can't avoid (bounds checking on arrays, for example). If you really need to get native machine-code level access to optimise this kind of thing away, then again you will probably prefer C/C++ over Java.

Note that there are also a few deployment options to consider:

Applet - runs in a browser, very convenient for users, however applets are rather restricted in what they can do for security reasons. Note that you can sign applets to get extra security privileges, although this will cause a slightly scary prompt for most users.

Java Web Start - better for more sophisticated games that need a full local download and also need to access local system resources. It also works in a pretty platform-independent way. Probably the best route for a medium-sized game or something that needs to escape applet security restrictions.

Installer download - You can write an installer for a Java game just as you could for any other language. It's a bit more work to configure and test of course, since installers tend to have some platform-specific features.

Web - you could write a HTML5 web application and make use of the strength of Java purely on the server side. Worth considering for a multiplayer web game.

Finally, it's also worth considering some of the other JVM languages - these have all the benefits of the Java platform listed above, but some consider them to be better languages than Java itself. Scala, Clojure and Groovy would be the most prominent ones, and they can all make use of the Java tools and libraries listed above.

Title: Is Java a good choice for cross-platform games?

Body: I'm looking to create a game in Java and would like it to work on Windows, Linux, and Mac. I'm pretty sure C# is a bad choice for this, and I don't have enough experience in C or C++. I want to stay away from Flash. Therefore, is Java a good choice for me? Mostly, I use C#, and think that Java is similar, so I assume it won't be that hard to learn. But is it fast enough? Is there a language more suited for my needs than Java?</p>


答:
As a direct measure of competence, the number of years you work on something is probably irrelevant for the most part.  From a recruitment perspective however, it gives a very broad idea about whether a candidate has spent the time developing the experience needed for a given position.  The recruiter may not be inherently aware of this, but when you say something like "It takes 12 months to really get to know system X", what you are really saying is that in your experience, on the average most people would take about 12 months to learn enough about system x to be competent in your view. Of course, there are always a large enough number of people who exist outside the curve to make such statements inaccurate, but in order to have a wide enough selection of candidates without having to sift through every single person yourself, you specify criteria that will allow you to be introduced to a broad selection of candidates with varying skills and talents, and then work from there. If on the other hand you said "I expect you to have learned everything about system x in 2 months, 7 days, 5 hours, 11 minutes and 37 seconds, you're probably narrowing your field too unreasonably.

As far as whether or not to answer such questions... well that's entirely up to you.  Personally I think it's better to simply play the game, and then allow yourself to be able to quickly move on.  You may feel something is "stupid" or "unreasonable", but remember that even if you don't understand or agree with the reasoning, the method itself is simply a means to an end, and not necessarily a reflection of th competence of the interviewer!  ;-)


答:
The most obvious and least resistant way is to use HTML5+javascript combo. Any application or game made using this will run on almost every device and browser.

Advantage :- You will need zero configuration for making your game run on various platforms and devices.

NOTE:- I have seen few games that are build using the above said technologies but they were smaller in stature. But, I suppose if one can make butter out of milk then cheese is not impossible


答:
Short answer: no.

Java do not generates a binary executable but only bytecode as C# does ( CLI ), and this is not a good thing for serious business in "opened environments" for two main reasons:

the probability to get trapped in reverse engeneering are very high, especially with old and really well knowed languages like Java

you are not in full control over the machine performances, in the case of Java the JVM plays a big role taking the full control.

Of course every language has its own libraries but due to the great amount of them for each and every language this is not a real problem and i don't think is the purpose of this topic.

Maybe at a professional level you can find something that can break the rule like a dev-Kit that can translate all C# statements into assembly code for a real world machine, but if this kind of approach it's not in the cards you are pratically forced to consider only the C and the C++ for your development when you aim to sell your product in an open environment.

The things are a little bit different for the mobile devices because they are "closed environment" even Android is pratically closed considering the fact that the source of the real world ROMs are not usually available to the public, Android may be considered opensource but the 99% of the ROMs on actuals devices aren't. In this cases you can't argue too much, everything is already set for you and every platform has its own language like everybody knows.

In the end if you are going to sell this products in an opened environments i can only suggest languages that can produce compiled and binary/assembly code, in closed environments the decision is tipically more easy to do for different reasons.


问:
What are the best documentation patterns?
I've seen a lot of different ways to [or not to] comment out the code, specially patterns on desciptions of function details and file purposes.

I'd like to know what is most used pattern to do that [I'm specially interested on documentation generators and their patterns]

答:
Numerous projects are using Doxygen, and I think you won't go wrong to pick that one as your choice. I've previously been involved in a portion of a much larger project that used Doxygen during their build process, do I didn't get into the actual doc generation part of the build, but adding the comments was easy and straight forward .

If your project is large with sub-systems written in different languages, then Doxygen is beneficial because of the many languages it supports: C++, C, Java, Objective-C, Python, IDL (Corba and Microsoft flavors), Fortran, VHDL, PHP, C#, and to some extent D.


问:
How to estimate effort required to convert a large codebase to another language/platform

Possible Duplicate:

  Best way to estimate cost related to porting code from language A to language B?

We have an MFC C++ program with around 200,000 lines of code in it.  It's pretty much finished. We'd like to hire someone to convert it to work for Macs, but we are not sure how to properly estimate a reasonable timeline for this project.

What techniques can we use to estimate what it would take to convert this project to work on a Mac?

Also, is there anything in particular we should be watching out for specific to this sort of conversion?

答:
The first thing I'd do in trying to estimate the amount of work involved in this or any port is to figure out how much of the code needs to change and how much should work unmodified on the target platform.

If half the code is platform-neutral, the size of the porting project changes accordingly. It may be worthwhile to refactor the code on the original platform to make more of it platform neutral and achieve better separation between the platform-specific part and the platform-neutral part. You might consider that work to be part of the porting project, but it can be done by developers working on the original platform using tests that already exist. This approach lets you use the expertise you already have to best effect, saves time and money during the actual port, and leaves you with a code base that's partly shared between the two platforms, making it easier to keep the two versions in sync.

The next thing to do is to figure out how you want to implement the port. Do you want to rewrite the UI using Objective-C and Cocoa? Do you want to try to use some sort of compatibility tool that lets you build MFC on Mac? Do you want to port to Java instead, so that you can run anywhere? The degree of similarity between the original and target platforms will of course have a big impact on the amount of work required. If you can more or less use the original code as a template for the port, that'll speed up the work.

Evaluate your product's use of user interface conventions on both platforms. How much are you willing to change your product to make it feel less like a ported Windows product and more like a Mac product? Again, a straight port will be simpler, but may not fulfill your customers' expectations of what a Mac version should be. Certain differences (e.g. the Mac's Services menu) may not cost much because they're more or less automatic, while others (possibly undo support) may be a lot of work. Don't forget to factor in the cost of reworking graphic elements that can't be reused. For example, Windows applications often use ribbon bars full of tiny icons that would drive most Mac users nuts, and those icons may need to be redrawn for a better effect on the Mac.

These things will all help you understand what you want and what parts of the project are likely to be most difficult, but you'll probably still only end up with a ballpark idea of how much work is involved. If you're going to hire an outside firm to do the port, get estimates from several firms. If they mostly agree, you can feel better that the estimates are reasonable.


问:
Can the customer be a SCRUM Product Owner in a project?
I just had a discussion with a colleague about the Product Owner role: In a project where a customer organization has brought in a sofware developing organization (supplier), can the role of Product Owner be successfully held by the customer organization, or should it always be held by the supplier?

I always imagined, that the PO was the supplier organizations guy. The guy that ensured that the customer is happy, and continously fed with new and high-businessvalue functionality, but still an integral part of the developer organization. However, maybe I have viewed the PO role too much like the waterfall project manager.

My colleague made me think: If the customer organization is mature and proffessional enough, why not let a person from their camp prioritize the backlog?? That would put the PO role much closer to the business, thus being (in theory) better to assess the business value of backlog items. To me, that is an intriguing thought. But what are the implication of such a setup???

I look forward to your input.

答:
Good product owner needs to answer few fundamental questions:

Will I be available for team enough for planning and review?

Will I be able to constantly work on next release & sprints preparation?

Will I be able to approve implemented functionality fast enough? In ideal case it means immediately is functionality completed.

In my experience it is better to have product owner who is YOUR team member.

You need someone who understand what developers say, but also what customer needs.

product owner should works with your accounting, sale etc.

developers must see & feel that product owner is on 'the same boat'

sometimes you will have to say NO to customer to open his mind.


答:
You are miss-using a lot of terminology in your question.

OOP is a style of structuring programs. As such it is independent of programming language, you can easily do OOP in C. A lot of OS-APIs are in fact object-oriented, for example everything that returns a handle. OOP has nothing to do with not being able to unsafe operations in your programming language.

I think what you are really asking is: Can you write an OS in a language with automatic memory management and memory-safety?

The answer to that is: You have to cheat at some place.

Some options:

Make the compiler/runtime map some special objects directly to the addresses
you need.

Add the necessary hardware-representation objects to the compiler/runtime build-in library (and do the unsafe stuff within the compiler) - somewhat similar to the first option

Extend the language/library with unsafe operations

Change the hardware so that it directly supports your language objects (e.g. http://en.wikipedia.org/wiki/Java_processor)

Title: Object-Oriented Operating System


答: Developers in Visual Studio tend to use the ///  because apart from being able to generate an Xml usable as input for document generators, you also get tooltips during development when using the commented method/class.

Title: What are the best documentation patterns?

Body:
I've seen a lot of different ways to [or not to] comment out the code, specially patterns on desciptions of function details and file purposes.

I'd like to know what is most used pattern to do that [I'm specially interested on documentation generators and their patterns]

Body: Developers in Visual Studio tend to use the /// <summary /> because apart from being able to generate an Xml usable as input for document generators, you also get tooltips during development when using the commented method/class.


问:
What, if anything, to do about bow-shaped burndowns?
I've started to notice a recurring pattern to our team's burndown charts, which I call a "bowstring" pattern.  The ideal line is the "string" and the actual line starts out relatively flat, then curves down to meet the target like a bow.

My theory on why they look like this is that toward the beginning of the story, we are doing a lot of debugging or exploratory work that is difficult to estimate remaining work for.  Sometimes it even goes up a little as we discover a task is more difficult once we get into it.  Then we get into implementation and test which is more predictable, hence the curving down graph.  Note I'm not talking about a big scale like BDUF, just the natural short-term constraint that you have to find the bug before you can fix it, coupled with the fact that stories are most likely to start toward the beginning of a two-week iteration.

Is this a common occurrence among scrum teams?  Do people see it as a problem?  If so, what is the root cause and some techniques to deal with it?

答:
Your situation is typical. Many scrum masters are hunting for great burn down chart. I see such behavior as mistake that leads to many problems later. Burn down chart is an early warning indicator.

If on your Y axis are story points then flat line is correct. Stories are typically longer than 1 day and oonly once they are completed, the line is going down.

If you have hours on your Y axis then such pattern says your team is either not updating remaining time or they are not able to estimate it.

Even such pattern the team is still able to deliver, then it means they are able to estimate sprint capacity correctly. And this is what really matters. To estimate so they are able to accomplish what they promised.

Different burn down patterns are described in interesting way at http://www.scrumdesk.com/is-it-your-burn-down-chart/


问:
What's the worst programming book you've ever read?
What's the worst programming-related or technical book you've ever read? This can be any book which one way or another can be connected to programming, as long as it's not fiction.</p>

答:
Let Us C -  Yashavant P. Kanetkar

Object Oriented Programmig with C++ - E Balagurusamy


问:
How do I learn Python from zero to web development?
I am looking into learning Python for web development.

Assuming I already have some basic web development experience with Java (JSP/Servlets), I'm already familiar with web design (HTML, CSS, JS), basic programming concepts and that I am completely new to Python, how do I go about learning Python in a structured manner that will eventually lead me to web development with Python and Django?

I'm not in a hurry to make web applications in Python so I really want to learn it thoroughly so as not to leave any gaps in my knowledge of the technologies involving web development in Python. Are there any books, resource or techniques to help me in my endeavor? In what order should I do/read them?

UPDATE:

When I say learning in a structured manner, I mean starting out from the basics then learning the advanced stuff without leaving some of the important details/features that Python has to offer. I want to know how to apply the things that I already know in programming to Python.

答:
First learn Python well

Here are some online resources for learning Python

The Python Tutorial

Wiki-Book

Byte of Python

Building Skills in Python Version 2.5

Python Free Online Ebooks

Python Bibliotheca

Think Python

Data Structures and Algorithms in Python

How to Think Like a Computer Scientist: Learning with Python

Python for Fun

Invent Your Own Computer Games With Python

Learn Python The Hard Way

Thinking in Python

Snake Wrangling For Kids

For Django you can refer

The Django book

What I suggest is

The Python Tutorial

Wiki-Book

The Django Book

Also check out this video


问:
Template Functions and Function templates in C++
I came across a question which asked the difference between Function Templates and Template Functions in C++ and also Template Classes and Class Templates.

I was under the impression that Function Templates and Template Functions were the same thing. Is there any difference between the two, if so what is it?

答:
Is there any difference between the two, if so what is it?

No difference at all. If you google for it, you can see that somewhere it is defined as function templates and somewhere as template function.

I was under the impression that Function Templates and Template
  Functions were the same thing.

Your understanding was correct.


答: They are the same thing. The Standardese is "function template" and "class template", however many people (including myself) tend to refer to them as "template function" and "template class", for the simple and obvious reason that when you define one, first you write "template" and then you write "class", or a function. Hence, they are often referred to as both.</p>

Title: Template Functions and Function templates in C++

Body:
I came across a question which asked the difference between Function Templates and Template Functions in C++ and also Template Classes and Class Templates.

I was under the impression that Function Templates and Template Functions were the same thing. Is there any difference between the two, if so what is it?


问:
Programming logic to group a users activities like Facebook
So I am trying to develop an activity feed for my site. Basically If I UNION a bunch of activities into a feed I would end up with something like the following.

Chris is now friends with Mark

Chris is now friends with Dave

What I want though is a neater way of grouping these similar posts so the feed doesn't give information overload...

E.g.

Chris is now friends with Mark, Dave and 4 Others

Any ideas on how I can approach this logically? I am using Classic ASP on SQL server. Here is the UNION statement I have so far:

```<code>SELECT
    U.UserID As UserID, L.UN As UN,Left(U.UID,13) As ProfilePic,U.Fname
    + ' '
    + U.Sname As FullName, 'said '
    + WP.Post AS Activity, WP.Ctime
FROM
    Users AS U LEFT JOIN Logins L ON L.userID = U.UserID
LEFT OUTER JOIN
    WallPosts AS WP ON WP.userID = U.userID WHERE WP.Ctime IS NOT NULL
UNION SELECT
    U.UserID As UserID, L.UN As UN,Left(U.UID,13) As ProfilePic,U.Fname
    + ' '
    + U.Sname As FullName, 'commented '
    + C.Comment AS Activity, C.Ctime
FROM Users AS U
LEFT JOIN Logins L ON L.userID = U.UserID
LEFT OUTER JOIN
    Comments AS C ON C.UserID = U.userID WHERE C.Ctime IS NOT NULL
UNION SELECT
    U.UserID As UserID, L.UN As UN,Left(U.UID,13) As ProfilePic, U.Fname
    + ' '
    + U.Sname As FullName, 'connected with '
    + (SELECT Users.Fname
    + ' '
    + Users.Sname FROM Users WHERE userID = Cn.ToUserID)
    + '' AS Activity, Cn.Ctime
FROM
    Users AS U
LEFT JOIN
    Logins L ON L.userID = U.UserID
LEFT OUTER JOIN
    Connections AS Cn ON Cn.UserID = U.userID WHERE CN.Ctime IS NOT NULL
</code>```

答: My suggestion is to use a subquery to select only those messages and to group them: as long as all the messages begin with the same string ("Chris is not a friend with") you can easily select them and extract the friends' names. Then you just have to concatenate those and add it to your personal webpage. </p>

OwnerDisplayName: Chris Dowdeswell

Body:
So I am trying to develop an activity feed for my site. Basically If I UNION a bunch of activities into a feed I would end up with something like the following.

Chris is now friends with Mark

Chris is now friends with Dave

What I want though is a neater way of grouping these similar posts so the feed doesn't give information overload...

E.g.

Chris is now friends with Mark, Dave and 4 Others

Any ideas on how I can approach this logically? I am using Classic ASP on SQL server. Here is the UNION statement I have so far:

```<code>SELECT
    U.UserID As UserID, L.UN As UN,Left(U.UID,13) As ProfilePic,U.Fname
    + ' '
    + U.Sname As FullName, 'said '
    + WP.Post AS Activity, WP.Ctime
FROM
    Users AS U LEFT JOIN Logins L ON L.userID = U.UserID
LEFT OUTER JOIN
    WallPosts AS WP ON WP.userID = U.userID WHERE WP.Ctime IS NOT NULL
UNION SELECT
    U.UserID As UserID, L.UN As UN,Left(U.UID,13) As ProfilePic,U.Fname
    + ' '
    + U.Sname As FullName, 'commented '
    + C.Comment AS Activity, C.Ctime
FROM Users AS U
LEFT JOIN Logins L ON L.userID = U.UserID
LEFT OUTER JOIN
    Comments AS C ON C.UserID = U.userID WHERE C.Ctime IS NOT NULL
UNION SELECT
    U.UserID As UserID, L.UN As UN,Left(U.UID,13) As ProfilePic, U.Fname
    + ' '
    + U.Sname As FullName, 'connected with <a href="/profile.asp?un='+(SELECT Logins.un FROM Logins WHERE Logins.userID = Cn.ToUserID)+'">'
    + (SELECT Users.Fname
    + ' '
    + Users.Sname FROM Users WHERE userID = Cn.ToUserID)
    + '</a>' AS Activity, Cn.Ctime
FROM
    Users AS U
LEFT JOIN
    Logins L ON L.userID = U.UserID
LEFT OUTER JOIN
    Connections AS Cn ON Cn.UserID = U.userID WHERE CN.Ctime IS NOT NULL
</code>```

OwnerDisplayName: Alexander Galkin


问:
Why the loops are avoided in Kruskal's algorithm?
I read Kruskal's algorithm as it's presented on Wikipedia. There, it says that it's an algorithm in graph theory that finds a minimum spanning tree for a connected weighted graph.

But while going through the examples that illustrate this algorithm I am unable to understand why the loops are avoided by marking some of the edges in red.

What is the reason for this?

答: Kruskal's algorithm, gives a minimum spanning tree, and a tree does not have any cycles (loops). So the algorithm should avoid construction of loops in finding the minimum spanning subgraph.

OwnerDisplayName: Suhail Gupta

OwnerDisplayName: saeedn


答:
You must already know that you cannot have cycles in a tree. So while adding any edge to the MST you must make sure that no loop or cycle is being created .
Secondly in the example that you posted , red color is only used to clarify that this particular link should not be added to the MST as it will create a loop. So loops are not avoided by making some of the edges red rather loops are avoided by not adding the edges that connect the already connected vertices ( for example B and D in step 5 of the example mentioned by you) and such links are shown in red to avoid confusion</p>

Title: Why the loops are avoided in Kruskal's algorithm?

Body:
I read Kruskal's algorithm as it's presented on Wikipedia. There, it says that it's an algorithm in graph theory that finds a minimum spanning tree for a connected weighted graph.

But while going through the examples that illustrate this algorithm I am unable to understand why the loops are avoided by marking some of the edges in red.

What is the reason for this?


问:
Best practices for upgrading user data when updating versions of software
In my code I check the current version of the software on launch and compare it to the version stored in the user's data file(s).  If the version is newer, then I call different methods to update the old data to the newer data version, if necessary.

I usually have to make a new method to convert the data with each update that changes user data in some way, and cannot remove the old ones in case there was someone who missed an update.  So the app must be able to go through each method call and update their data until they get their data current.  With larger data sets, this could be a problem.

In addition, I recently had a brief discussion with another StackOverflow user this and he indicated he always appended a date stamp to the filename to manage data versions, although his reasoning as to why this was better than storing the version data in the file itself was unclear.

Since I've rarely seen management of user data versions in books I've read, I'm curious what are the best practices for naming user data files and procedures for updating older data to newer versions.

Edit:
The 'date stamp' stemmed form a discussion here:

https://stackoverflow.com/questions/8104812/does-releasing-a-new-version-of-the-app-delete-files-of-the-older-one/8104906#8104906

Since the question is too open-ended, I should say I'm looking for the recommended procedures for upgrading user data between versions.

If possible, it would be nice to see iOS / objective-c practices, but it's not required.

答:
Dates are helpful for when you need extra information about when something was happening. There is no harm to adding them to a file that already contains a version number.

However, you can not use a time stamp as the sole indicator of what version is running, therefore deciding what needs updating. Just because you released 2 updates in the last year does not mean that someone with an install date within that range is using one of those two versions. If the user gets a copy of the installer, they can hold on to it for future clean installs and expect the software to update itself instead of getting the newest version.


问:
How does fair use apply to code snippets?
Is there a size where you can copy under fair use for code you don't have a license for the purpose? For example, what if I copy a snippet that is (normally) 3 lines of code? Is that fair use? If it is fair use, what length is required before I need a license?</p>

答:
In the US, the legal doctrine of Fair Use does not apply to embedding excerpts of copyrighted works into source code. How such doctrine is applied by the laws of your jurisdiction may vary.

I will excerpt from a US Copyright Office article on Fair Use, and of copyrights generally:

Section 107 contains a list of the
various purposes for which the
reproduction of a particular work may
be considered fair, such as criticism,
comment, news reporting, teaching,
scholarship, and research [emphasis mine]. Section 107
also sets out four factors to be
considered in determining whether or
not a particular use is fair:

The purpose and character of the use,
including whether such use is of
commercial nature or is for nonprofit
educational purposes

The nature of the
copyrighted work

The amount and
substantiality of the portion used in
relation to the copyrighted work as a
whole

The effect of the use upon the
potential market for, or value of, the
copyrighted work.

The distinction
between fair use and infringement may
be unclear and not easily defined.
There is no specific number of words,
lines, or notes [emphasis mine] that may safely be
taken without permission.
Acknowledging the source of the
copyrighted material does not
substitute for obtaining permission.

It summarizes the legal limits of copyright, which Fair Use further limits, like so:

Copyright protects the particular way
an author has expressed himself. It
does not extend to any ideas, systems,
or factual information conveyed in the
work.

The safest course is always to get
permission from the copyright owner
before using copyrighted material. The
Copyright Office cannot give this
permission.

What the limits of what copyright protects tells us is though you cannot copy "snippets" of code via Fair Use, you can rewrite the way ideas, systems (including algorithms), or factual information are expressed in those snippets.

In short, 3 lines of code should be small enough for you to rewrite it so as not to violate the original work's copyright. It probably took longer to write your question than it will to do the rewrite.

ContentLicense: CC BY-SA 4.0


答:
The immediate benefit of a timestamps I can see is that you then have a sequence. I'd recommend the timestamp be inserted into a constants file, though, at build time. This makes the timestamp indicative of the build version (not the time of installation/upgrade).

Other than that, though, I'd say it's up to you. You can easily write a class to help out with version sequencing, depending on your version naming method (1.x, 1.2.x, etc.).

Title: Best practices for upgrading user data when updating versions of software

Body:
In my code I check the current version of the software on launch and compare it to the version stored in the user's data file(s).  If the version is newer, then I call different methods to update the old data to the newer data version, if necessary.

I usually have to make a new method to convert the data with each update that changes user data in some way, and cannot remove the old ones in case there was someone who missed an update.  So the app must be able to go through each method call and update their data until they get their data current.  With larger data sets, this could be a problem.

In addition, I recently had a brief discussion with another StackOverflow user this and he indicated he always appended a date stamp to the filename to manage data versions, although his reasoning as to why this was better than storing the version data in the file itself was unclear.

Since I've rarely seen management of user data versions in books I've read, I'm curious what are the best practices for naming user data files and procedures for updating older data to newer versions.

Edit:
The 'date stamp' stemmed form a discussion here:

https://stackoverflow.com/questions/8104812/does-releasing-a-new-version-of-the-app-delete-files-of-the-older-one/8104906#8104906

Since the question is too open-ended, I should say I'm looking for the recommended procedures for upgrading user data between versions.

If possible, it would be nice to see iOS / objective-c practices, but it's not required.


问:
How to be up to date with the LAMP platform?
Most of times I get to know about the new features too late. It is okay at least I know about them does not matter from where I know But I feel it is too late to know about those features.

I am working on LAMP platform and I want to keep myself up to date with the new things, anything happening new with LAMP.

Can you please let me know what resources should I use? What groups should I follow?
From where I can get the latest updates about any activity, event and feature about LAMP?

答:
There isn't a single authoritative source for LAMP.  A good place to start is subscribing to the news on the front pages of each of the components:  your favorite Linux distro, apache, mysql, and php.  They should all have rss feeds.  Mysql even has a facebook page.  Likewise for related technologies you may be using, such as jQuery or a CMS.

There are sites that specialize in tech news, such as slashdot or reddit.  Google news also lets you subscribe to news based on search terms, from which you will find other sources you like.

If you read questions on StackOverflow, even if you don't know enough to answer them, you will find out about the newer technologies.


问:
What web oriented language would work best with binary data?
I want to create a service where people can upload files. However, since file storage costs money, I want to compress the files so they take less space. I would want to write my own compression algorithm, however, PHP doesn't have good ways to handle binary data (which is needed for many compression algorithms). So I wondered, what would be a better language to create such a website in?

I have knowledge of PHP (and Javascript, HTML and CSS) but no experience with other things like Ruby, Perl, Python, and other web development languages.

答:
PHP supports a variety of compression algorithms and popular compression libraries, like Bzip2, LZF and Rar, and for most common scenarios it provides excellent support for working with binary data. There's at least one working PHP implementation of a compression algorithm out there, proving that it's possible. PHP and any other interpreted language may prove inefficient for the task, but efficiency issues highly depend on the specifics of the implementation and the actual usage of your library, for which you don't provide enough information.

I would advise you to not try and create your own compression algorithm and use an established library instead, there's no point in reinventing the wheel. You don't have to use PHP if you don't want to, every web oriented language out there has support for popular compression libraries. You can use perl's Gzip and Zlib core modules, or Python's gzip or bzip2 modules. I don't know what kind of support for compression Ruby has, but this StackOverflow question can help you, if you choose Ruby.

But if for any reason you really want to write your own original compression algorithm, you should probably choose C. C is extremely portable* and if you manage to actually built a compression library then you can use it from PHP via an extension or in Python via a module. Both PHP extensions and Python modules are also commonly written in C, and it would be fairly easy to write one of those if you coped with writing a compression algorithm. And there's always the old school option of C web programming via CGI, if you don't mind diving into a world of hurt.

* There are C compilers for almost every imaginable platform and ways to use C libraries from almost every other language.


答:
Haskell, Ruby, Python, Java and other JVM languages, and C# and other .NET languages all have good support for both web programming and programming against binary data.

I personally would find Ruby and Python to be the simplest to get into.

Title: What web oriented language would work best with binary data?

Body:
I want to create a service where people can upload files. However, since file storage costs money, I want to compress the files so they take less space. I would want to write my own compression algorithm, however, PHP doesn't have good ways to handle binary data (which is needed for many compression algorithms). So I wondered, what would be a better language to create such a website in?

I have knowledge of PHP (and Javascript, HTML and CSS) but no experience with other things like Ruby, Perl, Python, and other web development languages.


答: Any language that allows you to shuffle bits and bytes can be used to write a compressor. I'm pretty sure PHP lets you shuffle bits and bytes but it's been a while since I wrote anything in it. Various javascript environments like Node.js also have support for binary data so it's not a matter of which web-oriented language would work best with binary data but how much of a performance penalty you're willing to take by writing a compressor in one.</p>


问:
Why isn't Java more widely used for game development?
I'm not a game developer or anything, but I know that Java is not very widely used for game development. Java should be fast enough for most games, so where's the catch? I can think of some reasons:

Lack of game developers with expertice in Java

Lack of good game development frameworks

Programmers don't want to accept Java as a games programming language. Most only accept C++ as that?

No support for game consoles (though the PC market still exists)

It could of course be something else. Could someone who knows the business better than me explain why Java isn't getting momentum when it comes to game development?

答:
Technical reasons:

Most of the best 3D game engines are written in C/C++. This is a big deal, since most game developers don't want to compromise on their 3D engine, but nor do they want to write one from scratch. Java has jMonkeyEngine which is open source and actually really good but it still can't yet compete with the Unreal Engine.

For some very rare situation, there are advantages in getting "close to the metal" in C or assembly language, specifically for access to special hardware features. This is not so important nowadays, but professional game developers still like to have the option.....

Java has a garbage collected, managed runtime. 99% of the time this is a huge advantage, it certainly makes coding easier and less error-prone and is one of the big reasons why Java is so popular. However it does cause an occasional latency issue for games as garbage collection cycles can cause noticeable pauses. This is getting to be less of an issue with the newer low-latency JVMs, but is still an issue for graphically intensive games where maintaining high FPS is critical.

Non-technical reasons:

Professional game development houses are heaviliy invested in C/C++ skills and technologies. This creates a huge amount of inertia.

The largely irrational perception that Java is slow. Possibly true in the 90s, definitely not true now - you can certainly write a profitable, commercial 3D game with Java (Runescape anyone? Or how about Minecraft? )

A pretty fair perception that Java is more focused on business applications and the web rather than gaming. This might change with the growth of Mobile and the need for more cross-platform development, but is certainly true at present.

Interestingly there are also some good reasons why game developers should consider Java:

Portability - as the number of target platforms proliferate, Java becomes more and more attractive with it's pretty much unparalleled ability to create genuinely cross-platform binaries

Library ecosystem - with the very important exception of 3D game engines, Java has the best range of libraries overall of any platform. Networking, sound, AI, image processing, key/value data stores, you name the topic and there's probably an open-source Java library for it.

Server side development - Java is a great langauge/platform for the server, and as more games incorporate massively multi-player elements the server side will become more and more important. Java on Linux looks pretty compelling here as a platform.

The JVM - is probably the best engineered VM execution environment in the World, with fantastic garbage collection, JIT compiler, concurrency support etc. It's only going to get better, and as game developers increaingly start to use dynamic languages within their games they will want the best possible runtime environment.

Other JVM languages - Java is a solid old workhorse, but the real innovation is happening with the new JVM langauges (Kotlin in particular). These languages get all the advantages of the Java/JVM platform, plus they are extremely powerful modern languages.


问:
Why do we need URIs for XML namespaces?
I am trying to figure out why we need URIs for XML namespaces and I cannot find a purpose for that. Can anyone brighten me a little showing their use on a concrete example?

EDIT:

Ok so for instance: I have this from w3schools

```<code><root
xmlns:h="http://www.w3.org/TR/html4/"
 xmlns:f="http://www.w3schools.com/furniture">

 <h:table>
   <h:tr>
     <h:td>Apples</h:td>
     <h:td>Bananas</h:td>
   </h:tr>
 </h:table>

 <f:table>
   <f:name>African Coffee Table</f:name>
   <f:width>80</f:width>
   <f:length>120</f:length>
 </f:table>

 </root>
</code>```

So what should http://www.w3schools.com/furniture hold ?

答:
In general terms, any unique identifier would serve for a namespace; but since it's supposed to be globally unique, the standard would have to either mandate some arbitration authority, or use another resource that is at the same time globally unique but easy to get hold and to prove it's yours.

Oh, look! if you have a domain, it's obviously only yours, and it's easy to prove it's yours!

For example, they wanted to avoid the situation where two different bookstores start using "books" as a namespace, with totally different internal definitions.  While they use it internally, there's no problem; but as soon as one of them wants to publish their specification, all hell breaks loose.

Instead, if you're encouraged to use your domain, anybody (well, anybody who owns a domain) can define their own private namespace with the confidence that nobody else will use the exact same identifier.

As a bonus, you can optionally store the definition of your namespace at the URI, making it self-documenting.

Seems like a great idea to me.

Title: Why do we need URIs for XML namespaces?


答:
A namespace is a way of saying "This kind of Foo" is different from "That kind of Foo", even though they are spelled the same.  Or, if you prefer "MY kind of Foo" is different from "Everybody else's kind of Foo".

The technical way of saying this is "The URI of my namespace for Foo" is different from everybody else's URI for their namespace for Foo.  In other words, URIs are just strings that allow you to say so.

The trick is then to say, "Hey, URLs are valid URIs", and then use a URI corresponding to a URL under your control.  If everybody does that, then you can avoid accidental namespace collisions.  You could as well have said namespace "A" and namespace "B", but you risk that somebody else would use the same namespace too, and then your kind of Foo is not different from their Foo anymore which is exactly what you want to avoid.

You can then add additional conventions to the URLs used as URIs, for instance, that the URL must correspond to a page containing documentation or XSDs or similar, but this is not necessary.  It is just convenient.

Title: Why do we need URIs for XML namespaces?

Body:
I am trying to figure out why we need URIs for XML namespaces and I cannot find a purpose for that. Can anyone brighten me a little showing their use on a concrete example?

EDIT:

Ok so for instance: I have this from w3schools

```<code><root
xmlns:h="http://www.w3.org/TR/html4/"
 xmlns:f="http://www.w3schools.com/furniture">

 <h:table>
   <h:tr>
     <h:td>Apples</h:td>
     <h:td>Bananas</h:td>
   </h:tr>
 </h:table>

 <f:table>
   <f:name>African Coffee Table</f:name>
   <f:width>80</f:width>
   <f:length>120</f:length>
 </f:table>

 </root>
</code>```

So what should http://www.w3schools.com/furniture hold ?


问:
MIT vs. BSD vs. Dual License
My understanding is that:

MIT-licensed projects can be used/redistributed in BSD-licensed projects.

BSD-licensed projects can be used/redistributed in MIT-licensed projects.

The MIT and the BSD 2-clause licenses are essentially identical.

BSD 3-clause = BSD 2-clause + the "no endorsement" clause

Issuing a dual license allows users to choose from those licenses—not be bound to both.

If all of the above is correct, then what is the point of using a dual MIT/BSD license? Even if the BSD refers to the 3-clause version, then can't a user legally choose to only abide by the MIT license?

It seems that if you really want the "no endorsement" clause to apply then you have to license it as just BSD (not dual). If you don't care about the "no endorsement" clause, then MIT alone is sufficient and MIT/BSD is redundant.

Similarly, since the MIT and BSD licenses are both "GPL-compatible" and can be redistributed in GPL-licensed projects, then dual licensing MIT/GPL also seems redundant.

答:
My understanding is that:

MIT-licensed projects can be used/redistributed in BSD-licensed projects.

True (but unless there are modifications, the users can get it from the sources also.

BSD-licensed projects can be used/redistributed in MIT-licensed projects.

False The BSD 3-clause places additional restrictions on redistribution.

The MIT and the BSD 2-clause licenses are essentially identical.

True Although there is some ambiguity around whether some parts of the MIT license apply to binaries.

BSD 3-clause = BSD 2-clause + the "no endorsement" clause

True.

Issuing a dual license allows users to choose from those licenses—not be bound to both.

True.

Similarly, since the MIT and BSD licenses are both "GPL-compatible" and can be redistributed in GPL-licensed projects, then dual-licensing MIT/GPL also seems redundant.

No. Here is a major difference. MIT license and Apache License only requires that you give credit to original copyright holders. If you choose, you can redistribute source; but if you choose you can keep your new derived product without opening code. Hence, it is possible to use code developed under MIT and Apache—under a commercial license.

If you ever use code with GPL-based license and happen to modify it, you must distribute your modified code as well under GPL. In other words, once any GPL codebase is used under a project, and if you want to publish that as a product, it has to be published with the source code and it has to be published under GPL. It cannot ever be a commercial license or closed source, and it cannot be any other license which is less strict than GPL.

An example can take MIT, Apache or BSD license code, modified and distributed under GPL. Once a codebase is distributed as GPL, its further derived versions cannot be distributed under MIT, Apache or BSD license but must be GPL only.

Edit:

An example case of dual license: Suppose Nice Office is released under dual license—MIT and GPL. It has two possibilities. Some people can create NicePro Office, which can be commercial and sell. Whereas some other open source community creates a fork NiceOpen Office. In this case, it can enforce upon GPL distribution (of the original Nice Office as well as NiceOpen Office version) hence if you start with NiceOpen Office, you must comply to GPL only and not MIT license.

The point is in case of dual license the first person who derives a license has a choice. He can choose either way - however, the second person needs to adhere to the choice the first person made. He/She cannot override the original rights of either generation and cannot in any way reduce the obligation of the applicable license.

EDIT 2

Adding an interesting read - GPL and MPL Licenses has a serious conflict. Read this.

OwnerDisplayName: ryanve

Title: MIT vs. BSD vs. Dual License


答:
DOM Level 2 was published in late 2000. It introduced the
  "getElementById" function as well as an event model and support for
  XML namespaces and CSS.

What xmlIns specifies?

As attribute nodes named "xmlns" or "xmlns:xxx", exactly as the namespaces are written in the source XML document. This is the model presented by DOM.

What URI contains?

An XML namespace is declared using the reserved XML pseudo-attribute xmlns or xmlns:prefix, the value of which must be a valid namespace name.

For example, the following declaration maps the "xhtml:" prefix to the XHTML namespace:

xmlns:xhtml="http://www.w3.org/1999/xhtml"

AS i have discovered after reading the article on Wikipedia. URI contains the XML formatted specifications of the namespace  provide a method to avoid element name conflicts.

May be you know xml document uses XML Schema for the element/table/class structure of elements of the XML document.

what should http://www.w3schools.com/furniture hold ?

The answer is on your page where you have learned about the XML Namespace. Check Namespaces in Real Use section on this W3Schools article.

Check following link of stackoverflow which some what demonstrate that what this URI carries:

How to create and use XML namespace?

Title: Why do we need URIs for XML namespaces?


问:
What are the key points of Working Effectively with Legacy Code?
I've seen the book Working Effectively with Legacy Code recommended a few times.  What are the key points of this book?

Is there much more to dealing with legacy code than adding unit/integration tests and then refactoring?

答:
In a nut shell that's true - adding tests and refactoring is what's it all about.

But the book gives you many different techniques to do so with code that is very difficult to test and refactor safely.