答:
Is adding tests a good idea?

Absolutely, though I find it a little hard to believe that the code is clean and working well and using modern techniques and simply has no unit tests. Are you sure they're not sitting in a separate solution?

Anyways, if you're going to extend/maintain the code then true unit tests are invaluable to that process.

If so, how would one even start on something like this?

One step at a time. If you're unfamiliar with unit testing, then learn a bit. Once your comfortable with the concepts, pick one little section of the code and write tests for it. Then the next, and the next. Code coverage can help you find spots you've missed.

It's probably best to pick dangerous/risky/vital things to test first, but you might be more effective testing something straight-forward to get into a groove first - especially if you/the team isn't used to the codebase and/or unit testing.

Title: Writing Tests for Existing Code

Body:
Suppose one had a relatively large program (say 900k SLOC in C#), all commented/documented thoroughly, well organized and working well. The entire code base was written by a single senior developer who no longer with the company. All the code is testable as is and IoC is used throughout--except for some strange reason they did not write any unit tests. Now, your company wants to branch the code and wants unit tests added to detect when changes break the core functionality.

Is adding tests a good idea?

If so, how would one even start on something like this?

EDIT

OK, so I had not expected answers making good arguments for opposite conclusions. The issue may be out of my hands anyway. I've read through the "duplicate questions" as well and the general consensus is that "writing tests is good"...yeah, but not too helpful in this particular case.

I don't think I am alone here in contemplating writing tests for a legacy system. I'm going to keep metrics on how much time is spent and how many times the new tests catch problems (and how many times they don't). I'll come back and update this a year or so from now with my results.

CONCLUSION

So it turns out that it is basically impossible to just add unit test to existing code with any semblance of orthodoxy. Once the code is working you obviously cannot red-light/green-light your tests, it usually not clear which behaviors are important to test, not clear where to begin and certainly not clear when you are finished. Really even asking this question misses the main point of writing tests in the first place. In the majority of cases I found it actually easier to re-write the code using TDD than to decipher the intended functions and  retroactively add in unit tests. When fixing a problem or adding a new feature it is a different story, and I believe that this is the time to add unit tests (as some pointed out below). Eventually most code gets rewritten, often sooner than you'd expect--taking this approach I've been able to add test coverage to a surprisingly large chunk of the existing codebase.


问:
Will a MQ topic persist messages when one of the consumers is down
If I have a websphere MQ topic and 3 listeners have subscribed to the Topic. One listener is down when a message comes in the Topic. Other listeners consume the message. When the listener comes back up, will the message still be there? My gut feel is no, but i cannot say for sure.</p>

答: It is configurable, not by the topic but by subscriber.  If you subscribe to a topic as a durable subscriber(all you have to do is set a flag and give a unique name) then you get all messages.  Don't forget you have to unsubscribe when done or you have issues where the queue hold on to data forever and explodes. Relevant documentation.</p>

ContentLicense: CC BY-SA 3.0


问:
Writing Tests for Existing Code
Suppose one had a relatively large program (say 900k SLOC in C#), all commented/documented thoroughly, well organized and working well. The entire code base was written by a single senior developer who no longer with the company. All the code is testable as is and IoC is used throughout--except for some strange reason they did not write any unit tests. Now, your company wants to branch the code and wants unit tests added to detect when changes break the core functionality.

Is adding tests a good idea?

If so, how would one even start on something like this?

EDIT

OK, so I had not expected answers making good arguments for opposite conclusions. The issue may be out of my hands anyway. I've read through the "duplicate questions" as well and the general consensus is that "writing tests is good"...yeah, but not too helpful in this particular case.

I don't think I am alone here in contemplating writing tests for a legacy system. I'm going to keep metrics on how much time is spent and how many times the new tests catch problems (and how many times they don't). I'll come back and update this a year or so from now with my results.

CONCLUSION

So it turns out that it is basically impossible to just add unit test to existing code with any semblance of orthodoxy. Once the code is working you obviously cannot red-light/green-light your tests, it usually not clear which behaviors are important to test, not clear where to begin and certainly not clear when you are finished. Really even asking this question misses the main point of writing tests in the first place. In the majority of cases I found it actually easier to re-write the code using TDD than to decipher the intended functions and  retroactively add in unit tests. When fixing a problem or adding a new feature it is a different story, and I believe that this is the time to add unit tests (as some pointed out below). Eventually most code gets rewritten, often sooner than you'd expect--taking this approach I've been able to add test coverage to a surprisingly large chunk of the existing codebase.

答:
Yes, adding tests is definitely a good idea.

You say that it's well documented, and that puts you in a good position.  Try creating tests using that documentation as a guide, focussing on parts of the system that are either critical or subject to frequent change.

Initially, the sheer size of the codebase will probably seem overwhelming compared to the tiny amount of tests, but there's no big-bang approach, and making a start somewhere is more important than agonising about what the best approach will be.

I'd recommend Michael Feathers's book, Working Effectively with Legacy Code, for some good, detailed advice.

Title: Writing Tests for Existing Code


答:
While tests are a good idea, the intention was for the original coder to build them as he was building the application to capture his knowledge of how the code is supposed to work and what may break, which would have then been transferred to you.

In taking this approach, there is a high probability that you will be writing the tests that are least likely to break, and miss most of the edge cases that would have been discovered while building the application.

The problem is that most of the value will come from those 'gotchas' and less obvious situations.  Without those tests, the test suite loses virtually all of its effectiveness.  In addition, the company will have a false sense of security around their application, as it will not be significantly more regression proof.

Typically the way to handle this type of codebase is to write tests for new code and for the refactoring of old code until the legacy codebase is entirely refactored.

Also see.

Title: Writing Tests for Existing Code


问:
How much does the data model affect scalability and performance in so called "NoSQL" database?
You can't ever have a talk about so called "NoSQL" database without bringing the CAP theorem (Consistency, Availability, Partition : pick two). If you have to pick say, between MongoDB (Partition, Consistency) and CouchDB (Availability, Partition), the first you need to think about is "Do I need correct data or do I need access all the time?".

Those new database were made to be partitioned. But what If I don't? What if I just think its pretty cool to have a Key/Value, Column, Document, whatever database instead of a relational one, and just create one server instance and never shard it? In that case, wouldn't I have both availability and consistency? MongoDB wouldn't need to replicate anything, so it would be available. And CouchDB would have only one source of data, so it would be pretty consistent.

So that would mean that, in that case, MongoDB and CouchDB would have little difference in term of use case? Well, except of course performance, API, and al, but that would be more like choosing between PostgreSQL and MySQL than having two fundamentally different set of requirements.

Am I right here? Can I change a AP or CP database to an AC one by not creating more than one instance? Or is there something that I am missing?

Let's ask the question in reverse. What if I take a relational database, let say MySQL, and put it in a master/slaves configuration. I don't use ACID transactions If I require that any write be synchronized to the slave immediately, wouldn't that make it a CP database? And what if I synchronise it a some predefined intervals, and it doesn't matter if a client read stale data from a slave. Wouldn't that make it an AP database? Wouldn't that mean that if I give up ACID compliance I can still use the relationnal model for a partionned database?

In essence : is scalability about what you are ready to give up in the CAP theorem, more than the underlying data model? Does having Column, Document, Key Value, whatever give a boost to scalability over a relational model? Could we design a relational database designed from the ground up for partition tolerance? (Maybe it already exists). Could we make NoSQL database ACID compliant?

Sorry, its a lot of questions, but I have read a lot about NoSQL database recently and it seem to me that the biggest benefit of using them is that they fit better the "shape" of your data, rather than just the partition, CAP and giving up ACID compliance. After all, not everyone has so much data that they need to partition it. Is there a performance/scalability benefit to not using the relational model before I even think about partitioning my data?

答:
Does using a NoSQL database give a boost to scalability even if you aren't sharding data? Well lets define scalability. If you are referring to scalability as database/backend systems are concerned, in that you have vertical and horizontal scaling where horizontal scaling IS sharding data then this becomes a trivial question because then the answer would be absolutely no, because the only option you have left is vertical scaling (ie getting better hardware). If however you are talking about scalability in a broader sense referring to flexibility of the application, data value, etc... Then that is a completely different question with a number of answers. And like you mentioned it will often come down to what are you doing with the data and how it should be stored. Let me preface everything here with the statement that in most cases you should still be using a RDBMS and NoSQL should fill niche's. The following is a description of a specific instance where a NoSQL database would be more beneficial given specific requirements, and where we can ignore horizontal scaling.

Take for instance the idea that you are creating a cloud file storage system similar to google drive, dropbox, or box but instead of using an actual file system you decide that it would be more beneficial to you to virtualize the file system. Now you have a problem because your data model is suddenly the tree structure that is going to be horribly inefficient in a RDBMS (despite the fact that that is how everything is indexed). Because now you have a 3 column table with Name, User, and Parent. User is a foreign key to a users table and Parent is a self referencing nullable foreign key (nullable because the root directory could not have a parent). So what is the primary key? In this instance it is a compounded key across all columns... Which suddenly makes Parent our worst enemy.

Now instead think about how you would put that in some form of document store? Instead of fighting the data you are able to work with it and store it as the tree structure which will in turn decrease your development time as well as decrease maintenance costs. If you are decreasing costs doesn't that allow for a different kind of scalability? Plus in this instance you are creating the system correctly from the ground up which should give more flexibility to the application itself. Currently I am running this on a single server using MongoDB, which as you explained gives me an Available, Consistent model that is not much different than looking at the difference of MySQL or Postgres.

With MongoDB at least you can define how many servers you need to communicate with for a query to succeed so, yes you can convert it to a Consistent, Available model if you tell all queries to communicate with all server instances.

So I think that you have the right of it in that there is a big benefit in how the data is stored. There are things that don't fit well in a relational model that fit well in other models (as another brief example, Amazon uses some form of Graph Database for their recommendation engine for products).

Did I correctly understand your question?

Edit:
Will more data slow things down? Yes. How much will it slow things down? I honestly don't have enough experience to give an adequate answer.
Key/Value: Essentially a lookup table with large amounts of data associated with the lookup key. This is going to be really really fast because you can only look things up by the key.
Column/Family: Essentially a much more structured Key/Value store. You can only query based on the Column and so this should be really fast too.
Document: Aggregation style schema. Here you will want to aggregate similar data together. Denormalization is ok and expected for this kind of database. Depending on whether you are doing a lot of writes or reads you can organize your data so that it gets distributed across multiple shards to distribute the writes or the reads out (note that you can create a hybrid approach that is good for both but generally you need to choose optimization for one or the other)
Graph: The strength of this one is that it can create and tear down relationships really quickly. If you have some data where you have relationships that need to change between data (think some form of recommendation engine) then you should use this.

How you store data in any of these databases will influence performance (similar to the fact that if you store data incorrectly in some RDBMS it will influence performance). So to hopefully make this more clear: You need to know which database system you should use as well as how to store data in that database system.


问:
User story and Web Service
I am writing a user story and have a simple questions.

Consider, I am writing it for login module which calls internally a web service to authenticate the user and returns the data. How this can be converted into a  user story.

Should this be written as:

As a user,

I would like to login to the system and see the resultset.

and leave it or should I write validations/web service call as well as well.

As I understand, as a user I am not concerned with web service. So how should I write about this?

答:
As a user,
  I would like to login to the system and see the resultset.

This leaves out part of the story.  While the functionality is to login and see the resultset, why is that important?  The technical details of the web service aren't useful for the user as why would they care about the behind the scenes part of the service.  They just want it to work though you are missing why this is important.  Is the resultset so they can know what to do next?  Is it something for them to monitor how well is the system working?  There are tons of reasons for wanting to allow someone to log-in and you have the why part of things here.

"As a user, I am able to login to the system so that I can see the results of my sales this month to update my goals." would be something that captures that last part as if there is an alternative method that could be explored to get the same benefit.

Title: User story and Web Service


问:
Which is better for small bug fixes and small features - naming branches by ticket number or naming them by feature description?
I am in the middle of a disagreement (cordial, of course) with my lead about proper branch naming.  This applies to bug-fix and small feature branches, not long-running feature branches.  For long-running feature branches, we agree that human-readable names are better.  Here are the two points of view:

Mine:

Naming branches according to their team and ticket number is better.  It makes it easier to find them in our ticketing system, and shorter to type.  It also makes it easier to look up relevant branches in GIT when looking for historical information about a ticket.

Example:

```<code>team-name/12345
team-name/53719
</code>```

His:

Naming branches according to their feature/functionality.  It makes it easier to autocomplete, and is easier to remember than individual numbers.

Example:

```<code>team-name/fix-that-sql-bug
team-name/expand-http-parser
</code>```

One compromise I offered is this:

```<code>team-name/12345-fix-that-sql-bug
</code>```

But he does not like this, as it messes with GIT autocomplete.

If this is primarily opinion-based, please feel free to give me guidance on how this can be a better fit for SO - but I think that the reasons I gave can be amended/added to to give an empirical answer.

答:
In this case it seems like you could both compromise on a naming convention that has both the number and description:

Example:

team-name/(12345)-fix-that-sql-bug

team-name/(53719)-expand-http-parser

There really is no correct answer here, it is subjective depending on your point of view.

But if you both compromise you get the best of both worlds. I try and keep this in mind when we have similar disagreements on my team.

Edit:

To deal with the autocomplete issue you can put the numbered id in brackets, this way when you goes to type in a branch you always type ( to see the branches. From this list you will be able to see the numbered id and the description. Simply key in a couple numbers, tab, and it will


问:
What aspects make websites load faster?
I want to know what aspects in VPS hosting packages are related to performance for the website which will make it faster in loading for the end useres. And does RAM really matter?</p>

答:
There are hardware and software aspects:

Hardware: A starting point is going to be a single server with capable hardware - lots of RAM, multi-CPU system, high performance disks, multiple disks (separate OS, swap and data disks), multiple network cards (lots of incoming connections). Once you're beyond one large machine, you're going to be looking at multiple machines and load balancing solutions. Splitting out the database to a separate server with tons of RAM will help to a degree, but you'll soon need to add additional web servers.

Where to invest depends on your web application and its' usage profile - measure the performance, response, utilisation, etc, and scale accordingly.

After this, you're going to be looking to spread servers around the globe, perhaps leveraging Content Distribution Networks to capitalise on their setup first.

Software: Proper server caching settings for the pages you serve will make a massive difference to your users and your bandwidth costs. Modern web browsers can cache all the JS and images that your site has. If you can structure your site to be as cache-able as possible, with the least number of dynamically-built pages, the better.

Use the Developer Tools in your browser to explore a popular site and see how they achieve great response.

ContentLicense: CC BY-SA 2.5

Title: What aspects make websites load faster?


答:
It really doesn't matter as long as there is a consistent system that everyone agrees and understands.

I would say though that going by ticket number would keep things easier to remember for which branch to work on.  As they directly tie to the issue number rather than a description.  Doing only description does seem to make it more difficult to recall which specific issue it is supposed to be and could become long winded trying to avoid being vague.

team-name/bug-that-has-specific-circumstances-to-occur-and-takes-alot-to-describe

Title: Which is better for small bug fixes and small features - naming branches by ticket number or naming them by feature description?

Body:
I am in the middle of a disagreement (cordial, of course) with my lead about proper branch naming.  This applies to bug-fix and small feature branches, not long-running feature branches.  For long-running feature branches, we agree that human-readable names are better.  Here are the two points of view:

Mine:

Naming branches according to their team and ticket number is better.  It makes it easier to find them in our ticketing system, and shorter to type.  It also makes it easier to look up relevant branches in GIT when looking for historical information about a ticket.

Example:

```<code>team-name/12345
team-name/53719
</code>```

His:

Naming branches according to their feature/functionality.  It makes it easier to autocomplete, and is easier to remember than individual numbers.

Example:

```<code>team-name/fix-that-sql-bug
team-name/expand-http-parser
</code>```

One compromise I offered is this:

```<code>team-name/12345-fix-that-sql-bug
</code>```

But he does not like this, as it messes with GIT autocomplete.

If this is primarily opinion-based, please feel free to give me guidance on how this can be a better fit for SO - but I think that the reasons I gave can be amended/added to to give an empirical answer.


答:
Not all unit tests have equal benefit.  The benefit of a unit test comes when it fails.  The less likely it is to fail, the less beneficial it is.  New or recently changed code is more likely to contain bugs than rarely changed code that is well tested in production.  Therefore, unit tests on new or recently changed code are more likely to be more beneficial.

Not all unit tests have equal cost.  It's much easier to unit test trivial code you designed yourself today than complex code someone else designed a long time ago.  Also, testing during development usually saves development time.  On legacy code that cost savings is no longer available.

In an ideal world, you'd have all the time you need to unit test legacy code, but in the real world, at some point it stands to reason that the costs of adding unit tests to legacy code will outweigh the benefits.  The trick is to identify that point.  Your version control can help by showing you the most recently changed and most frequently changed code, and you can start by putting those under unit test.  Also, when you make changes going forward, put those changes and closely related code under unit test.

Following that method, eventually you will have pretty good coverage in the most beneficial areas.  If you instead spend months getting unit tests in place before resuming revenue-generating activities, that might be a desirable software maintenance decision, but it's a lousy business decision.

Title: Writing Tests for Existing Code


答:
it's a user story, not an implementation description, so it should focus only on what is to be done and what the benefit to the user is

As a user, I want to log in to the system, so that I can use it

The fact the the login operation currently returns some kind of result-set is irrelevant. Displaying the result-set is a separate story.

Title: User story and Web Service

Body:
I am writing a user story and have a simple questions.

Consider, I am writing it for login module which calls internally a web service to authenticate the user and returns the data. How this can be converted into a  user story.

Should this be written as:

As a user,

I would like to login to the system and see the resultset.

and leave it or should I write validations/web service call as well as well.

As I understand, as a user I am not concerned with web service. So how should I write about this?


问:
Tracking unpaid voluntary effort in open source projects
I am curious if any open source project actually tracked effort by a measure like self-reported hours put by unpaid voluntary coders. Do they? How? Why?

I don't care for cost estimations functions of SLOC or any other nonsense variable.

I suggest as answer an example with multiple contributors with a explanation of how and why they do that.

答: I doubt it.  Most software developers see time tracking activities as an evil necessary to functioning within a business.  It's extremely unlikely someone would do it when they don't have to.</p>


问:
When should we clean up old, no longer used GIT branches?
We have several bugfix branches that are starting to pile up.  They have been merged into master, and deployed to production.

Is there a good benchmark for when these branches should be cleaned up?

Should they ever be cleaned up, or is it good to have the historical data?

答: If it's merged into master, then deleting the branch won't delete the history.  You can always recreate the branch again later from the last commit before the merge.</p>


答:
The way git works is that a branch name is just a pointer to a specific commit. Once you merge a hotfix branch into master, your hotfix and master will point to exactly the same place in the commit tree.  As you make more commits on master, the hotfix branch will continue pointing at the same place while master will get updated.  Your history will always be preserved.

So basically the only reason to keep hotfix branch after a merge is if you plan to make any more changes to the same hotfix, which doesn't make much sense once you release the hotfix.  So you should feel perfectly safe deleting the branch after the merge.

One more thing you could do though, is once the hotfix is merged, create a tag on the master branch identifying that point as the hotfix release.

Title: When should we clean up old, no longer used GIT branches?

Body:
We have several bugfix branches that are starting to pile up.  They have been merged into master, and deployed to production.

Is there a good benchmark for when these branches should be cleaned up?

Should they ever be cleaned up, or is it good to have the historical data?

ContentLicense: CC BY-SA 4.0


答:
I often have ran into this situation, inherit a large code base without adequate or no test coverage, and now I am responsible for adding functionality, fixing bugs, etc.

My advice is to make sure and test what you add, and if you fix bugs or alter use cases in the current code, author tests then.  If you have to touch something, write tests at that point.

When this breaks down is when the existing code isn't structured well for unit testing, so you spend a lot of time refactoring so you can add tests for minor changes.

Title: Writing Tests for Existing Code


问:
Will high reputation in Stack Overflow help to get a good job?
In a post, Joel Spolsky mentioned that 5 digit Stack Overflow reputation can help you to earn a job paying $100k+. How much of that is real?

Would anyone like to share their success in getting a high paid job by virtue of their reputations on Stack Exchange sites?

I read somewhere that, a person got an interview offer from Google because a recruiter found his Stack Overflow reputation to be impressive. Anyone else with similar stories?

答:
Beyond landing a job, Stack Overflow can be of great benefit for independent developers and consultants.  By demonstrating knowledge in a specific area, along with the ability to communicate what you know, you can become very attractive to someone looking for a consultant in that area.

I've been contacted on several occasions by individuals and companies who were looking to hire me as a contractor, based solely on an answer or two that I had left on Stack Overflow.  I don't have the time to consult, so I can't say what those opportunities would have been worth.  A couple of them sounded interesting, though.

However, I've received a greater number of these requests from the non-Stack-Overflow content that I've put out there like my course, the open source projects I've worked on, and the guides that I've published on my blog.  All of this public information can help to identify you as an expert in an area.  Think of how many people use the phrase "he wrote the book on that" when speaking about an authority on a subject.

Overall, I look at Stack Overflow as a way of keeping my skills sharp, while at the same time giving back for all of the help I've received from others over the years.  I take time that I would have wasted on blogs, etc. and channel it here.  If it benefits my career, that's a great side effect.


问:
Is it necessary to map integers to bits in a genetic algorithm?
From what I've read, genetic algorithms are usually (always?) applied to chromosomes of bits. So if a problem involves maximizing a function that takes integer values, the integers are first encoded as bits.

Is this mapping necessary? It seems that you could take chromosomes of integers and apply crossover and mutation directly. So, if I have a function that takes 35 integer inputs, I can just apply the genetic operators to those integers, rather than on the 35xB bits (where B is the number of bits needed to encode an integer). Is there a reason this isn't done?

Perhaps the algorithm would suffer because the problem is defined more coarsely (that is, a problem can be defined with shorter chromosomes if we're not using bits), but I'm curious if anyone has a better answer.

答:
In GA all the chromosomes are usually represented as bit strings. You can have exceptions, but let´s forget them for now.

A chromosome is a possible solution to your problem, so if your solution is an integer number, it must have a binary representation to be worked by the genetic operations. Fortunately, integer numbers already have this binary representation (in fact, they *are natively bit strings), so you don´t have to do anything, just apply the operators over individuals of your population along the evolution process.

OwnerDisplayName: itzy


答:
Encoding the values as bits isn't necessary.  Look at 2d box car (don't waste too much time on it) for an example where the crossover is done on whole (float) values.  Entire 'assemblies' are crossed over, this adds to the recognizability of the source (part of the aesthetics of the game), but makes it it so that the variations between a given chromosome and its parents are more limited.

The reason to consider using bits instead of integers has to do with the range of data that the pool is seeded with.  Having 35 integers means that cross over can only occur on 35 values that are taken as whole values.  having 1120 bits (35 * 32 bit integers) gives a finer granularity (consider traditional 'genetic algorithms' work on ATCG - not entire 'values' of amino acids or proteins).

Having bits lets you have 'cleaner' mutations (flip a bit) and crossover that takes the top part of one integer and the bottom part of another.  Both of these things help increase the potential variety of offspring.

Consider the chromosome of just two bytes (we're doing bytes rather than integers to make it easier to see):

```<code>chromosome 1: 0xA3 0xB2
chromosome 2: 0x12 0x34
</code>```

Cross over between these two chromosomes can happen only at limited places.  You'll end up with:

```<code>chromosome 1': 0x12 0xB2
chromosome 2': 0xA3 0x34
</code>```

If this was done as bits instead:

```<code>chromosome 1: 1010001110110010
chromosome 2: 0001001000110100
                    ^   ^
</code>```

Now you can select the ^ sites for crossover giving:

```<code>chromosome 1': 1010001000110010
chromosome 2': 0001001110110100
                     ^   ^
</code>```

This provides a richer model with more possible variations between two chromosomes.

Title: Is it necessary to map integers to bits in a genetic algorithm?

Body:
From what I've read, genetic algorithms are usually (always?) applied to chromosomes of bits. So if a problem involves maximizing a function that takes integer values, the integers are first encoded as bits.

Is this mapping necessary? It seems that you could take chromosomes of integers and apply crossover and mutation directly. So, if I have a function that takes 35 integer inputs, I can just apply the genetic operators to those integers, rather than on the 35xB bits (where B is the number of bits needed to encode an integer). Is there a reason this isn't done?

Perhaps the algorithm would suffer because the problem is defined more coarsely (that is, a problem can be defined with shorter chromosomes if we're not using bits), but I'm curious if anyone has a better answer.

Body:
Encoding the values as bits isn't necessary.  Look at 2d box car (don't waste too much time on it) for an example where the crossover is done on whole (float) values.  Entire 'assemblies' are crossed over, this adds to the recognizability of the source (part of the aesthetics of the game), but makes it it so that the variations between a given chromosome and its parents are more limited.

The reason to consider using bits instead of integers has to do with the range of data that the pool is seeded with.  Having 35 integers means that cross over can only occur on 35 values that are taken as whole values.  having 1120 bits (35 * 32 bit integers) gives a finer granularity (consider traditional 'genetic algorithms' work on ATCG - not entire 'values' of amino acids or proteins).

Having bits lets you have 'cleaner' mutations (flip a bit) and crossover that takes the top part of one integer and the bottom part of another.  Both of these things help increase the potential variety of offspring.

Consider the chromosome of just two bytes (we're doing bytes rather than integers to make it easier to see):

chromosome 1: 0xA3 0xB2
chromosome 2: 0x12 0x34

Cross over between these two chromosomes can happen only at limited places.  You'll end up with:

chromosome 1': 0x12 0xB2
chromosome 2': 0xA3 0x34

If this was done as bits instead:

chromosome 1: 1010001110110010
chromosome 2: 0001001000110100
                    ^   ^

Now you can select the ^ sites for crossover giving:

chromosome 1': 1010001000110010
chromosome 2': 0001001110110100
                     ^   ^

This provides a richer model with more possible variations between two chromosomes.


答:
For the user story always stay focused on what really matters to the end user. They care about what your application does, not about how it is implemented. Are there any benefits of using a webservice for authentication from the user's perspective? It shouldn't be difficult to add a bit more detail (and acceptance criteria) to a user story like this. (What is an acceptable response time? What happens when I provide the wrong credentials? What kind of data is returned and what does that look like?)

However, if you and your team have decided to use a web service, it may be valuable to write that down somewhere as well, in a format that works for your team. (Which might be as simple as a short, written list of technical decisions).

Title: User story and Web Service


问:
When should I start using frameworks?
I'm little confused with the motive and need for frameworks. At what stage should I use frameworks? For example, if I want to use some CSS framework, should I learn CSS at pro or advanced level to use it?</p>

答:
You should start using frameworks when it becomes impractical not to for either reasons of complexity, time, or correctness. I will address each case separately:

Complexity: Let's say you've built some website and handcrafted all the CSS for it. It's a very complicated design and keeping track of it is a pain. That's okay for this website but what about the next one? If you had a framework, you could easily manage the bits you want to transfer over as they would be part of the framework and simplify the management of those components by setting them up for you.

Time: You have a client. They have a dog. They love their dog. They want a website about their dog last week because all their friends have dog websites and are vain and loud about it. Do you code all that CSS for their website from scratch? No, you use a framework to set it up, fill in the bits that need to be filled in, get your pay check for a job well done and move on.

Correctness: You have massive codebase that you built all by your lonesome. What if it has a bug in it? It probably has a good many in it. While frameworks are not bug-free, they are less likely to have bugs since they are either open-source and thus have many pairs of eyes looking for bugs or they are built by a company with (ideally) an interest in using the money it makes from selling the framework to fix those bugs that do occur.

All that being said, if you want to really learn something that isn't a framework unto itself, use it without the framework. As far as needing to know something to use a framework, generally there's a simple test. When attempting to learn the framework, do you understand what's going on? If not, go back and learn the relevant bits of the base product and then come back and continue. Repeat until you've mastered the framework.

Title: When should I start using frameworks?


答:
Let's consider the purpose of a framework:

Reusing code which others have built and tested.

Assisting with organizing code for modularity and teamwork.

Helping enforce platform-specific best practices and rules (e.g. cross-browser support).

Future enhancements "for free" from the framework maintainers.

For any project of medium to high complexity you will usually want those things.  Before using a framework you should have a solid understanding of the underlying technology.  Let's take your example of CSS. Get to know it well, then see how a framework such as Bootstrap or a utility such as SASS might save you time and effort.

Title: When should I start using frameworks?

Body: I'm little confused with the motive and need for frameworks. At what stage should I use frameworks? For example, if I want to use some CSS framework, should I learn CSS at pro or advanced level to use it?</p>


问:
Programming structural question, controlling lots of states and specific transitions between states case by case
This is a theory question for me just to try and write better code. I am pretty new so hopefully I am using terms like state in the correct way.

How I should be thinking about this problem? I am coding something that sort of works but whatever I do it seems complicated, hard to understand and hard to modify.

I'm playing a video clip with an id, I also want it to be able to dynamically switch to a thumbnail view of that video clip. I want to be able to set this video blank also and shut down any connections that are not needed, I'm trying to do all of this efficiently - not reconnecting to the server when I don't need to etc.

so I have-

connected -> on/off

video id -> a string

mode -> streaming video/thumbnail view/disabled

Hopefully you will see my dilemma with some examples-

Case 1.The user starts from scratch and wants to view a thumbnail of video "a"

-connect to server for "a", send request for thumbnail, turn thumbnail object on.

Case 2.The user starts is viewing a thumbnail of video "a" and wants to start watching a stream of video "b"

-compare strings "a" and "b"- see they are different. hide thumbnail object and clear its buffer. Disconnect from server for "a" and connect to "b" server. start streaming video, turn video object on, request thumbnail from the server so its loaded in memory in case the user wants to switch to thumbnail mode.

Case 3.the user is watching a stream of "b" and wants to view a thumbnail of "b"

-compare strings "b" and "b"- see they are the same and stay connected to the server, hide video object and stop streaming, turn thumbnail object on, send another request to server for the thumbnail...

All these options are doing my head in, I want it to choose the most efficient way to get from one state to another but all the different options are confusing me. I guess Im looking for help about whats the best way to structure this, because what Im doing at the moment seems very confusing, i end up with huge tree of nested ifs of lots of specific cases and then patching up where it goes wrong.

```<code>if (connected but used to be disconnected) {
    if (mode streaming but used to be thumbnail) {...
    if (mode streaming but used to be streaming) {...

if (connected but used to be connected) {....

if (disconnected but used to be connected) {....

if (disconnected but used to be disconnected) {...
</code>```

it goes on forever..

答:
Martin Wickman is correct in suggesting a state-machine.

It looks like you might benefit from nesting some of your state information (e.g. connection status) -- nesting means that your overarching states will have internal state-machines of their own -- in which case you might want to check out UML state machines.

UML state machines are more complex than regular finite state machines and, in my experience, fairly cumbersome to implement by hand. As an alternative, to clean up what you have now and move towards a more OOPish implementation, you could try this:

Split things into three or four orthogonal functions:

A next-state determination function -- this would take the machine's current state and its current input and determine what the next machine state should be

A transition output function -- this would look at what state transition was being taken, along with the input, and react to it (comparable to a Mealy machine's output)

A state output function -- this would look at the current state and output for it (comparable to a Moore machine's output)

A transition function -- this would call the other three functions and set the machine's state

Example:

```<code>func getNextState(input, curr_state)
{
    if (curr_state == STATE_FOO)
    {
        if (input == fizz)
            return STATE_FIZZ
        else
            return STATE_BUZZ
    }
    else if (curr_state == STATE_BAR)
    {
        ...
    }
    else
    {
        return STATE_DONE
    }
}

func outputForTransition(input, prev_state, next_state)
{
    if (prev_state == STATE_FIZZ && next_state == STATE_BUZZ)
    {
        print "Fizz Buzz"
    }
    else if (prev_state == STATE_FOO && next_state == STATE_BAR)
    {
        ...
    }
}

func outputForState(curr_state)
{
    switch(curr_state)
    {
        case STATE_FOO:
            foo()
        case STATE_BAR:
            bar()
        case STATE_FIZZ:
            fizz()
        case STATE_BUZZ:
            buzz()
    }
}

func transitionStates(input)
{
    prev_state = curr_state
    curr_state = getNextState(input, curr_state)

    // you could use either or both output functions:
    outputForTransition(input, prev_state, curr_state)
    outputForState(curr_state)
}
</code>```

It may still look somewhat messy, but believe me it clears things up quite a bit.

(And obviously you'd want to implement the above after having come up with your state diagram.)

Body:
Martin Wickman is correct in suggesting a state-machine.

It looks like you might benefit from nesting some of your state information (e.g. connection status) -- nesting means that your overarching states will have internal state-machines of their own -- in which case you might want to check out UML state machines.

UML state machines are more complex than regular finite state machines and, in my experience, fairly cumbersome to implement by hand. As an alternative, to clean up what you have now and move towards a more OOPish implementation, you could try this:

Split things into three or four orthogonal functions:

A next-state determination function -- this would take the machine's current state and its current input and determine what the next machine state should be

A transition output function -- this would look at what state transition was being taken, along with the input, and react to it (comparable to a Mealy machine's output)

A state output function -- this would look at the current state and output for it (comparable to a Moore machine's output)

A transition function -- this would call the other three functions and set the machine's state

Example:

func getNextState(input, curr_state)
{
    if (curr_state == STATE_FOO)
    {
        if (input == fizz)
            return STATE_FIZZ
        else
            return STATE_BUZZ
    }
    else if (curr_state == STATE_BAR)
    {
        ...
    }
    else
    {
        return STATE_DONE
    }
}

func outputForTransition(input, prev_state, next_state)
{
    if (prev_state == STATE_FIZZ && next_state == STATE_BUZZ)
    {
        print "Fizz Buzz"
    }
    else if (prev_state == STATE_FOO && next_state == STATE_BAR)
    {
        ...
    }
}

func outputForState(curr_state)
{
    switch(curr_state)
    {
        case STATE_FOO:
            foo()
        case STATE_BAR:
            bar()
        case STATE_FIZZ:
            fizz()
        case STATE_BUZZ:
            buzz()
    }
}

func transitionStates(input)
{
    prev_state = curr_state
    curr_state = getNextState(input, curr_state)

    // you could use either or both output functions:
    outputForTransition(input, prev_state, curr_state)
    outputForState(curr_state)
}

It may still look somewhat messy, but believe me it clears things up quite a bit.

(And obviously you'd want to implement the above after having come up with your state diagram.)


问:
Solving which bugs will give greatest cost benefit
I wanted to get an idea of categorizing bugs based on how easy is it to solve and how much benefit it will give me. for e.g., if there is a bug which will take say an hour (double file close etc.) to solve vs another which takes a day (segmentation fault). But if solving the first bug is not very important, then I'll probably work on the second one.

Is there a practical method or an approach to categorize bugs based on cost-benefit or similar metric?

Let's say it is possible to categorize bugs based on bug characteristics e.g. security vulnerability, memory error, logic error etc. On the other dimension there could be parameters like difficulty (easy, medium, hard). Are there other dimensions I should be looking for. To simplify things, I can assume two things:

Every programmer in the team is equally capable of solving any bug

There is no deadline

答:
Another consideration might be the type of test or testing organization that uncovers the bug, when trying to determine the impact and cost of the bug and fix. Unit or functional testing may point to something in the design that needs to be changed, and thus correcting early would be easier and less costly than later. System or integration testing may point to something that affects a wider variety of customers. And Standards testing, while often something non-critical to a large subset of customers, may lead to a loss of certification if not corrected and have a negative impact on the business.

That said, just because a particular test organization has a test fail shouldn't automatically make a bug "critical." For example, there might be a temptation to say something like "all system tests must pass before shipping, thus any system test that fails automatically results in a critical/high-severity bug." Hopefully no organization would make that statement (good test exit criteria is a different discussion), but the point is that the "severity" of bug should be judged on its impact to the customer, product, or company image rather than where or when it is uncovered.

One possible way to address that is to make a distinction between "severity" and "urgency." For example, as the release date nears there can be time pressure to determine if an apparently lower-severity bug might affect a large subset of customers, giving the bug a greater "urgency" and elevating work on that bug above (some) others at least until that determination can be made. A proper balance between the two, along with experience and good judgement, would help direct where time and effort is spent.


问:
How much time can I spend learning at work?
I've been working as a software developer for about 2 years by now. It seems obvious that in a field so rapidly evolving as software development, you need to spend time on learning new technologies, frameworks, etc.

I always thought I could take it for granted that if I need to learn something to solve a problem at work, I am free to spend the hours needed learning that at work as well. However, I have had discussions about this topic with various colleagues, and we were holding very different opinions, apparently on the span of two extremes:

Your employer pays you for knowing stuff. You got hired for having knowledge on the field of expertise required for doing this job, and if the field emerges so that you need to aquire more knowledge, it is only natural that you do so in your free time.

And the other extreme being

Whatever makes me more productive at work in the long run, is worth spending the time on at work, because the employer will eventually profit from that. This does of course apply to learning new techniques, but also, e.g. learning VIM to get faster, etc.

But even when discussing how long to spend time on something with the guys tending to the second extreme, we were of vastly different opinions, ranging from "an hour every now and then is okay" to "however long it takes".

Does your workplace encourage learning new skills and if so what processes do they have to encourage this? How much time do you spend learning new things (and not writing production code) during your day as a programmer?

答:
In the book The Clean Coder, the author, Robert C. Martin, says that you need around 20 hours per week to practice and acquire new skills. This is on top of your job and it's your responsibility to train yourself up. Why? Because most workplaces will not train you for your next position or even your current position. Most workplaces aren't equipped for that.

As this blog post says,

It is your own responsibility to keep training yourself by reading, practicing and learning - actually anything that helps you grow as a software developer and helps you get on board with the constant industry changes.

An important note is this should be done on your own time, not on your employer's. It is not their responsibility to train you, but your own. However, do not mistake this with you should be doing your job during this time. This time should be dedicated for you and your own enjoyment only. You should do anything that interests you.


问:
How do I manage the technical debate over WCF vs. Web API?
I'm managing a team of like 15 developers now, and we are stuck at a point on choosing the technology, where the team is broken into two completely opposite teams, debating over usage of WCF vs. Web API.

Team A which supports usage of Web API, brings forward these reasons:

Web API is just the modern way of writing services (Wikipedia)

WCF is an overhead for HTTP. It's a solution for TCP, and Net Pipes, and other protocols

WCF models are not POCO, because of [DataContract] & [DataMember] and those attributes

SOAP is not as readable and handy as JSON

SOAP is an overhead for network compared to JSON (transport over HTTP)

No method overloading

Team B which supports the usage of WCF, says:

WCF supports multiple protocols (via configuration)

WCF supports distributed transactions

Many good examples and success stories exist for WCF (while Web API is still young)

Duplex is excellent for two-way communication

This debate is continuing, and I don't know what to do now. Personally, I think that we should use a tool only for its right place of usage. In other words, we'd better use Web API, if we want to expose a service over HTTP, but use WCF when it comes to TCP and Duplex.

By searching the Internet, we can't get to a solid result. Many posts exist for supporting WCF, but on the contrary we also find people complaint about it. I know that the nature of this question might sound arguable, but we need some good hints to decide. We're stuck at a point where choosing a technology by chance might make us regret it later. We want to choose with open eyes.

Our usage would be mostly for web, and we would expose our services over HTTP. In some cases (say 5 to 10 percent) we might need distributed transactions though.

What should I do now? How do I manage this debate in a constructive way?

答:
Team management aside, you do not choose one over the other. You need to look at the purpose of each web service and use the appropriate technology for the specific part of the application. It's like banning store procedures when the team is using entity framework.

Our usage would be mostly for web, and we would expose our services
  over HTTP. In some cases (say 5 to 10 percent) we might need
  distributed transactions though.

Then you write those 5~10% web services in WCF. If the service is to be referenced internally in other projects, there's no debate. The advantage of the ability to import WCF contract to create the client proxy is NOT open for discussion. It takes the whole integration, efficiency, and type safety to a whole new level.

You write what's to be used for public api(maybe) / Ajax requests in Asp.net web api.

If it's just page specific ajax call, you can just use Asp.Net MVC.

Don't choose, embrace them all. WCF and Asp.net web api serve different purposes. No one says you can't have apple and orange both in your fruit salad. Trying to pick one over the other and shoving it down every single scenario is just sheer laziness.


问:
What must be done to allow a development team to minimize difficulties as new team members are added?
I work at a small Web Dev firm, and have been handling all the PHP/MySQL/etc. for a while. I'm looking at improving our practices to allow for easier collaboration as we grow. Some things I have in mind are:

Implementing a versioning system (source control)

Coding standards for the team (unless
mandated by a certain framework,
etc.)

Enforcing a common directory
structure for our Desktops (for
backup purposes, etc.)

Web-based
task/project/time/file/password/contact
management and collaboration
app(we've tried a bunch; I may just
create one)

What do more experienced developers view as necessary first steps in this area? Do you recommend any books? One thing to consider is that the bulk of our daily tasks involve maintenance and adding minor functionality rather than new projects, and the team size will be between 3 and 5.

I just found a related question about teams that will be expanding from a solo developer.

答:
Implementing a versioning system

If this means source control and you're not doing it, then do it NOW. Don't wait, don't even finish reading this. Do it.
If you mean coming up with some fancy pants scheme for numbering your releases then simple is best. Try this...

X.00 = major release that may break compatibility or you want to charge money for.

0.X0 = new features that don't break things. Free update.

0.0X = bug fixes.

Coding standards for the team (unless mandated by a certain framework, etc.)

Again, keep it simple. One A4 page is more than enough.

Enforcing a common directory structure for our Desktops (for backup purposes, etc.)

Your source control system will do this for you. When a dev does a check out they will get the directory structure. Your VCS is a backup, just make sure you backup the machine with the VCS on it. Anything not in VCS isn't important and doesn't need backing up.

Web-based task/project/time/file/password/contact management and collaboration app(we've tried a bunch; I may just create one)

Don't waste your time building one. The free tools on the net are good enough.

In addition you want...

a continuous integration system. When a dev checks something in they need to know that they haven't broken anything, ie. it builds in a clean environment, they haven't forgotten to add new dependencies, run tests to show they haven't caused a regression, the system deploys to a clean environment.

a deployment system that includes roll back. You should be able to deploy a new system or push an update with a single command and back out a broken version just as simply.


问:
Java - Why do we call an array a "vector"?
I am reading a book on Java Programming, and want to confirm I understand the  definition of the word "vector".  Wikipedia says vector is "A one-dimensional array", source http://en.wikipedia.org/wiki/Vector.

Wouldnt it be simpler to call the array simply an array?  Is there any reason we need to use such fancy language as "vector"?  Is there a difference between an array and a vector?

Source: Cracking the Coding Interview, 4th Edition, by Gayle McDowell, page 47.

FAQ

Q - Why didnt you post this on english.stackexchange.com?

A - Because I think only computer science oriented people will have a good answer.

答:
Usually, vector and array are the same thing and are used interchangeably when programming. That is in most places, so you shouldn't worry much about it most of the time.

That said, language is imprecise and we sometimes have words that have different meanings in different contexts that end up meaning the same thing, or one word having two or more different meanings.

In C an array is a series of data elements of the same type that are stored in memory contiguously. Java inherited that meaning. It's not the same as a List or a Vector, as arrays are more basic than those.

A vector is a mathematical construct defined as an object that can be added to another object of the same type, or be multiplied by any real (or complex) number resulting in another vector of the same type. It also has a few other properties that are very useful.

A vector has dimension. It's the minimum number of different vectors that have to be combined to get every possible vector of that type. Velocity and acceleration are 3-dimensional vectors because space has 3 base directions and by adding multiples of those three base directions you can get any position in space. Position in a plane is a 2-dimensional vector, and individual numbers are 1-dimensional vectors.

One way to represent a vector of dimension n is by using an array of n elements each one representing how much of each base vector you have to add to get to your vector.

Since you can represent a vector using an arra of elements, with time, the two concepts were equated. So, in many places, they simply are the same thing and in some languages arrays are called vectors.

Another case where one word has two different meanings is, for instance, dimension. The wikipedia definition of a vector as a 1-dimensional array is an example. You are not talking of vector dimension here. You are talking about the computer representation of the data structure. A 3-Dimensional vector can be represented by a "1-dimensional" array of size 3. 3 numbers in line. A 3x3 matrix can be represented by a "2-dimensional" array, which is what programmers call an array of arrays. Yet a 3x3 matrix is also a mathematical vector of dimension 9 (since it has all the properties of a vector) and has 9 numbers. Confusing, huh?

Anyway, I think the answer is simply: don't worry. It all depends on context. The two words have different origins, but in the context of data structures, when they say vector they mean exactly array.


问:
How should we handle extra cosmetic features in Scrum sprints?
I was reading the Scrum documents and it says that the tasks in Sprint should be "potentially shippable".

I am confused by what this means. Suppose in Sprint 1 the goal was, "user registration form".

How much detail do I need to add for something to be ready to ship? For example:

I can show the simple form with fields without any fancy styling and mark them as done

I can just do client side validation as mark as done but server side is also the option or both

I can also add some jQuery fancy tool tips, hover overs, captcha, colors, labels for the form

Then there is whole lot of styling about how to show error messages on screen

I can do endlessly on one topic. So how do we divide that and when I can think of that as shipping ready.

Or do I need to write each smallest possible thing like showing errors, popup or light box text as subtasks and put them as sprint. This would lead to 1000s of tasks for whole project.

I mean then again if some work for Internet Explorer and some for Firefox then again do I need to divide those as tasks as well. Time has to be spent on them and when manager asks me what you did in that time, I won't have any tasks to tell but in reality they all are part of User registration

答:
In my understanding, each story should be "done-able" and "shippable" to the extent that it's ready for consumption by someone, not necessarily the end-user. So, your story may deliver some functionality that can then be delivered to the product owner, who can choose to have it released to end-users or to iterate over the feature again.

That said, you're not precluded from including styling in the "As an end-user, I will be able to register" story. On our team, we try to make every story as small as possible to maintain higher predictability and better ensure we're able to deliver what we promise. If we have a design ready up-front and think it's trivial to apply, it's included in the story. If we think there may be some iteration on the design, that's a separate story -- possibly multiple.


答:
If the cosmetic features are part of the feature, they should probably be done as part of the story. The point is, once you say a story is done, you shouldn't have to do any more coding on a particular feature. Though, ultimately this is decided by the product owner -- they may want the cosmetic features or they may not. This should be spelled out in the acceptance criteria.

That doesn't necessarily mean it's ready for the end user to use, it just means it's ready for someone. That someone could be a tester, or another team such as the back-end team.

If you are asking this as a developer, the answer becomes "you know, because the product owner will tell you whether they want the cosmetic features or not".

If you are asking this as a product owner, you simply have to decide whether you want to break the feature down into more than one story. There is no requirement, other than it must satisfy you, as a means to satisfy your customer.

Remember: the goal isn't to adhere strictly to scrum. The goal is to deliver high quality software to the end user. Use that as a guide when struggling with questions like this. Will adding the cosmetics in the same story as the purely functional parts help you to deliver quality code to your customer? Or, will breaking that into two stories help? Either the answer is clear, or it doesn't matter and you can do whatever works for your team.

Title: How should we handle extra cosmetic features in Scrum sprints?

Body:
I was reading the Scrum documents and it says that the tasks in Sprint should be "potentially shippable".

I am confused by what this means. Suppose in Sprint 1 the goal was, "user registration form".

How much detail do I need to add for something to be ready to ship? For example:

I can show the simple form with fields without any fancy styling and mark them as done

I can just do client side validation as mark as done but server side is also the option or both

I can also add some jQuery fancy tool tips, hover overs, captcha, colors, labels for the form

Then there is whole lot of styling about how to show error messages on screen

I can do endlessly on one topic. So how do we divide that and when I can think of that as shipping ready.

Or do I need to write each smallest possible thing like showing errors, popup or light box text as subtasks and put them as sprint. This would lead to 1000s of tasks for whole project.

I mean then again if some work for Internet Explorer and some for Firefox then again do I need to divide those as tasks as well. Time has to be spent on them and when manager asks me what you did in that time, I won't have any tasks to tell but in reality they all are part of User registration


问:
Design Pattern dilemma. Strategy seems wrong?
I would like some help/advice on a design pattern or similar I could use for my problem.

I have some shared functionality in my code and I use the Strategy pattern at present. I have a base class
named "ProjectSectionBase" and from here I have 2 derived classes, "ProjectSectionStandard" and "ProjectSectionSuperior".
Now the problem is that "ProjectSectionSuperior" has a lot of extra functionality than "ProjectSectionStandard" and I'm
finding that throughout my code i am calling methods like this:

DirectCast(_projectSection, ProjectSectionSuperior).DoSuperiorStuff

And I am also wrapping IF statements such as IF typeof(_projectSectio) is superior then.

It just feels like bad class design. Both standard and superior share a lot of common functionality but then Superior
has so much more functionality. Any advice would be greatly appreciated.

答: One solution would be that all functions are implemented as virtual in base class, and have empty bodies, and only superior class overrides them with meaningful code. One special function is bool IsSuperior() that returns false in base class and overridden in superior it returns true. All this just cleans the code a little bit. Maybe cleaning the code is just what you need, as code does not have to be perfect and idealistic, but needs to get the job done.

OwnerDisplayName: Ahmad Zandi

OwnerDisplayName: Dialecticus


答:
This is a common problem.  Usually the problem is that your class has too many responsibilities.  Consider:

```<code>public interface IProjectSection
{
    void DoSectionStuff()
}

public class SimpleProjectSection : IProjectSection
{
    public void DoSectionStuff(){/*simple stuff here*/}
}

public class SuperiorProjectSection: IProjectSection
{
    public void DoSectionStuff(){/*complex stuff here*/}
    public void DoSuperiorSectionStuff(){/*additional superior stuff here*/}
}

public class ProjectSectionUser
{
    public void DoSomeProjectSectionThings(IProjectSection section)
    {
        section.DoSectionStuff();
        var superior = section as SuperiorProectSection;
        if(superior != null)
            superior.DoSuperiorSectionStuff();
    }
}
</code>```

This is actually nicer to represent as two strategy patterns, separating the DoSuperiorSectionStuff() into another interface, like so:

```<code>public interface IProjectSection
{
    void DoSectionStuff();
}

public interface ISuperiorProjectSection
{
    void DoSuperiorSectionStuff();
}

public class SimpleProjectSection : IProjectSection
{
    public void DoSectionStuff(){/*simple stuff here*/}
}

public class SuperiorProjectSection: IProjectSection, ISuperiorProjectSection
{
    public void DoSectionStuff(){/*complex stuff here*/}
    public void DoSuperiorSectionStuff(){/*additional superior stuff here*/}
}

public class ProjectSectionUser
{
    public void DoSomeProjectSectionThings(IProjectSection section, ISuperiorProjectSection superior)
    {
        section.DoSectionStuff();
        superior.DoSuperiorSectionStuff();
    }
}
</code>```

Then the two ways to use it are:

```<code>...
var superiorSection = new SuperiorProjectSection();
projectSectionUser.DoSomeProjectSectionThings(superiorSection, superiorsection);
...
</code>```

or

```<code>...
var superiorSection = new NullSuperiorProjectSection();
var section = new SimpleProjectSection();
projectSectionUser.DoSomeProjectSectionThings(section, superiorsection);
...
</code>```

where NullSuperiorProjectSection is defined as

```<code>public class NullSuperiorProjectSection : ISuperiorProjectSection
{
    public void DoSuperiorSectionStuff(){/*do nothing*/}
}
</code>```

Note: normally I would implement these two interfaces in separate classes.  In this case, I don't know enough about your code to make a decent example that way, so i left it like this.  Split separate responsibilities into separate classes where it makes sense; it increases your codes flexibility over time.

Title: Design Pattern dilemma. Strategy seems wrong?

Body:
I would like some help/advice on a design pattern or similar I could use for my problem.

I have some shared functionality in my code and I use the Strategy pattern at present. I have a base class
named "ProjectSectionBase" and from here I have 2 derived classes, "ProjectSectionStandard" and "ProjectSectionSuperior".
Now the problem is that "ProjectSectionSuperior" has a lot of extra functionality than "ProjectSectionStandard" and I'm
finding that throughout my code i am calling methods like this:

DirectCast(_projectSection, ProjectSectionSuperior).DoSuperiorStuff

And I am also wrapping IF statements such as IF typeof(_projectSectio) is superior then.

It just feels like bad class design. Both standard and superior share a lot of common functionality but then Superior
has so much more functionality. Any advice would be greatly appreciated.

Body:
This is a common problem.  Usually the problem is that your class has too many responsibilities.  Consider:

public interface IProjectSection
{
    void DoSectionStuff()
}

public class SimpleProjectSection : IProjectSection
{
    public void DoSectionStuff(){/*simple stuff here*/}
}

public class SuperiorProjectSection: IProjectSection
{
    public void DoSectionStuff(){/*complex stuff here*/}
    public void DoSuperiorSectionStuff(){/*additional superior stuff here*/}
}

public class ProjectSectionUser
{
    public void DoSomeProjectSectionThings(IProjectSection section)
    {
        section.DoSectionStuff();
        var superior = section as SuperiorProectSection;
        if(superior != null)
            superior.DoSuperiorSectionStuff();
    }
}

This is actually nicer to represent as two strategy patterns, separating the DoSuperiorSectionStuff() into another interface, like so:

public interface IProjectSection
{
    void DoSectionStuff();
}

public interface ISuperiorProjectSection
{
    void DoSuperiorSectionStuff();
}

public class SimpleProjectSection : IProjectSection
{
    public void DoSectionStuff(){/*simple stuff here*/}
}

public class SuperiorProjectSection: IProjectSection, ISuperiorProjectSection
{
    public void DoSectionStuff(){/*complex stuff here*/}
    public void DoSuperiorSectionStuff(){/*additional superior stuff here*/}
}

public class ProjectSectionUser
{
    public void DoSomeProjectSectionThings(IProjectSection section, ISuperiorProjectSection superior)
    {
        section.DoSectionStuff();
        superior.DoSuperiorSectionStuff();
    }
}

Then the two ways to use it are:

...
var superiorSection = new SuperiorProjectSection();
projectSectionUser.DoSomeProjectSectionThings(superiorSection, superiorsection);
...

or

...
var superiorSection = new NullSuperiorProjectSection();
var section = new SimpleProjectSection();
projectSectionUser.DoSomeProjectSectionThings(section, superiorsection);
...

where NullSuperiorProjectSection is defined as

public class NullSuperiorProjectSection : ISuperiorProjectSection
{
    public void DoSuperiorSectionStuff(){/*do nothing*/}
}

Note: normally I would implement these two interfaces in separate classes.  In this case, I don't know enough about your code to make a decent example that way, so i left it like this.  Split separate responsibilities into separate classes where it makes sense; it increases your codes flexibility over time.

OwnerDisplayName: tallseth


问:
Are Protected Auto-Cast Methods Ok?
I often have superclasses that contain a more abstracted form of a class as a member variable than my subclasses need. I find my code littered ((ClassName)variableName).methodName(). Is the best way to solve this to create a protected/private method called something like getVariableNameAsClass()? It's not much shorter in letters, but an IDE can do that much faster than maneuvering around with the keys to add in parenthesis. Or is there a better solution?

The reason I need to cast is because all of the subclasses of Line use an Output class, so I put the getters and setters that relate to the Output class in the base class. The issue is that an AudioLine uses and AudioOutput, and needs to define additional methods that use the more specific features.

So, here's my entire class design: I have a Line class with two subclasses, VideoLine and AudioLine, which delegate some of their functionality to a internal Output class. Output class has a AudioOutput and VideoOutput subclass. I defined all the functionality for the Line class that relies only on methods from the Output class inside the Line class, in accordance with DRY. Line's AudioLine and VideoLine both deligate additional functionality to AudioOutput and VideoOutput. Since they both set up the Output protected variable in their constructors (and therefor KNOW what subclass it contains), it seemed to make sense to caste it.

答:
Declaring a protected Output field on Line implies that any implementation of Output can be used with any implementation of Line. In your case this is not true, and the repeated casts are a good indicator that your class structure isn't as type-safe as it should be.

(Imagine if, due to a change or a bug, Line were to replace the VideoOutput required by VideoLine with an AudioOutput - you wouldn't know until it crashed)

Recommendation:

Move the output field to the sub-classes. Two options (I prefer the former, but consider both valid):

1) Make the Output-dependent methods abstract and provide utility methods to do the work

```<code>public abstract class Line{
    public abstract void doThing();
    protected final void doThing(Output output){
        ...
    }
}
public class VideoLine extends Line{
    private VideoOutput output;
    public void doThing(){
        super.doThing(output);
    }
}
</code>```

2) Provide a getOutput() method for the super-class to use.

```<code>public abstract class Line{
    public abstract Output getOutput();
    public void doThing(){
        Output output = getOutput();
        ...
    }
}
public class VideoLine extends Line{
    private VideoOutput output;
    protected Output getOutput(){
        return output;
    }
}
</code>```

Title: Are Protected Auto-Cast Methods Ok?

Body:
Declaring a protected Output field on Line implies that any implementation of Output can be used with any implementation of Line. In your case this is not true, and the repeated casts are a good indicator that your class structure isn't as type-safe as it should be.

(Imagine if, due to a change or a bug, Line were to replace the VideoOutput required by VideoLine with an AudioOutput - you wouldn't know until it crashed)

Recommendation:

Move the output field to the sub-classes. Two options (I prefer the former, but consider both valid):

1) Make the Output-dependent methods abstract and provide utility methods to do the work

public abstract class Line{
    public abstract void doThing();
    protected final void doThing(Output output){
        ...
    }
}
public class VideoLine extends Line{
    private VideoOutput output;
    public void doThing(){
        super.doThing(output);
    }
}

2) Provide a getOutput() method for the super-class to use.

public abstract class Line{
    public abstract Output getOutput();
    public void doThing(){
        Output output = getOutput();
        ...
    }
}
public class VideoLine extends Line{
    private VideoOutput output;
    protected Output getOutput(){
        return output;
    }
}


答: I think the term "vector" came from C++'s std::vector. It appeared before Java and C#.</p>

Title: Java - Why do we call an array a "vector"?

Body:
I am reading a book on Java Programming, and want to confirm I understand the  definition of the word "vector".  Wikipedia says vector is "A one-dimensional array", source http://en.wikipedia.org/wiki/Vector.

Wouldnt it be simpler to call the array simply an array?  Is there any reason we need to use such fancy language as "vector"?  Is there a difference between an array and a vector?

Source: Cracking the Coding Interview, 4th Edition, by Gayle McDowell, page 47.

FAQ

Q - Why didnt you post this on english.stackexchange.com?

A - Because I think only computer science oriented people will have a good answer.


问:
Ongoing confusion about ivars and properties in objective C
After almost 8 months being in ios programming, I am again confused about the right approach. Maybe it is not the language but some OOP principle I am confused about. I don't know..

I was trying C# a few years back. There were fields (private variables, private data in an object), there were getters and setters (methods which exposed something to the world), and properties which was THE exposed thing. I liked the elegance of the solution, for example
there could be a class that would have a property called DailyRevenue...a float...but there was no private variable called dailyRevenue, there was only a field - an array of single transaction revenues... and the getter for DailyRevenue property calculated the revenue transparently.
If somehow the internals of daily revenue calculation would change, it would not affect somebody who consumed my DailyRevenue property in any way, since he would be shielded from getter implementation.

I understood that sometimes there was, and sometimes there wasn't a 1-1 relationship between fields and properties. Depending on the requirements. It seemed ok in my opinion. And that properties are THE way to access the data in object.

I know the difference betweeen private, protected, and public keyword.

Now lets get to Objective-C.

On what factor should I base my decision about making something only an ivar or making it as a property? Is the mental model the same as I describe above? I know that ivars are "protected" by default, not "private" as in C#.. But thats ok I think, no big deal for my present level of understanding the whole iOS development. The point is ivars are not accessible from outside (given I don't make them public.. but I won't).

The thing that clouds my clear understanding is that I can have IBOutlets from ivars. Why am I seeing internal object data in the UI? *Why is it ok?* On the other hand, if I make an IBOutlet from property, and I do not make it readonly, anybody can change it. Is this ok too?

Let's say I have a ParseManager object. This object would use a built in Foundation framework class called NSXMLParser. Obviously my ParseManager will utilize this NSXMLParser's capabilities but will also do some additional work. Now my question is, who should initialize this NSXMLParser object and in which way should I make a reference to it from the ParseManager object, when there is a need to parse something.

A) the ParseManager

-1) in its default init method (possible here ivar  - or - ivar+ppty)

-2) with lazyloading in getter (required a ppty here)

B) Some other object - who will pass a reference to NSXMLParser object to the ParseManager object.

-1) in some custom initializer (initWithParser:(NSXMLPArser *)parser) when creating the ParseManager object..

A1 - the problem is, we create a parser and waste memory while it is not yet needed. However, we can be sure that all methods that are part of ParserManager object, can use the ivar safely, since it exists.
A2 - the problem is, the NSXMLParser is exposed to outside world, although it could be read-only. Would we want a parser to be exposed in some scenario?
B1 - this could maybe be useful when we would want to use more types of parsers.. I don't know...

I understand that architectural requirements and language is not the same. But clearly the two are in relation.

How to get out of that mess of my?

Please bear with me, I wasn't able to come up with a single ultimate question. And secondly, it's better to not scare me with some superadvanced newspeak that talks about some crazy internals (what the compiler does) and edge cases.

答:
Well, as mentioned above, there're so many questions :)

First of all, you should read more about properties and the whole Objective-C principles. In modern Objective-C style you should not use ivars at all. Only properties with some very rare exceptions. For private properties there's some unusual trick: class extensions. You definitely should read about categories and extensions since they are very powerful and useful mechanics. You just keep your private properties and all outlets in the class extension and no one will see it outside your class implementation. But you'll be still able to access your outlets in Interface Builder! It's amazing solution I use everyday and feels good.

Now for your question about ParserManager. As said above, it depends. If you don't want the actual NSXMLParser be accessed directly outside the manager (you'd better don't :)), just leave it inside and create in the manager. I'd recommend to create it in the init method because of quite heavy and continuos initialization of such huge object. Yes, you're waste some memory for it much earlier you actually need it, but you'll get much faster access when the time's come.


问:
How up-to-date is the Joel test?
I want to convince my partners that we should have a spec and that bugs should get fixed before writing new code. Should I refer to the Joel test? Do you think that the Joel test is up to date? I think that not having a spec is bad project management. Do you agree with the Joel test? Could you add something? It doesn't mention for instance Open Source. </p>

答:
I'm going to play the devil's advocate here and suggest that the Joel Test is not up to date.  It is too general.  As technology has matured, the questions should be more specific than when he wrote the test.

Specifications documents, at least big up-front spec documents are not necessary now that we have user stories and Agile development processes.  This question should be changed to "Is the level of documentation appropriate to the solutions being engineered?"  Smaller, tighter user stories that are delivered upon every two weeks are much more useful in most cases than a big up front document which describes the product in detail.  However, if you're building the next Mars Rover, you might want a detailed up front design document.  If you asked whether a company has design specs, I would not be surprised to hear a response of "not really, we use agile processes and user stories instead".

Secondly, the "daily builds" question should change to a question about continuous integration.  Unless you are building software that takes hours to build (which 99.99% of places will not be doing), the question should ask whether the company uses continuous integration.

Most of the Joel test really hasn't dated at all.  It's still a good way of getting an indication of the working environment.

Title: How up-to-date is the Joel test?


答:
What you describe is certainly not the Strategy Pattern. In Strategy all classes (of the strategy) have the same interface.

What you have is inheritance. The 'superior' should derive from 'standard' and then possibly override some virtual functions and add some additional methods and behavior. I am not sure if there is another pattern that can help you. Perhaps the State pattern, but it all depends on your requirements.

Since 'standard' and 'superior' are so very different you would ideally place a single IF statement somewhere in your logic and then have two entirely self-contained components that handle the particular situation. So, you apply some form of refactoring.


问:
How can I use JIRA for project management with Green Hopper
I am thinking of using JIRA + GreenHopper for my project management.

I have seen that Green Hopper is for making User stories, sprints.

I am not able to find how do i need to add tasks, or how to break user stories in to sub stories.

Do I first need to  create project in JIRA and then use Green Hopper or I can use use Green Hopper standalone for project management?

I am thinking of JIRA as issue tracker not project management.

答:
You need a JIRA project created with the GreenHopper template as a base. There you can create different "tickets" (Epics, Stories, Tasks, Defects etc) and follow through with your project by estimating story points, moving them on the SCRUM board and having reports like burndown charts.

JIRA has a standalone installer that installes a full package (Webserver, Database, JIRA, GreenHopper) on your PC for testing. Although maybe a bit slow on a user PC, I highly recommend it to play around with all the features and see them for yourself.


答:
In other words, we'd better use Web API, if we want to expose a service over HTTP, but use WCF when it comes to TCP and Duplex.

That would be the most reasonable approach. It's quite common to have both WCF and WebApi services in the same web application where both serve different purposes.

Just to correct few arguments:

WCF models are not POCO, because of [DataContract] & [DataMember] and those attributes

In many cases WCF models work without datacontract/datamember attributes.

SOAP is not as readable and handy as JSON

It is not, true, but WCF web services usually carry plain XML rather than bloated SOAP. This definitely is readable.

One argument for WCF: if there is a WSDL available, there are tons of tools in almost all technologies that can create proxies out of the metadata. On the other hand, the JSON Schema is not yet all widely supported.

Title: How do I manage the technical debate over WCF vs. Web API?

Body:
I'm managing a team of like 15 developers now, and we are stuck at a point on choosing the technology, where the team is broken into two completely opposite teams, debating over usage of WCF vs. Web API.

Team A which supports usage of Web API, brings forward these reasons:

Web API is just the modern way of writing services (Wikipedia)

WCF is an overhead for HTTP. It's a solution for TCP, and Net Pipes, and other protocols

WCF models are not POCO, because of [DataContract] & [DataMember] and those attributes

SOAP is not as readable and handy as JSON

SOAP is an overhead for network compared to JSON (transport over HTTP)

No method overloading

Team B which supports the usage of WCF, says:

WCF supports multiple protocols (via configuration)

WCF supports distributed transactions

Many good examples and success stories exist for WCF (while Web API is still young)

Duplex is excellent for two-way communication

This debate is continuing, and I don't know what to do now. Personally, I think that we should use a tool only for its right place of usage. In other words, we'd better use Web API, if we want to expose a service over HTTP, but use WCF when it comes to TCP and Duplex.

By searching the Internet, we can't get to a solid result. Many posts exist for supporting WCF, but on the contrary we also find people complaint about it. I know that the nature of this question might sound arguable, but we need some good hints to decide. We're stuck at a point where choosing a technology by chance might make us regret it later. We want to choose with open eyes.

Our usage would be mostly for web, and we would expose our services over HTTP. In some cases (say 5 to 10 percent) we might need distributed transactions though.

What should I do now? How do I manage this debate in a constructive way?


问:
Disadvantages of functional intermediate form
I'm writing an optimizer for a language similar to JavaScript, and need to choose an intermediate code representation. The obvious/typical choice these days is Static Single Assignment (SSA).

However, Modern Compiler Implementation in C also discusses functional intermediate form, which basically means going pure functional for the intermediate representation (pure in terms only of local variables, heap data is still mutable, and not CPS, just straightforward let blocks and tail calls) and has some advantages in terms of being easier to reason about.

Presumably it's not a no-brainer or everyone would already be using such a representation, so my question is, what disadvantages does functional intermediate form have compared to SSA?

答: SSA is great for dead code elimination, constant propagation, partial specialisation and such. If this kind of stuff is not on your menu, you can skip SSA and use a more relaxed representation for simpler analysis passes</p>


问:
What does 'between' and 'in range' mean in the world of numeric types?
Given is an integer with the value 5. Given is a range with start and end values of 2 and 5. So is the integer 5 now between the range? What should a 'InBetween()' method return and which one is the correct representation of 'between':

```<code>int val = 5
</code>```

```<code>if(val >= 2 && val <= 5) // would return true
</code>```

```<code>if(val > 2 && val < 5) // would return false
</code>```

答:
For integer types, it's normal practice to include the specified values within the range. You would say that the range of a single standard die is between 1 and 6, not 0 and 7.

For floating point types, it varies depending on the specification of the particular project. When defining adjacent bands, it's common to include one value, but to exclude the other.

e.g.

```<code>double value
if (value >= 0.0 && value < 2.0)
    ...
else if (value >= 2.0 && value < 5.0)
   ...
</code>```

Body:
For integer types, it's normal practice to include the specified values within the range. You would say that the range of a single standard die is between 1 and 6, not 0 and 7.

For floating point types, it varies depending on the specification of the particular project. When defining adjacent bands, it's common to include one value, but to exclude the other.

e.g.

double value
if (value >= 0.0 && value < 2.0)
    ...
else if (value >= 2.0 && value < 5.0)
   ...


答:
There is no clear answer to this as "between" can be interpreted in lots of way. I'd argue that inBetween(1, 4) should check 2, 3 but that's just me.

There are other examples like, Random.nextInt(1,4) - does it return values 1,2,3,4; 2,3 or 2,3,4?

So most functions tend to clarify that in the documentation, for instance:

public String substring(int beginIndex, int endIndex)

Returns a new string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1. Thus the length of the substring is endIndex-beginIndex. Examples:

```<code> "hamburger".substring(4, 8) returns "urge"
 "smiles".substring(1, 5) returns "mile"
</code>```

Parameters:

```<code>  beginIndex - the beginning index, inclusive.
  endIndex - the ending index, exclusive.
</code>```

If you want to be precise, then use the common mathematical notation as described here:

So [1, 5) means the interval 1,2,3,4 (integers) or 1 to 4.999... if we're using floats.

Title: What does 'between' and 'in range' mean in the world of numeric types?

Body:
Given is an integer with the value 5. Given is a range with start and end values of 2 and 5. So is the integer 5 now between the range? What should a 'InBetween()' method return and which one is the correct representation of 'between':

```<code>int val = 5
</code>```

```<code>if(val >= 2 && val <= 5) // would return true
</code>```

```<code>if(val > 2 && val < 5) // would return false
</code>```

Body:
There is no clear answer to this as "between" can be interpreted in lots of way. I'd argue that inBetween(1, 4) should check 2, 3 but that's just me.

There are other examples like, Random.nextInt(1,4) - does it return values 1,2,3,4; 2,3 or 2,3,4?

So most functions tend to clarify that in the documentation, for instance:

public String substring(int beginIndex, int endIndex)

Returns a new string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1. Thus the length of the substring is endIndex-beginIndex. Examples:

 "hamburger".substring(4, 8) returns "urge"
 "smiles".substring(1, 5) returns "mile"

Parameters:

  beginIndex - the beginning index, inclusive.
  endIndex - the ending index, exclusive.

If you want to be precise, then use the common mathematical notation as described here:

So [1, 5) means the interval 1,2,3,4 (integers) or 1 to 4.999... if we're using floats.


答:
In math, there are four interval (range) specification forms, shown here with corresponding C expressions:

```<code>(a,b) ((a < x) && (x < b))
[a,b) ((a <= x) && (x < b))
(a,b] ((a < x) && (x <= b))
[a,b] ((a <= x) && (x <= b))
</code>```

The idea is that ( and ) denote open ends, while [ and ] denote closed ends.

Added, based on the comment from "stakx": An open end of an interval is one that does not include the actual endpoint.  A closed end is one that does include the endpoint.  For example, (3,5) is an open interval, 3 < x < 5.  Neither 3 nor 5 are included.  [4,6) is a half-open interval: 4 is included, 6 is not.  [5,7] is a closed interval: both 5 and 7 are included.

The different forms are not that interesting for integers, as any open or half-open integer interval can be expressed as the equivalent closed interval (and vice versa, of course).  They become useful for rationals and reals.

Saying "in between" is ambiguous.  It doesn't say whether the endpoints are included (i.e., is the range open or closed on either or both ends).  You need to specify it more clearly, so you can say which of the four forms is intended as the specification, given the endpoints.

Body:
In math, there are four interval (range) specification forms, shown here with corresponding C expressions:

(a,b) ((a < x) && (x < b))
[a,b) ((a <= x) && (x < b))
(a,b] ((a < x) && (x <= b))
[a,b] ((a <= x) && (x <= b))

The idea is that ( and ) denote open ends, while [ and ] denote closed ends.

Added, based on the comment from "stakx": An open end of an interval is one that does not include the actual endpoint.  A closed end is one that does include the endpoint.  For example, (3,5) is an open interval, 3 < x < 5.  Neither 3 nor 5 are included.  [4,6) is a half-open interval: 4 is included, 6 is not.  [5,7] is a closed interval: both 5 and 7 are included.

The different forms are not that interesting for integers, as any open or half-open integer interval can be expressed as the equivalent closed interval (and vice versa, of course).  They become useful for rationals and reals.

Saying "in between" is ambiguous.  It doesn't say whether the endpoints are included (i.e., is the range open or closed on either or both ends).  You need to specify it more clearly, so you can say which of the four forms is intended as the specification, given the endpoints.


问:
how to pluralize 'special' terms e.g. class names
Quite often I find myself referring in text to objects which have strict naming conventions e.g. Java objects, processes, services.  I find myself in a dilemma over how to pluralize these names.

It seems wrong to pollute the meaningful name by adding an 's' - or worse, a plural that modifies the rest of the name like SomethingUtility -> SomethingUtilities.  What if someone does a text search looking for the name?  Or cuts and pastes from my comment to search through a log file?

I have sometimes resorted to an ungrammatical apostrophe, but this can confuse plural with ownership.

Is there any better solution?

答:
In my Documentations, I do it like we do it here on Stackexchange and use different font Styles for special Terms.

For those terms where a different pluralization would be required according to English grammar, I just don't do it. My excuse for this is that the names of my Classs are not English words. They are a made-up words for my program.


问:
Should EICAR be updated to test the revision of Antivirus system?
I'm posting this here since programmers write viruses, and AV software.  They also have the best knowledge of heuristics and how AV systems work (cloaking etc).

The EICAR test file was used to functionally test an antivirus system.  As it stands today almost every AV system will flag EICAR as being a "test" virus.  For more information on this historic test virus please click here.

Currently the EICAR test file is only good for testing the presence of an AV solution, but it doesn't check for engine file or DAT file up-to-dateness. In other words, why do a functional test of a system that could have definition files that are more than 10 years old.  With the increase of zero day threats it doesn't make much sense to functionally test your system using EICAR.

That being said, I think EICAR needs to be updated/modified to be effective test that works in conjunction with an AV management solution.
This question is about real world testing, without using live viruses... which is the intent of the original EICAR.

That being said I'm proposing a new EICAR file format with the appendage of an XML blob that will conditionally cause the Antivirus engine to respond.

```<code>X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-EXTENDED-ANTIVIRUS-TEST-FILE!$H+H*
<?xml version="1.0"?>
<engine-valid-from>2010-1-1Z</engine-valid-from>
<signature-valid-from>2010-1-1Z</signature-valid-from>
<authkey>MyTestKeyHere</authkey>
</code>```

In this sample, the antivirus engine would only alert on the EICAR file if both the signature  or engine file is equal to or newer than the valid-from date. Also there is a passcode that will protect the usage of EICAR to the system administrator.

If you have a backgound in "Test Driven Design" TDD for software you may get that all I'm doing is applying the principals of TDD to my infrastructure.

Based on your experience and contacts how can I make this idea happen?

答:
As you said in the question, it would have to work in conjunction with an AV solution.  In order for that to happen you would either need to write an AV engine, or become involved with an existing AV vendor.

If such a thing did exist... Where does the benefit come in?  Just thinking devil's advocate here..  Couldn't the AV engine just report when it's database was updated?


问:
Best books on Managing a Software Development Team?
The canonical books on software development is fairly well established. However, after reading through a dreadful book full of bad advice on managing programming teams this weekend I am looking for recommendations for really good books that focus on the management side of programming (recruiting, performance measurement/management, motivation, best practices, organizational structure,  etc.) and not as much on the construction of software itself.

Any suggestions?

答: Crystal Clear by Alistair Cockburn. Even if you aren't into Agile, it includes a lot of good advise on managing teams and gives you good background to build your own development process.</p>