答:
If you are on linux, you should be able to set up a "cd device" that is just a named pipe. Your api writes to the "device" and you hook the other end up to a program that lets you see what it does/convert it to a disk image. Lots of options there. See this article  for info on named pipes.

Kevin's answer is far easier IMO.

Title: How to test software that burns CDs without wasting CDs?

Body:
I want to write an application that can be used to burn CDs (music). I know I should test it with real CDs anyway, but I don't want to do this every time I make a small change. But I do want to know and test if the right data will be burnt, so you don't get corrupted CDs.

I am using a library which only exposes APIs to directly burn to a physical drive; it doesn't allow you to write to a disk image (which would be much easier to test).

How could I test this without wasting CDs and time for every change/few changes I make?


问:
How to test software that burns CDs without wasting CDs?
I want to write an application that can be used to burn CDs (music). I know I should test it with real CDs anyway, but I don't want to do this every time I make a small change. But I do want to know and test if the right data will be burnt, so you don't get corrupted CDs.

I am using a library which only exposes APIs to directly burn to a physical drive; it doesn't allow you to write to a disk image (which would be much easier to test).

How could I test this without wasting CDs and time for every change/few changes I make?

答:
What testing are you exactly talking about?

Reading "I don't want to do this every time I make a small change" in your question, I imagine that you are talking about unit testing.

But later, you add that you're using an API which is in charge of burning data to CDs. If this API is tested and documented correctly, you don't have to deal with actual process of burning the data to the CD, and you don't have to test it. In this case, you deal with integration testing, that you don't have to do "every time [you] make a small change".

ContentLicense: CC BY-SA 3.0


问:
is there any relationship between a story point in two different projects?
Assume we have two projects and one or more teams (one team doing the projects in serial or two teams doing the projects in parallel). </p>

<p>If Team A decides that a task is 8 story points and Team B decides that a task on their project is also 8 story points, does that say anything about the relationship between the two tasks? Or is there no relationship between the complexity of the two tasks? </p>

答:
a story is sized by a Team against other stories from a pool (Product Backlog if you do Scrum).

So unless your 2 projects involve the same team and a common pool, the answer is a NO


答:
Write as many tests as you can that use a mock of the API of the library. This allows you to test your code in units. This shows that your code works within itself assuming that the library performs the way it is supposed to.

At some point, you will need to do integration testing that actually does use the library. But the point is that you already have a level of confidence with your own code before you get to the this point. Integration tests often take more time and resources, as you've seen. So thorough unit testing allows you to not rely completely on integration testing.


问:
Organising MVC App with virtual model using external API
I am creating a rails app with following constraints

It has no database

It uses a web API to store and retrieve the data

The connection to the web API is via a custom gem.

The Gem has a basic functionality to make a web API call based on the parameters given.

I have 2-3 different kinds of object that I can think of  ( or may be more precisely virtual model )

How should the structure of my program be ?

Should I incorporate all the method calls within the gem ?

Should I create models and put the api related calls  in there (then through the gem's basic method)

Should I just ignore the model and put everything in the controller . ?

The second method seems most appropriate , but then all the methods from model would be static and I would be calling all methods in essence without any objects.

答: If you don't have too many models and sure that would be the case going forward, then create a virtual model, or if it's other way around and if API support JSON, then use JSON library.It doesn't make sense to transform data if we are not going to do any post processing on object.</p>


问:
In .net, why can't values of intrinsic data types (such as DateTime) be null?
First the history:

I found out DateTime data types cannot be null (Yes they can be nullable using the ? nullable declaration).

I was told this is because they are value types and placed on the stack (not on the heap).

I can understand why the stack is quicker and why value types need to (mostly) be placed on the stack, what I do not know is.

Is it true the real limitation of why a value type cannot be null is because the stack cannot handle null values?

If yes - Why? If No what is the real limitation.

I understand in .net we often don't care about exact memory allocation, yet it is important in performance applications to take the stack and heap into consideration, so I'm trying to wrap my head around this.

Thanks in advance for your expertise on a difficult question.

EDIT: Another thing to add are nullable types hence placed on the heap or stack?

答:
I found out DateTime data types cannot be null.

Your questions show that you have a pretty vague idea about how the whole system works. Let's start by picking apart what you mean by "DateTime data types cannot be null". I think what you mean here is that the null literal cannot be implicitly converted to a value of DateTime, and hence the null literal cannot be assigned to a variable of type DateTime.

That is:

```<code>DateTime d = null;
</code>```

is not legal in C#. The null literal cannot be converted to DateTime, and so the initialization must fail at compile time.

I was told this is because they are value types...

That is almost correct.

There are two kinds of value types: nullable value types and non-nullable value types. A nullable value type always has an "underlying" type. The underlying type is always a non-nullable value type.

It is always legal to implicitly convert a null literal to a nullable value type.

It is almost always illegal to implicitly convert a null literal to a non-nullable value type; the only time this happens is if someone creates a user-defined conversion operator on the non-nullable value type, and that user-defined conversion operator takes an argument to which the null literal is implicitly convertible.

... and placed on the stack (not on the heap).

This is completely and utterly wrong. Whomever told you that does not know what they are talking about. This makes no sense whatsoever. Whether a null literal is convertible to a type or not at compile time has nothing whatsoever to do with where in memory the data is going to be stored at runtime.

I can understand why the stack is quicker and why value types need to (mostly) be placed on the stack

Then you are misunderstanding something. Values of value types need not be "mostly" placed on the stack.

Values of value type, and references to values of reference type, can sometimes be put on the short term allocation pool when it is known at compile time that the lifetimes of the storage for those values is going to be short. At runtime, that short term pool might be realized as stack locations or registers.

Whether data goes on the short term pool or the long term pool has nothing whatsoever to do with whether the data is a value of value type or a reference. They are not called the "value pool" and the "reference pool". They are the short term pool and the long term pool. Obviously which pool is used has only to do with the answer to the question "do we know ahead of time when we are going to be done using this value or reference?" If the answer is "yes", then the value or reference can go on the short term pool. If the answer is "no", then it has to go on the long term pool.

Is it true the real limitation of why a value type cannot be null is because the stack cannot handle null values?

No, absolutely not. That makes no sense.

What is the real limitation?

Let's look at an easier example than DateTime. Let's look at int. An int is four bytes, no more, no less. Suppose you have a variable of type int. It takes up four bytes. It might take up four bytes on the heap, four bytes on the stack, four bytes in a register -- doesn't matter. It is four bytes of storage, somewhere.

There are 232 possible values you can put into an integer: 0, 1, -1, 2, -2, ... and so on. When you say:

```<code>int x = null;
</code>```

what value do you suppose is going to go into those four bytes of storage?  There are only 232 possible values of four bytes, and they are already taken up by the numbers! You can't put six pigeons into five pigeonholes and still have only one pigeon in every pigeonhole. You can't put 232 + 1 values into 32 bits; you need at least 33 bits, and that's one more bit than we've got available.

Non-nullable value types cannot be null because there are exactly as many possible values of a value type as their bits are capable of holding. A distinct "null" value requires one more value than the maximum number the bits are capable of holding.

So how then do we do it with references? Simple; one of the references is reserved as "special"; the reference whose bits are all zero is set aside as never a valid reference. With ints we have a requirement that all 232 values be valid; with references implemented, say, as 32 bit pointers, we have no requirement whatsoever that all 232 possible pointers be valid; the vast majority of them are invalid.

Why don't we do that with value types? Because then:

```<code>int x = null;
</code>```

is exactly the same as

```<code>int x = 0;
</code>```

and it seems bogus to say that "null" just means "the zero of this type". Null should be a distinct value from every other value. (If you want to get the "zero" of a value type you can always say default(T) where T is the type. So int x = default(int); is the same as int x = 0;)

So how then do we do it with nullable value types? We add more bits. When you say:

```<code>int? x = null;
int? y = 123;
</code>```

that is exactly the same as saying:

```<code>int x = 0;
bool xHasValue = false;
int y = 123;
bool yHasValue = true;
</code>```

When you use a nullable value type, you are doing nothing more than passing around a non-nullable value type along with a flag that says whether it is null or not.

I understand in .net we often don't care about exact memory allocation, yet it is important in performance applications to take the stack and heap into consideration, so I'm trying to wrap my head around this.

That is important in some scenarios, yes. But it has nothing whatsoever to do with the question of why the null literal cannot be assigned to a non-nullable value type.

are nullable types hence placed on the heap or stack?

Values of nullable value types are placed wherever the compiler thinks best; they are not different from any other value of any other type.

If the compiler knows that a value will never be used again after a short period then the compiler generates code to place the value on the short-term storage. At runtime, this will be realized as a location on the stack or a register. If the compiler does not know that for sure then it generates code to place the value on the long-term storage heap.

Again, where the storage for a value is located has nothing whatsoever to do with the type of that value. It has only to do with the answer to the question "do I know for sure how long this value needs to hang around?" If the answer is "yes, and it is a short time", then the storage goes on the short-term pool. If the answer is "yes, and it is a long time" or "no, I don't know", then the storage goes on the long-term pool.

Body:
I found out DateTime data types cannot be null.

Your questions show that you have a pretty vague idea about how the whole system works. Let's start by picking apart what you mean by "DateTime data types cannot be null". I think what you mean here is that the null literal cannot be implicitly converted to a value of DateTime, and hence the null literal cannot be assigned to a variable of type DateTime.

That is:

DateTime d = null;

is not legal in C#. The null literal cannot be converted to DateTime, and so the initialization must fail at compile time.

I was told this is because they are value types...

That is almost correct.

There are two kinds of value types: nullable value types and non-nullable value types. A nullable value type always has an "underlying" type. The underlying type is always a non-nullable value type.

It is always legal to implicitly convert a null literal to a nullable value type.

It is almost always illegal to implicitly convert a null literal to a non-nullable value type; the only time this happens is if someone creates a user-defined conversion operator on the non-nullable value type, and that user-defined conversion operator takes an argument to which the null literal is implicitly convertible.

... and placed on the stack (not on the heap).

This is completely and utterly wrong. Whomever told you that does not know what they are talking about. This makes no sense whatsoever. Whether a null literal is convertible to a type or not at compile time has nothing whatsoever to do with where in memory the data is going to be stored at runtime.

I can understand why the stack is quicker and why value types need to (mostly) be placed on the stack

Then you are misunderstanding something. Values of value types need not be "mostly" placed on the stack.

Values of value type, and references to values of reference type, can sometimes be put on the short term allocation pool when it is known at compile time that the lifetimes of the storage for those values is going to be short. At runtime, that short term pool might be realized as stack locations or registers.

Whether data goes on the short term pool or the long term pool has nothing whatsoever to do with whether the data is a value of value type or a reference. They are not called the "value pool" and the "reference pool". They are the short term pool and the long term pool. Obviously which pool is used has only to do with the answer to the question "do we know ahead of time when we are going to be done using this value or reference?" If the answer is "yes", then the value or reference can go on the short term pool. If the answer is "no", then it has to go on the long term pool.

Is it true the real limitation of why a value type cannot be null is because the stack cannot handle null values?

No, absolutely not. That makes no sense.

What is the real limitation?

Let's look at an easier example than DateTime. Let's look at int. An int is four bytes, no more, no less. Suppose you have a variable of type int. It takes up four bytes. It might take up four bytes on the heap, four bytes on the stack, four bytes in a register -- doesn't matter. It is four bytes of storage, somewhere.

There are 232 possible values you can put into an integer: 0, 1, -1, 2, -2, ... and so on. When you say:

int x = null;

what value do you suppose is going to go into those four bytes of storage?  There are only 232 possible values of four bytes, and they are already taken up by the numbers! You can't put six pigeons into five pigeonholes and still have only one pigeon in every pigeonhole. You can't put 232 + 1 values into 32 bits; you need at least 33 bits, and that's one more bit than we've got available.

Non-nullable value types cannot be null because there are exactly as many possible values of a value type as their bits are capable of holding. A distinct "null" value requires one more value than the maximum number the bits are capable of holding.

So how then do we do it with references? Simple; one of the references is reserved as "special"; the reference whose bits are all zero is set aside as never a valid reference. With ints we have a requirement that all 232 values be valid; with references implemented, say, as 32 bit pointers, we have no requirement whatsoever that all 232 possible pointers be valid; the vast majority of them are invalid.

Why don't we do that with value types? Because then:

int x = null;

is exactly the same as

int x = 0;

and it seems bogus to say that "null" just means "the zero of this type". Null should be a distinct value from every other value. (If you want to get the "zero" of a value type you can always say default(T) where T is the type. So int x = default(int); is the same as int x = 0;)

So how then do we do it with nullable value types? We add more bits. When you say:

int? x = null;
int? y = 123;

that is exactly the same as saying:

int x = 0;
bool xHasValue = false;
int y = 123;
bool yHasValue = true;

When you use a nullable value type, you are doing nothing more than passing around a non-nullable value type along with a flag that says whether it is null or not.

I understand in .net we often don't care about exact memory allocation, yet it is important in performance applications to take the stack and heap into consideration, so I'm trying to wrap my head around this.

That is important in some scenarios, yes. But it has nothing whatsoever to do with the question of why the null literal cannot be assigned to a non-nullable value type.

are nullable types hence placed on the heap or stack?

Values of nullable value types are placed wherever the compiler thinks best; they are not different from any other value of any other type.

If the compiler knows that a value will never be used again after a short period then the compiler generates code to place the value on the short-term storage. At runtime, this will be realized as a location on the stack or a register. If the compiler does not know that for sure then it generates code to place the value on the long-term storage heap.

Again, where the storage for a value is located has nothing whatsoever to do with the type of that value. It has only to do with the answer to the question "do I know for sure how long this value needs to hang around?" If the answer is "yes, and it is a short time", then the storage goes on the short-term pool. If the answer is "yes, and it is a long time" or "no, I don't know", then the storage goes on the long-term pool.


问:
Does anyone else have a refactoring problem?
It seems like after I've written a significant amount of code I get this anxious feeling like I haven't done it in the best possible way, and I end up continuously refactoring and spending way too much time on the project, or never getting it done sometimes. Does this ever happen to anyone else, and how do you deal with this?</p>

答:
I enjoy these moments when they happen to me.

The reason: if I did not look back at my work and think there is something I could have done better than I would not be advancing as a developer.  Therefore, when these moments of enlightenment occur, embrace them and take note of what you learned.  Consider your timetable for current project and if possible refactor the code, if not possible take the lesson and use it in future implementations for projects.

Either way, learning from your own mistakes is a great thing!

ContentLicense: CC BY-SA 2.5


问:
How do programmers in the West see programmers in the East?
The other half of this question: How do Programmers in the East see programmers in the West?

The eastern part of the world (India/China/Philippines ) mainly provide outsourcing services to the western world (USA and Europe).

Do you have the experience of working with offshore teams? If yes, how was it?

Do you hold any generalized ideas or opinions about the programmers from the East (e.g. Are they cooperative, do they deliver on time or do they do quality work?).  What are these based on?

答:
Personally, I think everyone is different.  I've seen some as good, some as bad.

I think there is a negative perception, because most westerners are dealing with consultants and consultants tend to do the least possible and look for ways to blame others for what they did wrong.

Another thing to keep in mind, many American programmers are immigrants from India.  I don't have the statistics, but I would guess about half of them.


问:
Is prototype.js still relevant?
I'm developing a web application which I started on about 2 years ago. It is an AJAX-heavy single page design and prototype solved problems where I didn't want to reinvent the wheel. I am using a couple of third-party tools that depends on prototype, namely okonet modalbox, protofish tooltips, scriptaculous, My own use of prototype is relegated to simple operations such as reading input values and creating elements.

My concern started with the lack of updates for prototype and prima facie evidence on the Internet. If you search for something JScript related jquery is mentioned a lot and prototype hardly at all.

Lately it seems that jquery is the toolkit of choice and prototype is stagnating. Should I make the switch to jquery?

答:
I can't say anything about prototype stagnating or not, but jQuery is definitely worth the switch.  It is a very robust and growing library, with tons of add ons and libraries out there that use it.

Ruby on Rails recently made it the de-facto standard after dropping all standards in the previous release.

Title: Is prototype.js still relevant?


问:
Is it ethical to duplicate user licenses if the same person is going to be using it?
I was talking with someone today and this discussion came up.

Suppose you purchase some software and X user licenses for it. You then want to install another instance of the software, however the company tells you that you need to buy another X licenses to use the 2nd installation. Is it ethical to duplicate the licenses since the same X users are going to be using them? (the security on the program we were talking about is not very good)

EDIT
Licenses are per-concurrent-user. In this situation users would (generally) not be logged into both installations at once. Regardless, we would keep the number of users logged in between the two installations limited to the number of licenses we purchased.

答:
This may not be your case, but many programs, Delphi being one of them, have good-faith single user licensing where you can install it on multiple machines.

It was explained to me by an Embarcadero rep that you can install it on as many machines as you want, but you can only code on one of those machines at any given time.

This licensing makes sense to me and probably is best suited for developers - it wouldn't work very well for networked software.


问:
How to design a database wherein multiple tags(string) are to be associated with an id?
I have to design a database wherein I have to associate an audio_id with multiple tags(words). I am considering following approaches to select one from these:

1) To have multiple fields for multiple tags (columns: tag1, tag2, tag3.... tag10) corresponding to a single audio_id. The number of tags in my application will not be more than 10-15.

2) To save the tags(words) as comma separated single string corresponding to a single audio_id.

3) To save the associations (tag:audio_id) in a separate table. But the issue here is that the associations can be n to n. Multiple tags can be associated with an audio_id and same tag can be in multiple audio_id.

Also please let me know if there can be any alternate design for this scenario or its better to consider any other type of database other than MySQL.

Total number of tags will be around a million and audio_id are around a few thousands. I am concerned for the performance of the system.

答:
I'd suggest having one table for tags, one table for "audios", and a third table to keep track of which tag is associated with which audio. Something like:

```<code>tags_audios

audio_id   | tag_id
----------------------------
1          | 2
1          | 3
2          | 1
2          | 3
3          | 6
</code>```

This is usually how I see m:n relationships stored, and it is pretty close to Solution #3 which you proposed.

Solution #1 will give problems when you decide you do want more than 15 tags. You will also have to search all of the tag columns when you want to find just one value.

I can't think of a good situation to use Solution #2, except maybe in a reporting system where aggregating all of the tags into a string will make the final report easier to generate.

Body:
I'd suggest having one table for tags, one table for "audios", and a third table to keep track of which tag is associated with which audio. Something like:

tags_audios

audio_id   | tag_id
----------------------------
1          | 2
1          | 3
2          | 1
2          | 3
3          | 6

This is usually how I see m:n relationships stored, and it is pretty close to Solution #3 which you proposed.

Solution #1 will give problems when you decide you do want more than 15 tags. You will also have to search all of the tag columns when you want to find just one value.

I can't think of a good situation to use Solution #2, except maybe in a reporting system where aggregating all of the tags into a string will make the final report easier to generate.


问:
I keep failing hands on part of the interview, suggestions?
So I have a couple of software/site in my portfolio. They make money but not a whole lot.

So I decided to get some job experience, mainly applying to Java/PHP junior development positions.

The problem is that I answer all the technical questions correctly and we schedule to do a coding "test", the final phase of the interview. I can never relax and over think things and end up doing the test very slowly. OR sometimes I just hit a block and find it very difficult to think on my feet.

I don't understand this because other stuff I had written were solving far more complex problems while the "Test" is actually brutally simple such as writing and testing palindrome.

Other times, they will give me a logic test with flows to math operations and again I won't be able to do it in the time they assign.

I know I can write sellable software/websites that can generate small revenues and find ways to solve problems but I have great difficulty with simple coding tests in interviews.

Any suggestions?

答:
Ask for feedback at or after the interview. What did they like? What did they not like? You might be surprised at the answers.

Different people look for different things, of course, but how you go about trying to solve a problem is usually more important than writing a 100% correct solution. You may be worrying about all the wrong things.

The best way to get better at anything is to practice. Try writing down a list of short problems. Then, for each item on the list, write a small program that solve the problem. Start with very easy problems, like FizzBuzz, and ratchet up the difficulty as you go. Can you solve the problems that you've seen in previous interviews? Find the largest substring that two strings have in common? Calculate the prime factorization of n!?

The idea isn't to learn the solution to every problem you might encounter, but to give yourself some practice writing small programs quickly, and also to figure out where your weak spots are so that you can improve. Many problems are easy to solve with the right data structure, but difficult otherwise, so make sure you've got a solid foundation in data structures.


答:
This would typically be done with a many-to-many relationship.

This would involve the following tables:

```<code>audio (id, tags, ...)
tag (id, name, ..?)
tag_audio (audio_id, tag_id)
</code>```

Also, as you can see I included a "tags" field on the audio table. This would be a cached value (comma/semicolon/space delimeted) for times when you don't need 100% correct values. You could simply use this field, which would save on extra Joins to the database.

Secondly, as a best practice, table names should be sigular. You can adjust this example as you see fit, however.

Title: How to design a database wherein multiple tags(string) are to be associated with an id?

Body:
I have to design a database wherein I have to associate an audio_id with multiple tags(words). I am considering following approaches to select one from these:

1) To have multiple fields for multiple tags (columns: tag1, tag2, tag3.... tag10) corresponding to a single audio_id. The number of tags in my application will not be more than 10-15.

2) To save the tags(words) as comma separated single string corresponding to a single audio_id.

3) To save the associations (tag:audio_id) in a separate table. But the issue here is that the associations can be n to n. Multiple tags can be associated with an audio_id and same tag can be in multiple audio_id.

Also please let me know if there can be any alternate design for this scenario or its better to consider any other type of database other than MySQL.

Total number of tags will be around a million and audio_id are around a few thousands. I am concerned for the performance of the system.

Body:
This would typically be done with a many-to-many relationship.

This would involve the following tables:

audio (id, tags, ...)
tag (id, name, ..?)
tag_audio (audio_id, tag_id)

Also, as you can see I included a "tags" field on the audio table. This would be a cached value (comma/semicolon/space delimeted) for times when you don't need 100% correct values. You could simply use this field, which would save on extra Joins to the database.

Secondly, as a best practice, table names should be sigular. You can adjust this example as you see fit, however.


问:
How to add image support to client-server database application?
I have an architectural question about a project that I am working on.

Currently it is a simple .NET C# application that runs on several client machines, and communicates with a central MySQL server for data storage. There is not an application or service on the server at this time, just MySQL.

I would like to add image support so that users can add images to the database (and view after the fact), but after storing the images directly in MySQL as BLOB I've decided this approach is a bad idea, as suggested in many posts on SO.

The application can't store images on the local filesystem because they would then be inaccessible to other users not on the same local host.

That being the case, I'm not sure how best to implement image support otherwise:

The machines are all Windows-based, I can set up a shared folder but then I have the headache of maintaining a mapped network drive and user credentials/permissions.

I've thought of adding another application (or service) that runs on the server and handles reading/writing of images on the server side, but this seems redundant in light of the fact that the computers already are capable of file transfers.

Should I consider creating an application on the server to handle all communications between clients and the SQL database, adding filesystem communication there?

答:
The application can't store images on the local filesystem because they would then be inaccessible to other users not on the same local host.

1 - Storing the images in the database is not a great idea. However, you can store them on a separate table from your regular data in a compressed format.

2 - You can store the images on the database server file system and use FTP to access them.

3 - If this is not what you want, you'll need to use a server (intranet/internet) where you can store those images. You may also require a service to use for storing and fetching the images in a secured meaner.


答:
It really depends on how you use the tags.  If all you're doing is saving and displaying them, then a simple comma separated field might work best.  If you're searching, sorting, and filtering on the tags, a 3-table arrangement (as already described) might work best.

You really need to figure out what the usage patterns will be.  Once you've got that, you can figure out which table layout works best.  (And of course, you need to balance disk space and performance in your decision.)

Running a few tests (with LARGE numbers of rows) may be necessary before you can accurately decide which model to go with.


问:
Would it be dishonest to use side tools during a phone interview?
A lot of time for decent tech jobs you have to go through a phone screening process.  If you suck over the phone you generally don't get a chance to show how bad ass you are in person.

These interviews, even for experienced and advanced positions, very often involve trivia style questions over basics.  Unfortunately for me they're always in something I don't generally think about and didn't imagine to prepare for.  With more experience with them (I haven't applied for a lot of such positions) I imagine I might get better but in the meantime...

So for example, converting some decimal value XX to hexidecimal or binary.  Last time I interviewed for something I had a total brain-fart on how to actually do this.  I very rarely have to care.  I use hexidecimal any time I want to be associating values with bit construction and decimal when I want to think of the value as a number.  I rarely convert between the two.  When I do need to I just pop open the calculator and let it do it for me.  It's not like it's hard or anything but for some reason I simply couldn't even remember how to do it.  I told the interviewer the truth and told him I'd have a better chance to convert the other way (since it's way, way easy and still shows understanding I guess).

He then mentioned that most people struggled with that and wondered if it was some sort of age difference thing.  Maybe, maybe not.  I explained where I was coming from and let it at that.

But, being a phone interview he couldn't exactly tell how I'd come up with the answer.  Perhaps it's perfectly legitimate to just use the tools I always do?

What do you think?  If you where interviewing someone, asked a question like that, and then found out that they'd used a tool or reference to answer your question rather than do it by hand or in their head....would you be pissed off?  Would you consider that dishonest or a good use of tools available to solve the problem?

答:
As a frequent interviewer, I can always tell when someone is googling an answer or otherwise not paying attention while doing the phone interview.

Being honest and trying to work through the problem logically will get you a lot more points.  I often am looking more at wether this person can solve the problem at hand logically than if they can regurgitate some answer from a website or book.

As an aside I once worked with someone who could give you theory all day along about how object oriented programming should work etc., but he couldn't code his way out of box if he had too.  I am always on the lookout for those types.  I want to know that given some killer bug or problem you can apply your knowledge and solve it.


答:
I suggest reading To BLOB or Not To BLOB - it is a Microsoft Research paper regarding this issue.

They tested on SQL Server 2008 and concluded that if most files are under 150kb, storage in the DB is suitable.

Of course, you should test for your own environment and database.

Title: How to add image support to client-server database application?

Body:
I have an architectural question about a project that I am working on.

Currently it is a simple .NET C# application that runs on several client machines, and communicates with a central MySQL server for data storage. There is not an application or service on the server at this time, just MySQL.

I would like to add image support so that users can add images to the database (and view after the fact), but after storing the images directly in MySQL as BLOB I've decided this approach is a bad idea, as suggested in many posts on SO.

The application can't store images on the local filesystem because they would then be inaccessible to other users not on the same local host.

That being the case, I'm not sure how best to implement image support otherwise:

The machines are all Windows-based, I can set up a shared folder but then I have the headache of maintaining a mapped network drive and user credentials/permissions.

I've thought of adding another application (or service) that runs on the server and handles reading/writing of images on the server side, but this seems redundant in light of the fact that the computers already are capable of file transfers.

Should I consider creating an application on the server to handle all communications between clients and the SQL database, adding filesystem communication there?


答:
Is the license per-developer or per-machine?  That's really the determining factor.

i.e. The Resharper and Sublime Text licenses I bought are per-developer.  I am allowed to install it on multiple machines as long as I'm the only one using it.

If the license is a concurrent user license, you are legally bound to stay within that limit.  If you have a 5 user license and 4 people are using it, then one of those people could use a second install..  If the 5th user shows up and launches it, you would be in violation of your license.

That said, can they detect it? can they do anything about it?.. Perhaps not, but you asked about ethics... it would be unethical to violate your license.

Title: Is it ethical to duplicate user licenses if the same person is going to be using it?

Body:
I was talking with someone today and this discussion came up.

Suppose you purchase some software and X user licenses for it. You then want to install another instance of the software, however the company tells you that you need to buy another X licenses to use the 2nd installation. Is it ethical to duplicate the licenses since the same X users are going to be using them? (the security on the program we were talking about is not very good)

EDIT
Licenses are per-concurrent-user. In this situation users would (generally) not be logged into both installations at once. Regardless, we would keep the number of users logged in between the two installations limited to the number of licenses we purchased.


答:
Yes it's cheating, but....

I don't see anything wrong with saying something like "I don't know the answer off the top of my head, but I am fairly sure I could find the answer quickly", and then with the interviewers permission go Google to your hearts content.

At the very least, it'll show off your problem solving skills and ability to learn :)

Title: Would it be dishonest to use side tools during a phone interview?

Body:
A lot of time for decent tech jobs you have to go through a phone screening process.  If you suck over the phone you generally don't get a chance to show how bad ass you are in person.

These interviews, even for experienced and advanced positions, very often involve trivia style questions over basics.  Unfortunately for me they're always in something I don't generally think about and didn't imagine to prepare for.  With more experience with them (I haven't applied for a lot of such positions) I imagine I might get better but in the meantime...

So for example, converting some decimal value XX to hexidecimal or binary.  Last time I interviewed for something I had a total brain-fart on how to actually do this.  I very rarely have to care.  I use hexidecimal any time I want to be associating values with bit construction and decimal when I want to think of the value as a number.  I rarely convert between the two.  When I do need to I just pop open the calculator and let it do it for me.  It's not like it's hard or anything but for some reason I simply couldn't even remember how to do it.  I told the interviewer the truth and told him I'd have a better chance to convert the other way (since it's way, way easy and still shows understanding I guess).

He then mentioned that most people struggled with that and wondered if it was some sort of age difference thing.  Maybe, maybe not.  I explained where I was coming from and let it at that.

But, being a phone interview he couldn't exactly tell how I'd come up with the answer.  Perhaps it's perfectly legitimate to just use the tools I always do?

What do you think?  If you where interviewing someone, asked a question like that, and then found out that they'd used a tool or reference to answer your question rather than do it by hand or in their head....would you be pissed off?  Would you consider that dishonest or a good use of tools available to solve the problem?


问:
How does a Scrum team account for infrastructure tasks in the planning meeting?
How does a Scrum team account for dev/infrastructure tasks in the planning meeting?

At first glance, they do not seem like user stories since they do not deliver end user value.

However, attaching them as tasks to a particular user story sometimes does not make sense either.  For example, say the task is: "Setup Bamboo."  That task is not required to complete any user story since the team could manually build and deploy.  So attaching it to a user story does not make sense since this task is not required to complete the user story.

So, then, this suggests that these tasks become user stories.  But then, if the team story points them, then this changes the velocity which is odd since the Product Owner wants to know the velocity against his backlog, not against his backlog with a bunch of technical user stories attached to it.

答:
Consider the following:

Scrum team adding major features to an existing product suite.

There is a need to upgrade development technology/tools/utilities to
stay current based upon engineering best practices.

It makes sense to front load a release with this work so that over
the course of the release Sprints issues can be resolved.

Since the business obtains indirect value from these items I suggest
that in the interest of transparency these are Product Backlog
Items (PBIs).

The team sizes these items and treats them as they would any PBI.

This issue for me boils down to the fact that I don't want to waste
   time trying to figure out how to hide this work as tasks beneath
   other more business centered PBIs.

I don't want PBI sizing skewed by this sort of infrastructure work.  I want to see what is being done and understand what I'm paying for.

I also think there is value in having the team understand the commitment the business is making by investing in the infrastructure required to deliver quality solutions.


问:
Is it ok to write a quick software programme and then refactor it?
In my team, people have tendency to develop a POC (which is very close to actual deliverable in terms of features) which takes good amount of time to be created. And then spend a significant time to refactor the POC so that it matches the design principles using all required design patterns, sometimes naming etc...

One advantage everyone in team says is you have the confidence to meet deadlines one so called POC is ready, then you can spend time on design.

Just curious about, is it really good to refactor code after developing it in quick mode or we should spend time initially to work on architecture and design of the code?

EDIT:
After reading the answers I realized that, as most of guys said, what I am talking of is more than POC and as rightly put by Carl is an "evolutionary prototype." This is definitely not a throwaway code. Intention of the output is always to go to production.

答:
Someone, I believe it was Steve McConnell, probably in the first edition of Code Complete, made a very important distinction.  There are two kinds of prototypes, throwaway and evolutionary, and both are valuable.  And we make a grave mistake when we confuse the two.

A throwaway prototype should be very quick to write; it's what I think of when I hear "proof of concept" (I prefer the phrase "test of concept" because proof seems to imply an expected outcome, and if you know the outcome, why bother?)  Because it's quick to write, you can throw it away without misgivings.  And you should, because its code quality won't be up to your usual standards.  You learn what you need to from the throwaway prototype, and then you throw it away and apply what you have learned to your production code (remember, what you may have learned is, "this doesn't work;" that's a very good lesson).

An evolutionary prototype, to the contrary, is designed to evolve into your production code.  This is slower, because it must be written to satisfy your coding standards: exceptional cases must be handled, tests must be in place, proper commenting and naming, etc.  This can be a good way to go, but it's obviously a bigger investment than the throwaway prototype.

The critical mistake many organizations and developers make - a mistake it sounds like your organization is making - is to start with a throwaway prototype, and fail to throw it away.  Because now you've got crap code (on purpose), and you're trying to put it into production.  Don't do that.  Throw away the throwaway; that's what it was for.

OwnerDisplayName: Maheep


答:
The scenario you describe doesn't have the ring of truth to me. My guess would be that your proof-of-concept is quick to do because it is not robust, and is probably buggy. This is what I like to call "smoke and mirrors" because unfinished software can easily look finished to clients until they have to use it to do their job.

If I'm right, the cleanup that comes later can't be called "refactoring" so much as accounting for all the edge cases, eliminating bugs, and responding to feedback (which inevitably requires 80% of the time anyway). I suppose you might mix this with cleanup and therefore conclude that you are "just refactoring".

It's possible I'm wrong. The kind of thing you're describing just doesn't fit my personal experience. A proof-of-concept is generally most valuable in reducing risk, and it will prove the feasibility of just those portions of a project that seem most likely to fail unless they are well thought out in advance.

Title: Is it ok to write a quick software programme and then refactor it?

Body:
In my team, people have tendency to develop a POC (which is very close to actual deliverable in terms of features) which takes good amount of time to be created. And then spend a significant time to refactor the POC so that it matches the design principles using all required design patterns, sometimes naming etc...

One advantage everyone in team says is you have the confidence to meet deadlines one so called POC is ready, then you can spend time on design.

Just curious about, is it really good to refactor code after developing it in quick mode or we should spend time initially to work on architecture and design of the code?

EDIT:
After reading the answers I realized that, as most of guys said, what I am talking of is more than POC and as rightly put by Carl is an "evolutionary prototype." This is definitely not a throwaway code. Intention of the output is always to go to production.


答:
These interviews...very often involve trivia style questions over
  basics. Unfortunately for me they're always in something I don't
  generally think about and didn't imagine to prepare for.

The point is to help the interviewer judge how much you know. Questions like that are meant to be random enough that there's no way you can prepare for them right before the interview, but general enough that you'll be able to answer if you have a certain amount of experience.

If you have some idea, talk it out a bit. Sometimes just saying what yo do know will jog your memory, and if it doesn't then you've shown that you know something and that you're doing your best.

If you have no idea about the answer, say so -- nobody expects you to know everything, and any interviewer will appreciate an honest answer. It's easy to tell when someone is trying to look up an answer either online or in a book. Keyboards and pages both make more than enough noise to be heard over the phone, and the change in the tone of the conversation as you shift your attention away for a moment is a dead giveaway.

So for example, converting some decimal value XX to hexidecimal or
  binary. Last time I interviewed for something I had a total brain-fart
  on how to actually do this. I very rarely have to care.

The reason you couldn't convert from hex to decimal under pressure was exactly that you don't do it very often, and when you do you use a calculator. That doesn't make you a bad person, it just means that your experience in this particular area is limited, and that's exactly what the interviewer is trying to learn about you. Will it disqualify you from the position? It might, if the job requires the ability to covert between bases in your head, but there aren't too many jobs like that. On the other hand, it's very likely that you'll be disqualified if the interviewer senses that you're not being honest with them. On that basis alone, I think it's a poor idea to use "side tools."

You did the right thing by telling the truth.


答:
WTP,

Since you want to test your software (not the API, nor the recorder), as Chris pointed, a mock of the API would be necessary.

For the integration testing, a reliable "ISO" recorder should allow you to automate the testing of the CD contents by analyzing the .iso file.

Actually burning a CD or DVD would not render conclusive results, since you wouldn't be able to determine whether the error cause is a defective CD, a defective recorder or a software bug, unless you want to perform quality statistics by recording multiple copies of the same disc (wich you apparently don't).

Good luck!


问:
What skills to add for an older CS grad living in rural area?
The answers to this question might be different than the generic, "I graduated.  Duh, now what should I do?"  Living in an area with a low population presents limited opportunities compared to those in more urban or suburban communities.  On the other hand...maybe the answers will be largely the same.  I'm asking you folks who might be looking at this from a perspective of more years on the inside for your wisdom.

I have just finished a CS degree.  I am about 40 (does it matter much?).  I left a successful, professional career in the laboratory robotics industry because it required me to either move to a big city or continue to travel extensively.  In a few years we could potentially move somewhere else or I could start travelling again but I need to start working now.  I need to make myself as employable as possible.

There are few jobs available in my area for computer professionals.  Of those few, the majority seem to be IT related more than software development related -- SharePoint, ERP, network security, web services, etc..

Might I be well served by trying to pick up some IT knowledge? Or should I continue to work on my software development chops?

I have my own project now that I am proud of and excited about and could happily continue to extend it.  It is a good vehicle for learning new stuff until (and hopefully after) I find employment.  I'm hoping to get some others involved in it as well.

Or I could start a new project that would be a vehicle for learning something marketable -- from .net to being able to support all that legacy COBOL there seems like a lot of stuff out there.

Thanks for whatever insight anyone shares.

答:
I would like to add to the already good ideas and comments.  I was in a customer service/technical support role for a leasing company in my early 40's and was faced with the same problem.  However, I couldn't afford to go back to school due to time and money constraints.  What I did was the asked this same question to a consultant, listened to his advice and that became my business plan so to speak.

I worked 18 months 15 to 25 hours a week programming at night, weekends and lunch hours in self-study, while working my regular 40 hour a week day job.  I got on forums, bought programming books, went to user group meetings, and coded a lot!  I worked with a small business and wrote software for them to use.  When I was ready I started applying for programming jobs and had 2 offers.  That was how I started back in 1997 and in March 1999 I had my first full time position.

My point is the most important thing you need to bring to the table is commercial programming EXPERIENCE!  However you can get it.  That is the value you can bring to the table over all the other IT grads coming out of school.  I've found grades don't count for much.  The question is, can you code?  That can be proven by experience.

The industry experience is your edge as well if you can apply it.  In my case I had 14 years in the Leasing Industry and my first job was writing code supporting leased pc's in the company.


答:
I'm not involved in hiring, but if I was, one of the qualities I'd be looking for is resourcefulness and efficiency.  My software product does not depend on the abstract capacity for knowing how to derive an answer, it relies on getting the right answer. You'd pass that test.

If I wanted to test for some more abstract ability, I'd ask the question differently, e.g. "How do you convert from decimal to binary?", or I'd constrain the environment by brining you in to do it face to face, or ask "without using any calculators or other tools..." and leave it as a question for later whether or not you were honest about it.

In any case, a decent interviewer who himself knows what he's talking about can tell canned google answers apart from understood and thoughtful answers, and if there is some doubt, can follow up with more targeted questions.  If he doesn't know what he is doing and is just parroting a canned interrogation, your innate do-it-in-your-head abilities are not really being tested anyway, plus there's a whole new can of worms to consider, starting with "what would it be like working for this company?".


问:
Will .NET 4.5 Make the Reactive Extensions Obsolete?
Among other things, .NET's Reactive Extensions simplify concurrency management.

From what I've heard, .NET 4.5 will simplify concurrency management with things like the await keyword.

My Question:

Will .NET 4.5 make the Reactive Extensions obsolete?

Or is Microsoft expected to pitch the .NET 4.5 additions as an alternative way to approach asynchronous and concurrent programming?

答: The newest release of Rx Experimental supports the new .NET 4.5 features and integrates more seamlessly with async/await and Tasks.  So, the answer is no, .NET 4.5 doesn't make Rx obsolete, it makes it better.  Take a look at http://social.msdn.microsoft.com/Forums/en-US/rx/thread/23062737-e154-41af-99f6-45d819992254 for information on the integration with Tasks, especially under the post entitled "Prefer Async Policy".  Task is best used for single values, Observables work great for streams.  It depends on what you are doing.</p>


答:
If it's a per-user license, you can use it on many machines so long as the same person is using it. If it's a per-machine license, then you need a license per installation.

It seems pretty cut-and-dry to me. If it's a per-machine license and you want to install the product on multiple machines for the same people to use it, it's a license breach and therefore not ethical.


问:
How can I learn to write idiomatic C++?
I am a computer science student, and as a result, I was taught C++ as a better version of C with classes. I end up trying to reinvent the wheel whenever a solution to a complex problem is needed, only to find sometime after that, some language feature or some standard library routine could potentially have done that for me.

I'm all comfortable with my char* and *(int*)(someVoidPointer) idioms, but recently, after making a (minor) contribution to an open-source project, I feel that is not how one's supposed to think when writing C++ code. It's much different than C is.

Considering that I know objected-oriented programming fairly well, and I am okay with a steep learning curve, what would you suggest for me to get my mind on the C++ track when I'm coding C++?

答:
I can recommend the recent BUILD take given by Herb Sutter. The one called "Writing modern C++ code: how C++ has evolved over the years":

Many people think of C++ as the same language they experienced in
college or just as “C with classes”, but the C++ language has evolved
extensively over the years. In this session, we’ll cover how you can
use C++ to write innovative, expressive and beautiful apps that
deliver power and performance apps. Join us to see how the newly
finished C++0x standard can make writing C++ as productive as many
other languages.

Its not a bad presentation, not too long, has some nice pointers to the new features in the latest standard which would give you a few hints towards getting your old C/C++ style updated.

Other than that, you need to learn the STL - its not complicated and there are plenty of books, eg, Effective STL, or just google for STL tutorials to get you going.

Title: How can I learn to write idiomatic C++?

ContentLicense: CC BY-SA 4.0


问:
Are there any tools that allow you to track and manage test cases and test execution?
For the bugs or issues, there are now many good issues trackers available which allows status and tracking issues and also allows you to organize it to manage specific releases.

I am looking for test case tools should be able to support listing of functionality and test cases with possible linkage to them, allows test suits or test plans (as group/ hierarchies) to organize them. Some of the potential usage could be to identify list of key test cases that must be executed if particular functionality or modules are affected.

Also Additional parameters to support related to system of execution. It would be best if result of execution of tests can be recorded with necessary comments. Web interface and possible email notifications could be essential.

Please note that i am NOT looking at test automation systems like cruise control etc. but more as a system for testing management. I am more keen to see a system that allows visualization of Traceability matrix. Open source projects are most appreciated, though please also suggest if there is commercial software.

Are there any tools that allow you to track and manage test cases and test execution?

答:
At a previous job, we used ApTest with some success.

It was useful to implement test run results (for traceability requirements), and also to clarify expectations during development (the test cases were disclosed before dev was complete).

The product is web-based and you could comment during testing.

I do not think you could define sw modules and link to test cases. But you could organize releases and group test cases (with multiple levels of hierarchies).


答:
Best solution i would suggest is that upload (or store) all images behind a web server and attach each resources with a unique id (or URL) which can be stored inside the DB.

Because it is behind a web server, it can become accessible via a direct fetch will not load database server to pull the image out from it. Also, using web based (URLs) - you are not limited by the physical space of a given hard disk or worry about the redundancy, load balancing etc. because web based mechanisms are quite well established to allow massive redistribution.

Also, you can extend end-user based authentication for actual access.


答:
Storing images in the database is not always a bad idea.  If you have a small amount of images, say in the tens of thousands range, and they are small in size, sometimes the convenience of storing the images in the database outweighs the added complexity introduced by adding an additional storage server that needs to be written and supported into the mix.  Is storing the image in the db the most efficient means?  No.  Does that matter if you only have 10 client applications accessing a couple hundred images a day?  Probably not.  In that case, live with the inefficiency and save yourself a lot of effort.

If you have a lot of images (millions, tens of millions,...I've worked on systems that track billions), then you'll want a seperate server application that can handle storage and retrieval of files.  At the most basic level this can be (for example) simply a tcp/ip server app tha can handle requests for files, as well as accept them from across the network (a web server running a PHP script could be adapted for this).  You'd just access the images based on an id in the database for a row that stores metadata about that image.  Remember, if this is across a public wire, you'll need to implement your authorization system to access the images.  More complicated servers might handle mirroring, file type conversions, and the migration of files to and from longer term (and cheaper) storage mediums.


答:
We are using the Bugzilla/Testopia package. You can link specific Test Cases in Testopia back to specific Bugzilla entries. This gives you ability to trace the resolution of a bug (or feature) to a specific Test Case.

The Testopia feature set is decent for managing Test Runs. We use it to track running full regression tests (manual QA) on various products. (We also use some separate automated test tools to supplement the manual QA.)

There may be better packages out there.  We were already using Bugzilla for bug tracking, so it was natural to incorporate Testopia as well.

Body:
For the bugs or issues, there are now many good issues trackers available which allows status and tracking issues and also allows you to organize it to manage specific releases.

I am looking for test case tools should be able to support listing of functionality and test cases with possible linkage to them, allows test suits or test plans (as group/ hierarchies) to organize them. Some of the potential usage could be to identify list of key test cases that must be executed if particular functionality or modules are affected.

Also Additional parameters to support related to system of execution. It would be best if result of execution of tests can be recorded with necessary comments. Web interface and possible email notifications could be essential.

Please note that i am NOT looking at test automation systems like cruise control etc. but more as a system for testing management. I am more keen to see a system that allows visualization of Traceability matrix. Open source projects are most appreciated, though please also suggest if there is commercial software.

Are there any tools that allow you to track and manage test cases and test execution?


答:
Programmers are authors, and even the best authors don't get it right on the first draft.  There's a very simple reason for this:  programmers who have worked on a project for a month are much more knowledgeable on the subject than programmers who haven't worked on it at all.

However, scheduling in a refactoring phase isn't the answer.  You need to be doing continuous refactoring as you go.  When you find a cleaner alternative to an architecture that turned out to be awkward and bug-prone, refactor it right then.  You might think you're saving time by putting it off, but what you're really doing is condemning the programmers to work on an awkward and bug-prone architecture until the POC is complete.  That greatly increases the risk that it won't work, makes the job more difficult, and therefore it takes longer, even in the relatively short term.


答: It's amazing how many prototypes end up as being the final product. I would say follow your coding guidelines to create the prototype and once finished it shouldn't need a great deal of refactoring or else your guidelines need updating. Do it as near as right as you can the first time.</p>


答:
Practice and find someone to help guide you through the basics of how to get through it.  It may take a handful of tries but it could be surprising what gets uncovered if you can get some feedback and practice on this.  I had a recruiter walk me through how to handle a whiteboard problem once which appears to be similar to your issue here.

I'm not suggesting memorizing answers as much as it is having a blueprint of what to do when given such a problem and how to talk it through.  What does this look like?  Have you seen similar problems?  What could some simple approaches yield in terms of an algorithm?  At least that is my suggestion to you.

Title: I keep failing hands on part of the interview, suggestions?

Body:
So I have a couple of software/site in my portfolio. They make money but not a whole lot.

So I decided to get some job experience, mainly applying to Java/PHP junior development positions.

The problem is that I answer all the technical questions correctly and we schedule to do a coding "test", the final phase of the interview. I can never relax and over think things and end up doing the test very slowly. OR sometimes I just hit a block and find it very difficult to think on my feet.

I don't understand this because other stuff I had written were solving far more complex problems while the "Test" is actually brutally simple such as writing and testing palindrome.

Other times, they will give me a logic test with flows to math operations and again I won't be able to do it in the time they assign.

I know I can write sellable software/websites that can generate small revenues and find ways to solve problems but I have great difficulty with simple coding tests in interviews.

Any suggestions?


问:
Ensuring successful merges in Subversion
Subversion Re-education actually convinced me, but for now I'll stick to svn - mastering the use of a very popular tool can't be bad.

To date I've not used branching/merges in production code, now I decided to give it a try in a small team environment.

I'm afraid of suffering the same pain as the described in Spolsky's article. Is there a "right" way of working with branches in svn?

答:
The most important part of working with Subversion branches is to merge from trunk often. Daily at a minimum, more if possible. The converse is also true - merge to trunk often - once features can go to trunk, merge them.

The more branches diverge from each other, the more merging becomes hell.

The longer you take between merges, the more files you will have to merge, the more chances of conflicts and the more chances that people will not recall the details of changes (meaning that making the right call on a conflict can become very difficult).

You will also need to decide on a branching strategy - this is not something that you will need to tailor to your team and workflow and will probably need to tweak as you go along. Interesting presentation here (pdf).


答:
Though it's not free, Microsoft Test Manager does what you're asking for. If you have VS2010 Ultimate, it comes with it.

It supports running test cases (both automated and manual in virtualized or non-virtualized environments) and tracking the (history of) results of the runs.

Title: Are there any tools that allow you to track and manage test cases and test execution?


答:
Branching always begins with fear that merging will break things or leave unnoticed bugs for long.

However, it is the most essential element for a reasonably sized product or project. Here are the few distinct categories where branches are a must -
they are :

1. Branch post release

This is done to maintain post release patches. these patches are essential to support current versions in the market till next major releases are still not ready.

2. Branch per Task or component
Here a few independent groups are given the branch that they keep check-in while rest of the team (or other branches) doesn't have to accept any work till entire new functionality or project is completely finished and merged to trunk.

3. Branching for special customer support
Here a few branches are created to support only for a specific (set) of customers.

Branching and merging begins with some fear always, but in my experience, as people begin to put disciplined code, it becomes indispensable for any large development.

See URLS below for more details.

http://www.codinghorror.com/blog/2007/10/software-branching-and-parallel-universes.html

https://stackoverflow.com/questions/631900/branching-hell-where-is-the-risk-vs-productivity-tipping-point

Title: Ensuring successful merges in Subversion

Body:
Subversion Re-education actually convinced me, but for now I'll stick to svn - mastering the use of a very popular tool can't be bad.

To date I've not used branching/merges in production code, now I decided to give it a try in a small team environment.

I'm afraid of suffering the same pain as the described in Spolsky's article. Is there a "right" way of working with branches in svn?


问:
How to make Classic ASP interesting if you are stuck with it?
I used to work on a really small outsourcing company (4 programmers and the boss), then when the stress and the frequent long shifts made the situation unbearable I made the switch to a better paid job with a more relaxed schedule that allows me some more free time.

The problem, however, is that for the most part, everything is coded in Classic ASP that interfaces with a custom made C++ queueing system that stores everything in AS400 systems. My boss used to be one of the developers that made the initial efforts towards this, and naturally won't ever approve a switch to another languages / technologies despite the increasing difficulty that represents developing today business needs with yesterday tools.

I'm pretty much stuck coding with Classic ASP in the foreseeable future, and I'm struggling to find ways to make it at least interesting, as I used to work with .NET and Java previously, and I feel like I'm going backwards... Any advice?

答: Since the data is on AS400/IBMi already, you know you can run Java, PHP, MySQL interfaces and other things on that OS?  My guess is he's a 400 guy, not an ASP guy.  Try embracing this, I'd love to have an opportunity to grow a 400 ecosystem like that.</p>


问:
Staging environment vs Production environment
I work for a company where we build enterprise applications, and we maintain three environments: development (or dev), staging (or stage) and production (or prod).

The meaning of dev is intuitive: it's the environment used during development of the application.

What's the difference between staging and production environments?

答:
I am a bit surprised that a test environment is not present as well, as a location for code to go to before being promoted to staging.

To answer the question:

A stage environment should mirror the production environment as closely as possible.

It is used for verification of deployment procedures - making sure that when code is production ready it can be deployed without causing problems.

That is, code goes to staging - this is comprehensively tested and regressed to ensure that deployment went as planned (and to iron out any issues if it didn't).


问:
Why is $ in identifier names for so many languages?
A lot of scripting languages like Perl, Awk, Bash, PHP, etc. use a $ sign before identifier names. I've tried to look up why but never had a satisfactory answer.</p>

答: Why not?  It's easier to write a lexer that can tell an identifier is going to be a variable (and consequently easier to write the parser), especially for an interpreted language.  As to why $, that's probably largely tradition - one of the creators of an early language using the construct (Bash? or more likely a predecessor to it) used it for whatever reason and subsequent languages adopted it.


问:
Approach to a programming task
All,

Given a problem statement, when I start of with the analysis and design, I tend to think too much about the various functionalities associated with the task (sometimes not even mentioned in the task). My point is, I get diverted from the main task at hand thinking about various scenarios that I should consider while coding and this tends to demotivate me because I am often very confused in the end. What approach should I take in this case since thinking a lot on all possible scenarios comes naturally and I only try hard not to.

答:
I would very strongly advise you to have a good look at Test Driven Design.

Here you start with writing a test for each new piece of functionality.  The word "test" here indicates that you test the behaviour of the code by checking if it works as you expect.  By writing the test first, you are guaranteed that you start by thinking in how to use your code, instead of how to write it.  You then implement enough to make the test pass - i.e. fulfill the requirements, and then add more tests describing more functionality, and more code to make it pass.  Repeat until you have all the functionality you need.

I would suggest having a look at http://junit.sourceforge.net/doc/testinfected/testing.htm which describes how to develop a Money class in this way.

I have found the approach VERY helpful especially for libraries.  You might too.

Title: Approach to a programming task


答:
awk?

Sometimes called a sigil, generally used for translating the names of variables (and others) into values.

Title: Why is $ in identifier names for so many languages?

Body: A lot of scripting languages like Perl, Awk, Bash, PHP, etc. use a $ sign before identifier names. I've tried to look up why but never had a satisfactory answer.</p>


答:
A $ sign in variable name is a special case of "Sigil",
Back in the early days of BASIC (1964 or so) $ was used to denote string variable names. My guess is, since it makes it easier on compilers to separate variable names from the rest of the grammar using some symbol, and since it was common to BASIC, its usage has progressed. However, this is not the only one used.</p>


答: Both serve complimentary needs, Rx being an event stream processing library, and the new .NET 4.5 features focusing on single-value asynchrony. Watch the C9 video for more details.</p>

Title: Will .NET 4.5 Make the Reactive Extensions Obsolete?

Body:
Among other things, .NET's Reactive Extensions simplify concurrency management.

From what I've heard, .NET 4.5 will simplify concurrency management with things like the await keyword.

My Question:

Will .NET 4.5 make the Reactive Extensions obsolete?

Or is Microsoft expected to pitch the .NET 4.5 additions as an alternative way to approach asynchronous and concurrent programming?


问:
Is prototype.js still relevant?
I'm developing a web application which I started on about 2 years ago. It is an AJAX-heavy single page design and prototype solved problems where I didn't want to reinvent the wheel. I am using a couple of third-party tools that depends on prototype, namely okonet modalbox, protofish tooltips, scriptaculous, My own use of prototype is relegated to simple operations such as reading input values and creating elements.

My concern started with the lack of updates for prototype and prima facie evidence on the Internet. If you search for something JScript related jquery is mentioned a lot and prototype hardly at all.

Lately it seems that jquery is the toolkit of choice and prototype is stagnating. Should I make the switch to jquery?

答:
Prototype and Scriptaculous are both used extensively at my job.

Apparently, the next major version of Prototype is going to stop using DOM extension - and given that this was the basis Prototype was originally developed around, it's not surprising that it's taking a while for a new release to come about.

Title: Is prototype.js still relevant?


答:
The Bourne shell or its predecessor was probably the origin of the convention.  Shells tend to use $foo to refer to a shell variable or environment variable, whereas just foo is taken as a literal string (which could be a command name, a file name, or just a word to be passed to another command).

It's probably a matter of minimizing how much you have to type.  In most programming languages, most of what you type is going to be keywords (from a small fixed set) and names of things that have been declared; it makes sense to use just a name for those.  String literals are enclosed in quotation marks (single or double) to distinguish them syntactically.

In an interactive shell, most of the things you type are going to be command names and file names, so having an undecorated form for them makes sense.  Variable names aren't used quite as often, so preceding them with $ is a straightforward way to distinguish them.

The trailing $ that some BASICs use for string variables (as opposed to numeric variables) was probably an inspiration as well.

Perl's choice to use $ for scalar variables was undoubtedly inspired by shells such as the Bourne shell, and early versions of Perl commonly treated barewords as string literals (print FOO and print "FOO" were equivalent).  This use of barewords has been deprecated in more modern versions of Perl, but the sigils remain, and are mostly used to distinguish different kinds of variables.  Perhaps if Perl were being designed from scratch, scalar variables might be denoted by an "empty sigil", but that didn't happen.

(BTW, Awk doesn't use sigils.  It does have a $ syntax, but it refers to field numbers.  NF is the number of fields; $NF is the last (the NFth) field.)


答:
You can try thinking in small increments and writing stuff down at each stage.

Start with a requirements document. Think from the end user's perspective. Freeze the requirements. Most importantly write it down in a version controlled document.

Then move on to the functional specification. Think from an architect's perspective. Write down in a separate version controlled document, how each of the requirements will be met. It should describe all user interaction and functionality.

Now move on to the design document. Think from a lead's perspective. Write down the high level design document. This should describe high level modules and clearly spell out the interfaces between the modules. The interfaces must be frozen at this stage.

Now start actual coding. Think from a programmer's perspective. Implement module by module. Focus on one module at a time. Stop coding a module once it adheres to the already frozen interface.

If all goes well, integration shouldn't be too painful.

Title: Approach to a programming task

Body:
All,

Given a problem statement, when I start of with the analysis and design, I tend to think too much about the various functionalities associated with the task (sometimes not even mentioned in the task). My point is, I get diverted from the main task at hand thinking about various scenarios that I should consider while coding and this tends to demotivate me because I am often very confused in the end. What approach should I take in this case since thinking a lot on all possible scenarios comes naturally and I only try hard not to.


问:
Conflicting versions of jQuery in Separate Extensions
I have built a few browser extensions that live in GMail. Since they are larger extensions, they incorporate jQuery 1.6.x.

I am using jQuery as a content script which means it is injected into GMail then my scripts reference jQuery as they are loaded afterwards.

I have found that when other extensions are installed alongside of my extensions and they incorporate earlier versions of jQuery the earlier versions are loaded first and my 1.6.x is ignored. The functionality I have that depends on 1.6.x no longer works, and that's a dealbreaker.

I'm trying to come up with an elegant solution for this. My first instinct is to namespace my version of jQuery, but loading jQuery twice seams clunky. Possibly testing for jQuery and then doing a diff, but that seems tedious.

Any thoughts?

答:
You could possibly do what the HTML5Boilerplate does:</p>

```<code><script>window.jQuery || document.write('<script src="js/libs/jquery-1.5.1.min.js">\x3C/script>')</script>
</code>```

Body:
You could possibly do what the HTML5Boilerplate does:

<script>window.jQuery || document.write('<script src="js/libs/jquery-1.5.1.min.js">\x3C/script>')</script>


问:
Local Stack vs Call Stack
On the matter of Recursion:

When you create a recursive function, you create a call stack. Ok, no problem; However, a comment on this page (look for comments by "LKM") triggered my curiosity (and google was no help):

What is a local stack?

Why would it be faster than a call stack?

How would you actually implement it (pseudo-code, js/php/ruby/python are ok)?

Subsidiary question (might deserve another question, but I don't know on which (.*\.)?stack.*\.com to ask):

In these conversations about programming, I often see the "recursion" theme and how bad/newbie programmers don't grok it. I'm self-taught, and I never understood what the big fuss is all about. I use recursion a lot in my everyday coding, both for solving problems and sometimes just because I think they are beautiful. But these articles make me feel like maybe there is something there I just don't see. So:

What's all the fuss about recursion? What's there not to grok?

答:
A "local" stack, as that comment uses it, means stack implicitly declared as a local variable. I would differentiate it from the call stack by calling it an "explicit" stack.

Iterating on an explicit stack can be faster than recursion in languages that don't support recursion related optimizations such as tail recursion. Or a language may have limited stack depth.

Here is a good explanation with an example by Eric Lippert.

Title: Local Stack vs Call Stack


答:
LKM simply means a manually handled stack, for example a linked list where you push elements at the head and then pop them out again. It'd be faster because it's smaller, less data to shuffle around.

It's implemented by having a field in your struct that's a pointer (or reference if you wish) to the next element, and a head variable that's the top of the stack. When you push, you set the next pointer of your pushed element to the current value of the head variable, and then set the head variable to reference the pushed element. Popping does the inverse.

Another way to implement it, if you know the maximum stack of the stack, is to have a normal array and an index variable which tells where in the array the head is. That's actually how the recursion call stack is implemented, if you simplify it.

I believe most of the languages you mention above also have special constructs to treat arrays as stacks, usually called push/pop or shift/unshift.

Title: Local Stack vs Call Stack

Body:
On the matter of Recursion:

When you create a recursive function, you create a call stack. Ok, no problem; However, a comment on this page (look for comments by "LKM") triggered my curiosity (and google was no help):

What is a local stack?

Why would it be faster than a call stack?

How would you actually implement it (pseudo-code, js/php/ruby/python are ok)?

Subsidiary question (might deserve another question, but I don't know on which (.*\.)?stack.*\.com to ask):

In these conversations about programming, I often see the "recursion" theme and how bad/newbie programmers don't grok it. I'm self-taught, and I never understood what the big fuss is all about. I use recursion a lot in my everyday coding, both for solving problems and sometimes just because I think they are beautiful. But these articles make me feel like maybe there is something there I just don't see. So:

What's all the fuss about recursion? What's there not to grok?


答:
In this case, using a local stack means "using a local variable, e.g. an array that is accessed like a stack", i.e. FIFO, as opposed to "making function calls, which create stack frames, each of which contains an int, all of which taken together contain the same values as your array would". It can be faster because you're avoiding the overhead of pushing and popping registers, setting up the local stack frame for each function invocation etc. Instead you're doing  just one memory allocation and that's it (and if you use alloca then your local stack really is on the call stack - alloca is essentially just an in dex increment, while malloc can involve all sorts of expensive operations).

The trade-off, as always, is that by making the machinery of the stack visible, the actual recursive structure of the algorithm is a lot less clear to many  people. Note that I say "many people" - some people naturally understand recursion and some don't. (I used to teach Scheme and Prolog to freshmen, and I'd say that very roughly a third of them do and two thirds don't.) Entire books have been written just to get the latter kind of students over this hurdle, and since you seem to belong to the former kind, I don't know if I can convey to you how mystifying the concept is to many people. It isn't even a question of understanding the sequence of steps that happens, more an issue of believing that it is possible to use a definition that seems to be not yet complete. The solution involves lots of practice and lots of stepping through some small and medium-size examples. Eventually this will let the penny drop for many learners, although by far not all.

Title: Local Stack vs Call Stack


问:
Automated web tests depending on developer code
When QAs write automated selenium tests to test a multi-layered website (e.g. testing a web app which is on mvs design, spring and database) should the tests make use of existing classes and frameworks written by developers or should we write simplified classes to serve the test?

The downside of relying of frameworks developed by devs, is if there is a logical error in the framework it will be present in the tests.

a typical example is a class that fetches some links form a database and some framework printing them on the webpage.

If the tests rely on the framework to define the expected results and then verify them against the output on the webpage, then if the logic in the framework is incorrect, then the defined expected results will also be incorrect and there is a risk that the tests will pass even though the results are wrong.

In my opinion, the automated system tests written by QA should be independet on the underlying framework where as the automated unit tests should rely on the underlying framework.

What are your thoughts?

答:
I think you answered your own question in your question when you asserted "If the tests rely on the framework to define the expected results and then verify them against the output on the webpage, then if the logic in the framework is incorrect, then the defined expected results will also be incorrect and there is a risk that the tests will pass even though the results are wrong."  Your automation would in effect not be testing anything, it would simply be exploring the happy path.

You should not use the app itself to drive your automated tests, but it is perfectly reasonable and expected to use data from the app for validation within the automated tests.  For instance, it is common practice to perform a test case and then compare results in the UI with results from the database or web service.

OwnerDisplayName: Amir Ghahrai


问:
Is it ethical to duplicate user licenses if the same person is going to be using it?
I was talking with someone today and this discussion came up.

Suppose you purchase some software and X user licenses for it. You then want to install another instance of the software, however the company tells you that you need to buy another X licenses to use the 2nd installation. Is it ethical to duplicate the licenses since the same X users are going to be using them? (the security on the program we were talking about is not very good)

EDIT
Licenses are per-concurrent-user. In this situation users would (generally) not be logged into both installations at once. Regardless, we would keep the number of users logged in between the two installations limited to the number of licenses we purchased.

答: This is not an ethics question, but a license terms question.  Each product can have its own license terms.  Some allow multiple installations as long as they're used by the same user; some don't.  If you do what your product's license prohibits, then you're breaking the terms of the license.</p>


答:
The stage environment is a preprod environment that mirrors production. Often, it may have some production data so that a test group composed of actual users and QA testers can confirm that the pre-released code base/data will deploy and work properly in a prod-like environment, usually through scripted use cases and regression tests.

As @Oded notes, it's usually common to have a QA environment that QA testers use to test the code.

Title: Staging environment vs Production environment

Body:
I work for a company where we build enterprise applications, and we maintain three environments: development (or dev), staging (or stage) and production (or prod).

The meaning of dev is intuitive: it's the environment used during development of the application.

What's the difference between staging and production environments?


问:
How does Ruby, Python, PHP manage without Spring?
I write enterprise Java applications and web services at work (Spring, Hibernate, Maven, RESTEasy) and PHP (CakePHP) and Python (Django) for my side projects.

While I do see the value that Inversion of Control, Aspect Oriented Programming etc. that Spring brings in, I am not sure how massive web applications that are not on the Java stack manage without a framework like Spring.

So, do the developers just have to "put up with" tightly coupled components and other grievances that Spring eliminates or am I missing something?

For those unfamiliar with Spring, the features we use the most are:

Inversion of Control container: configuration of application components and lifecycle
management of Java objects,

Aspect-oriented programming: enables implementation of cross-cutting routines,

Transaction management: unifies several transaction management APIs and coordinates transactions for Java objects.

答:
Well Python enjoys the Spring also Spring Python.

Spring framework was created to ease Java development and what is true for Java development isn't necessary true for Ruby or Python development.

Ruby for example has Metaprogramming capabilities which means you can create your own AOP.

Ironically though, new Java web frameworks are trying to catch Django and Rails frameworks (see Grails and Play! frameworks for example).


问:
Many small scripts, one repository or multiple?
A co-worker and myself have run into an issue that we have multiple opinions on.

Currently we have a git repository that we are keeping all of our cronjobs in. There are about 20 crons and they are not really related except for the fact that they are all small python scripts and essential for some activity.  We are using a fabric.py file to deploy and a requirements.txt file to manage requirements for all of the scripts.

Our issue is basically, do we keep all of these scripts in one git repository or should we be separating them out into their own repositories?  By keeping them in one repository it is easier to deploy them onto one server.  We can use just one cron file for all the scripts.

However this feels wrong, as the 20 cronjobs are not logically related.  Additionally, when using one requirements.txt file for all the scripts, it's hard to figure out what the dependencies are for a particular script and they all have to use the same versions of packages.

We could separate all of the scripts out into their own repositories but this creates 20 different repositories that need to be remembered and dealt with.  Most of these scripts are not very large and that solution seems to be overkill.

A related question is, do we use one big crontab file for all cronjobs, or a separate file for each?  If each has their own, how does one crontab's installation avoid overwriting the other 19?  This also seems like a pain as there would then by 20 different cron files to keep track of.

In short, our main question and issue is do we keep them all closely bundled as one repository or do we separate them out into their own repository with their own requirements.txt and fabfile.py? We feel like we're also probably looking over some really simple solution. Is there an easier way to deal with this issue?

答:
Unless there exists a specific reason for you to think that each one of them deserves an invidual repo (Will they grow a lot? Probably not!) it seems more reasonable to put them all in one repo, and save yourself the trouble of cloning all of them from 20 repos.

Keeping each one in a separate repo seems like the path of creating a problem where a problem does not exist.

Don't create extra work for yourself (and others).


问:
Are there any OS which are simple enough for learning?
I would really like to understand how an operating  system works behind the scenes. However, I think that the kernel of most open-source OSs out there are too complex for learning purposes, even for a full-time programmer to learn. Are there any "simple" OSs made for learning purposes only out there?</p>

答: Andrew Tanenbaum's Minix (see Operating Systems Design and Implementation) is intended for exactly this sort of purpose. Another (albeit quite dated) possibility is to read through Lion's Book, which covers Unix V6 (full Unix, but an old enough version that it's still simple enough for fairly easy study). The obvious disadvantages of the latter are that the C it uses is quite obsolete, so even fairly experienced C programmers may find parts somewhat difficult to read, and you can't plan on a modern compiler digesting the code.


答:
Other platforms don't need Spring because those languages are not anywhere near as restrictive as Java.

I'll give an example with node.js

Inversion of Control container: configuration of application components and lifecycle management of Java objects

server configuration is done either in code or a simple json config file. As for generic IoC systems, we simply don't need them, Javascript is an expressive and dynamic language. Yes you need IoC but that's simple, pass dependencies to your objects as function parameters.

Aspect-oriented programming: enables implementation of cross-cutting routines

I simply don't think we need something like this, we write modular code and it just works.

Transaction management: unifies several transaction management APIs and coordinates transactions for Java objects

noSQL is incredibly popular. There is no notion of transaction.

Personally I would say such systems are bloated and over engineered and you just don't need them. Other languages and platforms simply stay lean and agile.

Title: How does Ruby, Python, PHP manage without Spring?

Body:
I write enterprise Java applications and web services at work (Spring, Hibernate, Maven, RESTEasy) and PHP (CakePHP) and Python (Django) for my side projects.

While I do see the value that Inversion of Control, Aspect Oriented Programming etc. that Spring brings in, I am not sure how massive web applications that are not on the Java stack manage without a framework like Spring.

So, do the developers just have to "put up with" tightly coupled components and other grievances that Spring eliminates or am I missing something?

For those unfamiliar with Spring, the features we use the most are:

Inversion of Control container: configuration of application components and lifecycle
management of Java objects,

Aspect-oriented programming: enables implementation of cross-cutting routines,

Transaction management: unifies several transaction management APIs and coordinates transactions for Java objects.


答:
You should consider a modern Unix-a-like, the Xv6 operating system, used in an OS course at MIT.  It appears to have some course material associated with it, as well.

It runs in both Bochs and Qemu x86 emulators.  I did that part.  It was fun.

Title: Are there any OS which are simple enough for learning?

Body: I would really like to understand how an operating  system works behind the scenes. However, I think that the kernel of most open-source OSs out there are too complex for learning purposes, even for a full-time programmer to learn. Are there any "simple" OSs made for learning purposes only out there?</p>


问:
License validation and calling home
I am developing an application that, when bought, can be activated using a license.

Currently I am doing offline validation which is a bit troubling to me. I am aware there is nothing to do against cracks (i.e modified binaries), however, I am thinking to trying to discourage license-key pirating. Here is my current plan:

When the user activates the software and after offline validation is
successful, it tries to call home and validate the license. If home
approves of the license or if home is unreachable, or if the user
is offline, the license gets approved. If home is reached and tells
the license is invalid, validation fails.

Licensed application calls home the same way every time during startup (in background). If license is revoked (i.e pirated license or generated via keygen), the license get deactivated.

This should help with piracy of licenses - An invalid license will be disabled and a valid license that was pirated can be revoked (and its legal owner supplied with new license). Pirate-users will be forced to use cracked version which are usually version specific and harder to reach.

While it generally sounds good to me, I have some concerns:

Users tend to not like home-calling and online validation. Would that kind of validation bother you? Even though in case of offline/failure the application stays licensed?

It is clear that the whole scheme can be thwarted by going offline/firewall/etc. I think that the bother to do one of these is great enough to discourage casual license sharing, but I am not sure.

As it goes in general with licensing and DRM variations, I am not sure the time I spend on that kind of protection isn't better spent by improving my product.

I'd appreciate your input and thoughts.

Thanks!

答:
From Disadvantages of dongles:

Some familiar disadvantages are that:

The software vendor has to buy, store and deliver a piece of hardware to each customer

Customers have to wait to run their license, but today users expect near-instant delivery of software

Customers have to keep an USB device inserted in their machine (either sticking out at the front or side, where it can be damaged)

If a customer wishes to move the license to another machine, they have to ship the dongle.

Title: License validation and calling home