答:
Personally, I store a class named MyClass in a file called MyClass.class.php, inside a classes directory.

My autoload function is then as simple as

```<code>function __autoload($class) {
    require_once("/classes/".$class.".class.php");
}
</code>```

There is no structure inside the classes directory, but in my projects this is never been a problem. If you need to have subdirectories, the method suggested by Asa Ayers is very practical and easy to implement.

Title: What naming conventions do you use for php classes?

Body:
I really like using ClassNames and memberNames as convention but I am not sure how I would name the file containing a class.

I like making my classes defined in a file with the exact same name as the class. But I also like making php files all lowercase. So I am conflicted.

If I have a class called ProductGroup should that be defined in ProductGroup.php, productgroup.php, or product_group.php?

I know there is no right answer, so I am looking for what is most common or your opinion of which to use.. which do you use?

Body:
Personally, I store a class named MyClass in a file called MyClass.class.php, inside a classes directory.

My autoload function is then as simple as

function __autoload($class) {
    require_once("/classes/".$class.".class.php");
}

There is no structure inside the classes directory, but in my projects this is never been a problem. If you need to have subdirectories, the method suggested by Asa Ayers is very practical and easy to implement.


问:
Best practices for generating new identifiers for persistent objects?
In a typical scenario, an object that needs to be persisted in the database will be created in application code without an identifier, and later saved to a table in the database.  Some database construct, such as an identity column, will generate a new identifier, typically an integer that's unique for all of the rows of that table.  This identifier can then be returned to application code and then treated as a key.

```<code>CREATE TABLE Users (
    UserId int IDENTITY(1,1) NOT NULL, DisplayName nvarchar(max),
    UserName nvarchar(50), [Password] nvarchar(50))
GO

INSERT INTO Users (DisplayName, UserName, [Password])
    VALUES ('Joe Shmo', 'jshmo', 'pw1')
SELECT @@IDENTITY
</code>```

Another common scenario is for the identifier to be GUID:

```<code>CREATE TABLE Users (
    UserId uniqueidentifier NOT NULL, DisplayName nvarchar(max),
    UserName nvarchar(50), [Password] nvarchar(50))
GO

DECLARE @id uniqueidentifier = NEWID()
INSERT INTO Users (UserId, DisplayName, UserName, [Password])
    VALUES (@id, 'Joe Shmo', 'jshmo', 'pw1')
SELECT @id
</code>```

This second way provides the following advantage: the GUID can be generated in application code, which can then be used as a key for application caching/referencing purposes before the object is ever saved.  However, there is a cost associated with using GUIDs in size and, especially look-up costs.  These may be trivial when the table is small, but can become a major factor when the table is massive.

Are there any best practices, or techniques for the cases where an identifier unique to the object type needs to be generated in application code, but cannot be a GUID for whatever reason?

One thought was to have a another table generating identifier wrapped by an identifier service which application code could call.

答:
If you want to use a persistence layer like NHibernate, then using a Guid has one significant advantage over an identity column:  Guid's can be generated on the client side as soon as the entity object is created in memory, without hitting the database to do an insert.  Using an incrementing identity column, you have to do the insert to get your value.

This is a specific benefit of the general benefit of being able to generate Id's in a distributed manner that Guids allow.  If you plan to have any kind of mobile devices, or distributed databases, or just the ability to batch-import rows, it can be very helpful to generate new Ids without hitting the database.

ContentLicense: CC BY-SA 3.0


问:
How would I develop an avatar based 3D conference environment?
I want to develop a 3d environment to be used for meetings and other such functions.

Each attendee could log in with a customized avatar and could collaborate and discuss via voice and text chat. I would like to add in multimedia content features as well into the environment.

I need help regarding platform selection preferably I want to implement it as a web application with no local installation. I'd like to avoid a browser plug-in unless absolutely necessary.

I don't know graphics programming so I'd prefer an approach that uses existing platforms and off the shelf software.

I have considered the following options thus far:

WebGL

Google O3d

web 3d's X3D

VRML

X3doom

Sirikata Platform

yogurt3d

Unity3d

Jibe

OpenSim

Papervision3d

Flash

3dmlw

Java3d

Infinity3d

Cube3

CloudMach

Are there other possibilities?

答: Given that most of the environments you listed would require 3d graphics programming knowledge. You have made clear that you do not know that sort of programming. Thus I'd recommend an existing environment like Second Life. The primary issue with that would be that it is a local application. There was an attempt to develop a web front end called "Ajax Life" but it appears to have died. Perhaps you could design something similar, the source for that project appears to be available.</p>


答:
Browser application? Try Java JMonkey engine. Powerful and easy.

By no browser plugin, I assume that excludes Java and Flash. If not, good luck with WebGL. xD

Title: How would I develop an avatar based 3D conference environment?

Body:
I want to develop a 3d environment to be used for meetings and other such functions.

Each attendee could log in with a customized avatar and could collaborate and discuss via voice and text chat. I would like to add in multimedia content features as well into the environment.

I need help regarding platform selection preferably I want to implement it as a web application with no local installation. I'd like to avoid a browser plug-in unless absolutely necessary.

I don't know graphics programming so I'd prefer an approach that uses existing platforms and off the shelf software.

I have considered the following options thus far:

WebGL

Google O3d

web 3d's X3D

VRML

X3doom

Sirikata Platform

yogurt3d

Unity3d

Jibe

OpenSim

Papervision3d

Flash

3dmlw

Java3d

Infinity3d

Cube3

CloudMach

Are there other possibilities?


问:
How do I optimize a web application for high-latency users?
Basically, I have an application that does searches and requests results from a backend via long polling.  It connects to the backend which collects results for 500 ms then sends them back to the client (I'm simplifying things here a bit of course).  As we've optimized this, we've noticed a growing divide between users who search at night vs users that search during the day.  Namely, users who search at night are much slower than users that search during the day due to the fact that these users are mostly international and have higher latency.

What are good high-level approaches to speeding things up for these users?

答:
Reduce the amount of data you're sending over.

Some ideas that might help:

Pay close attention to white space in your html

Enable compression in your web-server for static pages

Split up your responses such that they can be sent gradually to the user

Implement an animated waiting/loading screen, which is quick to transfer


问:
Hate repetition to the extreme
I program in a style that everything it's expensive or I really do hate repeating anything, mostly because I develop for embedded systems. So I get very annoyed when I have to do something that causes repetition.

An example would be that in my current project, I am creating a Layout Manager. I had this huge function that did all the work of placing everything, which I don't mind as long as I comment well. Some point down the line I realise that something I do in that long function I need to do again somewhere else, like adjusting for something that is bigger than the current. But what got me really annoyed ( and why I'm posting ) is that the needed function requires three variables. To me those three variables are expensive and should only be computed once per call. But to refactor the code the way I need to I have to put the variables in the needed function. Now the variables gets evaluated three times.

This is just an example, and things like this crop up a lot else where, so besides telling me those evaluations aren't expensive, at which point I'll say, "I'm still repeating it though", what can be done about this sort of thing, or, to my huge annoyance, is it unavoidable?

Update: One of the main suggestions given is store the value. Using the example above again, storing the value does not seem viable. Mostly because the needed function takes two needed values which are used to compute the three variables. It would mean I would have to create an object, and feel free to correct me if I'm wrong, store the values and variables into the object and then test them if they had changed.

In short, unless there are other ideas out there, it looks to be unavoidable. The only real thing you can do is minimise up to a limit. How deep do I create objects at the cost of property look ups? How many times to I repeatedly have to create those three variables? I hope you get the idea.

There is also the fact maybe I could better refactor my code. I tend to write in huge functions and only pull out what I need, which is probably KISS's fault. I think need another acronym to balance things out :P .

答:
Are you programming for embedded systems?  If not then modern hardware is at the point where quibbling over mundane details like that is likely not sensical unless of course you are working on high frequency trading where nanoseconds count.

Please remember that code is written for PEOPLE not for MACHINES.  A process being a couple of milliseconds faster with code that takes a smart developer a week to understand is much less desirable than a slightly slower application with code and design that any developer can look at, figure out, add features to quickly and refactor in a pinch.

Title: Hate repetition to the extreme


问:
How to define complex business rules using User Stories?
A quick and dirty definition of User Story:

```<code>"As a <role>, I want <goal/desire> so that <benefit>"
</code>```

In this commonly accepted definition there is little space for defining business rules, constraints or user input.

Trivial example just to illustrate:

```<code>"As a <librarian>, I want to <register new books> so that
<students can find their availability online>"
</code>```

In this silly example, where would one define the fields needed when registering a book? Should it be written anywhere? Or should the required business rules be passed as word of mouth by the Product Owner?

答:
Typically on a broad encompassing user story that has many facets I try to get the most general example of the story, and then for specifics I create child user stories that inherit from it.  Many Agile project management tools like RallyDev allow you to do this easily and I find it makes sense.

Registering new books is broad, so perhaps there are 10 other child user stories about how <role> would like books to be registered.

Extreme details of these things or bizarre fringe details I usually define in one or more tasks under that user story.  The tasks help define development and design work that should be done (on a general level) to meet that user story (Eg. Write validtor to ensure input in description field is less than 50 characters...)  EDIT:  I just wanted to add that it is probably better to keep extreme details out of user stories because it likely isn't something that a user will really care much about.  Users want to explain software in general terms and they are depending on software developers to figure out and hide the details from them.

This is just how I approach the problem but I am sure there a number of different ways.


问:
How do I deal with the need to know multiple programming languages?
I am a relatively young programmer. I am 23 and I have been programming professionally for about 5 years.

As most programmers I started with C, learned some x86 assembly for fun and then I found C++ which turned out to be my greatest passion in the programming world. Programming with C and C++ forces you to learn platform specific APIs, libs and frameworks all of each requires constant study and experimentation.
After some time I had to move on to Java and C# as the demand on my region is basically for these languages. With these languages I entered the world of web development and then I had to learn javascript.
Developing for the .NET Framework was exciting at first but I constantly felt as I was getting tied up by Microsoft (and of course the .NET Framework was driving me away from Linux).
For desktop development I could do pretty much everything I did with .NET using C++ with Qt but for web development I had to look for an alternative. Quickly I found Django and then I proceeded to learn Python so I could use Django.
Nowadays I am learning iOS development with Objective-C.

So far it was pretty much easy to learn all these languages (C++ trained me well) but I am worried that someday I won't be able to keep track of them all.
Just to clarify. The only languages I learned cause I had to were C# and Java. All of the others I learned for fun, because I love programming and learning new things. Also I like to keep my skills sharp on desktop, web and mobile development.

My question is: How do you keep track of multiple programming languages? (I mean, keep track of changes to these languages and keep your skills sharp) and: Is there such a thing as enough programming languages?

答:
Someone else suggested somewhere that "everyone should know 3 languages".

I tend to agree. You should know a compiled language (C/C++, C#, etc), an interpreted language (Python, Ruby, etc) and a text processing language (Perl, Awk, etc). I also think you should know a shell scripting language (Bash, these days or Windows power shell). The same advice applies to toolkits and APIs.

The only way to keep up with a language as it evolves is by using it. If you keep your toolkit of regular languages limited to a few you'll be more easily to use all of them regularly to solve problems, and thus you'll be able to keep up with developments in each.

So, get up to speed with the technologies you use daily and stay there. There's nothing wrong with dabbling in other interest areas when you have time.  It usually doesn't take a competent programmer long to learn a new technology given sufficient motivation and block time to sit with it.

There is no need to keep up with every single technology out there... you'll be able to spin up and down on them as needed, keeping the ones you use most regularly as your focus.


答:
You need to analyze your code looking for "turnarounds". A turnaround is a case where forward progress is blocked until data can be received from the other side. Each turnaround adds a penalty to performance that scales with the latency. So if you have 12 turnarounds, 100ms more latency means 1.2 seconds of wait. If you can drop the turnarounds to 4, 100ms additional latency only means an extra .4 seconds of wait.

Some turnarounds are explicit. If you send a request and wait for a reply, that's a turnaround. If you need to see that reply to decide what the next request will be, that's a turnaround.

Some turnarounds are implicit. If you open a TCP connection and wait to determine if the opening succeeded, that's a turnaround. If you close a TCP connection and wait for the close to complete with no errors, that's a turnaround.

Finding and measuring turnarounds is a bit of a black art. But one trick you can use is a latency simulator (Linux can do this with netem). If you can add logging with timestamping or otherwise tell what's going on, you can add a 4 second latency simulator (a device that adds 4 seconds of delay to every packet passing through it). Each 4 seconds you spend waiting for something is turnaround. You can count them, and you can also see where in your operating process they fall.

Code that's never been optimized for turnarounds frequently has a large number of needless turnarounds. They're typically invisible in testing environments because those environments typically have the client and server on the same LAN or, at worst, very close on a fast WAN.

There are four basic ways to eliminate a turnaround. One is pipelining -- this basically just means you don't wait for a reply if you don't have to. You can come back and check results later. Another is consolidation -- if you currently need two requests to do some higher-level operation and you reduce it to one request, that's a turnaround gone. The third way is concurrency -- if you can do more than one thing at a time, that's a turnaround gone. The last is prefetching -- if you know a web page element you're about to load is going to need to load the contents of another URL, you can start retrieving that URL while you're loading the web page that needs it.

Title: How do I optimize a web application for high-latency users?

Body:
Basically, I have an application that does searches and requests results from a backend via long polling.  It connects to the backend which collects results for 500 ms then sends them back to the client (I'm simplifying things here a bit of course).  As we've optimized this, we've noticed a growing divide between users who search at night vs users that search during the day.  Namely, users who search at night are much slower than users that search during the day due to the fact that these users are mostly international and have higher latency.

What are good high-level approaches to speeding things up for these users?


答:
If you "don't know graphics programming" then this will be a colossal task. Are you sure you know what you are letting yourself in for?

Having said that, my advice would be to go for a cross-platform game engine such as jMonkeyEngine. Advantages:

Game engines come with a lot more features "out of the box" than pure graphics libraries

Relatively mature / stable with all the 3D features you are likely to need

Available on many platforms

It will work from a browser - although you do need a plugin (Java) and some form of OpenGL support, virtually everyone has this nowadays

Friendly open-source licensing


问:
What is meant by "Now you have two problems"?
There is a popular quote by Jamie Zawinski:

Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.

How is this quote supposed to be understood?

答:
Regular expressions - particularly non trivial ones - are potentially difficult to code, understand and maintain. You only have to look at the number of questions on Stack Overflow tagged [regex] where the questioner has assumed that the answer to their problem is a regex and have subsequently got stuck. In a lot of cases the problem can (and perhaps should) be solved a different way.

This means that, if you decide to use a regex you now have two problems:

The original problem you wanted to solve.

The support of a regex.

Basically, I think he means you should only use a regex if there's no other way of solving your problem. Another solution is probably going to be easier to code, maintain and support. It may be slower or less efficient, but if that's not critical ease of maintenance and support should be the overriding concern.


问:
How baby are your baby-steps in TDD?
Today we were training TDD and found the following point of misunderstanding.

The task is for the input "1,2" return sum of numbers which is 3. What I have written (in C#) was:

```<code>numbers = input.Split(',');
return int.Parse(numbers[0]) + int.Parse(numbers[1]); //task said we have two numbers and input is correct
</code>```

But other guys preferred to do it other way. First, for input "1,2" they made added the following code:

```<code>if (input == "1,2")
   return 3;
</code>```

Then they introduced one more test for input "4,5" and changed implementation:

```<code>if (input == "1,2")
   return 3;
else if (input == "4,5")
   return 9;
</code>```

And after that they said "Okay, now we see the pattern" and implemented what I initially did.

I think the second approach better fits the TDD definition but... should we be so strict about it? For me it is okay to skip trivial baby steps and combine them into "twinsteps" if I am sure enough that I won't skip anything. Am I wrong?

Update. I have made a mistake by not clarifing it was not the first test. There already were some tests so "return 3" actually wasn't the simplest piece of code to satisfy the requirement.

答:
I think the second way is mind numbingly stupid. I see the value in making small enough steps, but writing those tiny zygote (can't even call them baby) steps is just asinine and a waste of time. Especially if the original problem you're solving is already very small by it's own.

I know it's training and it's more about showing the principle, but I think such examples do TDD more bad than good. If you want to show the value of baby steps, at least use a problem where there is some value in it.

Title: How baby are your baby-steps in TDD?


答:
To me it seems fine to combine several trivial implementation steps into one slightly less trivial - I do that all the time too. I don't think one needs to get religious about following TDD everytime to the letter.

OTOH this applies only for really trivial steps like the above example. For anything more complex, which I can't fully hold in my mind at once and/or where I am not 110% sure about the outcome, I prefer to go one step at a time.

Title: How baby are your baby-steps in TDD?

Body:
Today we were training TDD and found the following point of misunderstanding.

The task is for the input "1,2" return sum of numbers which is 3. What I have written (in C#) was:

```<code>numbers = input.Split(',');
return int.Parse(numbers[0]) + int.Parse(numbers[1]); //task said we have two numbers and input is correct
</code>```

But other guys preferred to do it other way. First, for input "1,2" they made added the following code:

```<code>if (input == "1,2")
   return 3;
</code>```

Then they introduced one more test for input "4,5" and changed implementation:

```<code>if (input == "1,2")
   return 3;
else if (input == "4,5")
   return 9;
</code>```

And after that they said "Okay, now we see the pattern" and implemented what I initially did.

I think the second approach better fits the TDD definition but... should we be so strict about it? For me it is okay to skip trivial baby steps and combine them into "twinsteps" if I am sure enough that I won't skip anything. Am I wrong?

Update. I have made a mistake by not clarifing it was not the first test. There already were some tests so "return 3" actually wasn't the simplest piece of code to satisfy the requirement.


问:
Creating public API definition for existing application
Let's say there's a successful open source application (written in PHP if it matters), which provides its users with multiple ways to extend it (think about something like Drupal or Wordpress, lots of custom plugins, etc.). Now let's say unfortunately there's no formal definition what constitutes the public API for this application, and we want to define such a public API, so that we could a) control application development and refactoring and know we don't screw up the extensions with the next version and b) give extenders some idea what they can safely use and what they better not use. So the question is - how is it best to approach this and what should be there? For example, some specific questions:

Should all classes be part of public API or should we mark those are public or mark those that aren't?

Should protected methods be part of the API (if somebody creates derived custom class, they will be relying on it) and if so - should we be explicitly marking those that we don't want others to use, or those we're allowing to use?

Should public properties be part of the API too? How about protected ones?

If we want to make change/refactoring which can't be backwards-compatible (e.g. old API was too buggy or doesn't really fit in the app anymore), how we best approach it?

If we want to remove some class/method completely, what should be the process? I imagine we want to make it deprecated first, and then remove in later versions, but for example should we give some warnings when deprecated, but still existing functionality is called? The problem here is we can't warn to aggressively as it may break the application, but if we're not agressive people would ignore the deprecated mark until we remove the old API piece and then they'd get major breakage.

Any other advice is welcome too, and references for good papers/examples/etc. on the topic.

答:
I'd suggest you buy this book:

RESTful Web Services Cookbook: Solutions for Improving
  Scalability and Simplicity by Subbu Allamaraju

I was told by a senior level Googler that many technical interview questions at Google (by the API teams) are directly taken out of this book. Thought, I haven't read it yet, I work mostly on the client-side these days. I'll probably end up reading that book only out of personal curiosity.


答:
Kent Beck covers this in his book, Test Driven Development: By Example.

Your example indicates an 'obvious implementation' - you want to return the sum two input values, and this is a fairly basic algorithm to achieve. Your counter-example fall into 'fake it until you make it' (although a very simple case).

Obvious implementation can be much more complicated than this - but basically it kicks in when the specification for a method is pretty tight - for example, return a URL encoded version of a class property - you don't need to waste time with a bunch of faked encodings.

A database connection routine, on the other hand, would need a bit more thought and testing so there is no obvious implementation (even if you might have written one several times already on other projects).

From the book:

When i use TDD in practice, I commonly shift between these two modes
  of implementation, When everything is going smoothly and I know what
  to type, I put in Obvious Implementation after Obvious Implementation
  (running the tests each time to ensure that what's obvious to me is
  still obvious to the computer). As soon as I get an unexpected red
  bar, I back up, shift to faking implementations, and refactor to the
  right code. When my confidence returns, I go back to Obvious
  Implementations.

Title: How baby are your baby-steps in TDD?


答:
Write the simplest code that makes the tests pass.

Neither of you did that, as far as I can see.

Baby Step 1.

Test: For the input "1,2" return sum of numbers which is 3

Make the test fail:

```<code>throw NotImplementedException();
</code>```

Make the test pass:

```<code>return 3;
</code>```

Baby Step 2.

Test: For the input "1,2" return sum of numbers, which is 3

Test: For the input "4,5" return sum of numbers, which is 9

Second test fails, so make it pass:

```<code>numbers = input.Split(',');
return int.Parse(numbers[0]) + int.Parse(numbers[1]);
</code>```

(Way simpler than a list of if...return)

You can certainly argue Obvious Implementation in this case, but if you were talking about doing it strictly in baby steps then these are the correct steps, IMO.

The argument is that if you don't write the second test then some bright spark could come along later and "refactor" your code to read:

```<code>return input.Length; # Still satisfies the first test
</code>```

And, without taking both steps, you have never made the second test go red (meaning that the test itself is suspect).

Title: How baby are your baby-steps in TDD?

Body:
Write the simplest code that makes the tests pass.

Neither of you did that, as far as I can see.

Baby Step 1.

Test: For the input "1,2" return sum of numbers which is 3

Make the test fail:

throw NotImplementedException();

Make the test pass:

return 3;

Baby Step 2.

Test: For the input "1,2" return sum of numbers, which is 3

Test: For the input "4,5" return sum of numbers, which is 9

Second test fails, so make it pass:

numbers = input.Split(',');
return int.Parse(numbers[0]) + int.Parse(numbers[1]);

(Way simpler than a list of if...return)

You can certainly argue Obvious Implementation in this case, but if you were talking about doing it strictly in baby steps then these are the correct steps, IMO.

The argument is that if you don't write the second test then some bright spark could come along later and "refactor" your code to read:

return input.Length; # Still satisfies the first test

And, without taking both steps, you have never made the second test go red (meaning that the test itself is suspect).


问:
How to implement a lightweight clustered architecture for a distributed application
I currently have a distributed application that runs on multiple embedded PCs. The whole application is composed of one master server and several nodes. Each node is an embedded PC that runs Windows 7 Embedded and has a dual core CPU with 2GB of RAM.

The application (by definition) only works if the master is up and running, controlling all the nodes. The master server has a SQL Express database where it keeps information about every node it's supposed to control and how they are organized. The nodes have no persisted state.

Once the master and the nodes are up and running they will be manipulated and put into a certain state which is only kept in memory at this point. The master can be controlled by a WinForm client UI that connects to it and can read its state and send commands that will change it's state (it's basically a bunch of web services exposed using .NET WCF).

The state kept inside the master (in memory) is what matters. The state inside each node can be regenerated if a node restarts for example. If the master is restarted it loses its current state (and the node states as a consequence). This means after a restart of the master server the configuration will be reloaded and a 'fresh' state will be set.

Typically a setup of this application consists of one master and 9 nodes (this is a 3x3 setup). At any point a node can fail and the application will continue without it (as long as the master is up). If the node that failed comes back the master detects it and put it back to the desired state.

I've been asked to improve the architecture of this application so the master server can run inside one of the nodes. So instead of a 9+1 setup we will have only 9 embedded PCs with one elected to be a master. According to our tests the hardware of the node has enough power to support both the node and the master piece together. However the embedded PC can't be trusted and will fail much more often than a regular server we've used to host the master so far.

Because of that I was asked to come up with a redundancy solution. It's my understanding that the proper solution would be to put two or more embedded running in clusters so if the node running the master piece fails then another one will assume it's place.

Now, the question is: how to implement a lightweight cluster that can run in those conditions?

There are two main concerns that must be solved:

Data Persistency: not only the configuration must be saved but also the master state. That way when the master node goes down another node can assume as master without resetting the entire state of the application.

WCF Clustering: at any point if the master node fails another one must assume and all connected clients (the WinForm client UI) must be able to automatically reconnect to the new re-elected master node. This doesn't have to be really transparent to the user, but the clients must be able to reconnect automatically (doesn't matter if the new IP address will be the same or not).

There are several limiting factors to a possible solution:

There is no way to have a data storage shared between the nodes (each node has it's own HD and a private gigabit network between them)

Hardware upgrades are out of question

The solution have to be light enough so it runs on a embedded PC. So installing a cloud server or a clustered DB probably won't be fast enough (if you think MySQL clustered will work to solve the data layer, I'll be interested in hearing your thoughts)

The solution can't involve buying an expensive piece of software

The overall platform of this application must be Windows based

The best solution I thought so far was to use something like Prevayler to keep the master state persisted and then implement a sync of every command the master received into the other nodes. That will solve the persistence problem across all nodes (maybe something similar can be implemented using memcache, I'm not sure). I have no solution yet to solve the WCF service problem.

Because this will involve a huge lot of development and proper testing I thought I should hear from you guys before implementing anything.

I think a solution could be put together either by using a framework or some sort of open source software that solves part of the problem.

Please feel free to ask anything so I can improve the text of this question to make it more clear.

答:
AMQP

Use an AMQP implementation to guarantee node updates go to all masters.  This will take care of having the data on all master sync'd. There are free AMPQ implementations (as well as non-free).  You would probably want to run some test to figure out the appropriate tolerances, etc.  Gigabit interconnects will support quite a bit of queued communication, assuming the update rate is not extremely high, and the average update is not huge.  YYMV, so you'll definitely want to run some numbers, and do some testing to back it up.

Network Load Balancing with a Cluster IP

One typical way of handling load balancing is by addressing a single cluster IP.  I don't know much about this solution other than it's pretty common in Windows. (it's used at my work quite a bit)


问:
How do I cope with a manager who’s always interfering in what I do, but doesn’t really understand it?
We've all had them, managers who have either come from sales or last looked at code 10 or more years ago but think they know how to write code.

What can I do to give the impression that I'm grateful for their intervention, but keep it as short as possible so I can get on with my work?

Or, should I be engaging more with the manager to educate them with modern coding techniques and practices? After all, a manager who understands these will be able to talk sensibly to clients and more senior management when discussing the project and its timescales.

答:
I say, go ahead and try to engage and educate.

If they're honestly trying to help you, the chance to learn something could be valuable to them.  If they're just shoving their nose in for ego or political reasons ("See, I'm helping, I'm helping!"), they'll likely get the notion you'll embarrass them if they keep this nonsense up -- or bore them to death with a wall of jargon they're only pretending to understand.

And if you've got the dreaded egomaniac who truly thinks they're an expert at your job no matter what evidence you can bring to the contrary, then smile, nod, and make whatever trivial cosmetic changes will make them go the hell away.  And update your resume.

ContentLicense: CC BY-SA 4.0

ContentLicense: CC BY-SA 2.5


问:
For ASP.NET Programmers: Does the executable 'dcpromo' have any significance?
Dcpromo.exe is famous among MCSEs for being they only way to create a Windows Domain Controller (in other words an Active Directory Domain) ... which in turn is often used by the ASP.NET Membership system.

I'm trying to determine if I should put content on "www.dcpromo.com" geared for developers or more towards sysadmins.

To me, a logical extension of this "domain controller on the internet" is to use WIF for the ASP.NET Membership system.  We'd then have a website that will serve the developer's interests in the SSO, SAML, user managment and identity areas we all struggle with.

So my question is:

Q:  Do programmers see a connection between the utility dcpromo.exe and ASP.NET Membership?  If so does it make sense to have a purpose of http://www.dcpromo.com  help developers in the areas of membership and cloud computing?

答: I've been a Microsoft developer for 11 years, mostly as a web developer.  Been coding since 1.1 and I've used .NET membership in many of my applications, and I've never heard of dcpromo.</p>


答:
Regular expressions are very powerful, but they have one small and one big problem; they are hard to write, and near impossible to read.

In a best case the use of the regular expression solves the problem, so then you only have the maintenance problem of the complicated code. If you don't get the regular expression just right, you have both the original problem and the problem with unreadable code that doesn't work.

Sometimes regular expressions are referred to as write-only code. Faced with a regular expression that needs fixing, it's often faster to start from scratch than to try to understand the expression.

Title: What is meant by "Now you have two problems"?

Body:
There is a popular quote by Jamie Zawinski:

Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.

How is this quote supposed to be understood?


问:
Scheduling dependent tasks in a scrum sprint
I'm on a project right now that is using the scrum methodology with 2 week sprints.  Here's what our team looks like:

1 business analyst

1 tester

1 user experience designer

2 developers (1 for the UI and 1 for the back-end processes)

1 project manager

In a single sprint, we'll have 1 product backlog item (PBI) to design the UI for a page, another PBI to write the .Net code for the page, and 1 PBI to test the page.

How should these 3 product backlog items be scheduled so that they all get completed by the end of the sprint?  Since they are all dependent on each other and require at least 3 members of the team to work together, it seems to me like they each need deadlines in order for them to get done in time.

The scrum master keeps saying that they don't need deadlines because the cross-functional team will take care of it.  This hasn't worked in 10+ sprints, though.

Shouldn't the project manager be aware of this critical path and monitor its progress?

答:
You don't follow Scrum because your 3 PBIs are not PBIs. It is one PBI. Also if you divide the PBI this way and have special role for each part you are not doing Scrum but ScrumFall. Your cross functionality doesn't work at all because you have separate role for each task so while one role is doing its part of PBI other roles are waiting.

Cross functionality means that almost every member in the team can do any task and it is one of core requirements to make Scrum work. Otherwise you cannot efficiently plan the sprint because you must count velocity per role and combine PBIs in the way to fill capacity of each member - that is mostly impossible.


问:
unit tests for a csv parser
What tests should I use to unit test a csv parser?

I have a simple csv parser in C#, and I want to be sure I have good unit test coverage of all the common (and uncommon) edge cases. What tests should I use to identify potential problems and boundary cases?

答:
Check this directory out and look at the code in the *.t files.:

http://cpansearch.perl.org/src/MAKAMAKA/Text-CSV-1.32/t/

(The version number -1.32 might change eventually so the link might become "dead". Increment the version number yourself by trial-and-error, or go to the parent directory or click here

https://metacpan.org/pod/Text::CSV

and click through via "Browse" to the source code of the newest version)

Text::CSV_XS is a mature perl module for parsing csv files. The *.t files are written in Perl 5, they contain lots of testcases for self-testing the module, they are to be performed at module installation time.

Title: unit tests for a csv parser


答:
Q: Should all classes be part of public API or should we mark those are public or mark those that aren't?

A: Do the clear distinction for users of your classes - mark those that are intended for use by "outside" developers AND mark those that aren't (the latter won't guarantee you from weird backward-compatibility issues in future but hopefully will make these less frequent and less painful)

Q: Should protected methods be part of the API (if somebody creates derived custom class, they will be relying on it) and if so - should we be explicitly marking those that we don't want others to use, or those we're allowing to use?

A: Protected methods intended for "outside" use in derived custom class should be part of the API. The rest of protected methods should be stated as unsupported (this won't guarantee you from weird backward-compatibility issues in future but hopefully will make these less frequent and less painful)

Q: Should public properties be part of the API too? How about protected ones?

A: All the properties intended for use by outside code should be part of the API. All others should be clearly declared as unsupported (again, this won't guarantee blah blah...)

Q: If we want to make change/refactoring which can't be backwards-compatible (e.g. old API was too buggy or doesn't really fit in the app anymore), how we best approach it?

A: The best approach is to have a backup plan for the case if particular incompatible change turns out unacceptable for you (eg if it will lead to immediately breaking relations with developers at customer who brings you 90% income)

Q: If we want to remove some class/method completely, what should be the process? I imagine we want to make it deprecated first, and then remove in later versions, but for example should we give some warnings when deprecated, but still existing functionality is called? The problem here is we can't warn to aggressively as it may break the application, but if we're not aggressive people would ignore the deprecated mark until we remove the old API piece and then they'd get major breakage.

A: Deprecate, then plan for removal - this is rather standard practice, why deviate? Be prepared for cases when removal takes longer than you anticipated or turns out plain unacceptable for you.

Any other advice is welcome too

Establish and maintain Developer Guide. Better get a good technical writer to maintain it.

Establish and foster community of "outsiders" using your API. Support them by providing public issue tracker, forum(s), mailing list(s), wiki, whatever.

Offer a certification for "outside" code that uses your API. "Application MegaVideoSharing is unsafe because it uses unsupported method temporaryHack in class Workaround. Suggested fix: use method permanentFacade from class AntiCorruptionLayer instead" - stuff like that.

"Public APIs, like diamonds, are forever. You have one chance to get it right so give it your best..." (Joshua Bloch, How to Design a Good API and Why it Matters)

Title: Creating public API definition for existing application

Body:
Let's say there's a successful open source application (written in PHP if it matters), which provides its users with multiple ways to extend it (think about something like Drupal or Wordpress, lots of custom plugins, etc.). Now let's say unfortunately there's no formal definition what constitutes the public API for this application, and we want to define such a public API, so that we could a) control application development and refactoring and know we don't screw up the extensions with the next version and b) give extenders some idea what they can safely use and what they better not use. So the question is - how is it best to approach this and what should be there? For example, some specific questions:

Should all classes be part of public API or should we mark those are public or mark those that aren't?

Should protected methods be part of the API (if somebody creates derived custom class, they will be relying on it) and if so - should we be explicitly marking those that we don't want others to use, or those we're allowing to use?

Should public properties be part of the API too? How about protected ones?

If we want to make change/refactoring which can't be backwards-compatible (e.g. old API was too buggy or doesn't really fit in the app anymore), how we best approach it?

If we want to remove some class/method completely, what should be the process? I imagine we want to make it deprecated first, and then remove in later versions, but for example should we give some warnings when deprecated, but still existing functionality is called? The problem here is we can't warn to aggressively as it may break the application, but if we're not agressive people would ignore the deprecated mark until we remove the old API piece and then they'd get major breakage.

Any other advice is welcome too, and references for good papers/examples/etc. on the topic.


答:
When first setting out down the road of TDD the size of steps can be a confusing issue, as this question illustrates. A questions I often asked myself when I first started writing test driven applications was; Is the test I am writing helping to drive my applications development? This may seem a trivial and unrelated to some but hang in there with me for a moment.

Now when I set out to write any application I will usually start with a test. How much of a step that test is largely relates to my understanding of what it is I am trying to do. If I think I have pretty much got the behaviour of a class in my head then the step will be a big one. If the problem I am trying to solve is a lot less clear then the step might simply be that I know there is going to a method named X and that it will return Y. At this point the method won't even have any parameters and there is a chance that the name of the method and the return type will change. In both cases the tests are driving my development. They are telling me things about my application:

Is this class that I have in my head actually going to work?

or

How the hell am I even going to do this thing?

The point is that I can switch between big steps and little steps in the blink of an eye. For example if a big step doesn't work and I can't see an obvious way around it I will switch to a smaller step. If that doesn't work I will switch to an even smaller step. Then there are other techniques such as triangulation if I get really stuck.

If like me you are a developer and not a tester then the point of using TDD is not to write tests but to write code. Don't get hung up on writing loads of small tests if they aren’t given you any benefits.

I hope you enjoyed your training an stick with TDD. IMHO if more people were test infected then the world would be a better place :)

Title: How baby are your baby-steps in TDD?


问:
How do I protect my website (Codes, Database, FTP informations) from freelancer?
I'm developing a website using Joomla and many other 3rd party plugins and also I want to make some custom components so I'm hiring some freelancer developers and few are an online companies they say located in UK or somewhere.

After explaining them about the component's functionality and layouts they are requesting access to my website's FTP, Database, CPanel.

In this case how I'm going to protect my website? What if they take my other code and make a clone site or something? Is there any ideas besides company contract?

答: Limited, restricted and monitored access to the parts they need. Whilst they do need access to be able to work, if they're serious they'll be happy to tell you what they do need access to (i.e. specific db tables etc). If you're really really concerned then provide them a minimal environment as a staging set up, and when it gets to a certain stage implement it and feed back to them any issues. </p>


答:
RegularExpressionsarenoworsetoreadormaintainthananyotherunformattedcontent;indeedaregexisprobablyeasiertoreadthanthispieceoftexthere-butunfortunatelytheyhaveabadreputationbecausesomeimplementationsdon'tallowformattingandpeopleingeneraldon'tknowthatyoucandoit.

(Regular Expressions are no worse to read or maintain than any other unformatted content; indeed a regex is probably easier to read than this piece of text here - but unfortunately they have a bad reputation because some implementations don't allow formatting and people in general don't know that you can do it.)

Here's a trivial example:

```<code>^(?:[^,]*+,){21}[^,]*+$
</code>```

Which isn't really that difficult to read or maintain anyway, but is even easier when it looks like this:

```<code>(?x)    # enables comments, so this whole block can be used in a regex.
^       # start of string

(?:     # start non-capturing group
  [^,]*+  # as many non-commas as possible, but none required
  ,       # a comma
)       # end non-capturing group
{21}    # 21 of previous entity (i.e. the group)

[^,]*+  # as many non-commas as possible, but none required

$       # end of string
</code>```

That's a bit of an over-the-top example (commenting $ is akin to commenting i++) but clearly there should be no problem reading, understanding, and maintaining that.

So long as you're clear as to when regular expressions are suited and when they're a bad idea, there's nothing wrong with them, and most times the JWZ quote doesn't really apply.

Body:
RegularExpressionsarenoworsetoreadormaintainthananyotherunformattedcontent;indeedaregexisprobablyeasiertoreadthanthispieceoftexthere-butunfortunatelytheyhaveabadreputationbecausesomeimplementationsdon'tallowformattingandpeopleingeneraldon'tknowthatyoucandoit.

(Regular Expressions are no worse to read or maintain than any other unformatted content; indeed a regex is probably easier to read than this piece of text here - but unfortunately they have a bad reputation because some implementations don't allow formatting and people in general don't know that you can do it.)

Here's a trivial example:

^(?:[^,]*+,){21}[^,]*+$

Which isn't really that difficult to read or maintain anyway, but is even easier when it looks like this:

(?x)    # enables comments, so this whole block can be used in a regex.
^       # start of string

(?:     # start non-capturing group
  [^,]*+  # as many non-commas as possible, but none required
  ,       # a comma
)       # end non-capturing group
{21}    # 21 of previous entity (i.e. the group)

[^,]*+  # as many non-commas as possible, but none required

$       # end of string

That's a bit of an over-the-top example (commenting $ is akin to commenting i++) but clearly there should be no problem reading, understanding, and maintaining that.

So long as you're clear as to when regular expressions are suited and when they're a bad idea, there's nothing wrong with them, and most times the JWZ quote doesn't really apply.


问:
What's the best way to show a CLI CRUD app to client?
I'm developing a CRUD application on command line for a non-tech client. What's a simple (for both parties) way for me to demo the application remotely? A middle-ground between SSH (easy for me) and setting it up as a webapp (easy for the client) would be great.</p>

答:
Simple ways you may consider:

Recording the presentation on your machine and sending a flv file to customer

Use web conferencing

Document presentation (power point, word, etc.) - Not very cool


答:
If you are using joomla and other plugins for it then they can just get the sourcecode freely on the web anyway.

Just give them access to whatever they need (if you think it's relevant). Probably means creating a seperate FTP account with limited permissions.

Title: How do I protect my website (Codes, Database, FTP informations) from freelancer?

Body:
I'm developing a website using Joomla and many other 3rd party plugins and also I want to make some custom components so I'm hiring some freelancer developers and few are an online companies they say located in UK or somewhere.

After explaining them about the component's functionality and layouts they are requesting access to my website's FTP, Database, CPanel.

In this case how I'm going to protect my website? What if they take my other code and make a clone site or something? Is there any ideas besides company contract?


问:
How do you learn Regular Expressions?
I'm not asking where to learn. I've found lots of good resources online, and books etc.

But how the heck do I tackle them. Where is the start of it, the end? When does the regexp processor advance on the text, when does it hold its stand and tries another match? etc.

I feel like trying to figure out hieroglyphs on the Egyptian pyramids.

答:
I think that the knowledge of the Automata theory is critical for understanding.

Once you understand what an automaton is, and how regular languages are defined, understanding the regular expressions will be much easier.

As to the specific syntax and differences between the various implementations... Well, some things you just have to remember. There are aids for that, too.

Edit

Some of the comments below raised important points:

Don't forget that regular expressions (as implemented in most programming languages) are a superset of regular expressions in automata theory. While a good theoretical background is a useful place to start, it won't tell you everything. (Thanks, David Thornley)

Multiple commenters say that it is possible to learn the various regex syntax without learning the theoretical basis. While it is true that you can learn syntax without fully understanding how it works, it was my impression that the full understanding is what the OP was after. The question was about the actual basis: when does the processor advance? When does it stop? How it decides that its a match? That's the basis, that's the theory, and it is based on the Automata Theory. Sure, you can drive a car without knowing how the engine works. But if you're being asked "how does the gas actually make it drive" - you have to talk about how the engine is built, don't you?

Title: How do you learn Regular Expressions?


答:
A contract is your best bet.

You need to give them access to your site in order to complete the work. There has to be the assumption of trust on both sides. You trust them to deliver their code and not rip you off. They trust you to pay them when the work is complete.

If they are reputable (a search should reveal problems) then they won't want to jeopardise that by doing anything illegal or immoral.

You should however create an FTP account that only gives them access to the part of the file system they need to see and a limited user account on your CPanel etc.


答:
Can the functionality they're building be entirely encapsulated in a plugin? If so, commission them to build a generic plugin that would work on any Joomla site, then they can develop it on their own servers and you will just need to deploy it on yours.

Of course, that's going to cost you extra (building something generic is much harder than building something specific) but you don't get anything for nothing...


答:
Regular expressions can become very complicated very quickly, so I would recommend that you start learning it using tutorials.  Know that the simplest form of regular expression is a string representing what you're searching for.  Unfortunately, to be able to define special search rules, it requires certain characters, and these characters must be escaped or you'd be creating an invalid or incorrect regular expression.

My advice is to start with an example of something you're searching for and escape it.  So in other words, if you were looking for anything in parentheses, take an example of one such string in the text you're searching in:  (this is an example of something you'd want to find)

Start by escaping characters so that you search for the literal character:
\(this is an example of something you'd want to find\)

Test it, verify that it finds your example correctly.  Then generalize the expression to find any such text, not just the example you found.  So it would then become:
\([^)]*\)  (means any character that isn't ")" for any number of occurrences, including 0).

Test it again, and verify that not only does it find your example, but others like it.  Search for more complicated but more frequent regular expressions on the internet and patch them with your existing regular expressions to avoid having to worry about every single possibility.

That's about it.  And oh, learn and love \Q ... \E.  In most regular expression languages, \Q indicates the beginning of a literal pattern and \E marks the end, in case you have to deal with searching for particularly sophisticated patterns and don't know how to escape them.  That saved my life more than a couple occasions.

Title: How do you learn Regular Expressions?

Body:
I'm not asking where to learn. I've found lots of good resources online, and books etc.

But how the heck do I tackle them. Where is the start of it, the end? When does the regexp processor advance on the text, when does it hold its stand and tries another match? etc.

I feel like trying to figure out hieroglyphs on the Egyptian pyramids.


问:
Testing-related methodologies except TDD/BDD
Are there any testing-related methodologies except TDD/BDD? I see a lot of people who practice their own testing approaches (e. g., see Ayende post), but I don't see any formalization for it, no naming for these approaches.</p>

答:
Testing is a very general term covering a huge field, so there are a lot of methodologies involved, e.g. risk-based testing, model-based testing or random testing.

It actually makes sense to build a taxonomie, differentiating e.g. manual vs automated testing, white-box vs. black-box testing and the level in the V model (unit, component, system). Here is a mindmap that gives a rough taxonomie.

If you come across a technical term, you will probably find it in this glossary from ISTQB, which is by far the best I know of. ISTQB also offers several syllabus in which you can read up what the terms mean. This foundational syllabus is a good start.


问:
How is Sencha Touch performing on Android in practice?
I'm just about to start a project using Sencha Touch, and just done some minor testing on my HTC desire device. All tutorial videos at Vimeo seems to be using an iPhone emulator running on a Mac. Im not sure how fast this emulator is compared to a real iPhone device or even an real Android device, but from what i have experienced, it seems that my HTC desire is not performing that nicly as this emulator.

All animations (sliding, fading, etc) seems abit laggy. You can easily notice that the FPS is much less than on the Vimeo videos.

HTC desire is a relativly new and modern Android 2.2 phone, running with decent hardware, so im wondering if Sencha Touch is "ready" for the Android platform.

Anybody with practical experience with Android and Sencha Touch ?

答:
We just launched a sencha touch app and there's some significant performance issues in Android compared to iOS. Take caution when trying to implement design-heavy interfaces.

Something i wish i knew 3 months ago: big upfront designs is bad in mobile. You really need an iterative approach between the design / dev team. CSS3 transitions are tough on Android: avoid lots of rounded corners, RGBA, gradients, text shadows. It will make your app have a seizure.

Keep the DOM as small as possible; destroy the panels as they are no longer used.

We've seen some strange draw() behaviors on Android, but that may simply come from the fact we're asking too much of the CPU. Only way to know is to profile all the code like a ninya


答:
Since you are moving away from a single master node (which is appropriate) you will have to change a few things. You will need to setup a Quorum. Since you already have 9 nodes, you are in good shape. For a Quorum to work you need 2n+1 nodes where (n) is the number of nodes that can go down and the system will still work. Within the Quorum a vote will take place on who the leader is, and what transactions are successful. This can be used to pass around configuration information and ensure everyone is synchronized without a database.

There are existing technologies out there that can help you with this. One of thos is ZooKeeper. It is an open source Apache v2 product for Distributed Coordination. You will need something along these lines. Whether it is using ZooKeeper or rolling your own their white papers will be invaluable. It can also be used to maintain your configuration information about each node.

ZooKeeper is written in Java but I have created a project (ZooKeeperNet that will allow it to be embeded within .NET application using IKVM. If this isn't acceptable then you'll want to read about Leader Elections when determining who will be the current Master node. I suggest reading all their Wiki pages and Recipes to get an idea of what you need to account for in a proper distributed system.

Just so you have a good understanding. ZooKeeper is the backing coordination system of Hadoop and HBase. Hadoop is a distributed Map/Reduce framework.

If you already aren't, you can use WCF adhoc or registry discovery information when attempting to find the current master node in your system. If only a single Master node is alive it will be the only registered to support IMaster features. Then your slave nodes will listen on each other's znodes for each other to go away, picking up being the Master almost immediately.

Keep in mind that in order to be high efficient, the data each node needs to work with has to be close (i.e. on the node itself) to the node. If one node acts as a data intermediary you won't be as efficient as you could if the nodes could pull data in a distributed fashion.

Title: How to implement a lightweight clustered architecture for a distributed application

Body:
I currently have a distributed application that runs on multiple embedded PCs. The whole application is composed of one master server and several nodes. Each node is an embedded PC that runs Windows 7 Embedded and has a dual core CPU with 2GB of RAM.

The application (by definition) only works if the master is up and running, controlling all the nodes. The master server has a SQL Express database where it keeps information about every node it's supposed to control and how they are organized. The nodes have no persisted state.

Once the master and the nodes are up and running they will be manipulated and put into a certain state which is only kept in memory at this point. The master can be controlled by a WinForm client UI that connects to it and can read its state and send commands that will change it's state (it's basically a bunch of web services exposed using .NET WCF).

The state kept inside the master (in memory) is what matters. The state inside each node can be regenerated if a node restarts for example. If the master is restarted it loses its current state (and the node states as a consequence). This means after a restart of the master server the configuration will be reloaded and a 'fresh' state will be set.

Typically a setup of this application consists of one master and 9 nodes (this is a 3x3 setup). At any point a node can fail and the application will continue without it (as long as the master is up). If the node that failed comes back the master detects it and put it back to the desired state.

I've been asked to improve the architecture of this application so the master server can run inside one of the nodes. So instead of a 9+1 setup we will have only 9 embedded PCs with one elected to be a master. According to our tests the hardware of the node has enough power to support both the node and the master piece together. However the embedded PC can't be trusted and will fail much more often than a regular server we've used to host the master so far.

Because of that I was asked to come up with a redundancy solution. It's my understanding that the proper solution would be to put two or more embedded running in clusters so if the node running the master piece fails then another one will assume it's place.

Now, the question is: how to implement a lightweight cluster that can run in those conditions?

There are two main concerns that must be solved:

Data Persistency: not only the configuration must be saved but also the master state. That way when the master node goes down another node can assume as master without resetting the entire state of the application.

WCF Clustering: at any point if the master node fails another one must assume and all connected clients (the WinForm client UI) must be able to automatically reconnect to the new re-elected master node. This doesn't have to be really transparent to the user, but the clients must be able to reconnect automatically (doesn't matter if the new IP address will be the same or not).

There are several limiting factors to a possible solution:

There is no way to have a data storage shared between the nodes (each node has it's own HD and a private gigabit network between them)

Hardware upgrades are out of question

The solution have to be light enough so it runs on a embedded PC. So installing a cloud server or a clustered DB probably won't be fast enough (if you think MySQL clustered will work to solve the data layer, I'll be interested in hearing your thoughts)

The solution can't involve buying an expensive piece of software

The overall platform of this application must be Windows based

The best solution I thought so far was to use something like Prevayler to keep the master state persisted and then implement a sync of every command the master received into the other nodes. That will solve the persistence problem across all nodes (maybe something similar can be implemented using memcache, I'm not sure). I have no solution yet to solve the WCF service problem.

Because this will involve a huge lot of development and proper testing I thought I should hear from you guys before implementing anything.

I think a solution could be put together either by using a framework or some sort of open source software that solves part of the problem.

Please feel free to ask anything so I can improve the text of this question to make it more clear.


问:
Do you know of any encryption techniques used to validate url redirection
I'm adding a click-tracking feature on my website to track click-thrus for my advertisers.

So, on my site, instead of having a direct link, I link to my re-direct page passing the destination url as an argument. This re-direct page then tracks the click thru and then 301 re-directs the user to the correct external url.

I want to prevent 3rd partys from harnessing this system to make it re-direct to arbitrary urls.

I'd like the code that creates the links to:

Create special token using ( destination url + secret )

Then, pass the destination url + special token arguments as query string parameters to my re-direct page in public.

Upon receiving the arguments the re-direct page will do a check:

Given ( destination url + special token + secret ), destination url is either:

good - re-direct it to destination

bad  - do not re-direct it to destination

and it should not be possible for Doctor Evil to:

Create secret using ( known valid destination url + its special token )

Ideally the re-direct page would not have to do any url-specific look-ups on data to validate the parameters - it should just be able to tell from 'the two params given + the secret + the known algorithm'.

I'm not very knowledgeable about encryption so was wondering what kind of method one would use to create and validate the parameters given the shared secret.

I'm sure this is a common technique but I have no idea what its called - thus its difficult to learn more about it.

Any help is appreciated.

答:
As Jerry wrote, a MAC function is the easiest way to do this.

In PHP there are library functions available for this. I would suggest using HMAC (see hash_hmac() in the PHP manual) using either MD5 or sha256 as the corresponding hashing algorithm (this is the first argument to the function).

If you are interested in further details on Message Authentication Codes or hashing algorithms then I would suggest reading the Wikipedia articles for a good overview.


答:
You start out with a basic string comparison. Very easy, but also not that powerful.

Next, it may have occured to you, that you need case insesitive comparisions, so that "greek" and "GreeK" compare equal. This is a bit more powerful.

One day you notice small differences in spelling should not prevent 2 words from comparing equal: i.e.  "organize" and "organise" should compare equal. You sit down and write some code that does this and you're happy.

Until you abstract a bit more and realize that you sometimes want all words that end in "ize" to compare equal with their brothers in british spelling. Or, repetitions of some strings a certain amount of times. And, of course, you need to combina all that.

And so on. Finally, you most likely end up with some notation where not every character stands for itself. Nothing else is a regexp. One can see it as description of a set of strings.

And then, it is fairly easy and comes down to the following 3 basic principles:

You have basic regexps: chars that stand for themselves, character classes, handy and not so handy abbreviations for character classes like \d or \p{Lu} for uppercase letters.

And then, you have some possibilities to combine them: if r1 and r2 are regexps, then so are r1r2 r1|r2 (r1).

Last, but not least the repetition modifiers: r? r* r+ r{n,m}

This is most you need to know. Anything else you can lookup when you need it.

Title: How do you learn Regular Expressions?


问:
How would I develop an avatar based 3D conference environment?
I want to develop a 3d environment to be used for meetings and other such functions.

Each attendee could log in with a customized avatar and could collaborate and discuss via voice and text chat. I would like to add in multimedia content features as well into the environment.

I need help regarding platform selection preferably I want to implement it as a web application with no local installation. I'd like to avoid a browser plug-in unless absolutely necessary.

I don't know graphics programming so I'd prefer an approach that uses existing platforms and off the shelf software.

I have considered the following options thus far:

WebGL

Google O3d

web 3d's X3D

VRML

X3doom

Sirikata Platform

yogurt3d

Unity3d

Jibe

OpenSim

Papervision3d

Flash

3dmlw

Java3d

Infinity3d

Cube3

CloudMach

Are there other possibilities?

答:
The 3xd renderimg, though not trivial, is actually the easy part of the problem here -- it is just a matter of picking a platform that can do it and learning how to animate things. </p>

<p>The trickier thing is building the network code and coordination service that works well enough for realtime collaboration. </p>

Body:
The 3xd renderimg, though not trivial, is actually the easy part of the problem here -- it is just a matter of picking a platform that can do it and learning how to animate things.

The trickier thing is building the network code and coordination service that works well enough for realtime collaboration.


答: Brian Kernighan writes a simple reg-ex processor in the book Beautiful Code. I realize you are not looking for resources, but it might help to see a basic implementation, on the inside.

Title: How do you learn Regular Expressions?


问:
Best free UML authoring tool
What free UML authoring tools do you use and why is it better than others?</p>

答: ArgoUML - I use it for its simplicity.

Title: Best free UML authoring tool

Body: ArgoUML - I use it for its simplicity.

LastEditorDisplayName: Sergio


问:
What is the Best Collation for Use in MySQL Tables?
I'm curious what is considered the standard today for use as the Collation of MySQL Tables?

I was told that Latin-1 was the best choice when I was beginning with MySQL, but came across this post from 2009.

It states that US-ASCII and LATIN-1 Character Sets are on the way out, and that UTF-8 is on the way in and should be made the default by MSQ version 6.

Does this gel with what you know, or with what you think, or with what you do?

For this question, let's assume there is no specific need for non-english characters.

答:
UTF-8 is becoming more and more common virtually everywhere (W3Techs in June 2015 puts UTF-8 at 84.3% on the web), has no storage penalty over US-ASCII for the US-ASCII range (U+0000 through U+007F) (depending on the implementation the BOM may carry a three-byte penalty, but a BOM is only needed if the encoding and/or byte order is not otherwise known, which it would be in this case), and it can represent the full range of Unicode so it will future-proof your application character-set-wise at no extra cost if you don't use that capability. In summary, I see no reason not to use UTF-8 encoding these days, particularly if your choices are between UTF-8 and US-ASCII. And even in a US-only world, I would be very wary of saying that there will be "no need" to encode any letters outside of the English alphabet.

I'm pretty sure I saw a RFC from a few years back that stated that UTF-8 is the new Internet standard character set (replacing US-ASCII), but then I couldn't find it again. However, BCP 18 (RFC 2277) section 3.1, What charset to use, comes close in stating that, in part:

All protocols MUST identify, for all character data, which charset is
  in use.

Protocols MUST be able to use the UTF-8 charset, which consists of
  the ISO 10646 coded character set combined with the UTF-8 character
  encoding scheme, as defined in [10646] Annex R (published in
  Amendment 2), for all text.

Protocols MAY specify, in addition, how to use other charsets or
  other character encoding schemes for ISO 10646, such as UTF-16, but
  lack of an ability to use UTF-8 is a violation of this policy; such a
  violation would need a variance procedure ([BCP9] section 9) with
  clear and solid justification in the protocol specification document
  before being entered into or advanced upon the standards track.


答:
In a primer about unit testing i read the same approach (steps that look really, really tiny), and as an answer to the question "how tiny should they be" something i liked, which was (paraphrased) like this:

It's about how confident you are that the steps work. You can make real big steps if you want. But, just try it for some time and you will find a lot misguided confidence in places you take it for granted.
So, the tests help you to build a fact-based confidence.

So, maybe your collegue is just a little shy :)

Title: How baby are your baby-steps in TDD?


答: I'd suggest Open Wonderland.  It's an open-source 3D "virtual world" toolkit.  Needs some serious bandwidth, though -- I played with it a bit five or six years ago, and it was barely usable on the DSL service I had then.  Might be a problem if people try using it from their phones.</p>


答:
I see this as following the letter of the law, but not its spirit.

Your baby steps should be:

As simple as possible, but no simpler.

Also, the verb in the method is sum

```<code>if (input == "1,2")
   return 3;
</code>```

isn't a sum, it's a test for specific inputs.

Title: How baby are your baby-steps in TDD?

Body:
I see this as following the letter of the law, but not its spirit.

Your baby steps should be:

As simple as possible, but no simpler.

Also, the verb in the method is sum

if (input == "1,2")
   return 3;

isn't a sum, it's a test for specific inputs.


问:
How can I organize my implementation notes to use as a future reference?
How should I document my designing of the app better so that I avoid programming by coincidence? How can I structure notes so that it is clear how an app works so that when I refer to it a year later I'm not lost for the first 3 days?</p>

答:
You can use a class diagram for documentation purposes. I don't mean to generate an automatic documentation using UML which is really crap but to create manually class diagrams views of your packages.

You don't really need to know UML because if you reverse your project then you get your model and a class diagram for each package.
You then just add notes on classes and methods. You save your diagram directly at the root of your package. Job done !!

Really easy and very efficient. This is what I do and developers love me :-)


答:
I know you're not asking for resources but Mastering Regular Expressions by Jeffrey E.F. Friedl was how I learned how they work and how to use them. Even after getting to the point of using a lot of them to parse different things the first chapter had new things for me.

You want to understand those damn regexp? Read this book.

Title: How do you learn Regular Expressions?


答:
By practicing.

I learned by having fun with web scraping. I'm sure I wasn't alone doing that just for fun.

One example: Write some code that retrieves the latest football, tennis (the sport you like in fact) scores from your favorite sports website. Do it by writing some code to load the page, extract the scores with regular expressions and output them to the console or to some text file. Make sure that with the regular expression you choose you only retrieve the scores, and nothing else. Sometimes this can be quite challenging :-)

Second example: Write some code that retrieves the picture of your favorite webcomic, (I like Sinfest a lot for example) and that stores it somewhere on your hard drive. Use only regular expressions to retrieve the "img" tag and its content. Optionally also retrieve its  title if it's stored somewhere.

Title: How do you learn Regular Expressions?


问:
How baby are your baby-steps in TDD?
Today we were training TDD and found the following point of misunderstanding.

The task is for the input "1,2" return sum of numbers which is 3. What I have written (in C#) was:

```<code>numbers = input.Split(',');
return int.Parse(numbers[0]) + int.Parse(numbers[1]); //task said we have two numbers and input is correct
</code>```

But other guys preferred to do it other way. First, for input "1,2" they made added the following code:

```<code>if (input == "1,2")
   return 3;
</code>```

Then they introduced one more test for input "4,5" and changed implementation:

```<code>if (input == "1,2")
   return 3;
else if (input == "4,5")
   return 9;
</code>```

And after that they said "Okay, now we see the pattern" and implemented what I initially did.

I think the second approach better fits the TDD definition but... should we be so strict about it? For me it is okay to skip trivial baby steps and combine them into "twinsteps" if I am sure enough that I won't skip anything. Am I wrong?

Update. I have made a mistake by not clarifing it was not the first test. There already were some tests so "return 3" actually wasn't the simplest piece of code to satisfy the requirement.

答:
Isn't the whole point that the implementation of the method is irrelevant, as long as the tests succeed?
Extending the tests will fail quicker in the second example, but can be made to fail in both cases.</p>

Title: How baby are your baby-steps in TDD?


问:
Hate repetition to the extreme
I program in a style that everything it's expensive or I really do hate repeating anything, mostly because I develop for embedded systems. So I get very annoyed when I have to do something that causes repetition.

An example would be that in my current project, I am creating a Layout Manager. I had this huge function that did all the work of placing everything, which I don't mind as long as I comment well. Some point down the line I realise that something I do in that long function I need to do again somewhere else, like adjusting for something that is bigger than the current. But what got me really annoyed ( and why I'm posting ) is that the needed function requires three variables. To me those three variables are expensive and should only be computed once per call. But to refactor the code the way I need to I have to put the variables in the needed function. Now the variables gets evaluated three times.

This is just an example, and things like this crop up a lot else where, so besides telling me those evaluations aren't expensive, at which point I'll say, "I'm still repeating it though", what can be done about this sort of thing, or, to my huge annoyance, is it unavoidable?

Update: One of the main suggestions given is store the value. Using the example above again, storing the value does not seem viable. Mostly because the needed function takes two needed values which are used to compute the three variables. It would mean I would have to create an object, and feel free to correct me if I'm wrong, store the values and variables into the object and then test them if they had changed.

In short, unless there are other ideas out there, it looks to be unavoidable. The only real thing you can do is minimise up to a limit. How deep do I create objects at the cost of property look ups? How many times to I repeatedly have to create those three variables? I hope you get the idea.

There is also the fact maybe I could better refactor my code. I tend to write in huge functions and only pull out what I need, which is probably KISS's fault. I think need another acronym to balance things out :P .

答:
It's a good idea to not repeat yourself, it's part of the DRY principles.
However, the compiler will often take care of those minor optimizations.

It's not worth getting worked up over.

It's a good idea to not repeat yourself, it's part of the DRY principles.
However, the compiler will often take care of those minor optimizations.

It's not worth getting worked up over.

Title: Hate repetition to the extreme


答:
I use ArgoUML because it's free. and in polytechnic they introduce, teach and make us use IBM Rational Software Modeler (RSM) school license.

In the case of simplicity, IMHO I think all UML modeling software are much complicated due to the requirements of UML standards and its various diagrams.

Title: Best free UML authoring tool

Body: What free UML authoring tools do you use and why is it better than others?</p>


问:
Why aren't there automated translators from one programming language to another?
Most programming languages are Turing complete, which means that any task that can be solved in one language can be solved in another one, or even on Turing machine. Then why aren't there automatic translators that can convert programs from any given language to any other language? I've seen couple attempts for two languages, but they always work only on a limited subset of a language and can hardly be used for converting real projects.

Is it possible, at least in theory, to write 100% correct translator between all languages? What are the challenges in practice? Are there any existing translators that work?

答:
Why would you want to convert a program?

Both languages, the source and the target language are compiled to (virtual)machinecode anyways*, so for technical reasons there's no need to have a compiler to another high level language.

Languages are for humans. So, the implicit requirement of your question is: 'why is there no translator that generates readable code', and the answer would be (imho): because if there are two languages that are sufficently different, the ways 'readable code' is written is different in a way that would not just require to translate the algorithms, but take different algorithms.

For example, compare a typical iteration in C and one in lisp. Or pythons 'one best way' with idiomatic ruby.

Here, the same problems begin to appear you have in real languages, like you translate 'It's raining cats and dogs' to something with the meaning of 'It's pouring like it would from buckets' when translating from english to german, you can't translate word by word anymore, but you have to look for the meaning.

And 'meaning' is not an easy concept to work on.

*) well, there's coffeescript...


问:
Is OOP hard because it is not natural?
One can often hear that OOP naturally corresponds to the way people think about the world. But I would strongly disagree with this statement: We (or at least I) conceptualize the world in terms of relationships between things we encounter, but the focus of OOP is designing individual classes and their hierarchies.

Note that, in everyday life, relationships and actions exist mostly between objects that would have been instances of unrelated classes in OOP. Examples of such relationships are: "my screen is on top of the table"; "I (a human being) am sitting on a chair"; "a car is on the road"; "I am typing on the keyboard"; "the coffee machine boils water", "the text is shown in the terminal window."

We think in terms of bivalent (sometimes trivalent, as, for example in, "I gave you flowers") verbs where the verb is the action (relation) that operates on two objects to produce some result/action. The focus is on action, and the two (or three) [grammatical] objects have equal importance.

Contrast that with OOP where you first have to find one object (noun) and tell it to perform some action on another object. The way of thinking is shifted from actions/verbs operating on nouns to nouns operating on nouns -- it is as if everything is being said in passive or reflexive voice, e.g., "the text is being shown by the terminal window". Or maybe "the text draws itself on the terminal window".

Not only is the focus shifted to nouns, but one of the nouns (let's call it grammatical subject) is given higher "importance" than the other (grammatical object). Thus one must decide whether one will say terminalWindow.show(someText) or someText.show(terminalWindow). But why burden people with such trivial decisions with no operational consequences when one really means show(terminalWindow, someText)? [Consequences are operationally insignificant -- in both cases the text is shown on the terminal window -- but can be very serious in the design of class hierarchies and a "wrong" choice can lead to convoluted and hard to maintain code.]

I would therefore argue that the mainstream way of doing OOP (class-based, single-dispatch) is hard because it IS UNNATURAL and does not correspond to how humans think about the world. Generic methods from CLOS are closer to my way of thinking, but, alas, this is not widespread approach.

Given these problems, how/why did it happen that the currently mainstream way of doing OOP became so popular? And what, if anything, can be done to dethrone it?

答:
Given these problems, how/why did it happen that the currently
  mainstream way of doing OOP became so popular? And what, if anything,
  can be done to dethrone it?

OOP became popular because it offers tools to organize your program at a higher level of abstraction than the popular procedural languages that preceded it. It was also relatively easy to make a language that had procedural structure inside of methods, and object-oriented structure surrounding them. This let programmers who already knew how to program procedurally pick up OO principles one at a time. This also led to lots of OO-in-name-only programs that were procedural programs wrapped inside a class or two.

To dethrone OO, build a language that makes it easy to transition incrementally from what most programmers know today (mostly procedural, with a little OO,) to your preferred paradigm. Make sure it provides convenient APIs to do common tasks, and promote it well. People will soon be making X-in-name-only programs in your language. Then you can expect it to take years and years for people to get good at actually doing X.

Title: Is OOP hard because it is not natural?


问:
Is it worth it for a developer to be a scrum master? Is it an official designation or?
Is it beneficial for a developer to become a 'scrum master'?

Is this an official certification or just someone who specializes?

What are the steps towards becoming one?

答:
tl;dr: The Scrum Master is a Facilitator -- it does not denote mastery of anything.

Is this an official certification or just someone who specializes?
  What are the steps towards becoming one?

There is an official "Certified Scrum Master" designation. It is an introductory course managed by the scrum alliance. If you take the course and pass the test, you will be a "Certified Scrum Master".

Is it beneficial for a developer to become a 'scrum master'?

I don't think that it is. The Scrum Master role is an important part of a team, but is not a technical role -- the scrum master is the guy who leads the meetings and makes sure everyone is on the same page. It's more of a facilitator role.  It's probably useful if you want to go into coaching, but not necessary if you are a developer.

A scrum team needs to have a scrum master, and is best served by having an experienced one. The CSM certification does not guarantee quality of the Scrum master. Sending a guy to take the CSM course and than assuming he'll be able to lead you to scrum victory is a crazy bet.

CSM Certification is like CPR Certification -- you know the basics, but you're not an expert.


问:
How would you approach developing a Hotel Reservation System?
Till now, I have had the experience of developing either a desktop application or a Website. But, with this Hotel reservation system, I am interfacing a problem that needs both.

The application needs to be fulfil the following requirements :

Manager can do the bookings/checkout of the incoming customers at the reception counter System.

Customers should be able to book themselves online.

As you can see, the second requirements clearly means that a web app is required, whereas the first can be accomplished via desktop development.

This type of requirement is pretty common. Like, in case of cinema seat bookings, We are free to book ourself online or we can go the ticket window and buy one. The question is how are these simultaneous and different requirements fulfilled for a single project. There has to be a sync or else the customer might book himself in an already booked room.

From my understanding, there are two ways to develop this solution.

You develop a Web application with a back-end(admin panel) and host it on a server. The customers can book themselves on the front-end, while the manager(at reception desk) can use the administrator panel to carry out his bookings and checkouts. Since both front-end and back-end are using a single database, there is no requirement for sync.

Develop a desktop application for use at the Hotel and a website for the customers to book online. The two applications are maintaining a single datbase, therefore synchronization comes into play. Some definite development for the sync is mandatory or else the system will fail.

Which of the above solutions should I choose ?. This is also a common scenario for banks. They handle transactions at the local branch as well as over the Internet. How do they achieve this thing. Much like i mentioned above or something different.

答: My approach is to develop a web service that has all of the business rules and data rules encoded in it and exposes objects that can be used by both a web based app and a desktop app.</p>


答:
You outline 2 approaches and it has already been suggested to you that you could have a desktop & web app talk to the same database or the same web service - both are of course possible.

The problem is how to choose the approach, and for this I suggest you consider the following scenarios:

What is the impact if the system becomes unavailable to the hotel staff?

What is the impact if the system becomes unavailable to online customers?

If both online customer and hotel staff wish to book the same room, will it be first come/first served or will priority be given to the higher rate? (hotels generally discount walk in non bookings for that night)

Does the hotel have facilities/procedures for backup/restore if the system is kept locally?

I would assume that your priority will be to maintain hotel access, not online access.

This would lead to the question, could the hotel operate if the system was unavailable due to the hotels internet connection going offline? can they accept that risk?

All of these questions need to be put to the client before you can decide on an approach.

Edit: with regards to banks, it occurs in numerous different ways, probably all possible ways and there are some surprising assumptions made (at least in the UK ATM system) on how much money an ATM will release if it is not able to comunicate with the bank infrastructure.

Title: How would you approach developing a Hotel Reservation System?

Body:
Till now, I have had the experience of developing either a desktop application or a Website. But, with this Hotel reservation system, I am interfacing a problem that needs both.

The application needs to be fulfil the following requirements :

Manager can do the bookings/checkout of the incoming customers at the reception counter System.

Customers should be able to book themselves online.

As you can see, the second requirements clearly means that a web app is required, whereas the first can be accomplished via desktop development.

This type of requirement is pretty common. Like, in case of cinema seat bookings, We are free to book ourself online or we can go the ticket window and buy one. The question is how are these simultaneous and different requirements fulfilled for a single project. There has to be a sync or else the customer might book himself in an already booked room.

From my understanding, there are two ways to develop this solution.

You develop a Web application with a back-end(admin panel) and host it on a server. The customers can book themselves on the front-end, while the manager(at reception desk) can use the administrator panel to carry out his bookings and checkouts. Since both front-end and back-end are using a single database, there is no requirement for sync.

Develop a desktop application for use at the Hotel and a website for the customers to book online. The two applications are maintaining a single datbase, therefore synchronization comes into play. Some definite development for the sync is mandatory or else the system will fail.

Which of the above solutions should I choose ?. This is also a common scenario for banks. They handle transactions at the local branch as well as over the Internet. How do they achieve this thing. Much like i mentioned above or something different.


答:
For hotels there is a third requirement you're not thinking of - exposing yourself to aggregation sites (think Expedia) for bookings.

If this is a requirement (and it probably is when they ask "so how do we sell through Expedia") then synchronisation sort of goes out of the window (there are ways around it but really you all want to look at the same data source).

So single hosted database, single set of web services and then call the web services from both the hotel staff interface (desktop or web) and the customer facing interface. If they ever want to sell through someone else, the web services can be used for that too.

But you should also look at buying this stuff - it's a solved problem and there are off the shelf solutions. Most of them are relatively low on capital outlay, they just take a per booking fee.

(Answering your other question - banks have centrally hosted systems, single data stores accessed live over a WAN - at least they do these days).


问:
Website development from scratch v/s web framework
Do people develop websites from scratch when there are no particular requirements or they just pick up an existing web framework like Drupal, Joomla, WordPress, etc.

The requirements are almost similar in most cases; if personal, it will be a blog or image gallery; if corporate, it will be information pages that can be updated dynamically along with news section.

And similarly, there are other requirements which can be fulfilled by WordPress, Joomla or Drupal.

So, Is it advisable to develop a website from scratch and why ?

Update:

to explain more as got commentt from @Raynos (thanks for comment and helping me clearify the question), the question is about:

Should web sites be developed and designed fully from scratch?

Should they be done by using framework like Spring, Zend, CakePHP?

Should they be done using CMS like Joomla, WordPress, Drupal (people in east are using these as frameworks)?

答:
A Web Site is best served by a CMS.

A Web Application is not well served by a CMS. Some sort of coding framework may be helpful though.

The key is to ask yourself where on the scale from Site to Application you are. If most of your pages are about presenting information, lean towards a CMS. If they are about doing something, lean towards a framework.


问:
Planning Poker and wordy developers
My team is composed of 4 developers; all seasoned and skilled. One of them is a wordy, well intended chap who insists on defining the technical solution to our stories before we put down our estimates with Planning Poker. He refuses to estimate if he doesn't have a rough idea of the agreed technical solution (which sounds reasonable, right?).

The problem is that our estimating sessions are taking forever to finish!! In your experience, how do you deal with this kind of personality when playing the planning poker?

答:
He seems to like things being defined formally, so a timer would be a good idea, since planning poker is defined as having set amounts of time for people to speak.

He's got the wrong idea about estimation too, everyone estimates against the story and not the implementation, which is why you get such variance. For example some people may be ignorant of a framework or off the shelf solution and start writing things from scratch.

Title: Planning Poker and wordy developers


答:
I agree with the other answers that include web services, but web services is really just one way to implement the solution. The important thing is to separate the reservation system from the various clients of that system. Think in terms of building a reservation server that implements all the logic and data storage needed to keep track of reservations irrespective of any particular UI. The reservation server only presents one interface, all the clients talk to that server through that one interface.

This design has a lot of advantages:

You can add as many clients as you want:

web client for online reservations

desktop client for use in the hotel

administrative client for producing reports

test client for validating changes to the server

custom clients for interfacing with aggregators

You can update the server with little or no impact on the clients, provided you don't change the interface

Completely avoids any synchronization issues -- nothing can get out of sync because the data is only stored in one place

Web services is one very popular way to implement the interface to this sort of server, and I'd say it's likely the right choice in most situations. There are other possibilities, such as defining your own protocol, but I don't see any reason to get into that if you don't have to.