问:
Strategy for maintaining assembly references in TFS
I have a 3 branch setup:  Dev, QA, Prod.  There is a references folder where we store common 3rd party and internal assemblies.  Change mgmnt has been challenging.  Sometimes Devs forget to go into the References folder and check in the new version.

We tried referencing Projects, which results in a reference to the bin folder.  This works out fine as long as you keep the build order correct and always contain all the projects in the same solution file.  This isn't always a good idea or feasible, so we went to a references folder.

Continuous Integration may help alleviate some of these issues, but we don't have a CI server yet.  Is there a good process for for managing the References folder that doesn't require so much manuel dev intervention?

I thought about copying the files out on post-build.  That doesn't solve the issue of checking the new version in so other devs can access it.

We have TFS.  This is for internal corporate development.  Anything that requires open-source of our product is not possible.

UPDATE

I own FinalBuilder.  I am  new to using it and do not know if it can benefit this process.

答:
I think you have a couple of things here to consider.

1 - If your source tree is reasonably complex, then I'd encourage you to separate your solution files from your build system and build the *proj MSBuild files directly using recommendations from Microsoft such as MSBuild Traversal projects (see this article for more information on this best practice

http://msdn.microsoft.com/en-us/magazine/dd483291.aspx

Decoupling the solution file from the build system allows you the ability to keep tight control over the build system, leverage Project References where they make sense and still allow developers the ability to use solutions at will as a productivity option.  If a dev adds a new project, there's a conscious decision to include it at the appropriate location in the build process.  Furthermore, you can use the MSBuild "BuildProjectReferences" property to indicate if MSBuild should auto-build Project references or use existing output.

2 - Nuget... http://nuget.org/

Using a package management system such as Nuget to host and deploy your 3rd party dependencies can eliminate them from source control and allow you to publish new versions and create new Nuget packages at will.  There's been a pretty large adoption rate for Nuget of late and the resulting internet documentation should help you decide whether to host your own Nuget server, use the public one, or skip it altogether.

Having said all of this, and regardless of whether or not either of these solutions sound good to you, I'd definitely encourage you to get a CI build running ASAP.  It's invaluable in enforcing quality and getting a team in the habit of following protocol.  In fact, if you are having issues getting quality up after standing up a CI build, I'd encourage you to use a Gated-Checkin build (part of TFS for free) to ensure stuff builds correctly prior to check-in.

If you choose to keep your dependency tree checked into source control, then I'd suggest that you a) separate internal dependencies from 3rd party ones and b) keep the dependency folder branch-specific so you can build against different dependency sets based on branch easily.


问:
Approach for housekeeping production data
If you are going write a set of program to housekeep the production data, how can you ensure your program will work correctly?

We cannot housekeep the data based on their creation time. We would delete the data only if it has a generation date older than 6 months. But the generation date is not equal to the timestamp of the file, instead we query the database for relavent generation date.

If we implement a logic to compare the generation date and today's date, who can be sure of the logic won't fail on some special occasion? Maybe I am expressing too much concern over this, but when it comes to delete of production data, one needs to be cautious.

答:
For your program - Test, test, test

Always make sure that you backup your database before carrying out housekeeping tasks

If possible instead of deleting the data completely, move it to archive tables so that it is always available.

ContentLicense: CC BY-SA 3.0


问:
Is there a certain number of lines of code to be followed /maintain?
I am developing a software system (Patient Administration System) and I have noticed it already had 451 lines of code(in one namespace).

Is this bad? Or does the number of lines of code not matter as long as the methods and comments are useful and they doing what they are intended to do?

Or there is a number of lines of code to maintain like a namespace should only have 500 lines of code something like that

答:
The reason for line-number guidelines is that huge blocks of code is hard to read. This does not apply to namespaces as they themselves do not have any code to be read.

It is not at all uncommon to have thousands if not millions of lines inside a single namespace and so 500 is not at all a problem.

Instead of going by line number, ask yourself, "is this a separate, contained component?" If so, give a namespace.


问:
What technology is needed to create a live video streaming service?
I am curious as to what technology is needed to create a service such as stageit.com and livestream.com. What hardware and software is involved, besides a camera and microphone, from the broadcaster's computer to a viewer's computer?</p>

答:
There are several streaming servers.
Apart from the well-known Wowza, Helix, PVNS, QTSS there are many free solutions (see below some sorted in order of ease of usage):

Feng/Lscube - http://lscube.org/howto/live_streaming_flux here is a  simple tutorial how to use it

Red5 - http://trac.red5.org/wiki/Documentation#Tutorials

Darwin streaming server - http://dss.macosforge.org/

Xuggler - http://www.xuggle.com/


答:
I've been in the streaming media business for 5 years now, and I can confirm you the best choice is Wowza Media Server. It was created by former Adode (flash server) employees.

Just check their references, they just speak for them.

One of the huge advantage of Wowza is its extensibility. You can customize it using Java.

Title: What technology is needed to create a live video streaming service?

Body: I am curious as to what technology is needed to create a service such as stageit.com and livestream.com. What hardware and software is involved, besides a camera and microphone, from the broadcaster's computer to a viewer's computer?</p>


答:
Is there is a number of lines of code to maintain like a namespace
  should only have 500 lines of code ?

In general, we cannot be particular about the number of lines of code a namespace can hold as it depends on the classes defined in it.

That said, usually a collection of well defined classes are grouped into a particular namespace. So the key here is that one must be wise in defining  individual class which are apt for their functional role and not a collection of classes that come under one namespace which form the total lines for a given namespace.

Title: Is there a certain number of lines of code to be followed /maintain?

Body:
I am developing a software system (Patient Administration System) and I have noticed it already had 451 lines of code(in one namespace).

Is this bad? Or does the number of lines of code not matter as long as the methods and comments are useful and they doing what they are intended to do?

Or there is a number of lines of code to maintain like a namespace should only have 500 lines of code something like that


问:
Why does Java define homogeneous methods in Matcher and Pattern classes
I wonder why java defines homogeneous methods in two distinct classes:  java.util.regex.Pattern and java.util.regex.Matcher.

For example split method defined in Pattern class and replaceAll method defined in Matcher class. I think these two methods are homogeneous, why are they not defined in the same class?

Have I understood it wrong?

By "homogenous", I mean: split and replaceAll methods are utilities for String, why not defined in a class?

答: I'm guessing there's a or more historical reasons because you say correct, those classes have homogenous methods.</p>


问:
Do Databases Optimize Queries with Sum/Average or Other Aggregates?
Imagine a database that has billions of rows with, say, payments. You need to calculate an average payment sum. That will be

```<code>SELECT avg(amount) FROM payments;
</code>```

Now, if you need to re-calculate this figure every day, running this formula on the whole dataset is an overkill.

Bicycles have speedometers that calculate every second the average speed and the average cadence (pedal RPMs), even though they don't keep the speed for each second, and you may ride hours, days and months without resetting the average counter.

This is done in a simple way: the speedometer keeps the average value and the number of seconds. So when you add a new item to the sum, it just does this:

```<code>new_average = (current_speed + old_average * count) / (count + 1)
</code>```

If you know maths, it's clear that any sum or product can be calculated incremententially. Even updates can be done the same way: substract the old value from the aggregate, add the new value.

I want to know if any database can do this for the programmer?

I understand that the query in the DB may be different and have criteria:

```<code>SELECT avg(amount) FROM payments WHERE condition_1 AND condition_2;
</code>```

Yet, it is possible to cache averages with more information (what rows were in the sequence and what was the filtering condition).

Is this done anywhere?

答:
Denormalization of the DB could be used in this instance.

In other words, for every new insert of a payment, you would update a total payments tracking value.

This is not a built in feature however.


问:
Calculate Ellipse based on 4 points
I need to move an object based on 100 images rotating. The object needs to move in a path that is forming an ellipse when I'm rotating the image based on my gestures.

I have 4 points, 2 pairs of opposite points on X/Y axis, on the ellipse but how do I calculate the rest of the points in code-behind so that I can calculate the new X/Y Value of my next/previous point?

Currently I'm just rotating my object in a circle what is a start but not what I want at all...

答:
If you work in polar coordinates, the equation for an eclipse is

(Courtesy of Wikipedia)

a and b are the scaling factors in the X and Y axis, Theta is the angle of rotation.

Translating to your situation, a and b correspond to the points where your ellipse crosses the X and Y axii.

This gives you the radial point at a certain angle of rotation.  You can then solve for x and y using Trigonometry.

Title: Calculate Ellipse based on 4 points


答:
If your points are always at the ends of the ellipse axes, then your equation should look something like

```<code>1 = (x - (x1 + x2)/2)^2 / ((x1 - x2)/2)^2 + (y - (y3 + y4)/2)^2 / ((y3 - y4)/2)^2
</code>```

Basically, the equation of an ellipse is

```<code>(x - x0)^2/a^2 + (y - y0)^2/b^2 = 1
</code>```

where (x0, y0) is the center of the ellipse and 2a and 2b are the lengths of the horizontal and vertical axes.

So if (x1, y1) and (x2, y2) are the ends of the horizontal axis, then (x1 + x2)/2 is the x-coordinate of the center of the ellipse. Also abs(x1 - x2)/2 is the value of a.

Similarly, if (x3, y3) and (x4, y4) are the ends of the vertical axis, then the same calculations with the y-coordinates give you the y-coordinate of the center and the value of b.

Title: Calculate Ellipse based on 4 points

Body:
I need to move an object based on 100 images rotating. The object needs to move in a path that is forming an ellipse when I'm rotating the image based on my gestures.

I have 4 points, 2 pairs of opposite points on X/Y axis, on the ellipse but how do I calculate the rest of the points in code-behind so that I can calculate the new X/Y Value of my next/previous point?

Currently I'm just rotating my object in a circle what is a start but not what I want at all...

Body:
If your points are always at the ends of the ellipse axes, then your equation should look something like

1 = (x - (x1 + x2)/2)^2 / ((x1 - x2)/2)^2 + (y - (y3 + y4)/2)^2 / ((y3 - y4)/2)^2

Basically, the equation of an ellipse is

(x - x0)^2/a^2 + (y - y0)^2/b^2 = 1

where (x0, y0) is the center of the ellipse and 2a and 2b are the lengths of the horizontal and vertical axes.

So if (x1, y1) and (x2, y2) are the ends of the horizontal axis, then (x1 + x2)/2 is the x-coordinate of the center of the ellipse. Also abs(x1 - x2)/2 is the value of a.

Similarly, if (x3, y3) and (x4, y4) are the ends of the vertical axis, then the same calculations with the y-coordinates give you the y-coordinate of the center and the value of b.


问:
When should one read 'Code Complete'?
I'm pretty sure about who, but when?

The one with proficient knowledge of programming and software development or the one who's just a beginner in programming?

I'm pursuing bachelors right now, when is it preferable for folks like me to read this Must read for programmers book?

答:
My case: As soon as possible.
And then I open it from time to time when I want to refresh something specific or in a random page.

McConnel changed my life :-)

ContentLicense: CC BY-SA 4.0

Title: When should one read 'Code Complete'?

ContentLicense: CC BY-SA 2.5


问:
What maths should I learn to become a better computer scientist?
I'm a self taught programmer, and although I know many people feel math isn't necessary,  I find that in many examples of algorithms I come across talk about (what sounds to be) some pretty complex mathematics. I would love to eventually have a solid understanding of the math that a good, university educated computer scientist should know.  I don't really remember any math past algebra 2.  With that being where I left off, what should my starting point be?  What math topics should I research, and in what order?

I'm looking to build a curriculum for myself that will be pretty easy to take on from where I left off and continually learn until I have a similar understanding to that of what a university would provide.

答:
Look into these types of math:

Trigonometry

Combinatorics & Counting

Graph Theory

Discrete Structures

And these algorithms / subject matter:

Logic

Time Complexity (Big-Oh notation)

Proof by induction

Loop Invariants

NP-Completeness

Turing Machines

Discrete Finite Automata

I'll keep adding more as I think of them.

There's a really good book called "The New Turing Omnibus" which provides a comprehensive overview and the "cliff notes" on many of these.  I highly recommend you find that book.

OwnerDisplayName: ThinkingInBits


问:
Does Service-Oriented Architecture require the robustness principle?
I try to migrate more and more of our IT infrastructure to a Service-Oriented Architecture (SOA), that means separation of independent tasks and implementation of this tasks as decoupled services, simply accesible via HTTP. If you don't like the term SOA, just put in another - the basic idea is to put functionality in little modules and expose them by well-defined interfaces.

It also means a lot of documentation and communication, because people tend to think in integrated systems. When I combine multiple services to a new component, I always take care to catch errors: if one service fails, the rest of the system should keep on running as best as possible. You probably know the Chaos Monkey, which I keep in mind. However, if other people use services, they tend to think in reliable parts. Does good SOA require the robustness principle? In short, if you use a service, you should not expect to much quality: be aware of any kinds of errors: the service response may not contain all information (missing fields), it may include additional, unknown parts, it may respond very slow, or it may not work at all. Is this a property of loose coupling or am I just to lazy to guaranteeing strict service quality? ;-)

答:
I think you have to err on the side of robustness.

Consider this:  at this time all the developers involved can remember the system as an integrated whole.  However, if the SOA approach is actually worth doing, you should end up with several services that can be used in new ways.  Used by new users who don't know the history, or even better by external users, who would be very disappointed if they didn't get reasonable service, clear error messages, and easily parsed responses.  The principle of least astonishment should guide you here.

Note my caveat - some companies do SOA to be buzzword compliant.  Or perhaps only one component needs to be exposed and scale.  Or they read that Amazon does it this way. Building each component as a robust, standalone service may be a waste of time.

There will always be components that require sub-services x, y, and z to do useful work.  You may not be doing anyone any favors if it tries to soldier on with missing dependencies.  Sometimes failing is better than catching everything at the service boundary and hiding the issues.


答:
It's not easy to comprehensively answer your question. It very much depends on what you would like to do with your programming skills.

However, as a starting point I would suggest reading the first book of Donald E. Knuth's excellect handbook The Art of Computer Programming. It contains a comprehensive chapter on the mathematical prerequisites for understanding algorithms, and computer science in general.

In addition, I feel that a thorough understanding of Boolean algebra and mathematical logic is essential for any programmer.

Title: What maths should I learn to become a better computer scientist?

Body:
I'm a self taught programmer, and although I know many people feel math isn't necessary,  I find that in many examples of algorithms I come across talk about (what sounds to be) some pretty complex mathematics. I would love to eventually have a solid understanding of the math that a good, university educated computer scientist should know.  I don't really remember any math past algebra 2.  With that being where I left off, what should my starting point be?  What math topics should I research, and in what order?

I'm looking to build a curriculum for myself that will be pretty easy to take on from where I left off and continually learn until I have a similar understanding to that of what a university would provide.


答:
I think you're confusing the Robustness Principle and Robustness in Distributed Systems.

The Robustness Principle says:

Be liberal in what you accept, and conservative in what you send.

If you apply the Robustness Principle, it's very difficult to provide a clear and accurate description of what input your application will accept.  In other words, it will harder, and your application more complicated and more difficult to maintain.  Even worse is when clients start assuming that "bad but accepted" input is "good" input.  I think a good example of the Robustness Principle gone wrong is early versions of HTML and its interpretation by web browsers.  I would not recommend applying this principle unless you really know what you're doing.

However, robustness in distributed systems, as discussed in Jeff's article and the comments below, means that you expect failure and design accordingly, doing things like:

providing multiple servers in case one goes down

as services fail, other services which depend on them experience only graceful degradation

To answer the original question:  yes, I think this kind of robustness is (or should be) required in service-oriented systems.

Title: Does Service-Oriented Architecture require the robustness principle?

Body:
I try to migrate more and more of our IT infrastructure to a Service-Oriented Architecture (SOA), that means separation of independent tasks and implementation of this tasks as decoupled services, simply accesible via HTTP. If you don't like the term SOA, just put in another - the basic idea is to put functionality in little modules and expose them by well-defined interfaces.

It also means a lot of documentation and communication, because people tend to think in integrated systems. When I combine multiple services to a new component, I always take care to catch errors: if one service fails, the rest of the system should keep on running as best as possible. You probably know the Chaos Monkey, which I keep in mind. However, if other people use services, they tend to think in reliable parts. Does good SOA require the robustness principle? In short, if you use a service, you should not expect to much quality: be aware of any kinds of errors: the service response may not contain all information (missing fields), it may include additional, unknown parts, it may respond very slow, or it may not work at all. Is this a property of loose coupling or am I just to lazy to guaranteeing strict service quality? ;-)


问:
Is there a drawback in defining multiple small DRY classes, instead of bigger more repetitive classes?
I read some articles and it seems that using multiple classes in CSS is encouraged.
I am curious to find out if there is a maximum number of classes an element can have before this multiple class solution loses its benefits. (It may become a speed matter of some sort)

For example I have a project which uses 4 types of fonts, 4 types of font sizes, 4 type of font colours and so on. Is it better to divide these styles in very small classes and assign them to different classes or just try to handle the code on bigger chunks, in which case the style file will be obviously bigger and not DRY.

I believe that besides a little more work and the code becoming a little more difficult to follow there should not be any other major drawbacks. Am I right?

答:
There are huge drawbacks to this approach.

Let's say that all over your website you have a consistent way of displaying a user. In every case, the user's full name is blue. You have given each box's fullname area a class of "bluetext".

Now say that the business comes along and decides that all names should be red. Are you going to make "bluetext" actually write in red? Are you sure it hasn't been used elsewhere, where blue is still required? Are you going to change the class in your HTML throughout the site? What if you miss one? Doesn't it feel wrong to edit HTML for a change in style anyway?

Your life is going to be much easier if you have a div of class "userpanel" class with a child span of class "fullname" (as has been said, describe the content, not the style).

Also, what if you want to write some Javascript to select all items of a given type and attach on event to onClick? This is going to read very badly if your only method of selection is "div.centered bluetext a.underlined".

CSS, as it is, is not well-designed to be DRY. If you want to stop repeating your code everywhere, look into abstraction layers on top of CSS, such as SASS or LessCSS, instead of butchering the idea behind a stylesheet.


答:
It is encouraged but you should not go overboard, use them sparringly. Also, David Dorward's comment is right on the point I think. Use them to describe the element, not the formatting they contain.

The problem is that it can quickly become confusing as to why one of your element is displayed one way and not the other. I always used multiple classes very carefully, the most commonly used one I even remember:

```<code>.mandatory { color: darkred; font-weight: bold }
</code>```

I think this one makes sense, because you are effectively describing a "mandatory" behavior for an element, which could be a text, an input field, etc. and as such you want to avoid having a .mandatoryText, a .mandatoryInput, etc.

What I mean is: if you want to use multiple classes, choose them carefully, choose the ones that make sense.

Also, this is an entirely different topic, but I'm not sure that having four different font styles for a website would be in the best practices in that field (I'm not a "pure" web designer per se, so I may be wrong, see http://www.internetmarketingsecrets.com/web-fonts-guide/, paragraph "Readability Do’s and Don’ts")

Finally, if you are afraid about repeating yourself, don't worry you have "replace all" in your favorite text editor in case you need to replace that color you are using 56 times :-)

Edit: I too wish you cold make CSS classes inherit from other CSS classes :-)

Title: Is there a drawback in defining multiple small DRY classes, instead of bigger more repetitive classes?

Body:
I read some articles and it seems that using multiple classes in CSS is encouraged.
I am curious to find out if there is a maximum number of classes an element can have before this multiple class solution loses its benefits. (It may become a speed matter of some sort)

For example I have a project which uses 4 types of fonts, 4 types of font sizes, 4 type of font colours and so on. Is it better to divide these styles in very small classes and assign them to different classes or just try to handle the code on bigger chunks, in which case the style file will be obviously bigger and not DRY.

I believe that besides a little more work and the code becoming a little more difficult to follow there should not be any other major drawbacks. Am I right?

Body:
It is encouraged but you should not go overboard, use them sparringly. Also, David Dorward's comment is right on the point I think. Use them to describe the element, not the formatting they contain.

The problem is that it can quickly become confusing as to why one of your element is displayed one way and not the other. I always used multiple classes very carefully, the most commonly used one I even remember:

.mandatory { color: darkred; font-weight: bold }

I think this one makes sense, because you are effectively describing a "mandatory" behavior for an element, which could be a text, an input field, etc. and as such you want to avoid having a .mandatoryText, a .mandatoryInput, etc.

What I mean is: if you want to use multiple classes, choose them carefully, choose the ones that make sense.

Also, this is an entirely different topic, but I'm not sure that having four different font styles for a website would be in the best practices in that field (I'm not a "pure" web designer per se, so I may be wrong, see http://www.internetmarketingsecrets.com/web-fonts-guide/, paragraph "Readability Do’s and Don’ts")

Finally, if you are afraid about repeating yourself, don't worry you have "replace all" in your favorite text editor in case you need to replace that color you are using 56 times :-)

Edit: I too wish you cold make CSS classes inherit from other CSS classes :-)


问:
Why is Python used for high-performance/scientific computing (but Ruby isn't)?
There's a quote from a PyCon 2011 talk that goes:

At least in our shop (Argonne National Laboratory) we have three
  accepted languages for scientific computing. In this order they are
  C/C++, Fortran in all its dialects, and Python. You’ll notice the
  absolute and total lack of Ruby, Perl, Java.

It was in the more general context of high-performance computing. Granted the quote is only from one shop, but another question about languages for HPC, also lists Python as one to learn (and not Ruby).

Now, I can understand C/C++ and Fortran being used in that problem-space (and Perl/Java not being used). But I'm surprised that there would be a major difference in Python and Ruby use for HPC, given that they are fairly similar. (Note - I'm a fan of Python, but have nothing against Ruby).

Is there some specific reason why the one language took off? Is it about the libraries available? Some specific language features? The community? Or maybe just historical contigency, and it could have gone the other way?

答:
At a guess, a large part of it would be the reliance on matlab by lots of researchers. Python has alternatives, such as sage. Whereas ruby does not, or at least there is no obvious ones.

Secondly, according to the Ruby FAQ, python is both procedural and object oriented, whereas ruby masquerades as a procedural language. If you are writing a small script for math purposes, like what you'd do in matlab, the OO paradigm is a headache. Not only that, but it forces a conceptual jump away from the functional/procedural paradigms that researchers use. Math is not OO. Math is functional, followed by procedural (think logic proofs).

Finally, note that the Ruby FAQ states that ruby is more complex than python. Programming comes second to researchers, not first like us.


问:
What are the restrictions on derived works of EPL licensed software?
I am contemplating paying a software consulting firm to provide my company with some enhancements to a piece of software that is licensed under the Eclipse Public License (EPL).  I'm wondering what rights we will have to what they produce, and whether they can tie us to paying them royalties forever.

What rights we will have to modify and redistribute what they provide us?

Can they insist on a royalty payment when we distribute it to 3rd parties?

Before I start negotiating, I need to understand what we're getting - and ideally get this sort of thing explicitly agreed in the contract.

I know I should consult a lawyer.

答:
I'm glad that you are aware that you need to consult a lawyer, because you do. The way language is read in the law is not always the same it is read elsewhere.

From the looks of the EPL you should have all rights to modify and redistribute what they provide you, and they have no right to a royalty payment. Section 2(a) of the EPL states:

Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.

However, Section 4 looks like it puts a responsibility on you to potentially have to defend anyone involved in the software that my get sued as a result of their work on the software.

Now you might run into trouble if what the other party is contributing to your software is governed by a separate licensing agreement. Section 1(b)(ii) states:

where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.

So if they are acting on your behalf, which it sounds like, and they are not giving you something that is a separate module of software distributed in conjunction with the program under its own licensing agreement, you should be good.

Again, to be 100% sure you need to consult with an attorney, as there are all sorts of likely exceptions to the EPL, or other open-source type licenses, that you must be aware to fully understand your liabilities and rights.


问:
How to develop line-of-business tablet apps as a .NET developer?
My company has a lot of experience in .NET development, and one of our products in an ERP system. Recently, a customer asked us if we could provide a tablet interface to that system, i.e., a software that allows the customer to view product information and create orders on a tablet.

Of course, we are not thrilled about the idea of investing a lot of time and money into learning Objective-C, purchasing Mac development workstations, paying fees to Apple, etc. just for this one project (we might be able to sell the app to a few additional customers afterwards, but the market is very small, since it would only be useful for existing customers of our ERP system).

So, what should we do? As far as I can see, we have the following options:

Write a "plain old Windows application" (WPF) and run it on a Windows 7 tablet, such as the Samsung Slate or Acer Iconia.

Drawbacks: Heavy, expensive devices with short running time (as compared to "real" tablets).

Wait for Windows 8 ARM-based tablets and write a Metro (WinRT) app.

Drawbacks: Wait for at least one year; it's unclear whether Windows 8 ARM will support installation of custom B2B apps without going through the app store.

Use mono for Android and write a .NET app for Android.

Drawbacks: Yet another UI library (different from WPF and Silverlight); some providers disallow sideloading of apps.

So far, options 1 and 3 seem to be the most realistic. Did I miss any obvious drawbacks or advantages? Is there another option that I haven't considered yet? Have you been in a similar situation and (successfully) chosen one particular option?

答:
view product information and create orders

Sounds like stuff well within the capability of HTML 5 (and the related technologies usually mentioned in the same breath). Write a rich Web application, and you immediately support any device with a browser.


问:
What can slow a developer down?
What things tend to slow a developer down?

Please try to refrain from posting answers that:

are slow now but useful in the feature. (TDD, Refactoring, ...)

list a distraction.

答:
Poor code.

Having to rewrite the part of someone else who could have done the job right in the first place is the biggest time sink I can imagine.

Title: What can slow a developer down?


答: I'd recommend developing it as a MVC web app. This would allow you to run it on most any device from a desktop to a smartphone provided you design it well. HTML5 might work but it will depend on the types of devices/browsers you'll need to support. It would be nice if you can get away with using it. Make sure that you architect it where you could adapt portions of it to be a WCF backend to a Metro app in the future.</p>

Title: How to develop line-of-business tablet apps as a .NET developer?

Body:
My company has a lot of experience in .NET development, and one of our products in an ERP system. Recently, a customer asked us if we could provide a tablet interface to that system, i.e., a software that allows the customer to view product information and create orders on a tablet.

Of course, we are not thrilled about the idea of investing a lot of time and money into learning Objective-C, purchasing Mac development workstations, paying fees to Apple, etc. just for this one project (we might be able to sell the app to a few additional customers afterwards, but the market is very small, since it would only be useful for existing customers of our ERP system).

So, what should we do? As far as I can see, we have the following options:

Write a "plain old Windows application" (WPF) and run it on a Windows 7 tablet, such as the Samsung Slate or Acer Iconia.

Drawbacks: Heavy, expensive devices with short running time (as compared to "real" tablets).

Wait for Windows 8 ARM-based tablets and write a Metro (WinRT) app.

Drawbacks: Wait for at least one year; it's unclear whether Windows 8 ARM will support installation of custom B2B apps without going through the app store.

Use mono for Android and write a .NET app for Android.

Drawbacks: Yet another UI library (different from WPF and Silverlight); some providers disallow sideloading of apps.

So far, options 1 and 3 seem to be the most realistic. Did I miss any obvious drawbacks or advantages? Is there another option that I haven't considered yet? Have you been in a similar situation and (successfully) chosen one particular option?


答:
If you want to leverage the existing .NET knowledge, you should go for a SOA approach, and put as much functionality as possible into a web service (SOAP or REST, pick whichever suits you better).
That way you only need a small client app on the device, which would only call the web service functionality and display the results.
This should be much easier to develop than a full blown client which implements business logic, no matter which client you choose.

It also allows for adding support for different devices later on, all you need is a small client app for the new device.

In order to pick a device, I see two criteria:

Pick the one your current customer favours (if they ask for a tablet app, they will have given some thought to it)

Pick the one that is most likely to be accepted by other customers as well. This could very well be the iPad, or perhaps the Kindle Fire, because people have already seen those.

In any case, don't wait for devices that are not on the market yet. That would rule out your option 2 (Windows 8 on ARM tablets).


问:
Help needed with class design and structure
This question is mostly about the best way to approach this problem. Any input is appreciated.

The Problem

In my application i need to send some data to a number of different destinations (we will call them receivers from now on) using different protocols (http post, ftp, soap services). Each of the different receivers respond differently and some processing needs to be done on each response to work out what happened. This response processing can become quite complex.

My application also needs to do take different actions based on the receiver.

My Solution

My plan is to create a separate class for each receiver that implements an interface and use Factory design pattern to decide which class to load based on the receiver. Each receiver has a unique name (which is stored in the database for other reasons) which i plan to use to decide which receiver to load. I'll pass this to the factory constructor.

Currently i plan to have my interface implement these methods

prepareData()

sendData()

handleResult()

I'd also like a wrapper for these function such as process() which would just return a boolean based on wether the send sent. I'm not sure where i would fit this in though.

Thanks

答:
If you're thinking that your interface needs to do three different things (prepare, send, and handle), think some more about cohesion.

That is, you need something that knows how to prepare data differently for different receivers.  This is a task in and of itself--so separate it from the other tasks into a series of items implementing an DataFactory interface (a la Factory Method pattern).

Again, the method for sending the data varies, encapsulate that into DataTransport classes (Strategy pattern?) Along the same lines, ResultHandler classes to handle each type of the result.

This way each class does exactly one thing, and can be tested and adjusted in its own right, without affecting anything else.

Think about it any way.


问:
Are code reviews necessary for junior developers?
I've worked at two companies, who each had a different methodology when it came to code reviews:

In the first company, a code review was conducted by the team leaders and was required after the completion of every module.

However, in the second company, team leaders weren't required to conduct any code reviews, and just checked for functionality and design issues.

So I am confused. Is the code review process really needed? If it is, why? And if it isn't, why not?

答:
Code review is a good way of spreading knowlege and good practice through a team. In my experience it is a good idea to make sure all code gets reviewed, and try to vary who reviews what code.

In my current team everyones' code is reviewed equally, and both programmer and reviewer have to be satisifed with the code before it can be released. This applies just as much to senior developers being reviewed by more junior developers, a junior developer reviewing another, or other senior developers reviewing each other. If the reviewer is inexperienced or does not feel comfortable reviewing any particular piece of code then they will team up with another developer (and maybe also the original developer) to do the review as a group.


答:
JQuery Mobile + Phone Gap Build.

This is basically saying "use HTML5 and JavaScript to build your app", as has been said before, but with an important twist.

Nitobi's Phone Gap Build service (now owned by Adobe) allows developers to convert HTML5/JavaScript apps to "native" apps (really hybrid apps) that can be deployed locally to a device. It's my understanding that basically what's happening under the hood is packaging a small native binary that calls the native browser and loads up your site from a file:// URL.

You don't need to target any specific JavaScript framework - the same HTML & JavaScript that would work really well in a mobile web app will work fine.

Offline support isn't hard, either. With local browser storage well supported with many mobile devices you can build truly powerful offline apps this way. Its best practice to package your external dependencies locally as opposed to using a CDN, so that your app works well offline.

Frameworks like KnockoutJS and BackboneJS are very helpful at allowing you to build well engineered JavaScript apps, and they work just fine with Phone Gap's build service.

When the device is online, you can easily have it hit ASP.NET/MVC, WebAPI or WCF service back ends to refresh data.

The resulting apps are really quite good, and can be distributed in the Apple and Android markets. There are already lots of apps in those marketplaces built with Phone Gap Build and other similar products, and 99% of people (including most devs) can't tell the difference.

Obviously you aren't going to try to build Angry Birds this way (though, with Canvas I suppose you might try), it works wonderfully well with the kinds of apps you are talking about.

Don't take my word for it. PhoneGap has been doing the rounds on the PodCast circuit, having recently been on Hanselminutes, DotNetRocks, and the Tablet Show. Also, I wrote about it in a recent blog post.


答:
I want to know if any database can do this for the programmer?

What you need is a database supporting triggers, almost any "serious" relational database supports this. Then you can write a stored procedure which does the needed calculations on any insert, delete and update to your payment table automatically. You will also need an additional table (for example, a payment_aggregates table), to hold calculation results. And if you want to do some aggregates for restricting criteria, you need to know the criteria beforehand. You will have to provide one record in your payment_aggregates table for each potential subset of payment defined by your criteria.

If you need this to be done in a more generalized way, you should have a look at the way how OLAP databases are designed. Those databases are optimized for allowing fast queries for aggregates on huge data sets.

Title: Do Databases Optimize Queries with Sum/Average or Other Aggregates?

Body:
Imagine a database that has billions of rows with, say, payments. You need to calculate an average payment sum. That will be

```<code>SELECT avg(amount) FROM payments;
</code>```

Now, if you need to re-calculate this figure every day, running this formula on the whole dataset is an overkill.

Bicycles have speedometers that calculate every second the average speed and the average cadence (pedal RPMs), even though they don't keep the speed for each second, and you may ride hours, days and months without resetting the average counter.

This is done in a simple way: the speedometer keeps the average value and the number of seconds. So when you add a new item to the sum, it just does this:

```<code>new_average = (current_speed + old_average * count) / (count + 1)
</code>```

If you know maths, it's clear that any sum or product can be calculated incremententially. Even updates can be done the same way: substract the old value from the aggregate, add the new value.

I want to know if any database can do this for the programmer?

I understand that the query in the DB may be different and have criteria:

```<code>SELECT avg(amount) FROM payments WHERE condition_1 AND condition_2;
</code>```

Yet, it is possible to cache averages with more information (what rows were in the sequence and what was the filtering condition).

Is this done anywhere?


问:
How to measure external quality of software
For my thesis, I am doing research into the characteristics of Behavior Driven Development (BDD). One of the BDD claims is that by specifying the requirements in a ubiquitous language together with the customer, the software will score better on the external quality. Another claim of BDD is that it produces clean code with a high code coverage.

In my experiment, I will perform a software project both in BDD and traditional style, so that in the end I have two end products. The second claim of BDD is easy verifiable, by checking the code against some quality metrics, like Lines of Code, Cyclomatic Complexity and Code Coverage. However, I cannot think of a good measurement for the first claim. Is there anybody out here who has done this already? Or maybe can propose an alternative experiment that can validate this claim?

答:
So, based on the proposed literature I have seen that various studies use Acceptance Tests to measure the external quality of a software product. Although this is not conclusive for measuring the external quality, it does give a precise indication of the amount of satisfied requirements by the product.

The next problem in my research is the shortage of available BDD products that can be measured. That is also one of the main reasons why I've chosen to set up this experiment on a synthetic base.


问:
Which applications have driven the mass spread of floating point units?
Floating point units are standard on CPUs today, and even desktops might use them today (3D effects). However, I wonder which applications have initially driven the development and mass adoption of floating point units in history.

Ten years ago, I think most uses of floating point arithmetics constituted in either

Engineering and Science applications

3D graphics in computer games

I think for any application where decimal numbers might have appeared at those times, fixed point arithmetic has been sufficient (2D graphics) or even desirable (finance). Usage of integers would have been sufficient then.

I think these two applications have been the major motivation to establish floating point arithmetic in hardware as a standard. Can you name others, or is there a compelling reason to disagree?

答:
I can go back even farther than 1990.  Oil and gas exploration companies used whatever minicomputers existed in the 1960's, plus the IBM 360 when it came out, to perform geophysical calculations.

The Electronic Numerical Integrator And Computer (ENIAC), developed in 1946, was used mainly to calculate artillery firing tables.

In 1822, Charles Babbage designed a difference engine.  A difference engine is an automatic, mechanical calculator designed to tabulate polynomial functions.  The London Science Museum constructed a working difference engine from 1989 to 1991.

The need for floating point calculations has been with us since the dawn of computing.


答:
I'll expand on my comment.

I think there are a few factors that influenced the use of Python in scientific computing, though I don't think there are any definitive historical points where you could say, "Yes, that is the reason why Python is used over Ruby/anything else"

Early History

Python and Ruby are of roughly the same age - according to Wikipedia, Python was officially first released in 1991, and Ruby in 1995.

However, Python came to prominence earlier than Ruby did, as Google was already using Python and looking for Python developers at the turn of the millenium. Since it's not like we have a curated history of uses of programming languages and their influences on people who use them, I will theorize that this early adoption of Python by Google was a big motivator for people looking to expand beyond just using Matlab, C++, Fortran, Stata, Mathematica, etc.

Namely, I mean that Google was using Python in a system where they had thousands of machines (think parallelization and scale) and constantly processing many millions of data points (again, scale).

Event Confluence

Scientific computing used to be done on specialty machines like SGIs and Crays (remember them?), and of course FORTRAN was (and still is) widely used due to its relative simplicity and because it could be optimized more easily.

In the last decade or so, commodity hardware (meaning stuff you or I can afford without being millionaires) have taken over in the scientific and massive computing realm. Look at the current top 500 rankings - many of the top ranked 'super computers' in the world are built with normal Intel/AMD hardware.

Python came in at a good time since, again, Google was promoting Python, and Google was using commodity hardware, and they had thousands of machines.

Plus if you dig into some old scientific computing articles, they started to spring up around the 2000-era.

Earlier Support

Here's an article written for the Astronomical Data Analysis Software and Systems, written in 2000, suggesting Python as a language for scientific computing.

The article has this quote about Python:

Python is an interpreted object-oriented programming language that is starting to receive considerable attention in scientific applications (Python, 1999). This is because Python, and scripting languages in general, represent a next logical step for many scientific projects (Dubois 1994). First, Python provides an interpreted programming language that can be viewed as an extension of the simple command languages already used by scientific programs

Second, Python is easily integrated with software written in other languages. As a result, it can serve as both a control language for driving existing programs as well as a glue language for combining different systems together. Finally, Python provides a large collection of third party modules, an established user base, and a variety of documentation in the form of books and online references. For this reason, one might view it as a highly polished and expanded version of what scientists often try to accomplish when writing their own command interpreters.

So you can see that Python had already had traction dating back to the late 90s, due to it being functionally similar to the existing systems at the time, and because it was easy to integrate Python with things like C and the existing programs. Based on the contents of the article, Python was already in scientific use dating back to the 1995-1996 timeframe.

Difference in Popularity Growth

Ruby's popularity exploded alongside the rise of Ruby On Rails, which first came out in 2004. I was in college when I first really heard the buzz about Ruby, and that was around 2005-2006. django for Python was released around the same time frame (July 2005 according to Wiki), but the focus of the Ruby community seemed very heavily centered on promoting its usage in web applications.

Python, on the other hand, already had libraries that fit scientific computing:

NumPy - NumPy officially started in 2005, but the two libraries it was built on were released earlier: Numeric (1995), and Numarray (2001?)

BioPython - biological computing library for python, dates back to 2001, at least

SAGE - Math package with first public release in early 2005

And many more, though I don't know many of their time lines (aside from just browsing their download sites), but Python also has SciPy (built on NumPy, released in 2006), had bindings with R (the statistics language) in the early 2000s, got MatPlotLib, and also got a really powerful shell environment in ipython.

ipython was first released in the early 2000s, and has had many features added to it that make it very nice for scientific computing, like integrated matplotlib graphing and being able to manage computational clusters.

From above article:

It is also worth noting a number other Python related scientific computing projects. The numeric Python extension adds fast array and matrix manipulation to Python (Dubois 1996), MMTK is Python-based toolkit for molecular modeling (Hinsen 1999), the Biopython project is developing Python-based tools for life-science research (Biopython 1999), and the Visualization Toolkit (VTK) is an advanced visualization package with Python bindings (VTK, 1999). In addition, ongoing projects in the Python community are developing extensions for image processing and plotting. Finally, work presented in (Greenfield, 2000) describes the use of Python in projects at the STScI.

Good list of scientific and numeric packages for Python.

So a lot of it is probably due to the early history, and the relative obscurity of Ruby until the 2000s, whereas Python had gained traction thanks to Google's evangelism.

So if you were evaluating scripting languages in the period from 1995 - 2000, what were you really looking at? There was Perl, which was probably different enough syntactically that people didn't want to use it, and then there was Python, which had a clearer syntax and better readability.

And yes, there is probably a lot of self-reinforcement - Python already has all these great, useful libraries for scientific computing, while Ruby has a minority voice advocating its use in science, and there are some libraries sprouting up, like SciRuby, but Python's tools have matured over the last decade.

Ruby's community at large seems to be much more heavily interested in furthering Ruby as a web language, as that's what really made it well known, whereas Python started off on a different path, and later on became widely used as a web language.

Title: Why is Python used for high-performance/scientific computing (but Ruby isn't)?

Body:
There's a quote from a PyCon 2011 talk that goes:

At least in our shop (Argonne National Laboratory) we have three
  accepted languages for scientific computing. In this order they are
  C/C++, Fortran in all its dialects, and Python. You’ll notice the
  absolute and total lack of Ruby, Perl, Java.

It was in the more general context of high-performance computing. Granted the quote is only from one shop, but another question about languages for HPC, also lists Python as one to learn (and not Ruby).

Now, I can understand C/C++ and Fortran being used in that problem-space (and Perl/Java not being used). But I'm surprised that there would be a major difference in Python and Ruby use for HPC, given that they are fairly similar. (Note - I'm a fan of Python, but have nothing against Ruby).

Is there some specific reason why the one language took off? Is it about the libraries available? Some specific language features? The community? Or maybe just historical contigency, and it could have gone the other way?


答: I think the real driver was silicon processes.  Once circuits were shrunk small enough that there was room for floating-point units, they were incorporated.  Same for MMUs and memory controllers.  Engineers abhor empty die space.</p>

Title: Which applications have driven the mass spread of floating point units?

Body:
Floating point units are standard on CPUs today, and even desktops might use them today (3D effects). However, I wonder which applications have initially driven the development and mass adoption of floating point units in history.

Ten years ago, I think most uses of floating point arithmetics constituted in either

Engineering and Science applications

3D graphics in computer games

I think for any application where decimal numbers might have appeared at those times, fixed point arithmetic has been sufficient (2D graphics) or even desirable (finance). Usage of integers would have been sufficient then.

I think these two applications have been the major motivation to establish floating point arithmetic in hardware as a standard. Can you name others, or is there a compelling reason to disagree?


问:
How serious is losing the source code?
If a software company loses the source code to one of the products they are selling, how serious would that be, in terms you could explain to a layman?  Would the term "gross negligence" be too strong?  Or "gross incompetence"?  Obviously no one got killed but isn't it as serious as some financial negligence that people get jail time for?

EDIT:
Let's say it's not a case of a disk drive crashing, natural disaster or anything like that.  Just they misplaced it.

答:
I think apart from the option of decompiling the code, this would be a pretty big issue assuming the company intended to continue to market the software product.  If it was an in-house application the same would be true to a lesser degree.

If you can not restore the source code then maintence (bug fixing) and enhancements can not be performed so the application is now static.  If Microsoft or Apple or Apache or whoever your operating platform is changes or upgrades their code then your old compiled code may not work and you can not fix it.   If you are selling this application to external clients you can not control when they will upgrade their Windows, MAC OSX, iPhone, Web Browser so you have a pretty big risk here to your company's reputation and possibly legal risk also if you have a maintenance contract with the clients.

Secondly the source code represents an asset for the company.  So for a software company it is an asset on the books.  It is something you can sell as a product or sell the source code and all rights to another software company.  I would not continue to sell a software product to clients I knew I could not maintain as I have lost the source code.  Further I doubt another software company would buy the application and all rights if they could not further develop the product.  So the asset value of this application must be reduced.

For an internal in-house application you may have more control over the operating platform for your application but I would still look to replace this application if the source code can not be decompiled into a useable code base for maintenance.

Cheers,

Kevin

PS I hope this is only a theoretical question...:)

Title: How serious is losing the source code?


问:
Main class passes dbConn obj to all its services, I need to change the dbConn for one of its services. - suggestion for design pattern
There is this main class

and there are several services ( which uses db connection to retrieve data )

These services are initialized in the main class
db properties are obtained from the property file and then

dbconnection is opened by calling a method dbOpen() written in the main class
and the resultant connection object is set to the service objects by iterating through the list of services and by calling setConnection method on the service

note: that the services are instantiated in the main class and the main class is not a superclass for services.

I also need to mention that there is this recycle db connection scenario only main class is aware of.

```<code>/** connects to DB, optionally recycling existing connection),
     * throws RuntimeException if unable to connect */
    private void connectDb(boolean recycle) {
        try {
            if (recycle) {
                log.status( log.getSB().append("Recycling DB Connection") );
                closeDb();
            }
            openDb();
            for ( int i = 0 ; i < service.length ; i++ )
            {
                service[i].setConnection(db);
            }
        }
</code>```

One of the service needs to use a different database, what is the best design pattern to use?

答: What if the service classes had some kind of attribute indicating the type of connection they needed, and the main class examined that attribute and passed the requested connection to the service?</p>


问:
UserControl inside Placeholder good/bad? + Postback problem
Currently I'm working a bit with ASP.NET and trying to find the best way to navigate through pages. Right now I have an UpdatePanel which has a Placeholder inside it. This Placeholder will then add the usercontrol I need.

I've been looking around on the internet and some say that this is a really bad thing to do, while others use it without trouble. Is this whole UserControl inside Placeholder inside updatepanel good/bad?

While I've been trying to implement this I run into a problem with postback.
When I click a button on my "Main page" to add a new UserControl to the Placeholder, the Page. IsPostback is of course the same on the UserControl and therefore it will always be true here.

Am I doing something wrong or do I need to use a session variable to keep my UserControlPostback perhaps?

I'm open to all options, just need to find the preferred way.

答:
I think you need to take a step back and say "Are UpdatePanels the spawn of Satan?".

But seriously, the way you're outlining does have some fairly bad side-effects (although it's a possible strategy to go about working with dynamic content in ASP.net WebForms and I have taken a similar approach myself).

The first side-effect you'll have is that dynamically added content does not persist after a postback, so you'll have to re-add your UserControl to the Placeholder at Page_Init if you want to handle any posted form data. This can cause issues if you've got no way of telling which UserControl you added to the placeholder, but I've implemented such a solution before without this being too much of problem.

The second side-effect is the huge amount of ViewState you're going to collect as your UpdatePanels go about their business. ViewState is fairly evil, and when you're posting it to and from the server with every request, combined with it being very large, it can provide some severe speed issues from a user-perspective. I'd suggest if you do want to go down this route you should try to disable ViewState for any controls you do not expect to retrieve data from at a later date.

The other issue I can think of off the top of my head is the replication of page state. When you get a defect report from a tester (or user), with the dynamic UpdatePanel approach you will have to log a number of steps to replicate the state the system is at. If you approach from a URL-driven page load perspective, where each URL (with query string data) represents a page state the amount of time you'll need to take to track down an issue will be (hopefully) cut down to the amount of time it takes you to copy a URL and paste it into your browser navigation bar. I personally think this is the most compelling argument for trying to avoid a stateful approach web events whenever possible.

In my opinion you'd be best off optimising your page load times to avoid the issue of doing full postbacks taking too long, then looking at using AJAX functionality and JavaScript templating to handle client-side requests. Sure, it's a lot closer to the metal so you'll have to write more code, but abstractions like UpdatePanels often have only a few use cases where they're beneficial, with the UpdatePanel's particular use case being "Get it out the door fast, don't make it fast".


问:
Is it reasonable to run processes with CI tools?
At my company, we have a quagmire of disparate cron jobs (on multiple systems) and manually kicked off processes which keep our business functioning that is a result of years of expedient development and subsequent neglect.

Someday, we will need to come up with a more centralized solution for obvious reasons.

One thought that we have been kicking around is to use our Continuous Integration software (Jenkins) to run these processes, which seems logical.

My question is: Are other companies doing this? Is this a generally accepted practice? Doesn't this conflict with the definition of a CI tool implicit in its name? Are there any other options?

Note:
https://wiki.jenkins-ci.org/display/JENKINS/Meet+Jenkins

Jenkins claims that it focuses on "Monitoring executions of externally-run jobs, such as cron jobs and procmail jobs". I'm not sure if this is exactly what I am talking about.

答:
In large enterprise systems that I worked with, they tend to use a tool designed for scheduling.  The most popular one I have used is CA7.  It allows you to centralize all the scheduling for all your systems.

Cron is generally used for the single machine, though you can "hack it" by doing ssh remote calls.  However, it won't have the concept of dependencies and other stuff.  When it comes to operations teams where their scope is even more limited, it's best that a tool is used.


问:
DCVS and Bug Database
I am considering implementing the following policy and would like to run it by the community before implementing it:

All mercurial commits must have a bug id corresponding to our bug reporting database.

All commits immediately preceding a push for a new feature must have a bug id (it's a new feature but the id is still a "bug id" in the database)

This will do several things. First, it will ensure that an entry is always put into the bug database for all code changes. Second, it will provide a diff of each change made for each bug fix. This would also simplify commenting in the mercurial commits and put most details about the commit into the bug report.

Do you know of any reasons why this would be a bad idea? Also, do you think I should make some additions to this policy?

答:
The more obstacles you put in the way of me committing, the less often I'll commit.  That really defeats the point of a DVCS.

You're really trying to solve a symptom with this approach rather than trying to fix the root cause.  You have a team of developers who:

Don't understand the value of the bug tracker;

Don't seem to communicate very well, and repeat work that other developers have already done;

Veer off-task and write code that hasn't been discussed and hasn't been authorised.

You could enforce this policy.  However, if the developers are already dysfunctional, what is this policy really going to achieve?  Is it suddenly going to give you a focused, communicative team who maintain an excellent set of bug reports?

No.  It will give you an awful lot of bug fixes checked in against the wrong bug report.

You need to address the issues in your team by managing them.  Show them how they are stepping on each other's toes.  Hold daily standup meetings so that Bob can tell the team that he's fixing bug X so that Dave won't start work on the same thing.  Explain the value of the bug tracker.  If your developers come to see that what you're trying to achieve is a good thing they'll do it automatically.

Title: DCVS and Bug Database


问:
API access question
FIRST, THE SCENARIO

We have an internal system that is effectively split into 2 very separate parts across 2 sub-domains, our back-end administrative system for internal access only we will call this admin.example.com and our public-facing interface for customers via our website - lets call this www.example.com/customers

We have built a series of APIs with PHP in the back-end system for the public interface to access, the APIs are split into multiple files based around the type of activity that is being performed and are also used in the admin interface, these are held in admin.example.com/apis/activity_api.php we have no problems here.

We also have API keys that are in-use, 1 for the front-end and one for the back-end so we can determine access levels without thinking about it.

SECOND, THE ISSUE

Now you know the structure of the application here is the issue, we are using jQuery AJAX to call the APIs but I don't like placing the API keys here as they are publicly visible and anyone with a little programming knowledge will be able to pull a huge range of data, at the same time we need to use them.

Note that the issue is only in the public interface.

What I am thinking of doing is calling a connecting script in PHP with AJAX that is stored locally on our public facing server, this would do a few things

Check the referrer, if it comes from example.com/customers/ or www.example.com/customers/ it continues, if not the request is killed with an unauthorized error

Gets the variables posted by the AJAX requests

Restructures the variables for the API (e.g. receives $_GET['request'] then reconstructs as $_GET['req'])

Adds the API key that is held as a variable within the PHP to the string

Uses file_get_contents() to make the actual request to the API, this would in turn populate the connecting PHP script with the required returned API data to the site

My questions are

Have I missed anything in this concept?

Are there any flaws that haven't been thought about?

Are there any compelling reasons why this type of structure should not be used?

I appreciate the input!

WHAT I HAVE DONE

I really want to thank you guys for your help and comments on this, you have pointed out what I missed and that was the purpose of posting the question in the first place. You also helped me spot the obvious weaknesses.

I have just written an algorithm that has taken into account HMAC principles. As with anything in this space there is room for unauthorized access but I believe my algorithm minimizes it.

The basic process we're going with is as follows

2 keys have been created, a private and public key

The public key is hashed first

A base calculation is carried out on part of the current time stamp

2 random keys for the get request are generated that will be used to transport the access keys, to determine the request keys a mathematical calculation is carried out on the base calculation in step 3, the result is then split into 2 parts, the 2 parts are verified as unique and converted to the final values, 1 part belongs to the public access key and the other to the private access key key

9 unique public values, plus the private access key issued are then taken, they are re-ordered based on a final calculation on the base value in step 3 creating a "signature" so to speak

The signature is then hashed and assigned to the private get key generated in step 4

On a quick calculation and basic testing, each request will be valid for approximately 27 seconds (give or take a few milliseconds) - enough time to process everything needed but not enough for much more. As the calculations are fairly basic the server load hasn't gone up an inch - I have only tested with 10 connections per second for 5 minutes however, I am going to run a series of load tests on it over the next 24-hours that will range from 20 request per second to 400 requests per second and compare with load test results taken last week.

So what my new algorithm does in a nutshell is disguises the public and private keys by hashing both - however after time the public access key will be obvious unless I assign an algorithm to randomize it, it assigns both access keys random get request keys and has a short validity time based on the request. It doesn't need to store any data in cookies or sessions. In addition, with exception to the login API, all requests are going via a PHP connector that requires the user to be logged in.

I spent more time explaining what I'm doing than actually creating it!

Thanks again for your help guys, it helped me open my eyes a bit more and reminded me about what I had forgotten.

答: If I understand you correctly, you have a public API that you don't want to be usable by the public?  Referrer headers can be spoofed.  The best you're going to be able to do is issue temporary keys when the page is created that expire after a certain amount of time.  Even then, all they'd have to do is refresh the page to get a new key.</p>

Title: API access question


问:
Calculate Ellipse based on 4 points
I need to move an object based on 100 images rotating. The object needs to move in a path that is forming an ellipse when I'm rotating the image based on my gestures.

I have 4 points, 2 pairs of opposite points on X/Y axis, on the ellipse but how do I calculate the rest of the points in code-behind so that I can calculate the new X/Y Value of my next/previous point?

Currently I'm just rotating my object in a circle what is a start but not what I want at all...

答:
Rotation on an elliptical path means that you will want to calculate the Cartesian coordinates (x,y) while time(t) varies.  This is dead simple.  If P is the period of revolution:

```<code>x = a * cos(2 * pi * t / P)
y = b * sin(2 * pi * t / P)
</code>```

Sorry, no fancy mathematical typesetting.  [If someone can point me to a convenient way to do that, that would be great]

Title: Calculate Ellipse based on 4 points

Body:
Rotation on an elliptical path means that you will want to calculate the Cartesian coordinates (x,y) while time(t) varies.  This is dead simple.  If P is the period of revolution:

x = a * cos(2 * pi * t / P)
y = b * sin(2 * pi * t / P)

Sorry, no fancy mathematical typesetting.  [If someone can point me to a convenient way to do that, that would be great]


答:
We do this where I work (in theory).

It's genuinely really helpful when people do it right, as you can go into the cases in our particular bug-tracker-of-choice and see that you're getting the right changesets for a particular release based on the case IDs of the features you're adding. Your point about keeping the comments on the case is another plus, as in my experience no-one will read your commit messages.

However, it's a pain when people either put the wrong case ID on or just plain don't bother, so I'd say if you're going to do it make sure you have a staging repo where you're able to change the case ID before you push it into your trunk, and add a policy to the remote end to reject changesets without a case ID on them.

Title: DCVS and Bug Database

Body:
I am considering implementing the following policy and would like to run it by the community before implementing it:

All mercurial commits must have a bug id corresponding to our bug reporting database.

All commits immediately preceding a push for a new feature must have a bug id (it's a new feature but the id is still a "bug id" in the database)

This will do several things. First, it will ensure that an entry is always put into the bug database for all code changes. Second, it will provide a diff of each change made for each bug fix. This would also simplify commenting in the mercurial commits and put most details about the commit into the bug report.

Do you know of any reasons why this would be a bad idea? Also, do you think I should make some additions to this policy?


问:
How can I bootstrap a software development community at my school?
I'm a student at the University of South Florida who's frustrated with the educational environment in the Computer Science program. Right now, I'm taking "Program Design." I should be learning how to organize my source code into functions and modules in order to make my programs readable and maintainable; instead, I'm learning about arrays and recursion in C. Next semester, I have to take "Object-Oriented Design," which is taught through C++ (shudder.)

Two years ago, I fell in love with programming, and I've been learning as much as I could since then. The prospect of taking another C++ class bores me almost to tears. For that reason, I thought I would start a programming club in order to meet similarly ambitious students, learn new languages, discuss software development topics, and work with other students developers.

However, I'm beginning to realize that there may not be any other students who share my software development experience. It's not because of a lack of motivation but a lack of opportunity: I know of only one other programming class ("Programming Languages") and no classes on real-world software development. Everybody else only has experience writing trivial scripts in C and C++.

I've realized that if I want to work with other student software developers, I'm going to have to train them myself. Now, I'm planning to make the club a software development bootcamp, teaching members how to develop software with modern tools and languages. Obviously, starting an unofficial software development course is a monumental task with many possible approaches. My question to you, dear reader, is

What's my plan of attack?

Should I

lecture the club myself, trying to balance club work with homework?

ask the CS faculty to teach on topics within their expertise which may be less than relevant to members?

try to find a sympathetic, experienced developer inside or outside the school who can share my workload?

show video lectures (from MIT OpenCourseWare, Google Tech Talks, etc)?

hold hands-on programming workshops?

assign homework?

do something else?

答:
Looking at the course flowchart for your major, you really are misunderstanding what to expect in different classes of a Computer Science major.

The classes that you're talking about are introductory classes that introduced students to various basic concepts in coding. It looks like "Programming Concepts"  an intro to the profession with 1-week overviews of all of the basic areas of computer science, with no actual coding. From there, it's NORMAL to have an introductory course in C, and another introductory course in C++ is NORMAL for a Computer Science major. You may be coming into the program with some coding experience, but most people are not. The program has to teach concepts like recursion, and how to write classes, and operator overloading, and templates and all that stuff (not to mention teaching about variables, for-loops, if-statements, etc...), so there are two classes basically designed to teach you how to code in some programming language. And they usually have the kinds of misleading names that your university's classes do. Classes that teach the level of organization you want are usually named "Software Engineering" or "Design Patterns". The former is typically a requirement, and the latter is typically an elective (maybe at the graduate level), but both may be electives.

There's an academic and industry debate about whether the Computer Science curriculum focuses on software organization as much as it should, whether the major should be reorganized, and whether Computer Science and Software Engineering are different majors, but for now, your Computer Science program is NORMAL.

(And hang in there -- in another semester or two, you will get to more challenging classes that teach you things you haven't already taught yourself.)


答:
Karl is correct, though you can do a bit more around the edges:

You can have both parts of the application tie the temporary key to a user with limited rights and always verify those rights.  Never trust the client of an API not to cheat.  You must think of both sets of APIs as public if there is any way for the public to get to them.

If you feel the need to say:

I don't like placing the API keys here as they are publicly visible and anyone with a little programming knowledge will be able to pull a huge range of data.

then I think you've answered your third question already.

Title: API access question

Body:
FIRST, THE SCENARIO

We have an internal system that is effectively split into 2 very separate parts across 2 sub-domains, our back-end administrative system for internal access only we will call this admin.example.com and our public-facing interface for customers via our website - lets call this www.example.com/customers

We have built a series of APIs with PHP in the back-end system for the public interface to access, the APIs are split into multiple files based around the type of activity that is being performed and are also used in the admin interface, these are held in admin.example.com/apis/activity_api.php we have no problems here.

We also have API keys that are in-use, 1 for the front-end and one for the back-end so we can determine access levels without thinking about it.

SECOND, THE ISSUE

Now you know the structure of the application here is the issue, we are using jQuery AJAX to call the APIs but I don't like placing the API keys here as they are publicly visible and anyone with a little programming knowledge will be able to pull a huge range of data, at the same time we need to use them.

Note that the issue is only in the public interface.

What I am thinking of doing is calling a connecting script in PHP with AJAX that is stored locally on our public facing server, this would do a few things

Check the referrer, if it comes from example.com/customers/ or www.example.com/customers/ it continues, if not the request is killed with an unauthorized error

Gets the variables posted by the AJAX requests

Restructures the variables for the API (e.g. receives $_GET['request'] then reconstructs as $_GET['req'])

Adds the API key that is held as a variable within the PHP to the string

Uses file_get_contents() to make the actual request to the API, this would in turn populate the connecting PHP script with the required returned API data to the site

My questions are

Have I missed anything in this concept?

Are there any flaws that haven't been thought about?

Are there any compelling reasons why this type of structure should not be used?

I appreciate the input!

WHAT I HAVE DONE

I really want to thank you guys for your help and comments on this, you have pointed out what I missed and that was the purpose of posting the question in the first place. You also helped me spot the obvious weaknesses.

I have just written an algorithm that has taken into account HMAC principles. As with anything in this space there is room for unauthorized access but I believe my algorithm minimizes it.

The basic process we're going with is as follows

2 keys have been created, a private and public key

The public key is hashed first

A base calculation is carried out on part of the current time stamp

2 random keys for the get request are generated that will be used to transport the access keys, to determine the request keys a mathematical calculation is carried out on the base calculation in step 3, the result is then split into 2 parts, the 2 parts are verified as unique and converted to the final values, 1 part belongs to the public access key and the other to the private access key key

9 unique public values, plus the private access key issued are then taken, they are re-ordered based on a final calculation on the base value in step 3 creating a "signature" so to speak

The signature is then hashed and assigned to the private get key generated in step 4

On a quick calculation and basic testing, each request will be valid for approximately 27 seconds (give or take a few milliseconds) - enough time to process everything needed but not enough for much more. As the calculations are fairly basic the server load hasn't gone up an inch - I have only tested with 10 connections per second for 5 minutes however, I am going to run a series of load tests on it over the next 24-hours that will range from 20 request per second to 400 requests per second and compare with load test results taken last week.

So what my new algorithm does in a nutshell is disguises the public and private keys by hashing both - however after time the public access key will be obvious unless I assign an algorithm to randomize it, it assigns both access keys random get request keys and has a short validity time based on the request. It doesn't need to store any data in cookies or sessions. In addition, with exception to the login API, all requests are going via a PHP connector that requires the user to be logged in.

I spent more time explaining what I'm doing than actually creating it!

Thanks again for your help guys, it helped me open my eyes a bit more and reminded me about what I had forgotten.


答: You definitely do not want to enforce this policy on all commits.  One advantage of DVCS is that developers can commit and promote changes to private branches at any time.  It's a reasonable policy for commits to production code in the central repository.

Title: DCVS and Bug Database


问:
Display dynamic content from embedded web server
I have an embedded device running a slimmed down version of a HTTP server. Currently, it can display static HTML pages. Here is an example of how it displays a static HTML page:

```<code>char *text="HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"
"<html><body>Hello World!</body></html>";
IPWrite(socket, (uint8*)text, (int)strlen(text));
IPClose(socket);
</code>```

What I'd like to do is display dynamic content, e.g. a reading from a sensor. What I thought of so far is to have the page refresh every once in awhile with

```<code><meta http-equiv="refresh" content="600">
</code>```

and use sprintf() to attach the sensor reading to the text variable for the response.

Is there a way I can do this without having to refresh the page constantly?

答: You could theoretically implement WebSockets on your server. And have the server fire updates manually. Either that or use long polling. The tough part for you would be implementing either properly. But it could be done.</p>


问:
How important is it to pick the best IDE for your programming language of choice?
As I learned some basic programming languages I came across tens of IDEs, and tens of compilers. Most people you ask will tell you "Go with that IDE or go with the best" etc, however they do not provide a proper statement as to why this is important. I understand a good IDE will provide you with functionalities to save time and money, such as debugging or quick-word-fill, but I doubt that's the whole reason a programmer picks a good IDE.

At school we work on old compilers (Money probably isn't the reason) because the theory "As long as you learn it's good" works.

The bottom-line question is: How important is it to pick the best IDE for your programming language? YOu have Eclipse for Java, C++, Python and more, but can't you simply use a different one? What difference does a good IDE to your programming skills or your programming time?

答:
It's fairly subjective to say how 'important' the decision is, but consider this:

You will be investing a huge amount of time inside the IDE/editor. Small slowdowns caused by IDE problems quickly become large slowdowns over time. Additionally, you should not feel like the IDE is ever working against you as that takes the fun out of programming.

If you ever have the choice, pick the best IDE/editor/compiler you can.

At school we work on old compilers (Money probably isn't the reason) because the theory "As long as you learn it's good" works.

New compilers contain bug fixes and possibly new language features. You're learning more outdated information than those who use new compilers.

Finally, if you pick an editor like Emacs/Vim then you can use it for any language that arises and with blindingly fast speed.


问:
How to Mentor a Junior Developer
This title is a little broad but I may need to give a little background before I can ask my question properly.

I know that similar questions have been asked here already. But in my case I'm not asking if I should be mentoring someone or if the person is a good fit for being a software developer. That is not my place to judge. I have not been asked outright, but it is apparent that myself and other fellow senior developers are to mentor the new developers that start here. I have no problem with this whatsoever and, in many cases, it lends me a fresh perspective on things and I end up learning in the process. Also, I remember how beneficial it was in the beginning of my career when someone would take some time to teach me something.

When I say "new developer" they could be anywhere from fresh out of college to having a year or two of experience.

Recently we've had people start here who seem to have an attitude toward development/programming which is different from my own and hard for me to reconcile; they extract just enough information to get the task done but not really learn from it. I find myself going over and over the same issues with them. I understand that part of this could be a personality thing, but I feel it's my job to do my best and push them out of the nest while they're under my wing, so to speak.

How can I impart just enough information so that they will learn but not give so much as to solve the problem for them?

Or perhaps:

What's the proper response to questions that are designed to take the path of least resistance and, in essence, force them to learn instead of take the easy way out?

These questions are probably more general teaching questions and don't have that much to do specifically with software development.

Note: I do not get a say in what tasks they are working on. Management doles the task out and it could be anything from a very simple bug fix to starting an entire application by themselves. While this is not ideal by any means and obviously presents its own gauntlet of challenges, I feel it's a topic best left for another question. So the best I can do is help them with the problem at hand and try to help them break it down into simpler problems and also check their commit logs and point out mistakes that they made.

My main objectives are to:

Help them out and give them the tools they need to start becoming more self-reliant.

Steer them in the right direction and break bad development habits early on.

Lessen the amount of time I spend with them (the personality type described above tends to need much more one-on-one time and does not do well over IM or email. While that's generally fine, I can't always stop what I'm working on, break my stride, and help them debug an error on a moments notice; I have my own projects that need to get done).

答:
I have only ever had to train a junior programmer once. It was to help maintain a system I had built. The goal was to eventually hand the entire system off to him.

After a short period where he shadowed me, I threw him into the fire. I would assign cases to him, and expect them to be completed. If he had trouble, I would have him explain what the problem was, and where he had looked. I would then advise him in the most general terms, where to look next. (Which app, maybe which module to look at etc). I would never leave him floundering, but I also would never do any of the work. Only provide direction. If he still had trouble, I would just shrug my shoulders and say "Start tracing the code". And every time I said that, he would cringe - knowing he was in for a tedious exercise. It drove him nuts, because we both knew I could probably find the problem in 10 minutes if I would just get off my butt and help.

Years later, he has moved on to bigger things and now he's training his own juniors. And his favorite story is how I would always tell him to "trace the code", and how those code tracing exercises were crucial to making him the programmer that he is today.

Title: How to Mentor a Junior Developer


问:
What are the warning signs of impending doom to watch out for on a project?
Having worked on a failed project is one of the few things that most programmers have in common, regardless of language used, industry or experience.

These projects can be great learning experiences, soul-crushing disasters (or both!), and can occur for a multitude of reasons:

upper management change of heart

under-skilled / under-resourced team

emergence of superior competitor during dev cycle

over/under management

Once you've worked on a couple of such projects, is it possible to recognise at an early stage exactly when a project is doomed to fail?

For me, a big sign is having a hard & fast external deadline combined with feature creep. I've seen projects which were well planned out and proceeding right on schedule go horribly off the rails once the late feature requests started to roll in and get added to the final "deliverable". The proposers of these requests earned the nickname of Columbo, due to rarely leaving the room without asking for "just one more thing".

What are the warning signs you look out for that set off the alarm bells of impending doom in your head?

答:
I think it's generally easy to spot a failing project when the deadline is approaching.  Like you said, feature creep combined with a set-in-stone deadline is a sure way of killing a project.

The key however is to spot a failing project way in advance.  I think the only real 'sign of doom' in this case would be a complete lack of the definition of 'when are we finished'.  Unless we know this at the offset we're doomed for failure IMO.


答:
What difference does a good IDE to your programming skills or your programming time?

Potentially a lot. If you get to know the features and capabilities very well, you can greatly improve your productivity. But if you ignore the advanced features and treat it like a pretty text editor, then it will be a little better than using Notepad and a CLI compiler.

Of course, you should be able to learn to use ANY IDE efficiently. For me that mostly that involves becoming familiar with the most commonly used commands and learning their key-shortcuts (or making my own bindings if they don't exist). If the IDE has tools for refactoring and generating code, that can also improve your productivity if you can get the IDE to do repetitive tasks quicker than you could ever do on your own.

Not all IDEs are made equal though, and so you might find that no matter how good you get with one, it might never be as productive as another (for the same kind of work) because there are some features it simply doesn't have.

Title: How important is it to pick the best IDE for your programming language of choice?

Body:
As I learned some basic programming languages I came across tens of IDEs, and tens of compilers. Most people you ask will tell you "Go with that IDE or go with the best" etc, however they do not provide a proper statement as to why this is important. I understand a good IDE will provide you with functionalities to save time and money, such as debugging or quick-word-fill, but I doubt that's the whole reason a programmer picks a good IDE.

At school we work on old compilers (Money probably isn't the reason) because the theory "As long as you learn it's good" works.

The bottom-line question is: How important is it to pick the best IDE for your programming language? YOu have Eclipse for Java, C++, Python and more, but can't you simply use a different one? What difference does a good IDE to your programming skills or your programming time?


答:
Documenting all changes in form of tickets is, in common, good style

Direct links ticket-changesets is good

But

Some changeset may be indirectly related to issue (1-st CS - changes for ticket, 2-nd+ - fixes for CS 1)

Flat history with only commit-messages doesn't provide nice interface for filtering from VCS-side

Branch-per-feature workflow hide side-effects of 1 and 2 and make marking all changesets obsolete even from issue-tracker side - referenced maybe only first and last commit

Title: DCVS and Bug Database


答:
People do not look in bug databases to see code diffs for bugs.  They look in version control.  Therefore, it makes sense to require a bug id for the last commit that fixes a bug, so you can make a note in the bug tracker and identify what build bug fixes are in, but every single commit is overkill.

If people are committing features you don't want, you have a whole other problem, and probably need some sort of gatekeeper workflow.  I'd highly recommend you look into more integrated solutions like kiln or bitbucket.

Title: DCVS and Bug Database


答:
How important is it to pick the best IDE for your programming language?

In my personal opinion, it is very important. With a good code parser, it can greatly speed up programming. With auto-completion feature on, it means less typing and automatically it shows all possible methods (potentially learning something new).

With correctly setting the code formating, it makes simple to correctly indent the code, without worrying much about part of the coding standards.


问:
Why is C++ still "hybrid"
On a related question, it has been clarified why C++ is not compatible with C in many aspects. However C++ is still a "hybrid"* language. And unfortunately, many programmers still consider C++ as a "C with streams and built-in strings". That results in really bad written code, that it's neither C++ nor C. IMHO, it would be better if the language/compiler forced to some extent programmers to write more elegant code. So is there a rationale for keeping modern C++ (for instance C++0x and future versions) hybrid?

* By hybrid I mean that it's up to the programmer to decide if he/she will use: standard strings and streams, classes, namespaces other than the default, etc.

答:
IMHO, it would be better if the language/compiler forced to some
  extent programmers to write more elegant code.

No, it wouldn't. At all. As a trivial demonstration of why, define elegant, and then I bet that ten people will come on to disagree with you.

Language-enforced coding styles are really, really bad. Not to mention all the legacy code that will be broken.

Notably, the Standard string and stream classes actually suck. std::string has no Unicode support and the worst bloated interface you could possibly imagine. The streams have horrendous overhead and a poor design, even resorting to virtual inheritance, and function pointers, and const char* and uglies like that. I wouldn't penalize anyone for completely replacing both of those classes/class groups with custom ones.

Not using classes and namespaces is fine for whiteboard-style code, and there are many, many libraries which provide functions not in a class. Enforced-class is a really bad idea.

Title: Why is C++ still "hybrid"


答: Yes, there is a strong rationale: C++ code almost always has to call existing C code.  The best we can do is make it easy to write good code.  There is nothing a language designer can do to make it impossible to write bad code.  </p>

Title: Why is C++ still "hybrid"

Body:
On a related question, it has been clarified why C++ is not compatible with C in many aspects. However C++ is still a "hybrid"* language. And unfortunately, many programmers still consider C++ as a "C with streams and built-in strings". That results in really bad written code, that it's neither C++ nor C. IMHO, it would be better if the language/compiler forced to some extent programmers to write more elegant code. So is there a rationale for keeping modern C++ (for instance C++0x and future versions) hybrid?

* By hybrid I mean that it's up to the programmer to decide if he/she will use: standard strings and streams, classes, namespaces other than the default, etc.


答:
Your idea constitutes much of the design rationale behind Java.  Java forces you to use classes, organize file hierarchy according to package hierarchy, catch exceptions, etc.  People still manage to write C-like code in it.

As programmers, we sometimes forget the best solution may not be a technical one.  Peer reviews are the best known solution in this case.

Title: Why is C++ still "hybrid"