问:
Is the agile approach too much of a convenient excuse for cowboys
I believe that an agile approach is best for projects where the requirements are fuzzy and a lot of interaction is required to help shape the end user's ideas.

However... In my professional work, I keep ending up at companies where an "agile" approach is used as an excuse as to why no effort was put into an up front design; when the requirements are well understood.

I can't help but thinking that if the agile approach wasn't around, I'd be sitting here with a nice high-level specification and not having to revisit the same screen and functionality every second day when something else crops up or so and so hadn't thought of that.

Are the benefits of agile methodologies really enough to outweigh the excuse for being lame it gives to cowboy technical leads?

Update: Ironically I'm now a certified Scrum Master. One of the papers presented on the Scrum course observed that the best development process was one where there was a single expert or guru making the design decisions, however that has obvious weaknesses. Scrum shifts the responsibility for producing quality software to the "Team" which means a sub-standard team can get away with churning out spaghetti which I guess is no different to other Agile and non-Agile development processes.

答: Oddly enough, from the "agile" projects I've been involved with, it seems more like a management excuse to skip the requirements-gathering phase than a cowboy desire to simply start coding.  My projects have been extremely frustrating because we don't have any end-users to interact with.  Instead, we have a director who talks to sales to find out what they think customers want, then calls a meeting and describes it to the managers, who then start assigning tasks to developers.  On a "good" project we might have a PP presentation to refer to, but usually we wind up spending our daily scrum meetings asking how some feature's supposed to work, and the manager writes down the questions and asks the director.  It's a huge waste of time -- but it's "agile"!


问:
What is the best way to generate an accurate release changelog?
I'm working on some projects where I'd like to supply an accurate changelog with each release, but I haven't found a method for collecting the changelog that would work without hassle. The problem is mostly when the time between versions is long and each version ships with a lot of features and bug fixes, and when the software has several branches being developed at the same time.

Some options I've considered:

Build the changelog from commit messages and require developers to write the messages as if they would be writing a line for the changelog (which they would effectively be doing).

Might not work when there are multiple branches and merging between branches (might be hard to know which commits have ultimately ended up in the release).

Require that for each change in the code there should be a corresponding ticket in the bug tracking system. The changelog could be written based on the tickets.

The devs might find it frustrating to make a ticket for even minor changes, especially if making the ticket takes longer than fixing the bug.

Require that the developers always update the changelog (as a text file in project root) at the same time when they make changes to the code.

Feels like manual labor that could be automated.

Have the project manager take the diff of the current version and the previous one and write the changelog at that point based on what they see that's been changed.

Extra work for the person responsible for the release and it might not be obvious what the practical effect of a change is just by looking at the code.

Ship only the features that have been planned for the release; you can write the changelog even before you start coding.

Not a real option unless you're using the waterfall model.

I've used each of these or a variation of them in the past but they have been too unreliable, laborous or rigid. Does anyone have a magic bullet or good ideas on how to solve the problem?

答:
Feels like manual labor that could be automated.

How could it be automated? There is no need to edit the changelog on each commit, but only when a feature worth mentioning is added. Does that happen so often on your software that it's a hassle to add one line to the changelog every time?

ContentLicense: CC BY-SA 3.0


问:
Are operators just "special" methods?
Here's what is meant by operators and methods.

Attempting to keep the questions as simple and open ended as possible, since the question is more about the conceptual nature of operators and methods NOT how a language has decided to implement them.

Proof of Concept: This example in Ruby is more of a proof of concept than anything else. EXAMPLE: In Ruby, "1+2" is equivalent to "1.+(2)", meaning the object "1" implements a method called "+" with object "2" as the method's argument.

答:
Some languages (SML of NJ comes to mind) allow you to declare functions as "infix". In this case a "function" and an "operator" are pretty much identical, differing only in notation. I can neither recall nor google up the source, but I've read an essay claiming that Combinatory Logic has, as its (philosophical) roots, the desire to make "operators" the foundation of mathematics.

I think you'll probably get a lot of bad arguments both for and against the idea of operators being identical to functions.  The arguments will feel similar to arguments about "what's an object?", except that mathmatically, "function" and "operator" really are identical, while "object" doesn't have a good mathematical foundation.

Title: Are operators just "special" methods?


答:
At least in Haskell, an operator is a symbol function with an arity of at least 2. (Although there is an extension that lifts this restriction) You can define your own operators, overload them via type-classes, give them precedence and associativity etc... After all, by putting parenthesis around an operator, you can use it just like any other (prefix) function. You can even use an ordinary function as an operator by encapsulating it in backticks.

Here are some (silly) examples:

```<code>(.:) :: (a -> b) -> (c -> d -> a) -> (c -> d -> b)
(.:) = (.) . (.)

(§) = negate .: (*)

-- or similiar

a § b = - (a * b)

infixl 7 *
infixr 9 .:
</code>```

Title: Are operators just "special" methods?

Body:
Here's what is meant by operators and methods.

Attempting to keep the questions as simple and open ended as possible, since the question is more about the conceptual nature of operators and methods NOT how a language has decided to implement them.

Proof of Concept: This example in Ruby is more of a proof of concept than anything else. EXAMPLE: In Ruby, "1+2" is equivalent to "1.+(2)", meaning the object "1" implements a method called "+" with object "2" as the method's argument.

Body:
At least in Haskell, an operator is a symbol function with an arity of at least 2. (Although there is an extension that lifts this restriction) You can define your own operators, overload them via type-classes, give them precedence and associativity etc... After all, by putting parenthesis around an operator, you can use it just like any other (prefix) function. You can even use an ordinary function as an operator by encapsulating it in backticks.

Here are some (silly) examples:

(.:) :: (a -> b) -> (c -> d -> a) -> (c -> d -> b)
(.:) = (.) . (.)

(§) = negate .: (*)

-- or similiar

a § b = - (a * b)

infixl 7 *
infixr 9 .:


答:
You could say this is the duty of the QA to keep the changelog updated, but some software configuration management systems or issue trackers can generate the changelog for you automatically, which is useful in a multiple developer environment. This assumes that you're using the feature/issue tracking the way it is intended.

For example, the open-source issue tracker Trac has a ChangeLogMacro.

Other issue trackers might have a macro or a plug-in that can generate the changelog for you. It's usually a simple query of selecting all tickets/issues that have been closed between the last release and the current release.

Title: What is the best way to generate an accurate release changelog?

Body:
I'm working on some projects where I'd like to supply an accurate changelog with each release, but I haven't found a method for collecting the changelog that would work without hassle. The problem is mostly when the time between versions is long and each version ships with a lot of features and bug fixes, and when the software has several branches being developed at the same time.

Some options I've considered:

Build the changelog from commit messages and require developers to write the messages as if they would be writing a line for the changelog (which they would effectively be doing).

Might not work when there are multiple branches and merging between branches (might be hard to know which commits have ultimately ended up in the release).

Require that for each change in the code there should be a corresponding ticket in the bug tracking system. The changelog could be written based on the tickets.

The devs might find it frustrating to make a ticket for even minor changes, especially if making the ticket takes longer than fixing the bug.

Require that the developers always update the changelog (as a text file in project root) at the same time when they make changes to the code.

Feels like manual labor that could be automated.

Have the project manager take the diff of the current version and the previous one and write the changelog at that point based on what they see that's been changed.

Extra work for the person responsible for the release and it might not be obvious what the practical effect of a change is just by looking at the code.

Ship only the features that have been planned for the release; you can write the changelog even before you start coding.

Not a real option unless you're using the waterfall model.

I've used each of these or a variation of them in the past but they have been too unreliable, laborous or rigid. Does anyone have a magic bullet or good ideas on how to solve the problem?


答:
If you don't already have the requirement of a ticket for each change, then getting developers to create a ticket for each change important enough to end up in the change log seems reasonable.

If the change is significant enough to tell users about, then you probably want to be making that change under a ticket anyway, and writing descriptive tickets is good practise.  Plus you can tie this in with whatever release versioning and roadmap support your bug tracker has.


答:
It is highly dependent on language.

Most high level function languages they are identical.

For interpreted languages there is usually little difference (especially when the language allows you to write your own operators (then it is just syntactic sugar for a method call), but then an interpreted language all operators are basically method calls as the language is interpreted).

When it comes to languages like C++ the story gets more complex.

operators on primitive types are not like method calls.

operators on class types are just that: method calls.

There is important distinction as this can change the inherent expected behavior of the operator. For example the && and || opertors are shortcut operators when used on primative types. But when you override for a particular class they are now the equivalent of method calls and thus all parameters must be evaluated before the method is called and thus they are no longer short-cut operators.

When using methods (and thus class specific overloaded operators) you have specific guarantees about where the sequence points are (thus certain side effects are OK). But with normal operators there are usually no sequence points until the end of the expression (thus side effects have a much larger scope for interfering with the rest of the expression).

Title: Are operators just "special" methods?


问:
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).

答: Because something was broken, and I needed to fix it for my own purposes anyway - why not share it with others in the same boat.</p>

ContentLicense: CC BY-SA 2.5


问:
Which deployment technologies makes sense in Continuous Deployment?
In my understanding a major point in Continuous Deployment is (well, obviously I guess) that deployment is automatically done as a part of the building process.

Conceptually it is easy to understand how the deployment can be done when the target is a website. However it appears hard/impossible to continuously deploy when it is a desktop application deployed via an msi-installer (sorry for my tech background being mainly a Microsoft one)?

Are there deployment technologies that cannot be used when continuously deploying? Or rather: Which deployment technologies makes sense in continues deployment?

答:
I'd suggest a two step process. Building creates the installer, which goes out to your server. The client machines are set up to pull the installer on startup/midnight/maintenance window and run it silently.

So you continuously build throughout the day, but the live systems grab the new installer at the appropriate time. It's not so much a matter of having any one thing do all the work of the build/deploy cycle. The point is having all of it automated which is a different animal.

The classic example is having a robot cook a meal. Most people start designing how the robot will open the door to the fridge, check produce by feel, so on and so forth. But a proper design throws out the concept of a kitchen! A robot for cooking would be the whole room. There would be a part that opens the prebagged produce, already determined correct, and moves it via conveyor belt to the stove. At the stove, multiple arms with built in utensils would begin whipping up the output product. The thing doesn't need hands, it doesn't need legs, it almost doesn't need eyes.

Your build system should not be: "take what a person would do/currently does and have a program step through it exactly." Start from what you want to accomplish. When your process does that, the deploy is done, wherever you've defined that to be.


答:
Operators are not always identical to functions, since their semantics could be significantly different from a plain function call semantics. For example, sizeof(...) operator in C does not evaluate its argument. Ternary operator (x?y:z) always evaluate only two of its arguments. Logical operators (&&, ||) may not evaluate second argument.

And even the plain arithmetic operators might have complicated implicit type casting behaviour.

For this reason, you can't define operators as functions, at least in an eager language. Lazy languages are different, but still, you won't be able to define something like sizeof(...) as a function.

Title: Are operators just "special" methods?


答: At least in Scala operators are functions methods.  You can use a method which takes single parameter as infix operator (see A Tour of Scala: Operators and Scala for C# programmers, part 6: infix operators

Title: Are operators just "special" methods?


问:
Examples of MVVM adoption outside the Microsoft community?
IS MVVM getting any kind of traction outside the Microsoft community?  Within Silverlight this is a non-issue, but for other technologies, like JavaScript it surely is:  For instance Knockout.js is a great framework, but the 'rest of the world' seems to be on a Backbone path.

My concern is that MVVM frameworks (like Knockout) are going to suffer a lack of network effect by being constrained to the Microsoft ecosystem, and thus fall behind compared to the rest.

答: Based on the Wikipedia article, there are a dozen+ implementations of the MVVM framework. Given that Mono is out there as well, I'm not sure I'd use the word "constrained". So, no I don't think they'll be constrained as such. However, as pointed out in the same article, MVVM isn't always the best design choice.</p>


问:
Is it possible for two DLLs to conflict , preventing solution to build
Though I have a specific case, but I was wondering about the general situation.

Can two DLLs, when added as Reference to a Visual C# project collide with each other to prevent the solution from building? If this is the case, what are the possible ways to mitigate this.

答:
Seeing as nobody else mentioned this, you asked:

what are the possible ways to mitigate this

There is a clean solution just for this case, without constraints, and without annoying workarounds. You can define Assembly alises so that the compiler would know which ones to refer to in the right place.

Have a look at Link

ContentLicense: CC BY-SA 4.0


答:
A great example to look at/steal from is google chrome -- they do continious, silent deployment on Windows. Without requiring administrator approval.

The main trick, as I understand is just using Microsoft Click-Once deployment combined with deploying to the %userprofile% rather than %programfiles% but I could be really wrong.

Title: Which deployment technologies makes sense in Continuous Deployment?

Body:
In my understanding a major point in Continuous Deployment is (well, obviously I guess) that deployment is automatically done as a part of the building process.

Conceptually it is easy to understand how the deployment can be done when the target is a website. However it appears hard/impossible to continuously deploy when it is a desktop application deployed via an msi-installer (sorry for my tech background being mainly a Microsoft one)?

Are there deployment technologies that cannot be used when continuously deploying? Or rather: Which deployment technologies makes sense in continues deployment?


答:
MVVM outside of the Microsoft is known by another name. Presentation Model. This appears to be gaining traction especially in the Flex world. I'm still learning the ropes but it seems to be gaining traction.

Various Flex examples I have found recently are:

Cafe Townsend

Score Keeper

One question that continues to bug me is when do you need a dedicated Controller in MVVM / Presentation Model. Some examples have dedicated controllers (e.g., Cafe Townsend) and others do not (e.g., Score Keeper).  However, I think this is a question for another post.

Title: Examples of MVVM adoption outside the Microsoft community?

Body:
IS MVVM getting any kind of traction outside the Microsoft community?  Within Silverlight this is a non-issue, but for other technologies, like JavaScript it surely is:  For instance Knockout.js is a great framework, but the 'rest of the world' seems to be on a Backbone path.

My concern is that MVVM frameworks (like Knockout) are going to suffer a lack of network effect by being constrained to the Microsoft ecosystem, and thus fall behind compared to the rest.


答:
In addition to the other answers here, which cover a lot of good examples, here's another bit.

In C++, for example, some operators have to be defined outside of a class's definition, and are thus 'free functions' with a left-hand-side and a right-hand-side (2 arguments).

So in this case they aren't even "Methods", as they are not defined inside any class.

Title: Are operators just "special" methods?


答:
I like the idea that most open source contributors do it for something else than the "benefits".

But because there is always a reason, conscious or not...

Some do it for the social aspect. They meet people, they make new friends.

Some do it for the status it gives them. (StackOverflow like websites are based on that behavior).

Some do it because they like to achieve things. They like to solve problems. They like the idea that they are useful in this world.

It's always a combination of more or less of the three.

I'm more of the last one, with a small amount of the first and the second.

Open Source has an additional behavior that is more "practical":

Some did it because they have to. Because of licensing terms, to clear they conscience, whatever.

Title: What made you contribute to that open source project?

Body:
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 have our build server configured to push the artifacts to an SVN repository. The testers are all working from a checked out copy of that repository and when they need/want/told to update it is simply a matter of them right clicking on the top level directory and selecting Update (TortoiseSVN).</p>


问:
Designing around the constraints of external services in a client-server architecture
Suppose you have a client that interfaces with a server which in turn invokes an external service to fulfill some of the client's requests. I'm designing the client and server and need to accommodate the limitations of the external service. I have these options:

Encapsulate (as much as possible) all code dealing with the service's limitations inside the server application.

Encapsulate (as much as possible) all code dealing with the service's limitations inside the client application.

Design both the client and server applications around the external service's limitations.

I had chosen option #1 because the server application was 'closer' to the external service and I didn't want to have to redesign the client if and when the external service was improved. However, now I'm being asked to choose option #3 by the server-side team so we can deal with the external service limitations in the API instead of by handling exceptions. Is there a design pattern I can reference to convince them (or myself) that one option is preferred? (Separation of concerns looks promising, but I haven't convinced myself that it's sufficient because it could also argue for option #2)

答:
#1 is clearly the correct solution.

The client should know nothing about the implementation details of the server. Adding knowledge of the server's internal topology (that it talks to an "external" service) violates the Single Responsibility Principle and Separation of Concerns and couples your client to the particular current internal implementation details of the server.

From the client's perspective, there is only one "external service": the server. Whatever the server does to compute its response for the client, it is "internal" to the server from the perspective of the client. That is, the client must treat the server is a black box. The client makes requests and gets responses according to whatever protocol is implemented between the two. It should know nothing at all about how the server creates those responses.


答: I did it to support the project. I loose if the project dies.</p>


问:
What imperative programming languages do not support recursion?
To my knowledge, all modern imperative programming languages support recursion in the sense that a procedure can call itself. This was not always the case, but I cannot find any hard facts with a quick Google search. So my question is:

Which languages did not support recursion right from the start and when was that support added?

答:
The OpenCL programming language does not support recursion. (see section 6.8 of the OpenCL Spec)

The current motivation for that is a) a lack of space for deep stacks b) a desire to know, statically, the total required allocations in order to optimize for performance in the presence of large register sets and extensive in-lining.

This may well apply to other GPU programming languages, e.g. shader languages.


答:
IMHO both options 1 and 3 will probably end up looking the same way in the end, unless the server application actually has business logic that can handle limitations of the external service.  In other words, the limits of external web service will likely influence the server application interface with the client, so the end result MIGHT be the same.

On that note pursuing 1 is what SHOULD be done.  The client in no way needs to directly communicate with the external web service, the only client for the external web service is the server application.

The scenario you describe is where most componentized software applications go awry and develop design smells.  The server application team is refusing to acknowledge that business logic integrating with the external web service is their responsibility.

I have been in this situation before and a number of things cause this:

Server application team being ignorant of componentized software development.

Server application team is overworked and has a tight schedule, trying to push work back onto other teams

Selfish manager trying to weasel out of further responsibilities for himself and his/her team.

Server application team is just being lazy and wants to be a hollow middleman between the external web service and their client.

Title: Designing around the constraints of external services in a client-server architecture

Body:
Suppose you have a client that interfaces with a server which in turn invokes an external service to fulfill some of the client's requests. I'm designing the client and server and need to accommodate the limitations of the external service. I have these options:

Encapsulate (as much as possible) all code dealing with the service's limitations inside the server application.

Encapsulate (as much as possible) all code dealing with the service's limitations inside the client application.

Design both the client and server applications around the external service's limitations.

I had chosen option #1 because the server application was 'closer' to the external service and I didn't want to have to redesign the client if and when the external service was improved. However, now I'm being asked to choose option #3 by the server-side team so we can deal with the external service limitations in the API instead of by handling exceptions. Is there a design pattern I can reference to convince them (or myself) that one option is preferred? (Separation of concerns looks promising, but I haven't convinced myself that it's sufficient because it could also argue for option #2)


问:
What are some patterns and anti-patterns of application logging?
I recently had to investigate a field issue for our large enterprise application. I was horrified by the logs that I had to comb through in an attempt to find the problem and at the end of the day the logs did not help at all identifying/isolating the bug.

Note: I understand not all bugs are discoverable through logs. This does not change the fact that the logs are horrible.

There are some obvious problems with our logging that we can already attempt to fix. I do not want to list those here and I cannot simply show you our log files so you can give advice on what to do.

Instead, in order to assess how bad we are doing on the logging front, I would like to know:

What are some guidelines, if any, when it comes to logging for an application, especially large application.

Are there any patterns we should follow or anti-patterns we should be aware of?

Is this an important thing to fix or can it even be fixed or all log files are simply huge and you need supplemental scripts to analyze them?

Side note: we use log4j.

答: Here's an anti-pattern: Making two dozen "genericvariable" fields in a database table to track anything conceivable and then having 88 (and counting) different enum values for different types of logs.</p>


问:
Is it unusual for a small company (15 developers) not to use managed source/version control?
It's not really a technical question, but there are several other questions here about source control and best practice.

The company I work for (which will remain anonymous) uses a network share to host its source code and released code.  It's the responsibility of the developer or manager to manually move source code to the correct folder depending on whether it's been released and what version it is and stuff.  We have various spreadsheets dotted around where we record file names and versions and what's changed, and some teams also put details of different versions at the top of each file.  Each team (2-3 teams) seems to do this differently within the company.  As you can imagine, it's an organised mess - organised, because the "right people" know where their stuff is, but a mess because it's all different and it relies on people remembering what to do at any one time.  One good thing is that everything is backed up on a nightly basis and kept indefinitely, so if mistakes are made, snapshots can be recovered.

I've been trying to push for some kind of managed source control for a while, but I can't seem to get enough support for it within the company.  My main arguments are:

We're currently vulnerable; at any point someone could forget to do
one of the many release actions we have to do, which could mean whole
versions are not stored correctly.  It could take hours or even days
to piece a version back together if necessary

We're developing new features along with bug fixes, and often have to delay the release
of one or the other because some work has not been completed yet.  We also have to force
customers to take versions that include new features even if they just want a bug fix,
because there's only really one version we're all working on

We're experiencing problems with Visual Studio because multiple
developers are using the same projects at the same time (not the same
files, but it's still causing problems)

There are only 15 developers, but we all do stuff differently; wouldn't
it be better to have a standard company-wide approach we all have to
follow?

My questions are:

Is it normal for a group of this size not to have source control?

I have so far been given only vague reasons for not having source control - what
reasons would you suggest could be valid for not
implementing source control, given the information above?

Are there any more reasons for source control that I could add to my
arsenal?

I'm asking mainly to get a feel for why I have had so much resistance, so please answer honestly.

I'll give the answer to the person I believe has taken the most balanced approach and has answered all three questions.

Thanks in advance

答:
This is just an accident waiting to happen.  You have no code history, and in one fell swoop, one of your developers could wipe out months of work.  As a small company you can't afford this kind of setback.

You are also very exposed on that share drive.  Even with a good backup, how long can you afford to not be working.  1 hour, 1 day, 1 week.  How long would it take to get a new server in place, restore from backup etc.  Again as a small company you probably don't have extra hardware on standby and might not be able to readily drop the money to get expedited shipping etc.

Think about offsite storage as well.  A flood or fire is not really that unusual.  What would happen if there was a fire in the building after hours.  How many months of work would be lost.  A managed code repository like github would be valuable for this.  Even using a simple SVN server on a hosted service would be a step up in this area.

OwnerDisplayName: LordScree


答:
It depends on what you mean by "support".
To support recursion you need a stack where to re-instantiate local variables at every re-entrance.

Even if the language does not have the concept of local variables, if it has the concept of "subroutine" and has a way to manage an indexing between identical variables (a.k.a. array) you can increment / decrement a global index upon every enter / exit of a function and access through it a member of one or more array.

I don't know if this can be called "support". The facts are that I wrote recursive function with the ZX-Spectrum BASIC, as I did it in Fortran77 as in COBOL ... always with that trick.

Title: What imperative programming languages do not support recursion?

Body:
To my knowledge, all modern imperative programming languages support recursion in the sense that a procedure can call itself. This was not always the case, but I cannot find any hard facts with a quick Google search. So my question is:

Which languages did not support recursion right from the start and when was that support added?


答:
Log the exception only once!

One of the common pain points that I have noticed is logging and rethrowing an exception.
As a result, the log files contains the same exceptions several times on several stack levels.

Title: What are some patterns and anti-patterns of application logging?

Body:
I recently had to investigate a field issue for our large enterprise application. I was horrified by the logs that I had to comb through in an attempt to find the problem and at the end of the day the logs did not help at all identifying/isolating the bug.

Note: I understand not all bugs are discoverable through logs. This does not change the fact that the logs are horrible.

There are some obvious problems with our logging that we can already attempt to fix. I do not want to list those here and I cannot simply show you our log files so you can give advice on what to do.

Instead, in order to assess how bad we are doing on the logging front, I would like to know:

What are some guidelines, if any, when it comes to logging for an application, especially large application.

Are there any patterns we should follow or anti-patterns we should be aware of?

Is this an important thing to fix or can it even be fixed or all log files are simply huge and you need supplemental scripts to analyze them?

Side note: we use log4j.


问:
Automake - how to keep the source tree clean?
I have a project that uses GNU autotools to build itself. I am trying to modify so that autotools generates all the non-versioned control files in a separate directory so that I can keep the source tree clean of temporary files. Anyone has any ideas how to do this ?</p>

答: The autotools package has a lot of hard coded relative paths and names in it for a good reason. Your best option is to sum up the output and tag them as ignored in your revision control, e.g. in .cvsignore, .hgignore or as svn:ignore attibute. Some RCS let you even recursively specify wildcards.


问:
Learning path for web developer .NET or Java
I am interested to know how many real world web application servers are hosted by windows?

I am going to learn C# and ASP.NET and want to convert my self from an embedded developer to a web app developer.

My friends told me that there are ways more Linux based servers than windows servers. He also mentioned the Java skills stack is much more useful than .NET in the world of web application.

My experience of Java and C# are rougly the same. I am an experienced C++ developer though.

Can anyone give me some suggestion about it?

Many thanks

答:
I'm not sure the number of servers really matters.  What does matter is: Can you accomplish the goals reliably, quickly, and cheaply enough with {x}?

As far as .NET is concerned, it would be rare to get a "no" answer to that question.  (I'm not a java person, so can't help much there.)

Linux vs. Windows servers is not quite relevent, either.  You can develop .NET web apps to run on Linux servers, using Mono.

OwnerDisplayName: Kevin Zhang


答: These days the debate is more php vs asp.net than asp.net vs jsp. I don't see many jsp/tomcat solutions these days. Anyhow, why not learn both asp.net and jsp? They are similar ideas and I think jsp lays a good framework for understanding asp.net. I agree with @John that linux vs windows is really irrelevant. .NET runs fine in linux and apache. If you know JAVA then maybe spend a couple weeks writing some JSP code and then transition over to asp.net and c#. See which one you like and go from there.</p>

Title: Learning path for web developer .NET or Java

Body:
I am interested to know how many real world web application servers are hosted by windows?

I am going to learn C# and ASP.NET and want to convert my self from an embedded developer to a web app developer.

My friends told me that there are ways more Linux based servers than windows servers. He also mentioned the Java skills stack is much more useful than .NET in the world of web application.

My experience of Java and C# are rougly the same. I am an experienced C++ developer though.

Can anyone give me some suggestion about it?

Many thanks


问:
Modern languages and the JVM
Many modern programming languages (Scala, Erlang, Clojure, etc.) are targeting the JVM. What are the main reasons behind that decision?

JVM's maturity?

Portability?

Because JVM simply exists, and the language designers were not willing to write a new VM/interpreter?

答:
I'd say it's 10% option (a), 70% option (b) and 20% option (c).

Writing  a reliable virtual machine is hard. It's a big part of why Perl6 was 10 years late - it runs on a register-based VM unlike the common ones and had to be written essentially from scratch). Also, you can leverage not just the VM but also the standard libraries, which are huge in Java.

But the major factor is probably that it is already on every conceivable platform - the direct competitor .NET is, in practice, Windows-only. And when you have already decided not to do your own VM, reusing the one that is most available is a no-brainer.

Title: Modern languages and the JVM


答:
Erlang is a standalone language but there is work being done on Erjang which is targeting the JVM. You're right that Scala and Clojure are targeting the JVM, and there are versions of Ruby and Python targeting the JVM as well (JRuby, Jython).

Yes, the JVM is a very mature platform and modern JVMs are able to optimize code and compile it on-demand to the host's native code for increased performance.

Yes, portability. Compiled Scala, Clojure, etc can be packaged using standard tools and distributed to any system that has a JVM (of a suitable version level).

Yes, the JVM means new languages "only" have to write a compiler to bytecode (and any supporting libraries they want to provide). They don't have to write a new runtime (which is what Erlang, Ruby, Python, JavaScript etc have all done in the past).

But I think you've missed one of the biggest benefits of the JVM: the huge ecosystem of libraries - both the Java standard library and the vast array of third party libraries are accessible to any language that targets the JVM.

Title: Modern languages and the JVM

Body:
Many modern programming languages (Scala, Erlang, Clojure, etc.) are targeting the JVM. What are the main reasons behind that decision?

JVM's maturity?

Portability?

Because JVM simply exists, and the language designers were not willing to write a new VM/interpreter?


答:
You forget to add another reason:

It's what language designers know.

Significant bits of education (and, as a result, early work experience) for potential language designers are now being done in Java. See, for example, Wikipedia's history for Scala. As more and more developers are moving to using Javascript and its VM, you'll see newer languages running on that VM instead.

Title: Modern languages and the JVM


问:
When should the presentation model design pattern include one or more controllers?
I have been researching the usage of the Presentation Model design pattern for an application I am preparing to build. The specific technology I will be using is Flex though I doubt that it matters for this question.

In general most of the Presentation Model examples I have run across are pretty consistent in the basic implementation. More or less they follow Martin Fowler's Presentation Model description to a T when it comes to the three basic concepts: View, Model, Presentation Model.

I think that I understand this.

However, I have seen some other examples that extend this further by including controller, event, and service objects in addition to the three basic constructs I listed above. The examples I have seen are (note these are both using Swiz for DI and event handling):

CafeTownsend

Swiz Presentation Model Example

I understand the reasoning for a service layer. You may want / need to retrieve your data from a SOAP interface one day, a REST interface the next, and a SharedObject on the third day. The service layer interface makes it easy to swap out retrieval and persistence logic.

However, I am not sure that I understand why the addition of the controller is an advantage?

In the examples linked above some logic within the presentation model is dispatched and handled within the presentation model itself while other logic is dispatched and addressed within a controller.

My guess is that logic that is view specific is captured within the presentation model. This supports the notion that the presentation model is simply an abstract representation of the view.

Further, I suspect that the controllers are used to capture common business logic and events that are not view specific and are not performed by the service layer (e.g., persistence). This should support reuse across the application and help to make the application more testable.

Is this conclusion right?

Are there other advantages I am missing?

What are the disadvantages (besides more code)?

How do you know when logic should be in the presentation model and when it should reside in a controller?

答:
The basic reason for a controller is Separation of Concerns... What you describe is a combination of the MVC and the MVVM patterns, which indeed is my approach of choice.

Basically you have your usual Model View Controller, but you add in the ViewModel. This helps you build more reusable code and have a true separation between you Data Layer, your Business Logic and your presentation.

Disadvantages? well, like you said more code. Other than that, non that make me think twice about it.

Where should logic be? Business Logic in the controller, Presentation logic in the ViewModel and the View.


问:
What do you need to succeed with Agile?
Agile adoption can fail in some organizations, I even worked for a company where waterfall was the only (the true) way but only because they tried Agile on a project and failed.

When I asked the people who still remembered that (I was a junior) I was shut down hard, like I was reminding them a bad nightmare that really happened.

I don't know why the project failed. There are resources found on the web why Agile fails is some companies but the reason are mostly economic. So I thought I ask here fore some feedback.

What are the reasons Agile adoption fails in some organizations? Or, another way of putting it.. What do you need to succeed with Agile?

答:
IMO "Agile" fails when there isn't a wholesale buy-in of the practices.  What I mean is that Agile relies on the "customer" (typically another department or manager) understanding that:

They don't know 100% what they want the software to do, even if they think they do

They have no idea how long it will take to complete, even if they think they do

They will be told how long it will take and must accept it or reduce features to meet a deadline

They will have to choose features each iteration and will not get the full, 100% complete application in one shot.

All of those are very difficult things for most managers to swallow, and IMO the #1 reason why it's hard to do Agile - managers are used to saying "It will be done by x date" and having it "Magically" done by that date (after developers put in 80 hour weeks) and it's a 180 to realize that the development team is going to tell you that this project will be done in 3 months, and the only choice you have is to accept it or reduce the requirements to get it done sooner.

Second, there has to be trust in the development team.  Going hand in hand with #1 above, very few managers actually seem to trust the opinion of people hired as experts; if a developer says a project will take x amount of time, and x is more than management thinks it will take, it's never a case of "I don't know how to write software, so the developer is probably right" it's more "Those good-for-nothing developers want to goof off at work so they said it will take 3 months".

Third, your development team needs to be behind Agile; that means not cutting corners and not ignoring constant feedback and questions of "Is this right?  When x happens what should Y do?". Even if you don't follow TDD or Pair Programming, your development team needs to be competent enough to follow the agile processes (e.g. sprints, iterations).  This involves having a lead/manager who can properly estimate tasks and understands that you don't need to make every feature a priority, it's OK to have a backlog of work, and you shouldn't overwork people.

Title: What do you need to succeed with Agile?


问:
What do you consider to be the prime cause of software defects (and how to minimize them)
I define defect as :

"something within the application design or code which prevents it functioning as per requirements."

I'm looking for ideas about the causes of defects, eg the human factor, lack of testing, lack of prototyping, and possible ideas to mitigate these.

答: Errare humanum est

Body: Errare humanum est


答:
In contrast to @John Fisher (+1) I'm a Java guy.

I am always jealous of the Windows/.Net world because everything seems to be much more integrated, at least for someone who is not familar with all the details and pitfalls.

The Java place is a bit more chaotic, therefore it produces a number of fairly innovative ideas (think of hadoop, Spring, etc.) outside of the JCP which promotes the official JavaSE and JavaEE standards. As the JCP is driven by a bunch of different (commercial) organizations it's sometimes far behind (e.g. lambda functions in Java) as it simply takes time to find agreements between all the different participants.

There are a number of pros and cons for both sides. Nevertheless, from a technical point of view it does not really matter whether to do Java or .Net as web development is much more about thinking in scalability and the overall complexity when it comes to e.g. 10k concurrent users accessing your system.

From a software architecture point of view .Net and Java (EE + frameworks) are fairly similar, they both provide APIs to solve all the common problems (e.g. MVC, Rest, JSON, Persistence, messaging - just to name a few) we're facing in today's world.

To conclude - have a look at both concepts and pick one. It's not a decision for lifetime.


答: An interesting historical footnote is that Martin Odersky, the creator of Scala was also the creator of a short-lived language called Pizza that was one of the first non-Java languages to target the JVM. It's implementation of generics was eventually incorporated in Java 5. You can read his interview on the origins of scala to get some insight into why he likes targeting the JVM.</p>

Title: Modern languages and the JVM


问:
Suggestions for Programs to develop for learning
i wonder apart from those very simple hello world apps, what other programs should i try developing for learning. i am entering uni next year and wonder what kind of programs will be developed in that environment.

this is not really a language specific thing, but if you want to know what i use currently mainly

windows: C#/WPF - i studied java/vb etc in poly but i think C# is the way to go, maybe even F#

web: PHP/MySQL, Zend Framework/Doctrine, + HTML/CSS/JS(jQuery) of course. looking to try google app engine with python too.

for now, i am thinking of

todo lists

apps that integrate with api eg. twitter/tumblr which i use

text editor - i am currently trying to develop a text editor that uses markdown and generates html files for viewing (link to blog entry). not very pratical after i started developing it. cos when editing theres no formatting and in HTML format, i cannot edit directly

blog software (for web)

答:
Spyrograph.  Specify dimensions of an outer ring, an inner disc, and pen point along its diameter.  Plot the path of the pen as the inner disc rolls along the inside of the outer ring.

Change Maker.  Input Cost and Amount given to teller.  Calculate the optimal for teller to make change. There's a slow way and a fast way to solve this.  Find the fast way.

OO-Life Simulation. Look up Life Algorithm.  Make random starting state and output subsequent steps, using OO design to decouple logic from presentation.  Give text output and graphical output.

Missionary/Cannibals Solver, Look up this famous puzzle.  Write a program to solve it using search trees.  Compare BFS to DFS.


答:
Apart from the stacktrace, log the current application state and the input.

Software is deterministic, these two are usually the only thing you need to reproduce the bug. Storing the full state might in some cases be troublesome so ways to reproduce the current state, by for example previous inputs, are also good.

Of course more data is always better but at minimum these two are a good start for the easiest crashes.


问:
File naming convention for images stored in version control?
My application has an icon file which is stored in version control.  Now tomorrow I might  decide to change the icon.  I'm debating between two possible naming conventions for the icon file:

Keep the filename fixed, e.g., application.ico

Have the filename reflect the nature of the image, e.g., happyface.ico

Option 1 doesn't say what the file is.  It could give the illusion that two wildly different images are somehow different "versions" of the same thing.  With option 2, I'd not only have to add a new file and delete the old one, I'd have to modify the resource file to reflect the new icon filename.

On a related but different angle:

A website with a header image.  Is the filename header.jpg or sunrise-family-smiling.jpg?

Should image file names reflect their function in the application or their content? What would be a best practice for this?

答:
Option 1 doesn't say what the file is. It could give the illusion that
  two wildly different images are somehow different "versions" of the
  same thing

Well, it is, isn't it? I know that it might have changed from a smiley face to a corporate logo, but it's still different versions of a specific icon in your application.

I think you're missing the point by focussing on subversion. The key deciding factor should be the application itself. When I'm adding the icon that appears in the title bar, I'm not thinking "I must describe the content of the image." I'm thinking "what is this image to the application, or to anyone else who needs to change it later?"

And therein lies a bigger point. When I come to change it later, do I really want to change the name of the image in the application? It's still doing the same thing, so why does the app need to know I've changed it?


答:
Personally, I have always used a descriptive name for all my files, including icons, and even if it resource names have to be changed.

In your case, I would actually take a third choice:

If the application was called XYZZY, then I would name the icon for the application "XYZZY.ico".  No matter what the icon looks like, it is the proper icon for the XYZZY application.

By extension, if I needed a couple of different sized icons, I would add the size of the icon to the name.  So for a 48x48 icon, I would have "XYZZY_48x48.ico".

In relation to the last part "A website with a header image. Is the filename header.jpg or sunrise-family-smiling.jpg?":  If the website is for Plugh Corp, then I would use "Plugh_Header.jpg".

Title: File naming convention for images stored in version control?

Body:
My application has an icon file which is stored in version control.  Now tomorrow I might  decide to change the icon.  I'm debating between two possible naming conventions for the icon file:

Keep the filename fixed, e.g., application.ico

Have the filename reflect the nature of the image, e.g., happyface.ico

Option 1 doesn't say what the file is.  It could give the illusion that two wildly different images are somehow different "versions" of the same thing.  With option 2, I'd not only have to add a new file and delete the old one, I'd have to modify the resource file to reflect the new icon filename.

On a related but different angle:

A website with a header image.  Is the filename header.jpg or sunrise-family-smiling.jpg?

Should image file names reflect their function in the application or their content? What would be a best practice for this?


答:
I'd go for application.ico and header.jpg as it's simpler and nearer to the image meaning in your application.

You may want to store the images as happyface.ico and sunrise-family-smiling.jpg somewhere else (in another repo or maybe in the same) if you want to keep them easily accessible, too.


问:
Designing an easily extensible XML driven OOP system
I've been working on a project that is very data-driven (a checkers board game with customizable rules; I'm using XML for the data storage). I need a design that is easy to extend as we add new features to the project via new XML tags.

My XML schema looks like this for a win condition (checkers):

```<code><game>
   <winconditions>
      <condition winner="Black">
         <Pieces color="Red" number="0" />
      </condition>
      <condition winner="Red">
         <Pieces color="Black" number="0" />
      </condition>
   </winconditions>
</game>
</code>```

<game> is the root element. There are other major sections such as <board> which defines the size and shape of the board and placement of the pieces, and <moves> which defines how pieces move. The idea is to have several "options" that combine to form a "condition" - if all "options" are true, the "condition"'s evaluation returns a winner.

Right now, the best strategy I have come up with is to create a package for the tag processing classes:

```<code>processors
   pieces
</code>```

And an interface to a win condition option:

```<code>public interface WinConditionOption {
   void setParameters(HashMap<String, String> args);
   boolean evaluate(GameState state);
}
</code>```

The file processor, when it sees a tag inside the <winconditions> tag, uses reflection to look up the corresponding class and calls it using the interface. So the Pieces tag causes a Pieces object to be created and setAttributes() is called with the tag's attributes. When we check for a win, evaluate() is called with the current state of the game. Pieces would evaluate whether the number of pieces belonging to that player was a certain number, 0 in this case (no pieces left).

Is this a good design? Is there a better way to do it and still be able to write minimal new code to add a new win option?

答:
The design you indicated is missing an important feature - flexible XML formatting of new conditions.  Based on your post, this wouldn't be possible:

```<code><condition ...>
    <pieceCombos>
        <combo>...</combo>
        <combo>...</combo>
    </pieceCombos>
</condition>
</code>```

An better way would be to have each of these classes know how to read (and write) their own information from the appropriate xml element.  So something like this could be cleaner and more flexible:

```<code>// This abstracts away specific methods of reading from xml.
public class YourXmlHandler
{
    ...
    GetChildElement(int index);
    GetAttribute(int index);
    ...
}

public interface IXmlReadable
{
    void LoadFromXml(YourXmlHandler reader);
}

public interface IWinOption
{
    bool Evaluate();
}
</code>```

This allows you to reuse the IXmlReadable interface for anything affected by the XML content.  It leaves the win option separate for the items that must be Wins.

You may end up with a WinConditions class that knows to read multiple WinCondition entries from the XML and a Pieces class that knows how to read its data.  The WinCondition class knows exactly what it wants from the XML and just gets it or throws a meaningful exception.

Body:
The design you indicated is missing an important feature - flexible XML formatting of new conditions.  Based on your post, this wouldn't be possible:

<condition ...>
    <pieceCombos>
        <combo>...</combo>
        <combo>...</combo>
    </pieceCombos>
</condition>

An better way would be to have each of these classes know how to read (and write) their own information from the appropriate xml element.  So something like this could be cleaner and more flexible:

// This abstracts away specific methods of reading from xml.
public class YourXmlHandler
{
    ...
    GetChildElement(int index);
    GetAttribute(int index);
    ...
}

public interface IXmlReadable
{
    void LoadFromXml(YourXmlHandler reader);
}

public interface IWinOption
{
    bool Evaluate();
}

This allows you to reuse the IXmlReadable interface for anything affected by the XML content.  It leaves the win option separate for the items that must be Wins.

You may end up with a WinConditions class that knows to read multiple WinCondition entries from the XML and a Pieces class that knows how to read its data.  The WinCondition class knows exactly what it wants from the XML and just gets it or throws a meaningful exception.


问:
What frequency of updates is acceptable for a mobile application?
It's possible to publish daily updates for your application on Google's Android Market, but I have an assumption that users don't like to get frequent updates. How can I determine when I should publish updates? Is there an optimum interval to balance between delivering new features and bug fixes while not upsetting my user base?</p>

答:
In my personal opinion anything that improves something for the user is worth a release. Especially with automatic updates and potentially updates only on wifi this is not disrupting to users imho.

Of course other factors will influence your release schedule as well. E.g. if your marketing team is still stuck in the old release habit with lots of features you might need to accumulate some for a marketable release.

Or if you are working with a server side application you might be tied to it updating as well.

So overall the answer probably is "It depends;-)" but more often is better. E.g. also consider upgrades to websites/webapplications like gmail or twitter.. many of these get daily updates..


答:
I work on a lot of projects by myself and I still use version control. The size does not matter. It always helps to have version control.

There is a reason it is #1 on The Joel Test: http://www.joelonsoftware.com/articles/fog0000000043.html

Also, it makes #2 and #3 on the list possible.

Title: Is it unusual for a small company (15 developers) not to use managed source/version control?

Body:
It's not really a technical question, but there are several other questions here about source control and best practice.

The company I work for (which will remain anonymous) uses a network share to host its source code and released code.  It's the responsibility of the developer or manager to manually move source code to the correct folder depending on whether it's been released and what version it is and stuff.  We have various spreadsheets dotted around where we record file names and versions and what's changed, and some teams also put details of different versions at the top of each file.  Each team (2-3 teams) seems to do this differently within the company.  As you can imagine, it's an organised mess - organised, because the "right people" know where their stuff is, but a mess because it's all different and it relies on people remembering what to do at any one time.  One good thing is that everything is backed up on a nightly basis and kept indefinitely, so if mistakes are made, snapshots can be recovered.

I've been trying to push for some kind of managed source control for a while, but I can't seem to get enough support for it within the company.  My main arguments are:

We're currently vulnerable; at any point someone could forget to do
one of the many release actions we have to do, which could mean whole
versions are not stored correctly.  It could take hours or even days
to piece a version back together if necessary

We're developing new features along with bug fixes, and often have to delay the release
of one or the other because some work has not been completed yet.  We also have to force
customers to take versions that include new features even if they just want a bug fix,
because there's only really one version we're all working on

We're experiencing problems with Visual Studio because multiple
developers are using the same projects at the same time (not the same
files, but it's still causing problems)

There are only 15 developers, but we all do stuff differently; wouldn't
it be better to have a standard company-wide approach we all have to
follow?

My questions are:

Is it normal for a group of this size not to have source control?

I have so far been given only vague reasons for not having source control - what
reasons would you suggest could be valid for not
implementing source control, given the information above?

Are there any more reasons for source control that I could add to my
arsenal?

I'm asking mainly to get a feel for why I have had so much resistance, so please answer honestly.

I'll give the answer to the person I believe has taken the most balanced approach and has answered all three questions.

Thanks in advance


答:
My estimation's:

20% JVM's maturity

50% Portability, especially of all the Java-libraries already available for the JVM

30% Because JVM simply exists, and the language designers were not willing didn't have the time to write a new VM/interpreter.

Title: Modern languages and the JVM


答:
So the Pieces tag causes a Pieces object to be created and setAttributes() is called with the tag's attributes.

That's object serialization in XML. You're de-serializing an object of the given class with the given values.

Don't write this yourself.  It's a waste of time.  Just download one that works with your target language.

When we check for a win, evaluate() is called with the current state of the game.

Right.  You've deserialized an object.  Now you evaluate a method.  The method then evaluates the various clauses and conditions to determine and overall value.

Is there a better way to do it and still be able to write minimal new code to add a new win option?

Not really.  Use a readily available XML serialization and you can avoid writing too much code.

Title: Designing an easily extensible XML driven OOP system

Body:
I've been working on a project that is very data-driven (a checkers board game with customizable rules; I'm using XML for the data storage). I need a design that is easy to extend as we add new features to the project via new XML tags.

My XML schema looks like this for a win condition (checkers):

```<code><game>
   <winconditions>
      <condition winner="Black">
         <Pieces color="Red" number="0" />
      </condition>
      <condition winner="Red">
         <Pieces color="Black" number="0" />
      </condition>
   </winconditions>
</game>
</code>```

<game> is the root element. There are other major sections such as <board> which defines the size and shape of the board and placement of the pieces, and <moves> which defines how pieces move. The idea is to have several "options" that combine to form a "condition" - if all "options" are true, the "condition"'s evaluation returns a winner.

Right now, the best strategy I have come up with is to create a package for the tag processing classes:

```<code>processors
   pieces
</code>```

And an interface to a win condition option:

```<code>public interface WinConditionOption {
   void setParameters(HashMap<String, String> args);
   boolean evaluate(GameState state);
}
</code>```

The file processor, when it sees a tag inside the <winconditions> tag, uses reflection to look up the corresponding class and calls it using the interface. So the Pieces tag causes a Pieces object to be created and setAttributes() is called with the tag's attributes. When we check for a win, evaluate() is called with the current state of the game. Pieces would evaluate whether the number of pieces belonging to that player was a certain number, 0 in this case (no pieces left).

Is this a good design? Is there a better way to do it and still be able to write minimal new code to add a new win option?


问:
How costly are the Python dict and set in-built types?
I have undertaken a project concerning database deduplication. I did some research and have found that the Python dict type actually is a hashmap that uses open addressing.

In the deduplication module, we'll have some rules that determine whether two records are identical, with the rules essentially spelling out the attributes that uniquely identify the record (did not call it a candidate key as the DB is going to be non-relational, no-sql). Now let's say we deal with a really large dataset. Naturally, hashing is the way to go ( found that advice here).

The question(s):

does the module need to compute a hash and then store it in a dict? Would that not be unnecessary, as the dict implementation is itself a hashmap?

how costly is the conversion of a list to a set? That conversion should remove all the duplicates, but given the huge scale, is that practical?

what is the cost incurred in checking membership in a dict/set using the "in" keyword?

Hadoop MapReduce is not an option at least for now.

I can't really dive into the Python sources to figure this out, as I'm strictly time limited :|

答:
http://wiki.python.org/moin/TimeComplexity

That should pretty much cover everything.  What more do you need that's not already on this page?


问:
Is a multi-page web app unsuitable when reliable server pushes are required?
Imagine a call center web application with a soft phone that automatically detects when a call has started or the caller has hung up.  The obvious approach to receiving these messages would be some kind of server push (a.k.a. Comet).  It's pretty disastrous if we miss one of those server pushes.

Must this application be written as a single-page JavaScript-heavy app, or is a more traditional multi-page app also a reliable option?  (Or is this what iframes are for?)

My biggest worry about using a multi-page app is losing push messages when changing pages.

My biggest worry about using a single-page app is complexity.

答:
As far as I know, the soft dialler resides on a separate server by itself, and the agents interact using web interfaces. Your web app must introduce constraints on the agent like not being able to "change pages" without disposing a live call first. Now, If I were you, yes, I'd use "heavy" AJAX in my pages to accomplish this. Also, check out ViciDial if you're serious on writing your own CC suite.

I'd recommend a mix of AJAX and traditional multi-page setup (e.g., you don't need to AJAXify the log-out/log-in of an off-call agent)


答:
I work with safety critical real-time systems and logging is often the only way to catch rare bugs that turn up once a blue moon on every 53rd tuesday when it's a full moon, if you catch my drift. This kind of makes you obsessive about the subject, so I'll apologise now if I start to froth at the mouth. The following was written for native code debug logs, but most of it is applicable to the managed world too...

Use text log files. Seems obvious, but some people do try to generate binary log files: that's just dumb because I don't need to be looking for a reader tool when I'm out in the field. Plus if it's text and the debug is verbose there's a good chance the field engineer can read the file and diagnose the problem without ever coming back to me. Everybody wins.

I design systems which are capable of logging pretty much everything, but I don't turn everything on by default. The debug information is sent to a hidden debug dialog which timestamps it and outputs it to a listbox (limited to around 500 lines before deletion), and the dialog allows me to stop it, save it to a log file automatically, or divert it to an attached debugger. That diversion allows me to see the debug output from multiple applications all neatly serialized, which can be a life saver sometimes. I used to use numeric logging levels (the higher you set the level, the more you capture):

```<code>off
errors only
basic
detailed
everything
</code>```

but this is too inflexible - as you work your way towards a bug it's much more efficient to be able to focus logging in on exactly what you need without having to wade through tons of detritus, and it may be one particular kind of transaction or operation that causes the error. If that requires you to turn everything on, you're just making your own job harder. You need something finer-grained.

So now I'm in the process of switching to logging based on a flag system. Everything that gets logged has a flag detailing what kind of operation it is, and there's a set of checkboxes allowing me to define what gets logged. Typically that list looks like this:

```<code>#define DEBUG_ERROR          1
#define DEBUG_BASIC          2
#define DEBUG_DETAIL         4
#define DEBUG_MSG_BASIC      8
#define DEBUG_MSG_POLL       16
#define DEBUG_MSG_STATUS     32
#define DEBUG_METRICS        64
#define DEBUG_EXCEPTION      128
#define DEBUG_STATE_CHANGE   256
#define DEBUG_DB_READ        512
#define DEBUG_DB_WRITE       1024
#define DEBUG_SQL_TEXT       2048
#define DEBUG_MSG_CONTENTS   4096
</code>```

This logging system ships with the release build, turned on and saving to file by default. It's too late to find out you should have been logging AFTER the bug has occurred, if that bug only occurs once every six months on average and you have no way of reproducing it. Logging that only works with debug builds is just. plain. dumb.

The software typically ships with ERROR, BASIC, STATE_CHANGE and EXCEPTION turned on, but this can be changed in the field via the debug dialog (or a registry/ini/cfg setting, where these things get saved).

Oh and one thing - my debug system generates one file per day. Your requirements may be different. But make sure your debug code starts every file with the date, version of the code you're running, and if possible some marker for the customer ID, location of the system or whatever. You can get a mish-mash of log files coming in from the field, and you need some record of what came from where and what version of the system they were running that's actually in the data itself, and you can't trust the customer/field engineer to tell you what version they've got - they may just tell you what version they THINK they've got. Worse, they may report the exe version that's on the disk, but the old version is still running because they forgot to reboot after replacing. Have your code tell you itself.

Lastly, you don't want your code to generate its own problems, so put in a timer function to purge the log files after so many days or weeks (just check the difference between time now and time of file creation). This is OK for a server app that runs all the time, on a client side app you can get by with purging any old data when you start up. We typically purge after 30 days or so, on a system without frequent engineer visits you might want to leave it longer. Obviously this is dependent upon the size of your log files as well.

Body:
I work with safety critical real-time systems and logging is often the only way to catch rare bugs that turn up once a blue moon on every 53rd tuesday when it's a full moon, if you catch my drift. This kind of makes you obsessive about the subject, so I'll apologise now if I start to froth at the mouth. The following was written for native code debug logs, but most of it is applicable to the managed world too...

Use text log files. Seems obvious, but some people do try to generate binary log files: that's just dumb because I don't need to be looking for a reader tool when I'm out in the field. Plus if it's text and the debug is verbose there's a good chance the field engineer can read the file and diagnose the problem without ever coming back to me. Everybody wins.

I design systems which are capable of logging pretty much everything, but I don't turn everything on by default. The debug information is sent to a hidden debug dialog which timestamps it and outputs it to a listbox (limited to around 500 lines before deletion), and the dialog allows me to stop it, save it to a log file automatically, or divert it to an attached debugger. That diversion allows me to see the debug output from multiple applications all neatly serialized, which can be a life saver sometimes. I used to use numeric logging levels (the higher you set the level, the more you capture):

off
errors only
basic
detailed
everything

but this is too inflexible - as you work your way towards a bug it's much more efficient to be able to focus logging in on exactly what you need without having to wade through tons of detritus, and it may be one particular kind of transaction or operation that causes the error. If that requires you to turn everything on, you're just making your own job harder. You need something finer-grained.

So now I'm in the process of switching to logging based on a flag system. Everything that gets logged has a flag detailing what kind of operation it is, and there's a set of checkboxes allowing me to define what gets logged. Typically that list looks like this:

#define DEBUG_ERROR          1
#define DEBUG_BASIC          2
#define DEBUG_DETAIL         4
#define DEBUG_MSG_BASIC      8
#define DEBUG_MSG_POLL       16
#define DEBUG_MSG_STATUS     32
#define DEBUG_METRICS        64
#define DEBUG_EXCEPTION      128
#define DEBUG_STATE_CHANGE   256
#define DEBUG_DB_READ        512
#define DEBUG_DB_WRITE       1024
#define DEBUG_SQL_TEXT       2048
#define DEBUG_MSG_CONTENTS   4096

This logging system ships with the release build, turned on and saving to file by default. It's too late to find out you should have been logging AFTER the bug has occurred, if that bug only occurs once every six months on average and you have no way of reproducing it. Logging that only works with debug builds is just. plain. dumb.

The software typically ships with ERROR, BASIC, STATE_CHANGE and EXCEPTION turned on, but this can be changed in the field via the debug dialog (or a registry/ini/cfg setting, where these things get saved).

Oh and one thing - my debug system generates one file per day. Your requirements may be different. But make sure your debug code starts every file with the date, version of the code you're running, and if possible some marker for the customer ID, location of the system or whatever. You can get a mish-mash of log files coming in from the field, and you need some record of what came from where and what version of the system they were running that's actually in the data itself, and you can't trust the customer/field engineer to tell you what version they've got - they may just tell you what version they THINK they've got. Worse, they may report the exe version that's on the disk, but the old version is still running because they forgot to reboot after replacing. Have your code tell you itself.

Lastly, you don't want your code to generate its own problems, so put in a timer function to purge the log files after so many days or weeks (just check the difference between time now and time of file creation). This is OK for a server app that runs all the time, on a client side app you can get by with purging any old data when you start up. We typically purge after 30 days or so, on a system without frequent engineer visits you might want to leave it longer. Obviously this is dependent upon the size of your log files as well.


问:
Is the Entity Framework appropriate when all you do is insert records in bulk?
My department develops software to migrate databases for our customers from their old CRM software to ours. In this process we could be inserting up do millions of rows, processed one at a time as we need to do mapping and formatting to go from their old system (which could be anything from a Relational Database to a set of flat binary files) to our MS-SQL database.

Currently we use a producer consumer model that reads in from their old system to our mapper, then use another producer/consumer model to go from that in to thread local DataTables which get batched out every 15,000 rows in a SQLBulkCopy operation to keep the number of objects held in ram down (larger tables can easy exhaust the 2 GB limit for a 32bit application if we try to hold the entire table in memory before inserting it.)

The issue is this is kind of a kludge setup to be able to generate the new rows and insert them in to the database. Recently we have had the opportunity to re-write the database to fit our needs and I have been working away at my manager at the idea to using some form of ORM.

I have been starting to look around at various ORM solutions, and I know we want to stay with a pure Microsoft stack (it was hard enough to get my manager to consider using an ORM, and I don't have a snowballs chance of convincing him of using a 3rd party library, since the main CRM app uses a 3rd party image processing library that is not very good and he has hated 3rd party libraries ever since). Comparing Linq-to-Sql and ADO.net Entity Framework I think the EF fits our needs better. However I am concerned about performance.

Most CRUD apps are Read->Update at a slow rate (only displaying one record or a set of records with a common variable at one time). However we will just be doing Create, Create, Create. Is an ORM like EF designed to do that?

My manager is obsessed with performance. When this process was done in VB6 (which is how it was done up to two years ago) it could take up to several hours to run a conversion. With our current kludge the longest ones take at most half an hour to process several Gigs of records (the slowest part is dealing with that 3rd party image library I mentioned earlier, ones that are pure text take at most 10 min). Could I potentially see a slowdown in EF versus using SqlBulkCopy, and what can I do to mitigate the running cost if it does?

答:
This is one scenario where an ORM can be quite counter-productive, at least from a performance standpoint. Especially out of the box, and following the typical usage patterns they will perform horribly at this sort of work. You would be better off using SQL bulk copy or straight ADO.NET [no entity framework] here.

If you do decide to take this dive, check out this blog post for some pointers. It is about nHibernate but the same sorts of things would apply to the Entity Framework I'd think.

Now just because you are using straight ADO.NET for a performance-intensive path in the app doesn't mean you can't use an ORM in other places where it makes sense.


答:
Couple of notes from the operations side of the house here:

1) Make sure the logs are locally configurable, preferably with a tool no heavier than a text editor. Most of the time we don't want to get TRACE level logging, but we love to be able to turn it on.

2) If at all possible, make sure the logs can be read with a tool no heavier than a text editor. Nothing is worse than having to go on a tool hunt at an odd hour when the production system is failing.


答: I think I found the best of both worlds. On Microsoft's MSDN archive they have a LINQ Entity Data Reader which will allow me to turn my EF object in to a DbDataReader which can be passed in to SqlBulkInsert.</p>

Title: Is the Entity Framework appropriate when all you do is insert records in bulk?

Body:
My department develops software to migrate databases for our customers from their old CRM software to ours. In this process we could be inserting up do millions of rows, processed one at a time as we need to do mapping and formatting to go from their old system (which could be anything from a Relational Database to a set of flat binary files) to our MS-SQL database.

Currently we use a producer consumer model that reads in from their old system to our mapper, then use another producer/consumer model to go from that in to thread local DataTables which get batched out every 15,000 rows in a SQLBulkCopy operation to keep the number of objects held in ram down (larger tables can easy exhaust the 2 GB limit for a 32bit application if we try to hold the entire table in memory before inserting it.)

The issue is this is kind of a kludge setup to be able to generate the new rows and insert them in to the database. Recently we have had the opportunity to re-write the database to fit our needs and I have been working away at my manager at the idea to using some form of ORM.

I have been starting to look around at various ORM solutions, and I know we want to stay with a pure Microsoft stack (it was hard enough to get my manager to consider using an ORM, and I don't have a snowballs chance of convincing him of using a 3rd party library, since the main CRM app uses a 3rd party image processing library that is not very good and he has hated 3rd party libraries ever since). Comparing Linq-to-Sql and ADO.net Entity Framework I think the EF fits our needs better. However I am concerned about performance.

Most CRUD apps are Read->Update at a slow rate (only displaying one record or a set of records with a common variable at one time). However we will just be doing Create, Create, Create. Is an ORM like EF designed to do that?

My manager is obsessed with performance. When this process was done in VB6 (which is how it was done up to two years ago) it could take up to several hours to run a conversion. With our current kludge the longest ones take at most half an hour to process several Gigs of records (the slowest part is dealing with that 3rd party image library I mentioned earlier, ones that are pure text take at most 10 min). Could I potentially see a slowdown in EF versus using SqlBulkCopy, and what can I do to mitigate the running cost if it does?


答:
Your case is typically solved by a class of application development tools usually referred to as ETL (Extract, Transform and Load).
In SQL Server, you can use SSIS (see this link for example: SSIS Tutorial

There are free ETL tools such as a special edition of Expressior Studio

The nice thing about tools such as these is that you can build your application using drap-and-drop and not write a single line of code unless you want to change the data or validate it.

Most ORMs I know, don't support batch updates/inserts. One exception may be N-Hibernate (see: batch)

Any approach that will work on a row-by-row will be slow. ADO EF is not the problem.
So either use Bulk Loader or an ETL tool but coding C#/ADO is not the best way to do it specially if you have large number of data sources.


问:
Multiple projects - similar platforms or as different as possible?
When working on multiple projects simultaneously (for the sake of simplicity let's say half time each on two projects), which is better? Should the two projects

Use the same language? Same/similar frameworks?

Use entirely different languages?

Additionally, is it best if they are target for similar platforms, or different (web v. desktop v. mobile v. utility library for internal use)?

The first responses that come to mind are

They should be similar, and play to the strengths of the developer to help him handle managing both of them

They should be as different as possible to help the developer keep organized

Since I've never done this in a professional setting, I was hoping more experience programmers could shed some light on the best way to go about doing this.

EDIT:

This question is assuming the existence of multiple other projects, each of which is underway (I think some underway and some brand new with no design decisions yet made would be too broad for one question). When choosing between existing projects for a second project, should a developer consider how similar his new project is to his current project, and how should that affect the decision?

答:
First of all, the actual requirements should drive the decision behind what language, frameworks and tools to use.

If the requirements allow you to work on similar languages, frameworks and tools, then you should definitely try to keep things as consistent as possible.

You want to keep things similar for the following reasons:

Less context switching for a developer is good - There is a lot less context switching when you allow your devs to use the same languages, tools etc... All they have to switch is between 'domains' but not between languages with different syntax and/or completely different principles.

Development environment complexity is less - It is complicated enough to set up your dev environment for a single kind of application stack, you do not want the pain of having to set up more than what you have to.

Consistency is good - Keep as much as possible consistent between the two projects, like coding standards, directory layouts, etc. Imagine a new dev coming onto the project and trying to understand both apps. They would require twice the ramp-up time.

UPDATE:
The question changed significantly, and my understanding is that you are asking the following...

I have a project that I am working on right now. I would like to pick up another project to work on simultaneously with the other. Is it better to pick a project that is similar to the existing one, or a completely different one.

This depends entirely on what you want to get into.

Do you want to learn a new language altogether? I would focus on the new language. I personally do better when my focus is not divided between projects so I like to work on a single thing at least for a couple of days before I switch to something else. As far as the type of language is concerned, if you learn something that is close to the original one (Java->Groovy), you will probably pick it up faster, you will have less frustration and less context switching. However, you might not get a great perspective on how much two languages can really differ (Java->Ruby or LISP->C) in their principles.


问:
What's a generic word for both Methods and Attributes?
In a class diagram, each class contains methods and attributes. What's the correct word for describing both of them besides something generic such as contents or items?

Context:

The Orange class extends the Fruit class and inherits its stuff.

where stuff = a single word for both methods and attributes

答:
The word you're looking for is "members". Typically they are referred to as "class members".

The Orange class extends the Fruit class and inherits its members.


问:
Why put SQL statement in a variable before using mysql_query()?
I'm been working with PHP on and off for a bit now, and I've seen plenty of code both ways:

```<code>$sql = "SELECT …";
mysql_query($sql);
</code>```

vs

```<code>mysql_query("SELECT…");
</code>```

Is there a reason for separating the two, beyond being able to also pass in something such as $con?

答:
Possibly because at one point the code looked like this:

```<code>$sql = "SELECT …";
echo $sql; //why is this <censored> query not working???????
mysql_query($sql);
</code>```

Otherwise, there's no compelling technical reason to go one way or the other.  I personally find using the temporary variable makes the code a tad bit easier to maintain if down the road you need to expand the query.  Larger queries seem easier to look at if they arent already embedded into a function call.  But thats just my personal preference.

Body:
Possibly because at one point the code looked like this:

$sql = "SELECT …";
echo $sql; //why is this <censored> query not working???????
mysql_query($sql);

Otherwise, there's no compelling technical reason to go one way or the other.  I personally find using the temporary variable makes the code a tad bit easier to maintain if down the road you need to expand the query.  Larger queries seem easier to look at if they arent already embedded into a function call.  But thats just my personal preference.


问:
When is it preferred to combine Add/Edit functionality, and when to keep them separate?
I regularly come across situations where I need to Add or Edit an item, and sometimes I use separate methods for Add and Edit, and other times I combine them into a single method.

Is one method preferred over the other? If so, why?

```<code>public void AddItem()
{
    ShowEditingPopup(new Item(), "Add Item");
}

public void EditItem(Item item)
{
    ShowEditingPopup(item, "Edit Item");
}
</code>```

OR

```<code>public void EditItem(Item item)
{
    ShowEditingPopup(
        (item ?? new Item()),
        string.format("{0} Item", (item == null ? "Add " : "Edit "))
    );
}
</code>```

where ShowEditingPopup is defined as

```<code>public void ShowEditingPopup(object popupDataContext, string popupTitle)
{
    PopupDataContext = popupDataContext;
    PopupTitle = popupTitle;
    IsPopupVisible = true;
}
</code>```

Edit: Just to clarify, I am not Saving the item, I am opening it for Editing. I almost always implement a generic Save method for saving to the database

Edit #2: Edited code samples so they more accurately reflect the sort of situation I am referring to

答:
This is a matter of how well you understand Single Responsibility Principle. It would be more cleaner and easier to read, understand, and maintain if the responsibilities are decoupled in to seperate methods/actions. However, this from the coding perspective.

If I had to pick one approach out of your examples, I would go for the first approach.

The user's perspective depends on how easy is to add new item or edit an existing item (number of clicks is one way I measure) and probably to follow few golden rules.

If I had to implement the functionality (UI/Form), I would have a single form when add and edit both have same fetures, and two seperate forms when they differ.


答:
There are a few reasons to do that:

Readability: it may not apply with a simple mysql_query("SELECT…"); (by the way, aren't you expected to use PDO? It's not year 1998!). But you see the usefulness of this when it comes to multiline arguments. When you have several of these, things become even harder to read.

Refactoring: it's really minor, but may apply as well. Imagine you will get the query from a config file instead of hardcoding it. It would probably be easier/more readable to have a variable defined first, then used as an argument.

Debugging: imagine the query is generated (the thing you must never done, but well, it's another subject). If you want to set the breakpoint after the query is generated but before the query is done, it would be possible to do only if the query is actually assigned to a variable.

Tracing: this may be a temporary code, and the author may know that he will add tracing of a query later.

In other words:

```<code>$sql = "SELECT …";
mysql_query($sql);
</code>```

will become:

```<code>$sql = "SELECT …";
$this->trace(123, TRACE_INFORMATION, 'Running the query ' . $sql . '.');
mysql_query($sql);
</code>```

Title: Why put SQL statement in a variable before using mysql_query()?

Body:
I'm been working with PHP on and off for a bit now, and I've seen plenty of code both ways:

```<code>$sql = "SELECT …";
mysql_query($sql);
</code>```

vs

```<code>mysql_query("SELECT…");
</code>```

Is there a reason for separating the two, beyond being able to also pass in something such as $con?

Body:
There are a few reasons to do that:

Readability: it may not apply with a simple mysql_query("SELECT…"); (by the way, aren't you expected to use PDO? It's not year 1998!). But you see the usefulness of this when it comes to multiline arguments. When you have several of these, things become even harder to read.

Refactoring: it's really minor, but may apply as well. Imagine you will get the query from a config file instead of hardcoding it. It would probably be easier/more readable to have a variable defined first, then used as an argument.

Debugging: imagine the query is generated (the thing you must never done, but well, it's another subject). If you want to set the breakpoint after the query is generated but before the query is done, it would be possible to do only if the query is actually assigned to a variable.

Tracing: this may be a temporary code, and the author may know that he will add tracing of a query later.

In other words:

$sql = "SELECT …";
mysql_query($sql);

will become:

$sql = "SELECT …";
$this->trace(123, TRACE_INFORMATION, 'Running the query ' . $sql . '.');
mysql_query($sql);


答:
Well having worked extensively in Java and a little in .NET, I would say categorically and absolutely that .NET is a much nicer environment to work in.

Its a much more coherent and integrated programming environment and the ".NET" framework is complete. Java is much more like a treasure hunt there are good libraries and frameworks out there but you need to actively search and evaluate almost everything you need for a practical project, just getting a development environment set up correctly can take days.

There are a lot more *nix servers out there than windows server (and they are cheaper to rent) but not many of them host a J2EE server -- so the server count is irrelevant. Its much more a case of .ASP vs PHP.

The main reason to favor Java over .NET is that many of the Fortune 500 companies have standardized on one of the big 2 J2EE platforms: IBM's Webshpere or Oracle's Weblogic.
Outside of this, admittedly gigantic, niche Java as a web application platform seems to have fallen out of favor.


答:
Nearly every common language has a standard library for handling this sort of thing.

In Java there is the "Properties" library which automatically loads an XML into a hash map. Other languages have similar libraries for handling simple XML config files.

If your config file is more than a simple Key/Value pairs, then, you may as well use Xereces of some similar full blown XML parser and use Xquery to get the data you require.

But remember "Jim's Law" --
"If you have a Turing Complete configuration file, then you are just programming in crappy langauge"


答:
On one hand, sure, for obvious reasons (less context switching, more consistency, etc.)

On the other hand, do you want to put all your eggs in one basket? What if the framework / platform / whatever of your choice somehow dies? What if the framework / platform / whatever that you didn't choose starts thriving? It does happen all the time, for example, with mobile platforms - currently the once mighty Symbian is slowly but surely going down, Windows maybe going up, but nobody knows what's the status quo in after a couple of years.

Title: Multiple projects - similar platforms or as different as possible?

Body:
When working on multiple projects simultaneously (for the sake of simplicity let's say half time each on two projects), which is better? Should the two projects

Use the same language? Same/similar frameworks?

Use entirely different languages?

Additionally, is it best if they are target for similar platforms, or different (web v. desktop v. mobile v. utility library for internal use)?

The first responses that come to mind are

They should be similar, and play to the strengths of the developer to help him handle managing both of them

They should be as different as possible to help the developer keep organized

Since I've never done this in a professional setting, I was hoping more experience programmers could shed some light on the best way to go about doing this.

EDIT:

This question is assuming the existence of multiple other projects, each of which is underway (I think some underway and some brand new with no design decisions yet made would be too broad for one question). When choosing between existing projects for a second project, should a developer consider how similar his new project is to his current project, and how should that affect the decision?


答:
Most significant, it makes it possible to output the exact SQL statement; e.g.

```<code>$S_BAG = "select * from BAG where NUMBER=" . $N ;
DebugLog( "S_BAG = " . $S_BAG );
mysql_query( $S_BAG );
</code>```

Also, when things get complex you may need to construct the SQL statement in parts; e.g.

```<code>$S_SELECT = "select ..."
if ( ... ) $S_WHERE = "where ...";
else $S_WHERE = "where ...";
$S_ORDER = "order by ..."
$SQL = $S_SELECT . " " . $S_WHERE . " " . $S_ORDER ;
DebugLog( "SQL", $SQL );
mysql_query( $SQL );
</code>```

Body:
Most significant, it makes it possible to output the exact SQL statement; e.g.

$S_BAG = "select * from BAG where NUMBER=" . $N ;
DebugLog( "S_BAG = " . $S_BAG );
mysql_query( $S_BAG );

Also, when things get complex you may need to construct the SQL statement in parts; e.g.

$S_SELECT = "select ..."
if ( ... ) $S_WHERE = "where ...";
else $S_WHERE = "where ...";
$S_ORDER = "order by ..."
$SQL = $S_SELECT . " " . $S_WHERE . " " . $S_ORDER ;
DebugLog( "SQL", $SQL );
mysql_query( $SQL );


答: You should strive to use the best tools for the job at hand.  However, if the best tools' usage are utterly unknown to the developers these may not be the best tools. </p>


答:
Another thing to keep in mind: if this is a web application, you'll want to change the filename even if the image has not change fundamentally simply because that forces the users' browsers to load the new version rather than using the old one from cache.

From Yahoo's Best Practices for Speeding Up Your Website:

Keep in mind, if you use a far future Expires header you have to
  change the component's filename whenever the component changes. At
  Yahoo! we often make this step part of the build process: a version
  number is embedded in the component's filename, for example,
  yahoo_2.0.6.js.