答:
Store them in a file, and encrypt it with a key linked to the logged in user's account. Windows then manages the encryption and the security of being allowed to decrypt the file.

This way the password will always be in clear text... if you've logged on as the user that's allowed to read that file. You may need to truecrypt the entire drive to be totally secure, but a quick code app can do this (see 'protected configuration' for examples of securing app.config files - similar code could be used here, I assume) but code-based solution would not allow you to see the contents in an external viewer (eg excel), but you could easily store the file encrypted and give them a special viewer app "for security" so only the admin can see them in the clear. I figure that is what the real requirement is - not that they can use Excel, but they can see the passwords.

Title: Storing web app passwords so that they can be retrieved

Body:
Short version

My boss wants me to store user passwords for an ASP.NET Web Forms web app we're developing in clear text, so that a user with admin rights can click a button and get back the current passwords for the accounts she controls.

I don't want to do that, because I deeply care about the security and privacy of users of a web app I am involved with in whatever way.

What would be a good way to store the passwords in an encrypted form, that can still however be decrypted?

I can't count on users having an email address, so sending the user a link to reset the password is not an option.

Read the following for more context.

Some context

This app was written by individuals who have little clue as to how software should be written. Lots of duplicated code, risks for SQL injection everywhere, no unit tests whatsoever, one new connection gets instantiated and opened for each and every query... name a bad practice, you'll find it in this codebase.

The passwords are currently stored as a simple MD5 of the original string, which is weak and horrible and everything, but still a tiny bit better than clear text.

I just finished implementing a feature request where the admin I was talking about can click a button and have an account automatically created for each employee she manages, with a random password.
I cringe while writing this, but one of the requirements was to export the credentials in an Excel spreadsheet. Which I did.

This is bad in and of itself, but then my boss said "What if the user loses the spreadsheet? Users are dumb, you know. There needs to be a way to get the passwords back."

Bang.

Getting him to listen to people who know what they're talking about is not an option, sadly.

The obvious suggestion would be "GTFO", I know, but rest assured that it's something I'll do as soon as I possibly can.

Meanwhile, I need to cheat and pretend I store passwords in clear text, while I do things in the best way possible to protect my users' passwords.

EDIT

For some reason people answering are assuming I'm a girl so, just for the record, I would like to clarify that I'm a guy. Not that it should make any difference, but hey ;)


问:
Object Calisthenics - reducing to two attributes
I'm refactoring an expense tracker system using Object Calisthenics. I'm able to bring my Class down to five attributes. How do I go forward from here?

This is my class right now.

```<code>public class Expense {
    private Identifiers ids;
    private AmountInCurrency amountInCurrency;
    private Remarks remarks;
    private UserList userList;
    private ExpenseDate expenseDate;
}
</code>```

Identifiers has attributes expenseId and reportId

AmountInCurrency has an amount and a currency

Remarks has a string with remarks.

UserList has a List which is List as User has only userName (String).

ExpenseDate is a Date object.

Also I have a sql database where i'm storing the contents of the Expense object. Should I directly pass the expense object and retrieve the primitives or should I create an entity object which takes this expense object as a constructor argument?

NOTE : This is not production code, I'm doing this just as an exercise.

答:
Object Calisthenics are simply theoretical exercises, which provide a good way train programmers to write cleaner code. This means that:

You shouldn't use Calisthenics when writing production code. Those are not best practices, and not even guidelines for production code.

There would always be counter-examples, i.e. cases where applying Calisthenics would lead to bad code. For example, there are numerous cases where code which uses else keyword would be much simpler than inheritance.

In your case, the object looks pretty clear. You may put some of its properties into objects and inherit from them or use them as properties, but probably in your precise context, it would only lead to:

More code,

Harder to understand architecture,

Difficulty to apply other Calisthenics, like, together, keeping entities small and using one dot per line.

For example, you may start by doing the following:

```<code>// One property less.
public class Expense {
    private Identifiers ids;
    private AmountInCurrency amountInCurrency;
    private UserList userList;
    private ExpenseDate expenseDate;
}

public class CommentedExpense {
    private Expense expense;
    private Remarks remarks;
}
</code>```

Following the comments to the original question, I think it's useful to detail a bit the context and the goal of Object Calisthenics.

The original paper (RTF document) is not absolutely clear on the subject, but much clearer compared to some of the websites and articles of Object Calisthenics adepts and followers, who make others believe that everyone should follow the described rules every time, everywhere.

Here's a relevant quote from the document, emphasis mine:

Do a simple project using far stricter coding standards than you’ve ever used in your life.  Below, you’ll find 12 “rules of thumb” that will help push your code into good object-oriented shape.

By suspending disbelief, and rigidly applying these rules on a small, 1000 line project, you’ll start to see a significantly different approach to designing software.  Once you’ve written 1000 lines of code, the exercise is done, and you can relax and go back to using these 12 rules as guidelines.

This is a hard exercise, especially because many of these rules are not universally applicable. The fact is, sometimes classes are a little more than 50 lines. But there’s great value in thinking about what would have to happen to move those responsibilities into real, first-class-objects of their own. It’s developing this type of thinking that’s the real value of the exercise. So stretch the limits of what you imagine is possible, and see whether you start thinking about your code in a new way.

In other words, the intention of the original author was never to incite people to use those rules for production code. Those rules have only a theoretical goal.

I've found it to be pretty useful for the programmers with years of experience who still write 500-LOC functions with 15 embedded if/for blocks. Applying Object Calisthenics on a tiny project is a good way to make them discover professional programming, give them basic habits they may then follow for production code and awake their curiosity to make them search for design patterns, inheritance, Dependency Injection, etc.

ContentLicense: CC BY-SA 3.0

Body:
Object Calisthenics are simply theoretical exercises, which provide a good way train programmers to write cleaner code. This means that:

You shouldn't use Calisthenics when writing production code. Those are not best practices, and not even guidelines for production code.

There would always be counter-examples, i.e. cases where applying Calisthenics would lead to bad code. For example, there are numerous cases where code which uses else keyword would be much simpler than inheritance.

In your case, the object looks pretty clear. You may put some of its properties into objects and inherit from them or use them as properties, but probably in your precise context, it would only lead to:

More code,

Harder to understand architecture,

Difficulty to apply other Calisthenics, like, together, keeping entities small and using one dot per line.

For example, you may start by doing the following:

// One property less.
public class Expense {
    private Identifiers ids;
    private AmountInCurrency amountInCurrency;
    private UserList userList;
    private ExpenseDate expenseDate;
}

public class CommentedExpense {
    private Expense expense;
    private Remarks remarks;
}

Following the comments to the original question, I think it's useful to detail a bit the context and the goal of Object Calisthenics.

The original paper (RTF document) is not absolutely clear on the subject, but much clearer compared to some of the websites and articles of Object Calisthenics adepts and followers, who make others believe that everyone should follow the described rules every time, everywhere.

Here's a relevant quote from the document, emphasis mine:

Do a simple project using far stricter coding standards than you’ve ever used in your life.  Below, you’ll find 12 “rules of thumb” that will help push your code into good object-oriented shape.

By suspending disbelief, and rigidly applying these rules on a small, 1000 line project, you’ll start to see a significantly different approach to designing software.  Once you’ve written 1000 lines of code, the exercise is done, and you can relax and go back to using these 12 rules as guidelines.

This is a hard exercise, especially because many of these rules are not universally applicable. The fact is, sometimes classes are a little more than 50 lines. But there’s great value in thinking about what would have to happen to move those responsibilities into real, first-class-objects of their own. It’s developing this type of thinking that’s the real value of the exercise. So stretch the limits of what you imagine is possible, and see whether you start thinking about your code in a new way.

In other words, the intention of the original author was never to incite people to use those rules for production code. Those rules have only a theoretical goal.

I've found it to be pretty useful for the programmers with years of experience who still write 500-LOC functions with 15 embedded if/for blocks. Applying Object Calisthenics on a tiny project is a good way to make them discover professional programming, give them basic habits they may then follow for production code and awake their curiosity to make them search for design patterns, inheritance, Dependency Injection, etc.


问:
Non-Recursive vs Recursive Locks?
I am thinking of using non-recursive locks; I have found them to be having performance superiority over the standard recursive locks (e.g. SimpleRWSync). I have mainly been using critical sections but in highly threaded environments, locking was producing significant delays.

What are the benefits and/or pitfalls?

Do the non-recursive ones make coding harder comparatively?

答:
The benefit of non-recursive locks is they are faster, because of reduced tracking and checking for which thread is holding the lock.  The drawback is you will deadlock if you try to lock it again within the same thread.

Technically, they are harder to use, because the burden is on the programmer to avoid locking it recursively.  In practice, programmers should already be worrying about it.  Most of the time, holding a lock recursively means you are holding it too long.  You want the time you are holding a lock to be as small as possible, and making function calls of unknown depth can hardly be considered as small as possible.  It may be a little bit of extra work, but refactoring your code to be able to use non-recursive locks is almost always worth it.

Title: Non-Recursive vs Recursive Locks?


问:
Where to put code documentation?
I am currently using two systems to write code documentation (am using C++):

Documentation about methods and class members are added next to the code, using the Doxygen format.  On a server Doxygen is run on the sources so the output can be seen in a web browser

Overview pages (describing a set of classes, the structure of the application, example code, ...) is added to a Wiki

I personally think that this approach is easy because the documentation about members and classes is really close to the code, while the overview pages are really easy to edit in the Wiki (and it's also easy to add images, tables, ...).  A web browser allows you to see both documentations.

My co-worker now suggests to put everything in Doxygen, because we can then create one big help file with everything in it (using either Microsoft's HTML WorkShop or Qt Assistant).  My concern is that editing Doxygen-style documentation is much harder (compared to Wiki), especially when you want to add tables, images, ... (or is there a 'preview' tool for Doxygen that doesn't require you to generate the code before you can see the result?)

What do big open-source (or closed source) projects use to write their code documentation?  Do they also split this up between Doxygen-style and a Wiki?  Or do they use another system?

What is the most appropriate way to expose the documentation?  Via a Web server/browser, or via a big (several 100MB) help file?

Which approach do you take when writing code documentation?

答: Since version 1.8.0 doxygen supports Markdown, which should make the experience of writing static pages similarly convenient as in a Wiki system.</p>

Title: Where to put code documentation?

ContentLicense: CC BY-SA 4.0


问:
GPLv3 code in non-GPL software -- linking vs. CLI
Suppose there's a GPLv3 app that has a GUI and a CLI. Can I legally expand its CLI (to give me access to functionality hitherto only available via the app's API), release the result under GPL and then create a non-GPL (perhaps proprietary) app that depends on this modified GPL app (via the expanded CLI)?</p>

答:
As a simple test answer this question: Is my proprietary program useful without the GPL component? Ignore how the components communicate for now.

If the answer to this question is no, then you probably should consider your program a derivative work and thus must be covered by the GPL.

If the answer is yes, then you can probably distribute your proprietary program with the GPL program. But according to the FSF GPL FAQ:

To do this validly, you must make sure that the free and non-free programs communicate at arms length, that they are not combined in a way that would make them effectively a single program.


答: If you are using ASCII, you should store your hide your documentation data in the high bit of your source code! Then only the most clever (read: deserving) of users have the opportunity to use your docs.</p>

Title: Where to put code documentation?

Body:
I am currently using two systems to write code documentation (am using C++):

Documentation about methods and class members are added next to the code, using the Doxygen format.  On a server Doxygen is run on the sources so the output can be seen in a web browser

Overview pages (describing a set of classes, the structure of the application, example code, ...) is added to a Wiki

I personally think that this approach is easy because the documentation about members and classes is really close to the code, while the overview pages are really easy to edit in the Wiki (and it's also easy to add images, tables, ...).  A web browser allows you to see both documentations.

My co-worker now suggests to put everything in Doxygen, because we can then create one big help file with everything in it (using either Microsoft's HTML WorkShop or Qt Assistant).  My concern is that editing Doxygen-style documentation is much harder (compared to Wiki), especially when you want to add tables, images, ... (or is there a 'preview' tool for Doxygen that doesn't require you to generate the code before you can see the result?)

What do big open-source (or closed source) projects use to write their code documentation?  Do they also split this up between Doxygen-style and a Wiki?  Or do they use another system?

What is the most appropriate way to expose the documentation?  Via a Web server/browser, or via a big (several 100MB) help file?

Which approach do you take when writing code documentation?


答: Having documentation in a well defined, easily exportable, portable format might be the real advantage. If sphinx dies (unlikely) I'll just have convert to other system, which I guess would be a scriptable task. Moving data out of wiki (presumably stored in database in a proprietary format might be a pain). </p>

Title: Where to put code documentation?


问:
What's the right licensing to sell a web app, without renounce to reuse the code?
I'm making a web app for a client who is probably going to use it for commercial use. I'm not affialited with me, nor we are commercial partners.

However, although I'm making this project for this client, I want to be sure I can reuse the same code on future projects.

I know there are many licenses (GPL etc.) but it's not clear to me which one complies the following requirments:

The code can be sold by me to the client (so he pays me for the code)

The client may use the code for commercial use

I still own the ownership on the code, i.e. , I can reuse the code for future works, either in open source works or other projects (which I may sell)

Furthermore, it's not clear to me: When I choose I license how can I "apply" it? I mean: who "certifies" my app is licensed udner that specific licence and do I have to pay for this "certification"?

Thanks in advance :)

答:
The way you do this is by entering into a contract with the client.  If you wish, you can do that by selling him a license.  In it, you specify the following conditions:

The code can be sold by me to the client (so he pays me for the code)

The client may use the code for commercial use

I still own the ownership on the code, i.e. , I can reuse the code for future works, either in open source works or other projects (which I may sell)


问:
How can I compensate for having gone to a JavaSchool?
In an earlier question, I asked for career advice for new software engineers who did well before and during college.  But what about people who weren't fortunate enough to go to MIT or Yale, for whatever reason?  What if you went to what Joel Spolsky calls a JavaSchool?

What can/should JavaSchool alumni do to develop their skills and make up for the things they missed in college?  (Or, was Joel wrong about those schools being disadvantageous?)

答:
Why not work through a textbook that introduces programming differently from how you learned it?  For example, there are several good, free books that use the functional paradigm.  How to Design Programs is very approachable.  The classic Structure and Interpretation of Computer Programs (http://mitpress.mit.edu/sicp/) is less so, but does provide a profound sense of enlightenment.

I highly recommend watching the first couple of Abelson's SICP lectures for a different perspective on what computer science is.  They're older but have aged very well (http://video.google.com/videoplay?docid=5546836985338782440#).

ContentLicense: CC BY-SA 2.5


问:
Which Web API routing attribute style is preferred?
You can do it this way:

```<code>[Route("api/DeliveryItems/{ID:int}/{CountToFetch:int}")]
</code>```

...calling it like so:

```<code>http://localhost:28642/api/deliveryitems/N/N
</code>```

...which has the benefit of the routing attribute documenting exactly which args the methods needs.

Or you can do it this way:

```<code>[Route("api/DeliveryItems")]
</code>```

...calling it like so:

```<code>http://localhost:28642/api/deliveryitems?ID=N&CountToFetch=N
</code>```

...which has the benefit of having a clear "separation of concerns" (or perhaps "separation of context" or "separation of intent"), so that path info is one thing, args are another, and never do the twain meet (in the routing attribute string, at any rate).

Any powerful reasons to opt for one style over the other?

答:
I don't really know about ASP.NET-MVC, but in RoR the convention is to use a combination that'll look like this:

```<code>[Route("api/{ID:int}/DeliveryItems")]
</code>```

And you'll use it like this:

```<code>http://localhost:28642/api/N/deliveryitems?CountToFetch=M
</code>```

How do you decide which parameters get in the path and which get in the query string? Think OOP! The HTTP request is running a method of an object. The path is for fetching the object and deciding the method while the query string is for specifying the arguments.

Assuming that ID is the id of a category of items to deliver, that category would be a ItemsCategory object and the HTTP request will resemble:

```<code>API.FetchItemsCategory(N).FetchDeliveryItems(M)
</code>```

Take a look at REST

OwnerDisplayName: B. Clay Shannon

Body:
I don't really know about ASP.NET-MVC, but in RoR the convention is to use a combination that'll look like this:

[Route("api/{ID:int}/DeliveryItems")]

And you'll use it like this:

http://localhost:28642/api/N/deliveryitems?CountToFetch=M

How do you decide which parameters get in the path and which get in the query string? Think OOP! The HTTP request is running a method of an object. The path is for fetching the object and deciding the method while the query string is for specifying the arguments.

Assuming that ID is the id of a category of items to deliver, that category would be a ItemsCategory object and the HTTP request will resemble:

API.FetchItemsCategory(N).FetchDeliveryItems(M)

Take a look at REST


问:
How to generate random numbers without making new Random objects?
I'm using this as part of a game, but it's not really a game development question, so I'm putting it on this more general Stack Exchange.

The goal is to generate "random" outputs for a fixed integer input, but (and this is the clincher) to generate the same random output every time the same random input is put in.

The idea here is that the function will generate the world the same way every time, so we don't need to store anything; the function itself is the storage.  Unfortunately access speed is a little slow, because the only way I can find to generate random numbers is to create a new Random() object with a seed based on the input, which is surprisingly slow.

Is there a better way?  I'm not worried about crypto-safe generation; in fact I'm just going to pick a random seed in advance and expose it quite publicly.

The current code looks like this:

```<code>private const int seed;

public MapCell GetMapCell(int x, int y)
{
    Random ran = new Random(seed + (x ^ y));
    return new MapCell(ran.NextInt(0, 4));
}
</code>```

Where the MapCell is one of four types (in fact it's more complicated than this, but not a whole lot).  The point is that this could be called for any parameters, at any time, in no particular order, but it needs to return the same answer every time, if x and y are the same every time.  That's why I can't fix a certain Random object and use it repeatedly.

I also don't want to store anything, because I want to keep the RAM usage quite low, but allow the player to wander freely to the edges of Int.MaxValue

答:
Sign is on a good track, but his algorithm is wrong. It is not much random. It is actually pretty hard to create random like this. I was playing around with this and everything I tried created obvious patterns when printed in 2D. In the end I manged to create an algorithm that doesn't create any eye-visible patterns. I looked for inspiration in existing random algorithms.

```<code>public static uint bitRotate(uint x)
{
    const int bits = 16;
    return (x << bits) | (x >> (32 - bits));
}

public static uint getXYNoise(int x, int y)
{
    UInt32 num = seed;
    for (uint i = 0; i < 16; i++)
    {
        num = num * 541 + (uint)x;
        num = bitRotate(num);
        num = num * 809 + (uint)y;
        num = bitRotate(num);
        num = num * 673 + (uint)i;
        num = bitRotate(num);
    }
    return num % 4;
}
</code>```

When this algorithm is used to render a 4-shades of gray image, it creates this:

For comparison, the Random algorithm creates this pattern:

And Sign's algorithm too has patterns:

Body:
Sign is on a good track, but his algorithm is wrong. It is not much random. It is actually pretty hard to create random like this. I was playing around with this and everything I tried created obvious patterns when printed in 2D. In the end I manged to create an algorithm that doesn't create any eye-visible patterns. I looked for inspiration in existing random algorithms.

public static uint bitRotate(uint x)
{
    const int bits = 16;
    return (x << bits) | (x >> (32 - bits));
}

public static uint getXYNoise(int x, int y)
{
    UInt32 num = seed;
    for (uint i = 0; i < 16; i++)
    {
        num = num * 541 + (uint)x;
        num = bitRotate(num);
        num = num * 809 + (uint)y;
        num = bitRotate(num);
        num = num * 673 + (uint)i;
        num = bitRotate(num);
    }
    return num % 4;
}

When this algorithm is used to render a 4-shades of gray image, it creates this:

For comparison, the Random algorithm creates this pattern:

And Sign's algorithm too has patterns:


问:
How to determine if a message should be a command message or event message?
Two enterprise integration patterns are the command message and the event message. I am working on a system in which we use messaging not only for integration with other systems, but for internal communication between services. It's supposed to be an eventually consistent system, and services are supposed to be ignorant of each other (with exception to a couple special-purpose services). As such, we try to avoid things that feel like remote procedure calls (RPC or RPI). We have a bus and message-oriented middleware system, and all messages are broadcasted.

We tend to name our messages as events, that is, as a phrase in the past perfect, e.g. PurchaseOrderShipped. However, the events are often added only when some other services needs to know about them, and in the beginning, often only one service cares. Moreover, sometimes that service emits an event as a result, which is listened to by the first service. Thus if I were to diagram the interaction, it would look much more like the diagram for the command message in the link above (or even the RPC diagram) than the one for the event message, though once again, this is not actually implemented with direct messaging but broadcast on a bus. Add to that the fact that I have recently seen some messages being added that are named as commands, that is, a phrase in the imperative, e.g. BillShippedPurchaseOrder.

The odd thing is that the names of the messages and the way they flow are not changes by whether it is named as an event or as a command. So how does one determine whether something should be a command message or an event? Is this just a difference of semantics and naming, or is there an actual implementation difference between command and event messages? Given that all our messages are broadcast, does that mean than none of them are truly command messages?

答:
There is a subtle, but important difference between commands and events.  A command has a presumption of a response whereas an event does not presume a response, it's merely a statement.

To be less abstract:

ShipOrder is a command and the sender of ShipOrder will likely expect a response of some sort.

OrderShipped is a declaration and the sender is unlikely to expect a response as GoodJob! is a useless response in this example.

If you're designing your systems to only expect event messages, then it doesn't necessarily matter to the system design what you call the messages.  Developers may get confused by the name of a message, but the systems will respond just fine regardless of what convention you follow to name things with.

But it doesn't sound like your fellow developers are following the event-only message model.  If services are expecting responses to the "event messages" they are sending out, then they are really sending out command messages.  It's not a big deal, and I can think of many cases where commands such as requests for information would be required.  But you'll have a semantic headache if you expected to only see event messages.

Broadcasting messages doesn't really have an impact on whether a message is a command or an event.  Generally, you don't broadcast commands as it duplicates effort.  But there's nothing to say you couldn't.  Early network protocols broadcasted every packet and the receivers had to be intelligent enough to know when to ignore messages packets that didn't belong to them.


问:
Rating Ecommerce Customers Formula
I'm developing a new extension for an ecommerce platform, that basically builds Customer Equity and Lifetime Value. Already got that.

But I'm having some problems trying to figure out a formula to rate an ecommerce customer.

I'm not looking for code, but rather for a formula.

I'm pretty sure I already have all vars needed, like customer sales, average sales, profit, first order, last order, marketing spent on a specific customer, discounts spent on a specific customers, shipping costs, payment costs,number of returns he made, etc.

What I'm missing is a formula to rank each customer. The basic Idea is that someone from customer support will see in customer's dashboard a summary and the customer rating. Like from 1-10

So he can have a better knowledge on how to deal with it. If it's a valuable customer or someone that gives the company a very low profit and is always returning things and stuff like that. My intention here is not to discuss the way we should treat customers.

My first thoughts we something like: Get current profit, add project profit, check lifespan point...

答:
I doubt there is a specific formula, and if there were one, it would almost certainly need to be tweaked to your specific situation.

Probably the best you can do is to create your own formula with behavior that makes you happy.  So what makes you happy?  If you have a low profit margin on an item, a single return might cost a lot, so you might not like customers that have a high return rate, even if they buy a lot.  In other circumstances, how much they buy trumps everything.  Unless you can specify what makes a customer "better" than another, you can't calculate it.

If you're a programmer and not a business person, you probably won't have a good enough idea of what your company likes about a customer to guess well.  Having someone who does have a feel for that rate some customers manually, and then reverse-engineering their evaluation process could work.

A few caveats:

Numbers that a computer spits out can be given more psychological weight than they deserve.  The formula may have bugs in it.  There is a possibility that bad decisions could be made because of a bug.

If this is something prominent that customer support people see as an official rating of a customer, they may see a low rating as an official sanction from the company to be unfriendly to "bad" customers.  This could easily affect the company's ability to keep customers.  I remember once when a customer service lady was rude to me.  That company will not be getting any more of my money.  Ever.

The formula may work well for old customers who buy a lot, but what about customers who don't buy much or don't buy often?  What about brand new customers?  Keep in mind that "good" customers will buy something for the first time, and if they are treated badly by customer service because their number isn't high, it might be the last time.

Title: Rating Ecommerce Customers Formula


问:
In Scrum, what to do when story points and task hours don't roughly correlate?
Our development team is pretty new to the scrum process, so I would like to help refine our methods to make better use of it. In particular, I noticed that the correlation between story points and task hours is not very good. That is, we often have stories of lesser points decomposed into a total task hours greater than stories of higher points.

Now, I am aware that these are two separate estimation processes and that we should use the hours to estimate only the remaining work for a sprint while using the story points to compute a velocity and be able to predict the length of the release cycle or the amount of features we will be able to address. However, it seems to me that if sprint points and task hours don't correlate well, then we must be doing a bad job at estimating either one or both of these.

Since we only adjust the remaining work hours as opposed to recording the time spent, I can't easily tell if the problem is the initial task hour break-down or the story point estimates.

So, my question is whether we should deal with this and how? I can think of several ways to start dealing with this:

Record time spent in a task and use this information as feedback to help refine our estimation process by retrospectively identifying user stories which we under/over estimated. But I am not convinced that we want to record this information and I anticipate resistance to it.

At the planning phase, identify outliers after the task hour break-down process and look at these further. This way we could try to identify whether we misjudged the complexity of the story or if the task breakdown is missing some efforts or over-estimating the length of simple tasks. However, I'm afraid this would couple the two estimation efforts, which doesn't seem as the right thing to do either... This also assumes we would have decomposed all stories in the planning phase, otherwise we won't be able do much about stories which were misjudged.

Another method to approach this would be to try to independently incorporate methods to enhance the estimation process and raise the team consciousness about the importance of estimation. Then just keep monitoring the correlation between story points and initial task hour break-down as an indicator of how we are doing and whether we need to keep working at it. I'm inclined to think that this is the best approach, but less pro-active.

What is the best way to approach this issue and/or what other suggestions are there for enhancing the estimation process in this context?

答:
Coming from the developer point of view, I cant estimate time for the life of me. I can estimate how hard something will be fairly well.

With that said, when I give an estimate in story points, its basically me saying it's hard or easy work. SP are to give you (the PM) an idea that this is a hard task, so leave me alone when Im working on it so that I can finish it fast, or Im doing mind numbing task, so, if you have a question, swing on by.

Also, you know your devs and there skill level, so if you have a junior dev, dont give him the 3's, but the 1's so that he does not drown.

Now, here are some examples:

easy (1sp): refactor a function
time: this could take 10min - 2hr's depending on the language and if its used as an magic function. Then there is testing, ect.

hard (3sp): set up a deployment server
time: If its a custom deployment system, a day or more.

so, in theory, I can do 3sp a day, but 3 refactor functions that take 10min each - 30 min of work? As for time management, the idea of SP does not translate to a gant chart, so get time estimates too if you need them.

OwnerDisplayName: miguelf


问:
Is there a way to efficiently allow a user to upload multiple content at once for e-commerce type sites?
Sellers on large sites like Amazon and Newegg need to provide names, descriptions, and images for their products to be displayed on the e-commerce sites.

These sellers could have 10000+ products to sell, each with their own unique name/descriptions/images. I can't imagine that e-commerce sites would have their sellers upload each product individually through some standard HTML form. Especially when a product can have multiple images, this method of uploading just seems too inefficient.

I'm guessing these sites allow sellers to upload via an API that the e-commerce site provides so that the uploading task may be automated with a script, but how exactly is this accomplished? Through JSON? JSON works great with text strings, but JSON doesn't allow for file uploads (so images can't be uploaded?).

答:
If you need to upload multiple items you can submit the form via a iframe or even jQuery as long as your site is developed with that in mind so the user can't just click "home" and the upload stops. Personally if it was a bother to the users I'd launch it into it's own window so the user can continue to use the site while the form continues to upload.

Also JSON can support files, you'd just have to read the contents into the JSON but that will not benefit you in any way as the files will still have to be uploaded.


问:
Multiple remote views of a C# application
I have a C# application (Desktop based application for Windows OS), which I wanted to use from Web browser.

The application is a kind of analyzing tool, which takes some input values and performs set of calculations over it then displays an animation of the results.

Since the application can't be coded again in a new language, Can anyone suggest me, how I can view and interact with this C# application from browser (like the way we interact with Java Applets)? Also the application can be used by more than one user at a time, so there must be multiple views for this web application.

答:
If you designed your application in a way that separates the UI from the business logic, then you should be able to easily rewrite the UI in ASP.Net using C#.   Ideally you have separate DLLs that contain all of your business logic and you can re-use those in you web application.

If you have your business logic intermingled with your UI logic, then you are going to have a rough time breaking out the functionality to build a proper web application.


问:
Is it possible to perform mutual exclusion of threads without OS support?
I suppose you could adapt distributed mutual exclusion algorithms (Ricart/Agrawala, etc), but aside from these more exotic approaches, are you required to use primitives provided by the OS in order to achieve mutual exclusion?

For example, in C# you would use something like lock:

```<code>lock (myobject)
{
    // Do something
}
</code>```

Lock then uses a condition variable provided by the operating system (I think?). From everything I've read about monitors, they all rely on certain sections of the monitor implementation being executed atomically. And the only way (that I can think of) to guarantee that is if the kernel explicitly made it so. Is this right?

答: Spin locks implemented with atomics can be used for mutual exclusion but they are used usually on lower levels. The thing is - thread is abstraction provided by operating system. Thus OS is the best place to control thread execution (create, start, stop, suspend).</p>


答:
You need a single compare and swap type instruction or load link/store conditional instruction pair which can alter the contents of a piece of storage depending on the contents of that storage. Generally speaking high level languages do not support this construct -- mostly because it varies wildly depending on hardware instruction set.

If you code in C and know your hardware architecture you could roll your own mutex library but it would be impossible in a higher level language.

Title: Is it possible to perform mutual exclusion of threads without OS support?

Body:
I suppose you could adapt distributed mutual exclusion algorithms (Ricart/Agrawala, etc), but aside from these more exotic approaches, are you required to use primitives provided by the OS in order to achieve mutual exclusion?

For example, in C# you would use something like lock:

```<code>lock (myobject)
{
    // Do something
}
</code>```

Lock then uses a condition variable provided by the operating system (I think?). From everything I've read about monitors, they all rely on certain sections of the monitor implementation being executed atomically. And the only way (that I can think of) to guarantee that is if the kernel explicitly made it so. Is this right?


问:
Choice between 1-dimensional and 2-dimensional array
I'm implementing the Chessboard class to represent the chessboard. I've to implement the transformations (reflections and rotations) on the chess board possible.

The possible transformations includes the combination of:

 1. Vertical Reflection
 2. Horizontal Reflection
 3. Diagonal Reflection
```

<p>Thus, we've <strong>8</strong> possible transformations for chess board.</p>

<p>There are <strong>64</strong> squares on the Chessboard numbered <strong>[0..63]</strong>.</p>

<p>Thus, to represent the total resulting values after the transformations is <strong>8*64</strong> (No.of Transformations * Chessboard_Size).</p>

<p>There are two fundamental ways to represent the <strong>transformed_board</strong> using Arrays:</p>

<pre class="lang-none prettyprint-override"><code>One-Dimensional Array with transformed_board[8*64]
Two-Dimensional Array with transformed_board[8][64]
</code>```

Questions:

Which approach is better?

What are the pros and cons of each approach?

How will effect the performance with respect to time factor?

答:
Well, in your problem space the 64 squares are formed from the 8 x 8 size of your board, so the most adequate design would be to use a 3 dimensional array:

```<code> transformed_board[8][8][8]
</code>```

Performance will depend on your implementation, the operations you will do on that array and the compiler you are using. Don't fall into the trap of premature optimization. Best approach here probably is to provide accessor functions like

```<code> SQUARE_TYPE GetSquare(int row,int column, int symmetry)
 {
      assert(0<=row && row<MAX_ROWS);
      assert(0<=column && column <MAX_COLUMNS);
      assert(0<=symmetry&& symmetry<MAX_SYMMETRIES);
      return transformed_board[row][col][symmetry];
 }
</code>```

and restrict all access to the board to the use of that accessors. Then it will be easy to change the decision about the array dimensions used for  transformed_board later, just by changing your accessor functions.

Body:
Well, in your problem space the 64 squares are formed from the 8 x 8 size of your board, so the most adequate design would be to use a 3 dimensional array:

 transformed_board[8][8][8]

Performance will depend on your implementation, the operations you will do on that array and the compiler you are using. Don't fall into the trap of premature optimization. Best approach here probably is to provide accessor functions like

 SQUARE_TYPE GetSquare(int row,int column, int symmetry)
 {
      assert(0<=row && row<MAX_ROWS);
      assert(0<=column && column <MAX_COLUMNS);
      assert(0<=symmetry&& symmetry<MAX_SYMMETRIES);
      return transformed_board[row][col][symmetry];
 }

and restrict all access to the board to the use of that accessors. Then it will be easy to change the decision about the array dimensions used for  transformed_board later, just by changing your accessor functions.


问:
"Match Making" script, a way without involving the database and php?
I am writing a matchmaking script for a game through a web portal. For the past few days I have been looking into the different options and I believe the following approach would be the most optimal but I would like the opinion of others.

Get players match requirements through a web form (Method GET) and place the player in queue (mySQL database entry with time stamp and match requirements) for 1 hour.

On the submit page run an ajax script every minute that contacts a php script that checks the following:

Is a player still in the system, if their hour is over or their ajax script has not ran in 5 minutes remove them from the database. Return time out.

Is the player in queue flagged for a match?

If yes then place both players in the in match table and remove both players from queue and send match variables.

If no then continue.

Do the remaining players match the current players requirements?

If yes:

Is the player the same one looking for a match.

If no: Return match variables. Flag other player.

If yes: Return match not found.

If no: Return match not found.

When match variables are received the page will be updated with jquery, including a new ajax request that will call a new php script every 30 seconds to find out if both players accept the match. Possible ajax results are: 0 waiting, 1 accepted, 2 declined. There will also be a button that will send the players response immediately to the php script through ajax that will disable itself through jquery when pushed. When both players accept the page will then use jquery again to display the instructions for beginning the match.

Is there a cleaner or less intensive way to do this with or without involving the database and php?

Notes:

No code is written yet.

The system will not have more than 100 players in queue at any time. (Most likely a peak of 25)

答:
Since you woun't have that much players, I wouldn't recommend on spending too much time on this issue, but continue on your other services.

I would use an AJAX script that scans off a php script every second, where the PHP script is looking for an opponent.

How would it work?
 - A "Find match" button calls an external PHP script via AJAX

The PHP script checks if the player with the matching login hash is in a queue, if not add the player, then search for an opponent, and return the results

If the player is in the queue (On second or more calls), it skips the queue registration and immediately starts searching for an opponent

If a match is found, create a "matchfound"-table with various states, such as "waiting for player 1" / "waiting for player 2" / "player 2 declined" etc

With this information being sent to the 2 clients each second, you just pass on the current state in json to the clients, where you then have your presentation code (with for example a turning wheel when waiting for opponent etc)

This system would support alot of players, but if you're aiming on creating a large match making system with thousands of players simultaneously, you should consider looking into other solutions then JavaScript/PHP, where socket-usage would be the best solution.


答: I suggest you look into websockets (like pusher.com or it's open source variant slanger or socket.io). It allows you to keep connections with clients open and thus see whether players are still active or not. It removes your need for ajax calls to any backend.</p>

Title: "Match Making" script, a way without involving the database and php?

Body:
I am writing a matchmaking script for a game through a web portal. For the past few days I have been looking into the different options and I believe the following approach would be the most optimal but I would like the opinion of others.

Get players match requirements through a web form (Method GET) and place the player in queue (mySQL database entry with time stamp and match requirements) for 1 hour.

On the submit page run an ajax script every minute that contacts a php script that checks the following:

Is a player still in the system, if their hour is over or their ajax script has not ran in 5 minutes remove them from the database. Return time out.

Is the player in queue flagged for a match?

If yes then place both players in the in match table and remove both players from queue and send match variables.

If no then continue.

Do the remaining players match the current players requirements?

If yes:

Is the player the same one looking for a match.

If no: Return match variables. Flag other player.

If yes: Return match not found.

If no: Return match not found.

When match variables are received the page will be updated with jquery, including a new ajax request that will call a new php script every 30 seconds to find out if both players accept the match. Possible ajax results are: 0 waiting, 1 accepted, 2 declined. There will also be a button that will send the players response immediately to the php script through ajax that will disable itself through jquery when pushed. When both players accept the page will then use jquery again to display the instructions for beginning the match.

Is there a cleaner or less intensive way to do this with or without involving the database and php?

Notes:

No code is written yet.

The system will not have more than 100 players in queue at any time. (Most likely a peak of 25)


答:
there are software solutions for mutual exclusion using only shared memory.

The major gotcha when implementing these is that the order of loads and stores of the shared variables is very important and the compiler/optimizer may not tinker with them at all, most languages have a volatile keyword for fields that will ensure this is true. Also the aforementioned loads and stores must be atomic (no garbage values may occur possible when multiple thread access the variables).


答:
you probable don't need to store all possible transformations so you can just compute them as needed when you access them

If you want to get clever in accessing the boards then you can use a variant of matrix transformations:

```<code>int[6][MAX_SYMMETRIES] transforms={{ 1, 0, 0,
                                     0, 1, 0},
                                   { 0, 1, 0,
                                     1, 0, 0},
                                   {-1, 0, 7,
                                     0, 1, 0},...};

SQUARE_TYPE GetSquare(int[8][8]& board, int row, int column, int symmetry)
{
     assert(0<=row && row<MAX_ROWS);
     assert(0<=column && column <MAX_COLUMNS);
     assert(0<=symmetry&& symmetry<MAX_SYMMETRIES);

     int newRow = transforms[symmetry][0]*row+ transforms[symmetry][1]*column+ transforms[symmetry][2]
     int newCollumn = transforms[symmetry][3]*row+ transforms[symmetry][4]*column+ transforms[symmetry][5]

     return board[newRow][newCollumn];
}
</code>```

you can also do this with the 64 length array if needed

Title: Choice between 1-dimensional and 2-dimensional array

Body:
I'm implementing the Chessboard class to represent the chessboard. I've to implement the transformations (reflections and rotations) on the chess board possible.

The possible transformations includes the combination of:

 1. Vertical Reflection
 2. Horizontal Reflection
 3. Diagonal Reflection
```

<p>Thus, we've <strong>8</strong> possible transformations for chess board.</p>

<p>There are <strong>64</strong> squares on the Chessboard numbered <strong>[0..63]</strong>.</p>

<p>Thus, to represent the total resulting values after the transformations is <strong>8*64</strong> (No.of Transformations * Chessboard_Size).</p>

<p>There are two fundamental ways to represent the <strong>transformed_board</strong> using Arrays:</p>

<pre class="lang-none prettyprint-override"><code>One-Dimensional Array with transformed_board[8*64]
Two-Dimensional Array with transformed_board[8][64]
</code>```

Questions:

Which approach is better?

What are the pros and cons of each approach?

How will effect the performance with respect to time factor?

Body:
you probable don't need to store all possible transformations so you can just compute them as needed when you access them

If you want to get clever in accessing the boards then you can use a variant of matrix transformations:

int[6][MAX_SYMMETRIES] transforms={{ 1, 0, 0,
                                     0, 1, 0},
                                   { 0, 1, 0,
                                     1, 0, 0},
                                   {-1, 0, 7,
                                     0, 1, 0},...};

SQUARE_TYPE GetSquare(int[8][8]& board, int row, int column, int symmetry)
{
     assert(0<=row && row<MAX_ROWS);
     assert(0<=column && column <MAX_COLUMNS);
     assert(0<=symmetry&& symmetry<MAX_SYMMETRIES);

     int newRow = transforms[symmetry][0]*row+ transforms[symmetry][1]*column+ transforms[symmetry][2]
     int newCollumn = transforms[symmetry][3]*row+ transforms[symmetry][4]*column+ transforms[symmetry][5]

     return board[newRow][newCollumn];
}

you can also do this with the 64 length array if needed


答: One option that requires no coding is to use VNC or any remote desktop client in a browser. Your app need to run on a Windows desktop though, and if you have more than one simultaneous user you need one one desktop per user.</p>

Title: Multiple remote views of a C# application

Body:
I have a C# application (Desktop based application for Windows OS), which I wanted to use from Web browser.

The application is a kind of analyzing tool, which takes some input values and performs set of calculations over it then displays an animation of the results.

Since the application can't be coded again in a new language, Can anyone suggest me, how I can view and interact with this C# application from browser (like the way we interact with Java Applets)? Also the application can be used by more than one user at a time, so there must be multiple views for this web application.


问:
How does Java handle cyclic data references when serializing an object?
As an assignment question, I am asked to answer the following:

How are cycles handled? Where does the term graph come from?

In the examples given, there does not appear to be any clear trick that was done to serialize a cyclic linked list, so I can't discern if anything special is being done on the part of the programmer, or if it's handled internally by the JVM. Moreover, a Google search does not appear to answer the question other than to say that the JVM handles cyclic serialization natively by not re-serializing objects. But I'm not satisfied that this actually answers the question of "how".

My best guess is that some form of spanning tree algorithm is run on the object graph to remove cycles, but again, this is unconfirmed...

Where can I find information to help answer this question?

答:
it caches the object and uses references so objects are not written out twice

5. If the object has already been written to the stream, its handle is written to the stream and writeObject returns.

  12. For regular objects, the ObjectStreamClass for the class of the object is written by recursively calling writeObject. It will appear in the stream only the first time it is referenced. A handle is assigned for the object.

http://docs.oracle.com/javase/6/docs/platform/serialization/spec/output.html

In other words it checks a IdentityHashMap<Object,Handle> for each object it writes out. and if present will just write out the handle.

this can be overridden by using writeUnshared(Object) to write out the object


问:
What is the benefit of having the assignment operator return a value?
I'm developing a language which I intend to replace both Javascript and PHP. (I can't see any problem with this. It's not like either of these languages have a large install base.)

One of the things I wanted to change was to turn the assignment operator into an assignment command, removing the ability to make use of the returned value.

```<code>x=1;          /* Assignment. */
if (x==1) {}  /* Comparison. */
x==1;         /* Error or warning, I've not decided yet. */
if (x=1) {}   /* Error. */
</code>```

I know that this would mean that those one-line functions that C people love so much would no longer work. I figured (with little evidence beyond my personal experience) that the vast majority of times this happened, it was really intended to be comparison operation.

Or is it? Are there any practical uses of the assignment operator's return value that could not be trivially rewritten? (For any language that has such a concept.)

答:
Technically, some syntactic sugar can be worth keeping even if it can trivially be replaced, if it improves readability of some common operation.
But assignment-as-expression does not fall under that. The danger of typo-ing it in place of a comparison means it's rarely used (sometimes even prohibited by style guides) and provokes a double take whenever it is used. In other words, the readability benefits are small in number and magnitude.

A look at existing languages that do this may be worthwhile.

Java and C# keep assignment an expression but remove the pitfall you mention by requiring conditions to evaluate to booleans. This mostly seems to work well, though people occasionally complain that this disallows conditions like if (x) in place of if (x != null) or if (x != 0) depending on the type of x.

Python makes assignment a proper statement instead of an expression. Proposals for changing this occasionally reach the python-ideas mailing list, but my subjective impression is that this happens more rarely and generates less noise each time compared to other "missing" features like do-while loops, switch statements, multi-line lambdas, etc.

However, Python allows one special case, assigning to multiple names at once: a = b = c. This is considered a statement equivalent to b = c; a = b, and it's occasionally used, so it may be worth adding to your language as well (but I wouldn't sweat it, since this addition should be backwards-compatible).


问:
How to make it obvious that a function is being accessed from the outside?
This is a C specific question. I am trying to keep everything possible inside the translation unit boundaries, exposing only a few functions through the .h file. That is, I am giving static linkage to file-level objects.

Now, a couple of functions need to be called by other modules, but not directly. My module/file/translation unit subscribes to the other modules, passing a pointer to a function. Then, upon a specific event, the pointer is called with some arguments.

So I am wondering how to make it very obvious that those functions are called from some obscure location.

Should they be static or extern (and expose them in the .h) ?

Should I include some hint in the name of the functions?

Or is it enough to put a comment "called by X"?

答: If callback functions are defined within your module and the user will never provide one of his own, I think you can use a placeholder during initialization phase.  The placeholder is typically an enum which is then internally translated to the right static function.


答:
Many languages do choose the route of making assignment a statement rather than an expression, including Python:

foo = 42 # works
if foo = 42: print "hi" # dies
bar(foo = 42) # keyword arg
```

<p>and Golang:</p>

<pre class="lang-golang prettyprint-override"><code>var foo int
foo = 42 # works
if foo = 42 { fmt.Printn("hi") } # dies
</code>```

Other languages don't have assignment, but rather scoped bindings, e.g. OCaml:

let foo = 42 in
  if foo = 42 then
    print_string "hi"
```

<p>However, <code>let</code> is an expression itself.</p>

<p>The advantage of allowing assignment is that we can directly check the return value of a function inside the conditional, e.g. in this Perl snippet:</p>

<pre class="lang-perl prettyprint-override"><code>if (my $result = some_computation()) {
  say "We succeeded, and the result is $result";
}
else {
  warn "Failed with $result";
}
</code>```

Perl additionally scopes the declaration to that conditional only, which makes it very useful. It will also warn if you assign inside a conditional without declaring a new variable there – if ($foo = $bar) will warn, if (my $foo = $bar) will not.

Making the assignment in another statement is usually sufficient, but can bring scoping problems:

my $result = some_computation()
if ($result) {
  say "We succeeded, and the result is $result";
}
else {
  warn "Failed with $result";
}
# $result is still visible here - eek!
```

<p>Golang heavily relies on return values for error checking. It therefore allows a conditional to take an initialization statement:</p>

<pre class="lang-golang prettyprint-override"><code>if result, err := some_computation(); err != nil {
  fmt.Printf("Failed with %d", result)
}
fmt.Printf("We succeeded, and the result is %d\n", result)
</code>```

Other languages use a type system to disallow non-boolean expressions inside a conditional:

int foo;
if (foo = bar()) // Java does not like this
```

Of course that fails when using a function that returns a boolean.

We now have seen different mechanisms to defend against accidental assignment:

Disallow assignment as an expression

Use static type checking

Assignment doesn't exist, we only have let bindings

Allow an initialization statement, disallow assignment otherwise

Disallow assignment inside a conditional without declaration

I've ranked them in order of ascending preference – assignments inside expressions can be useful (and it's simple to circumvent Python's problems by having an explicit declaration syntax, and a different named argument syntax). But it's ok to disallow them, as there are many other options to the same effect.

Bug-free code is more important than terse code.

Title: What is the benefit of having the assignment operator return a value?

Body:
I'm developing a language which I intend to replace both Javascript and PHP. (I can't see any problem with this. It's not like either of these languages have a large install base.)

One of the things I wanted to change was to turn the assignment operator into an assignment command, removing the ability to make use of the returned value.

```<code>x=1;          /* Assignment. */
if (x==1) {}  /* Comparison. */
x==1;         /* Error or warning, I've not decided yet. */
if (x=1) {}   /* Error. */
</code>```

I know that this would mean that those one-line functions that C people love so much would no longer work. I figured (with little evidence beyond my personal experience) that the vast majority of times this happened, it was really intended to be comparison operation.

Or is it? Are there any practical uses of the assignment operator's return value that could not be trivially rewritten? (For any language that has such a concept.)

Body:
Many languages do choose the route of making assignment a statement rather than an expression, including Python:

foo = 42 # works
if foo = 42: print "hi" # dies
bar(foo = 42) # keyword arg

and Golang:

var foo int
foo = 42 # works
if foo = 42 { fmt.Printn("hi") } # dies

Other languages don't have assignment, but rather scoped bindings, e.g. OCaml:

let foo = 42 in
  if foo = 42 then
    print_string "hi"

However, let is an expression itself.

The advantage of allowing assignment is that we can directly check the return value of a function inside the conditional, e.g. in this Perl snippet:

if (my $result = some_computation()) {
  say "We succeeded, and the result is $result";
}
else {
  warn "Failed with $result";
}

Perl additionally scopes the declaration to that conditional only, which makes it very useful. It will also warn if you assign inside a conditional without declaring a new variable there – if ($foo = $bar) will warn, if (my $foo = $bar) will not.

Making the assignment in another statement is usually sufficient, but can bring scoping problems:

my $result = some_computation()
if ($result) {
  say "We succeeded, and the result is $result";
}
else {
  warn "Failed with $result";
}
# $result is still visible here - eek!

Golang heavily relies on return values for error checking. It therefore allows a conditional to take an initialization statement:

if result, err := some_computation(); err != nil {
  fmt.Printf("Failed with %d", result)
}
fmt.Printf("We succeeded, and the result is %d\n", result)

Other languages use a type system to disallow non-boolean expressions inside a conditional:

int foo;
if (foo = bar()) // Java does not like this

Of course that fails when using a function that returns a boolean.

We now have seen different mechanisms to defend against accidental assignment:

Disallow assignment as an expression

Use static type checking

Assignment doesn't exist, we only have let bindings

Allow an initialization statement, disallow assignment otherwise

Disallow assignment inside a conditional without declaration

I've ranked them in order of ascending preference – assignments inside expressions can be useful (and it's simple to circumvent Python's problems by having an explicit declaration syntax, and a different named argument syntax). But it's ok to disallow them, as there are many other options to the same effect.

Bug-free code is more important than terse code.


答:
By the sounds of it, you are on the path of creating a fairly strict language.

With that in mind, forcing people to write:

```<code>a=c;
b=c;
</code>```

instead of:

```<code>a=b=c;
</code>```

might seem an improvement to prevent people from doing:

```<code>if (a=b) {
</code>```

when they meant to do:

```<code>if (a==b) {
</code>```

but in the end, this kind of errors are easy to detect and warn about whether or not they are legal code.

However, there are situations where doing:

```<code>a=c;
b=c;
</code>```

does not mean that

```<code>if (a==b) {
</code>```

will be true.

If c is actually a function c() then it could return different results each time it is called. (it might also be computationally expensive too...)

Likewise if c is a pointer to memory mapped hardware, then

```<code>a=*c;
b=*c;
</code>```

are both likely to be different, and also may also have electronic effects on the hardware on each read.

There are plenty of other permutations with hardware where you need to be precise about what memory addresses are read from, written to and under specific timing constraints, where doing multiple assignments on the same line is quick, simple and obvious, without the timing risks that temporary variables introduce

Body:
By the sounds of it, you are on the path of creating a fairly strict language.

With that in mind, forcing people to write:

a=c;
b=c;

instead of:

a=b=c;

might seem an improvement to prevent people from doing:

if (a=b) {

when they meant to do:

if (a==b) {

but in the end, this kind of errors are easy to detect and warn about whether or not they are legal code.

However, there are situations where doing:

a=c;
b=c;

does not mean that

if (a==b) {

will be true.

If c is actually a function c() then it could return different results each time it is called. (it might also be computationally expensive too...)

Likewise if c is a pointer to memory mapped hardware, then

a=*c;
b=*c;

are both likely to be different, and also may also have electronic effects on the hardware on each read.

There are plenty of other permutations with hardware where you need to be precise about what memory addresses are read from, written to and under specific timing constraints, where doing multiple assignments on the same line is quick, simple and obvious, without the timing risks that temporary variables introduce


答:
Since you get to make up all the rules, why now allow assignment to turn a value, and simply not allow assignments inside conditional steps? This gives you the syntactic sugar to make initializations easy, while still preventing a common coding mistake.

In other words, make this legal:

```<code>a=b=c=0;
</code>```

But make this illegal:

```<code>if (a=b) ...
</code>```

Body:
Since you get to make up all the rules, why now allow assignment to turn a value, and simply not allow assignments inside conditional steps? This gives you the syntactic sugar to make initializations easy, while still preventing a common coding mistake.

In other words, make this legal:

a=b=c=0;

But make this illegal:

if (a=b) ...


问:
Can I get sued over duplicating another program's UI?
If I see something I like in another application, and create something similar from the ground up in a commercial product, could I get sued over it?

Of course it would be styled to look differently, however most of the functionality would be the same since the functionality is what I liked about it. It also would not be the entire system, just a part of one.

I live in the US.

答:
Can I get sued over duplicating another program's UI?

This may happen.

I live in the US.

This is the biggest problem. US patent chamber seems to accept patenting of trivia.

As you know Apple patented their iPhone's "pinch to zoom" with two fingers. Other companys (Samsung, HTC) implemented this functionality as well and ship it worldwide, but disable it for the US market. You may want to provide a different version for the US users as well.

One other option would be to register a company elsewhere to get out of the US jurisdiction. This won't protect you from attempts to sue you though however may lower their success rate.

At the end of the day, it would also depend how close you duplicate the UI. I believe there is always a room to play, not just to make it look different but also much better in the process. Also if other folks start duplicating it, the mass might win.

One other consideration: while you're small and not really a competitor they won't come after you. When you're on the level they likely will. If you're huge and successful (like Google) everyone will come after you even if you're clean.


答:
Copyright licenses only restrict what others can do with your code.

With that in mind, as long as the code remains yours, your first and third bullet points become irrelevant, because they are about what you do with your own code.

In principle, any code that you write is owned by you (as in, you control who can do what with it), but there are a few exceptions to that principle, where the most obvious one is because you wrote the code as part of your job. A more tricky situation is that in some cases where you do freelance work and you haven't stipulated otherwise in your contracts, then the code could be owned by your client. If you want to retain ownership of your code, you should make clear provisions about that in contracts that you sign that involve (the writing of) the code.

Once the ownership issue is resolved in your contracts, the biggest question that remains for choosing a license is what you want to allow your client to do with the code.
b
Most copyright licenses don't restrict how you use the code (so commercial use is not a problem), but they restrict how the code can be modified or redistributed.
If you don't want to allow modification or redistribution, the standard "all rights reserved" copyright 'license' is sufficient (How you use the software is not generally considered one of those reserved rights).

Application of a copyright license is done simply by stating in the source code that copyright license X applies and by adding the additional license texts and notifications to your project as required by that license.

There is no authority that certifies that a particular license applies and it is your job to look out for violations of the copyright license you use for your code.

Title: What's the right licensing to sell a web app, without renounce to reuse the code?

Body:
I'm making a web app for a client who is probably going to use it for commercial use. I'm not affialited with me, nor we are commercial partners.

However, although I'm making this project for this client, I want to be sure I can reuse the same code on future projects.

I know there are many licenses (GPL etc.) but it's not clear to me which one complies the following requirments:

The code can be sold by me to the client (so he pays me for the code)

The client may use the code for commercial use

I still own the ownership on the code, i.e. , I can reuse the code for future works, either in open source works or other projects (which I may sell)

Furthermore, it's not clear to me: When I choose I license how can I "apply" it? I mean: who "certifies" my app is licensed udner that specific licence and do I have to pay for this "certification"?

Thanks in advance :)


答:
You said "I figured (with little evidence beyond my personal experience) that the vast majority of times this happened, it was really intended to be comparison operation."

Why not FIX THE PROBLEM?

Instead of = for assignment and == for equality test, why not use := for assignment and = (or even ==) for equality?

Observe:

```<code>if (a=foo(bar)) {}  // obviously equality
if (a := foo(bar)) { do something with a } // obviously assignment
</code>```

If you want to make it harder for the programmer to mistake assignment for equality, then make it harder.

At the same time, if you REALLY wanted to fix the problem, you would remove the C crock that claimed booleans were just integers with predefined symbolic sugar names.  Make them a different type altogether.  Then, instead of saying

```<code>int a = some_value();
if (a) {}
</code>```

you force the programmer to write:

```<code>int a = some_value();
if (a /= 0) {} // Note that /= means 'not equal'.  This is your Ada lesson for today.
</code>```

The fact is that assignment-as-an-operator is a very useful construct.  We didn't eliminate razor blades because some people cut themselves.  Instead, King Gillette invented the safety razor.

Body:
You said "I figured (with little evidence beyond my personal experience) that the vast majority of times this happened, it was really intended to be comparison operation."

Why not FIX THE PROBLEM?

Instead of = for assignment and == for equality test, why not use := for assignment and = (or even ==) for equality?

Observe:

if (a=foo(bar)) {}  // obviously equality
if (a := foo(bar)) { do something with a } // obviously assignment

If you want to make it harder for the programmer to mistake assignment for equality, then make it harder.

At the same time, if you REALLY wanted to fix the problem, you would remove the C crock that claimed booleans were just integers with predefined symbolic sugar names.  Make them a different type altogether.  Then, instead of saying

int a = some_value();
if (a) {}

you force the programmer to write:

int a = some_value();
if (a /= 0) {} // Note that /= means 'not equal'.  This is your Ada lesson for today.

The fact is that assignment-as-an-operator is a very useful construct.  We didn't eliminate razor blades because some people cut themselves.  Instead, King Gillette invented the safety razor.


问:
When is it worthwhile to replace working mature code with frameworks+patterns
Intro/Question

I fear that frameworks in many cases have become a fashion or trend and are being abused. In many ways people are sacrificing speed just because they want to keep up with every single lib that comes out. I am for a more conservative approach that only makes use of new libraries and frameworks when it absolutely makes sense.

Related: When NOT to use a framework

Update/Disclaimer (May 18, 2017)

I've come to the conclusion that rapid application development, ease, and maintainability are the targets. So frameworks (new and old) should be used  provided they help in reaching a final product quicker. Only when special cases exist (actual measurable performance issues) should we switch to custom code... or when the project itself is legacy and the cost of completely rewriting are too high.

Case

We have a Tomcat6 Servlet production that has been ongoing development since 2008 and there are many hours of work behind it. The code is very mature but it does not use any frameworks.

A new team member loves using frameworks and patterns for everything. Except for the love of frameworks, they also love cutting edge new releases and even proposed migrating from Tomcat6 to somethiong newer (JBOSS,GLASSFISH, or TOMCAT8).

I would never move a core production service to a container/server/web-server that just came out.

Not against refactoring code to keep it clean though!

I am against adding frameworks and patterns that add delay to production code servicing thousands of requests per second.

Serialization to stream (JSON/XML) while maintaining backwards compatibility

When a request comes, we produce both XML and JSON documents containing data related to the request params.

Since we maintain backwards compatibility for older clients changes must not break older support. Since we also support both JSON and XML, we make use of the Jackson but also KXML libraries.

For both formats we have 2 different serialization methods that use the streaming API. Except for being faster, I also find it is MUCH more flexible for maintaining backwards compatibility.

I like to use a sysyem of Major and Minor version. All minor changes to the backend that cause changes to the serialized document I add with IF statements in the serialization method. Once quite a few changes have accomulated (over 1 year), we add a new serialization method. So, all requests specifying version=1.00 to 1.99 are sent to serializeJSON1. All requests using version 2 to 2.99 are sent to serializeJSON2.

I've heard the argument that we should use ANNOTATIONS and MAP to objects.
I find this very distastefull as I have read streaming is the fastest.

The streaming API allows you to make necessary changes on the fly while MAPPING would require to store multiple versions of the same data as different objects, or jump through other hoops.

```<code> output.startTag(null, TagTable.PRODUCT);

 output.startTag(null, TagTable.ID);
 output.text(ID);
 output.endTag(null, TagTable.ID);

 output.startTag(null, TagTable.DESCRIPTION);

 if (locale != null && Translations.containsKey(locale) && version >= 1)
     output.text(this.DescriptionURL + "/" + locale);
 else
     output.text(this.DescriptionURL);

 output.endTag(null, TagTable.LONGDESCRIPTION);

 if (version >= 1 && version < 1.5) {
     output.startTag(null, TagTable.POPULARITY);
     output.text(String.valueOf((int) this.pop));
     output.endTag(null, TagTable.POPULARITY);
 } else if (version >= 1.5) {
     output.startTag(null, TagTable.RATING);
     output.text(String.valueOf((int) this.rating));
     output.endTag(null, TagTable.RATING);
 }
</code>```

In the specific 3 cases above I really don't see the point to replace working mature code with frameworks/libs/patterns that may add additional overhead and cost additional development time.

So, when is it worthwhile to replace working mature code with frameworks+patterns??

Comments?

Update: Some benchmarks

For the first two examples posted previously, using REST and HASHMAPs does not make overly that big a difference in performance but does make the code more readable.

Now for the more interesting issue about serialization when used in a hotspot.
Since the actual servlet in question had too much other code I made a toy example to test streaming vs mapping. The code is available at: https://stackoverflow.com/questions/21781540/

By all means test it, change it, run it.

What is very interesting is that the Just in time optimizer in java ends up making the difference negligable over time. So, here is how the percentage between mapping and streaming changes the more iterations there are.

```<code>Iter    Stream  Mapping
0       36,71%  63,29%
20      44,75%  55,25%
40      45,65%  54,35%
60      45,95%  54,05%
80      46,24%  53,76%
100     47,09%  52,91%
120     47,09%  52,91%
140     47,37%  52,63%
160     47,64%  52,36%
180     47,92%  52,08%
200     47,64%  52,36%
220     47,92%  52,08%
240     47,92%  52,08%
260     47,92%  52,08%
280     48,19%  51,81%
300     48,45%  51,55%
320     48,45%  51,55%
340     48,45%  51,55%
360     48,45%  51,55%
380     48,45%  51,55%
400     48,45%  51,55%
1000    48,72%  51,28%
2000    49,24%  50,76%
3000    49,24%  50,76%
4000    49,49%  50,51%
5000    49,75%  50,25%
6000    49,75%  50,25%
7000    49,75%  50,25%
8000    49,75%  50,25%
9000    49,75%  50,25%
</code>```

I also re-ran one more time have first 20 iterations more detailed:

```<code>0   39,76%  60,24%
1   41,18%  58,82%
2   40,83%  59,17%
3   40,12%  59,88%
4   40,48%  59,52%
5   40,83%  59,17%
6   40,83%  59,17%
7   40,83%  59,17%
8   40,48%  59,52%
9   40,12%  59,88%
10  41,52%  58,48%
11  42,53%  57,47%
12  42,86%  57,14%
13  42,86%  57,14%
14  43,18%  56,82%
15  43,50%  56,50%
16  43,50%  56,50%
17  43,82%  56,18%
18  43,82%  56,18%
19  43,82%  56,18%
20  44,75%  55,25%
</code>```

After 10,000 iterations (or calling JSON generation code 1000 times) here is the screenshot from VisualVM profiling (visualVM snapshot NPS file):

So, if this optimization behavior holds up in Tomcat servlets as well, it means there really is no point NOT to use mapping (and many other convenience functions/libs since the JVN will optimize over time).

Conclusions

Based on the answers/comments, I think at the end of the day whether to rewrite working production code is affected by business requirement, and specific cost-benefit analysis for each project.

Based on the benchmarking, it turns out avoiding some libs/frameworks may make no difference in the long run due to JIT JVM optimizations.

Update: After leaving code running all night

After 275,137 iterations and approximately 30,000 MS:

```<code>Mapping -   19,80%
Streaming -  80,20%
</code>```

I really wonder what JIT optimizations happen here and whether the behavior holds for a servlet.

答:
They say

a bird in the hand is better than 2 in the bush

Applied here, I take it to mean its better to have something that works and is maintainable than to tear it all down for some fantasy daydream of "but it'll be vaguely better if we use X Y or Z cool new technology for the sake of using the cool new technology".

I mean, you could have rewritten it in a functional language a few years ago, or Ruby on Rails a couple of years ago, or Node.js a year ago or... whatever comes along next that gets attention in the technical blogosphere. None of these things would create you a stable product that satisfies the 'must use new stuff' people as they will be considered old technologies before they're even finished and they'll want to re-rewrite!

So I have to ask "what's your problem?". You have good code that might be a bit mucky here and there, but in my extensive experience, when you start a big rewrite you end up with code that's a bit mucky (often quickly implemented due to inexperience with the tooling or done under time pressure that you will come back to and fix up nicely, promise.)

When you use a framework is when you are doing a new project and you want a load of code written for you, that's the time to go framework, to re-use all that boring boilerplate that you'd have to write yourself. You never go for a framework because its there to be used, especially when you have an existing framework that you know (even if you don't call it a framework because its grown by itself, it's effectively still one).

One thing to note, I do find a lot of the people who insist on using any kind of new technology want to for 1 of 2 reasons: they either want to boost their CV, or they do not want to learn the existing technology you use (after all, learning tech x is way more fun than actually doing work on existing product). I treat all calls with suspicion as in either case their intention is not in the best interest of the product or the business.

Heavy refactoring...that's a different story, and usually a good one.


问:
Product backlog acceptance criteria
I read on a similar forum https://stackoverflow.com/questions/8117530/examples-for-acceptance-criteria-for-a-user-story about putting in the acceptance criteria for product backlog item.

I am working on a Scrum based project and I need more info as my backlog item is as follows -

UserProfiles ( I am using this in the title field in tfs 2013) and the description contains all the "As a user I want to be able to create new users and assign permissions'

The acceptance criteria talks about how the user interacts with the UI (as discussed in one of the answers in the above link - which is very logical)

For example

As the user clicks on the home button, system will bring up 3 options

And then the user can enter their user name

Is this the right approach I am using to use title for PBI and put the actual user story in description field in tfs

Thanks in advance

答:
I like utilizing acceptance criteria, but as another user mentioned, stories should be negotiable. Let's see an example of how we could change this to better fit an agile environment:

"As the user clicks on the home button, system will bring up 3 options."

This is too specific for a story as far as I'm concerned.

You (sort of) have two options.

Change it to something more like, "The user needs to be able to select between these options when they are logging in...".  This way we're not directly dictating implementation. Depending on context, it's possible that this way still may be too specific.

And even then, this may be a separate story all together, depending on context:
"As a user, I need to be able to select between these options, so that..."

In the end, this is up to your team and what they're comfortable with.  Talk to them.  Bring it up in the retrospective.

Title: Product backlog acceptance criteria


答:
From the perspective of the compilation unit (file), the only thing you should concern yourself with is whether or not the function is available to the outside.  Making it available means that it was intended to be called, and you should operate under the assumption that those calls will happen.  Your concern with the function itself begins at its entry point.  How control gets there in the first place matters only to the code that makes it happen.

Since linkage in every implementation of C I know of is symbolic, anything that calls a function must refer to its symbol:

```<code>foo();  /* Direct */

some_function_pointer_t funcs[] = { &foo, &bar, &baz };  /* Indirect */
</code>```

If you mistakenly declare foo() to be static, your program won't link.  If you declare it non-static, you have an exposed function that isn't called.  Questions about whether or not a function is used can be resolved by dumping the symbol tables of your object files or searching for it in the sources.

Title: How to make it obvious that a function is being accessed from the outside?

Body:
This is a C specific question. I am trying to keep everything possible inside the translation unit boundaries, exposing only a few functions through the .h file. That is, I am giving static linkage to file-level objects.

Now, a couple of functions need to be called by other modules, but not directly. My module/file/translation unit subscribes to the other modules, passing a pointer to a function. Then, upon a specific event, the pointer is called with some arguments.

So I am wondering how to make it very obvious that those functions are called from some obscure location.

Should they be static or extern (and expose them in the .h) ?

Should I include some hint in the name of the functions?

Or is it enough to put a comment "called by X"?

Body:
From the perspective of the compilation unit (file), the only thing you should concern yourself with is whether or not the function is available to the outside.  Making it available means that it was intended to be called, and you should operate under the assumption that those calls will happen.  Your concern with the function itself begins at its entry point.  How control gets there in the first place matters only to the code that makes it happen.

Since linkage in every implementation of C I know of is symbolic, anything that calls a function must refer to its symbol:

foo();  /* Direct */

some_function_pointer_t funcs[] = { &foo, &bar, &baz };  /* Indirect */

If you mistakenly declare foo() to be static, your program won't link.  If you declare it non-static, you have an exposed function that isn't called.  Questions about whether or not a function is used can be resolved by dumping the symbol tables of your object files or searching for it in the sources.


问:
What is this design pattern called?
I have some code:

```<code>/// <summary>
/// Represents Record Locator class
/// </summary>
public class RecordLocator : IRecordLocator
{
    /// <summary>
    /// The Record Locator string, for example: ZT8C4O
    /// </summary>
    public string Name { get; private set; }

    /// <summary>
    /// Initializes a new instance of the <see cref="RecordLocator"/> class.
    /// </summary>
    /// <param name="recordLocator">The record locator string.</param>
    private RecordLocator(string recordLocator)
    {
        Name = recordLocator;
    }

    /// <summary>
    /// Parses the specified record locator.
    /// </summary>
    /// <param name="recordLocator">The record locator string.</param>
    /// <returns></returns>
    public static IRecordLocator Parse(string recordLocator)
    {
        if (string.IsNullOrEmpty(recordLocator))
        throw new ArgumentNullException("recordLocator");

        if (recordLocator.Length != 6)
        throw new ArgumentException("recordLocator.Length != 6");

        return new RecordLocator(recordLocator);
    }
}

/// <summary>
/// Represents Record Locator interface
/// </summary>
public interface IRecordLocator : IHideObjectMembers
{
    /// <summary>
    /// The Record Locator string, for example: ZT8C4O
    /// </summary>
    string Name { get; }
}
</code>```

What is this design-pattern called? When you have a class, which instantiating itself (and probably have a private constructor)?
Another example of this is System.DateTime class of .NET framework.

Is it OK to do it like that?

答:
No such pattern exists in GoF book. Nor I heard about this kind of pattern.

Yes it is OK to do that. But be careful, because it limits extensibility.

Title: What is this design pattern called?


答:
I can't recognize any established design patterns here. However, parsing a string to build an object is good, I have seen many examples in Java(my primary language) like Integer.parseInt.

You cannot have a constructor for parsing strings because if the parsing fails, you must throw an exception(expensive) or keep an object in undefined state(bad). Parsing method can either generate a new object or return null.

Title: What is this design pattern called?

Body:
I have some code:

```<code>/// <summary>
/// Represents Record Locator class
/// </summary>
public class RecordLocator : IRecordLocator
{
    /// <summary>
    /// The Record Locator string, for example: ZT8C4O
    /// </summary>
    public string Name { get; private set; }

    /// <summary>
    /// Initializes a new instance of the <see cref="RecordLocator"/> class.
    /// </summary>
    /// <param name="recordLocator">The record locator string.</param>
    private RecordLocator(string recordLocator)
    {
        Name = recordLocator;
    }

    /// <summary>
    /// Parses the specified record locator.
    /// </summary>
    /// <param name="recordLocator">The record locator string.</param>
    /// <returns></returns>
    public static IRecordLocator Parse(string recordLocator)
    {
        if (string.IsNullOrEmpty(recordLocator))
        throw new ArgumentNullException("recordLocator");

        if (recordLocator.Length != 6)
        throw new ArgumentException("recordLocator.Length != 6");

        return new RecordLocator(recordLocator);
    }
}

/// <summary>
/// Represents Record Locator interface
/// </summary>
public interface IRecordLocator : IHideObjectMembers
{
    /// <summary>
    /// The Record Locator string, for example: ZT8C4O
    /// </summary>
    string Name { get; }
}
</code>```

What is this design-pattern called? When you have a class, which instantiating itself (and probably have a private constructor)?
Another example of this is System.DateTime class of .NET framework.

Is it OK to do it like that?


答: It is a static factory pattern. In this particular instance it doesn't currently provide anything that a traditional constructor couldn't(IE object pooling or multiple implementation types) so it doesn't add much value, but isn't wrong.</p>

Title: What is this design pattern called?


答:
I would still make them static (they are not intended to be linked to and called by just anyone), and mark their purpose as callbacks supplied to external functions in their name.

static because I try to hide what I can hide, as much as I can hide it.

Mark them in their name, because a), comments get out of date, and b), it becomes obvious at the place where the callback is supplied that this function is intended to be used that way: this basically makes it a red flag to be taking the address of a function that doesn't follow the naming convention.


答: Besides "static factory" (see Sign's answer), I have also heard the term "creation method". Creation methods have the advantage that they have a specific name that conveys meaning. You can also create several methods with the same parameter signature, e.g. an Angle struct with methods static Angle FromDegrees(double degrees) and FromRadians(double radians). This is not possible with constructors.

Title: What is this design pattern called?


问:
Where do put INotifyPropertyChanged Interface in Model or ViewModel
I am new to MVVM pattern I have a window which has 3 text boxes namely Name,Address,Description ,a save button and a listview which displays the above fields Name,Address,Description respectively .When the save button is clicked I want to save the fields into database as well as show the record in the listview as well.
Where do I put INotifyPropertyChanged interface Model or in ViewModel or in both place?</p>

答:
First off, take a look at the basics of MVVM to get a better understanding of how the pattern is supposed to work.  This WPF specific version may be of interest as well.

Generally speaking, the pattern looks like this:

View <= (bound) => ViewModel <= (function calls + async callbacks) => Model

With that diagram in mind, it should be a little more clear that it's the ViewModel's responsibility to notify the View when the data has changed.  So the ViewModel needs to implement INotifyPropertyChanged.

To further validate that decision, you can see that the View should be completely ignorant of the Model and it should only know of its ViewModel.

In order to simplify implementing INotifyPropetyChanged, consider creating a base ViewModel class that the other ViewModels inherit from.  That way you only have to write the code once.  This sample from the MSDN library has an example NotifyPropertyChanged() function that you can use as a reference point.  I believe .NET 4.5 and later allows reflection to be used for the object name instead of relying upon passed strings.


答:
"As a user I want to be able to create new users and assign permissions"

I see at least two different stories in this statement:

As a user, I want to be able to create new users (and default permissions are assigned to these users)

A user can assign permissions to other users.

Small stories that add value to the product make for simpler story definition and more predictable development. For the acceptance criteria of a story, I personally use scenarios in the typical "given-when-then" form - for example, one scenario for the first story:

Given a user logged in the system (you can use "personas" instead of "a user"),

when the user enters the name and password of the new user,

and sends the request to create a new user,

then the new user is created,

and this new user can login into the system.

You can have other scenarios - for example, one more for dealing with duplicate names, another for weak passwords - probably you would also want to implement some kind of captcha or similar human detection stuff...

If you mix the user creation with the permissions assignment you will probably end up with a very big story. IMHO the most difficult part of writing good user stories is not writing the most accurate acceptance criteria, it's learning to define really small stories that add some value to the product. With stories that are all small, it's simpler and easier - I learned this the hard way...

Title: Product backlog acceptance criteria

Body:
I read on a similar forum https://stackoverflow.com/questions/8117530/examples-for-acceptance-criteria-for-a-user-story about putting in the acceptance criteria for product backlog item.

I am working on a Scrum based project and I need more info as my backlog item is as follows -

UserProfiles ( I am using this in the title field in tfs 2013) and the description contains all the "As a user I want to be able to create new users and assign permissions'

The acceptance criteria talks about how the user interacts with the UI (as discussed in one of the answers in the above link - which is very logical)

For example

As the user clicks on the home button, system will bring up 3 options

And then the user can enter their user name

Is this the right approach I am using to use title for PBI and put the actual user story in description field in tfs

Thanks in advance


问:
How to deal with a dev who asks too many questions
I've recently stepped in to a managing position which of course involves overseeing other people's work, and guiding juniors.

There's this guy who won't stop asking questions, and many times it's really basic stuff - which eats a lot of my time and breaks my in-the-zone mode. I tried the easy-going approach of sending him a link with "Let me Google that for you", but he only got excited about the joke, and didn't get the clue. Other times I'm just telling him I'm busy, and that he should go and research it himself.

The thing is, when I wasn't in the office he did a decent job on his own, so most of what he's assigned with he can handle.

The question is how can I make him filter the issues he comes to me with? I realize that I'm the professional authority he should be addressing when he needs help, I only wish he would do it on non-trivial matters.

答:
Sometimes people don't get the message unless you hit them with the proverbial clue-by-four, and sometimes you need to attach a giant rock to it.  You might be at that point.  I'd start with "That's fairly trivial, I'm sure you can figure it out.", and head to "I would expect any developer working for me to know that.  If you don't, then that's going to be a problem.".  Then follow through.

I'm assuming you've had the "George, you are a smart guy, you don't need to come to me with all of these basic questions.  What's up with that?" type conversation.