问:
How are my licensing options limited when I use and/or include other projects in my own?

Setup

I have a project (pynliner, a python module) on github that I never gave much thought about licensing. Today I got an email asking what license it is under because someone wants to use it in their commercial software.

My first thought is that I would love to have 2 licenses one that is free for non-commercial use and one for commercial use. So I started researching software licenses... and got very dizzy. Then I realized I may not even be able to use most of them because my module uses several other modules. So I have a few questions about how licenses filter down.

My module uses but does not include code under:

MIT License BeautifulSoup

LGPL3 cssutils

And my module uses and includes code under:

MIT License soupselect.py

This is a relatively minor project but I would like to use it as a learning process for the right way to approach licensing.

Questions

If I include someone else's code then any licenses I use must not break the included code's license correct?

Does the same hold true for other software I use but don't include? Am I limited by the MIT License on BeautifulSoup or LGPL3 on cssutils if I use them but don't include the source in my project?

edit

Thanks for pointing out the licenses I had missed on cssutils and soupselect.py. Once these were pointed out the rest of my questions really come down to what is allowed within the MIT License since it is the only one over code I have included and whether or not the output of cssutils is free.

I'm comfortable with looking these up the rest of the way. Thanks all.

答:
If I include someone else's code then any licenses I use must not
  break the included code's license correct?

Correct - you are only allowed to use it or distribute it under the terms of their licence. If you re-use it, you are actually using it under their licence - you aren't re-licencing it - so anything you do must be allowed under their licence.

Does the same hold true for other software I use but don't include? Am
  I limited by the copyright on cssutils if I use it but don't include
  the source in my project?

You can use tools, information etc without including them in your project. The test is does your project become a 'derived work' - normally meaning you have included significant IP from that tool in the project you distribute. If you are distributing source code this is unlikely (unless the GPL tool is a code generator) - if you are distributing a binary it might have parts of the tool's library included in it.

If using code under the MIT License doesn't prevent me from having
  commercial and non-commercial licenses, what permissions would I need
  to get from the authors of the the copyrighted cssutils?

cssutils is licenced under LGPL. That means you can include it in your own closed source project if you include it as a dynamic library or run-time loaded module such that the user can swap it for their own version.

edit: not entirely familiar with cssutils but it seems to also be a css code generator. If you are using it in your app when run by your user, then yes - it is distributed as a runtime loaded python module, that's fine under the LGPL. All you have to do is make the original source available to your users.

If you are using it to generate css files which will then be included separately in your project that's a little trickier. The css files may contain parts of the cssutils IP. You should probably check with the authors of csutils, or check for a faq on their site.  The same question comes up with the GPL version of YACC which includes a specific exemption to use it's output freely.

Note copyrighted isn't the same as licenced. Everything you create is copyrighted to you (or perhaps your employer) you only need to consider the licence when you want to give it to other people and want to attach conditions to what they can do with it.


问:
In plain English, what is recursion?
The idea of recursion is not very common in real world. So, it seems a bit confusing to the novice programmers. Though, I guess, they become used to the concept gradually. So, what can be a nice explanation for them to grasp the idea easily?</p>

答:
Josh K already mentioned the Matroshka dolls. Assume that you want to learn something that only the shortest doll knows. The problem is that you can't really talk to her directly, because she originally lives inside the taller doll which on the first picture is placed on her left. This structure goes like that (a doll lives inside the taller doll) until ending up only with the tallest one.

So the only thing that you can do is to ask your question to the tallest doll. The tallest doll (who doesn't know the answer) will need to pass your question to the shorter doll (which on the first picture is on her right). Since she also doesn't have the answer she needs to ask the next shorter doll. This will go like that until the message reaches the shortest doll. The shortest doll (who is the only one who knows the secret answer) will pass the answer to the next taller doll (found on her left), which will pass it to the next taller doll... and this will continue until the answer reaches its final destination, which is the tallest doll and finally... you :)

This is what recursion really does. A function/method calls itself until getting the expected answer. That's why when you write recursive code it's very important to decide about when recursion should terminate.

Not the best explanation but it hopefully helps.

ContentLicense: CC BY-SA 3.0

Title: In plain English, what is recursion?


答:
MIT is a permissive license: there are little or no restrictions on code under it. As others have mentioned, GPL and LGPL can be harder to figure out. Sometimes it's just easiest to ask the authors if they think your usage is OK. </p>

<p>This is an aside, but I tend to use MIT or BSD for my OSS code because I want as many people to use it as possible. </p>

Title: How are my licensing options limited when I use and/or include other projects in my own?

Body:
Setup

I have a project (pynliner, a python module) on github that I never gave much thought about licensing. Today I got an email asking what license it is under because someone wants to use it in their commercial software.

My first thought is that I would love to have 2 licenses one that is free for non-commercial use and one for commercial use. So I started researching software licenses... and got very dizzy. Then I realized I may not even be able to use most of them because my module uses several other modules. So I have a few questions about how licenses filter down.

My module uses but does not include code under:

MIT License BeautifulSoup

LGPL3 cssutils

And my module uses and includes code under:

MIT License soupselect.py

This is a relatively minor project but I would like to use it as a learning process for the right way to approach licensing.

Questions

If I include someone else's code then any licenses I use must not break the included code's license correct?

Does the same hold true for other software I use but don't include? Am I limited by the MIT License on BeautifulSoup or LGPL3 on cssutils if I use them but don't include the source in my project?

edit

Thanks for pointing out the licenses I had missed on cssutils and soupselect.py. Once these were pointed out the rest of my questions really come down to what is allowed within the MIT License since it is the only one over code I have included and whether or not the output of cssutils is free.

I'm comfortable with looking these up the rest of the way. Thanks all.

Body:
MIT is a permissive license: there are little or no restrictions on code under it. As others have mentioned, GPL and LGPL can be harder to figure out. Sometimes it's just easiest to ask the authors if they think your usage is OK.

This is an aside, but I tend to use MIT or BSD for my OSS code because I want as many people to use it as possible.


问:
Arguments for or against using Try/Catch as logical operators
I just discovered some lovely code in our companies app that uses Try-Catch blocks as logical operators.

Meaning, "do some code, if that throws this error, do this code, but if that throws this error do this 3rd thing instead".

It uses "Finally" as the "else" statement it appears.

I know that this is wrong inherently, but before I go picking a fight I was hoping for some well thought out arguments.

And hey, if you have arguments FOR the use of Try-Catch in this manner, please do tell.

For any who are wondering, the language is C# and the code in question is about 30+ lines and is looking for specific exceptions, it is not handling ALL exceptions.

答:
Reason to use exceptions:

If you forget to catch an exceptional circumstance, your program will die and the stack trace will tell you exactly why. If you forget to handle the return value for an exception circumstance there is not telling how far away your program will exhibit incorrect behavior.

Using return values only works if there is a sentinel value you can return. If all possible return values are already valid, what are you going to do?

An exception will carry additional information about what happened which may be useful.

Reasons not to use exceptions:

Many languages aren't designed to make exceptions fast.

Exceptions which travel several layers up the stack can leave inconsistent state in their wake

In the end:

The goal is to write code that communicates what is going on. Exceptions can help/hinder that depending on what the code is doing. A try/catch in python for a KeyError on a dictionary reference is perfectly (as long as you know the language) try/catch for the same KeyError five function layers away is dangerous.


问:
Proper OO design for State and Command
I'm working (a bit) on a (turn-based strategy) game. There are two classes relevant for the question:

State: This is an immutable class, which exposes all its fields (either via getters or another way, as I felt appropriate). The state is a bit complicated, so I decomposed it into several classes in the package ...state

Command: This is an abstract immutable class with a couple of subclasses like MoveCommand(Field from, Field to), PassCommand(), BidCommand(int amount), etc. in the package ...command. All of fields have public getters.

I need one of the two methods

State Command.applyTo(State) or

State State.apply(Command)

returning the new state (obtained by applying the command to the state).

Using the first method looks better at the first sight, since it dispatches to different implementations of applyTo in the subclasses of Command. Unfortunately, it forces me to fiddle with the many details of State in the class Command. In order to make it work, I need something like MutableState, or State.Builder, or a many-args constructor of State, or whatever.

Using the second method looks ugly, as it'd force me to use instanceof (or some other ugly way to simulate the virtual method dispatch). OTOH, it would concentrate the working with State in the class itself.

So I think the first method is the way to go. With Command and State each in its own package it means that MutableState (or whatever gets used for building the resulting State) need to be a public class since there are no friends in Java. No real problem, but not nice, is it?

So what is the proper design?

答:
I think you're fine using your first method.  You will probably want to utilize a StateBuilder to allow the command to build out the new state.

Thus you've divided your state, your commands (allowing you to roll back to prior states, I assume), and your means of building new states.

That said, I'm not sure what the immutable state is giving you in this case, beyond something with a handle that can be tracked or rolled back to.  If that is not your purpose, I don't know that you need it.

Title: Proper OO design for State and Command


问:
Is it a good idea to use Header("Content-Type [...]"); in the core file of a CMS?
I have been working on content management systems for about 7 years. 2 years ago created my own. Currently building a newew, better and bigger version.

However, fell into dilemma. I have a core file, that gets included to all pages. Core file makes sure of adding functions, config, mysql connection etc. I also have added Header("Content-Type: text/html; charset=UTF-8"); on the top of the code in the core file.

Recently I had to make a xml-generator, with Header("content-type: text/xml; charset=UTF-8");. First, of course I couldn't get the xml working, because I forgot about my content-type setting in the core file.. Later I just added the content-type: text/xml after the core file include..

Basically everything works, but I wish polish this project to the finest.

So I'm thinking now, is adding the "content-type: text/html" in the core file, a good idea?

I had an idea, to include the core file like this: include($rootpath . 'inc/core.php?content-type=xml');, then in the core file, the header will be set based on the $_GET['content-type'].. Is that a good solution?

答:
I don't like loose ends, so I will answer this question myself, based on my research and testing.

In a nutshell, YES it is a good idea in most cases. As you want to avoid adding it manually to every index file, that requires the core file. However, real question is.. how useful is setting the content-type and encoding in the first place...?! My experience has shown, that this can avoid possible problems in the future.

When you need to escape from the content-type text/html in index-file, that is actually XML. Simply add the new content-type after the core-file gets included.

Making a function, that sets the content-type is just extra space and doesn't really reflect on the functionality. If anything, it is not optimal solution.


问:
Need advice on designing interactions between various parts of my application
I'm trying to design the "main" classe(s) of a Rich Desktop Application based on NetBeans Platform 7.
This application will consume HTTP services and, through a "push system" over TCP, will receive messages.

We are 3 developpers and we want to develop modules in parallel

Application will be layered (Data, Business, Presentation)

We'll use Presentation Model in order to separate responsibilites

Some granular data (a bean Person for example) will be shared by several screens (and possibly displayed on several screens at the same time)

...

We are able to develop individual screens, but We don't know exactly how to organize the whole application and define each module content.

So, have you any advice (a pattern / best practice / book / sample app) to coordinate/manage interactions inside of the whole application?

Any advice about how to define modules content?

Thanks!

Small example to illustrate what I want to build: A Foo User Management Application

Launch the application

At the left [explorer] we have a list of platforms (list is stored in a local file)

At the top we have button to add a new Platform (also available with right click)

By double-clicking on a platform, the app calls a HTTP service a retrieve a complete list of users. This list is displayed in the [editor] (in a JTable)

A background process is started: through a TCP connection we receive messages

It is possible to Add new user thanks to a button in a Toolbar

If the application is launched on another PC, and if the user is connected to the same platform, its User List will be updated dynamically (add/remove/status:{offline/online}) (thanks to messages)

In the future it a Chat Module will be provided.

My question is (in other words): any advice/best practice to decide on content of each module?
If PM (Presentation Model) is a good way to separate view/business and data and create screens, what is the best way to link several screens based on PM?
Imagine we develop the Chat Module, how to add an entry "Discuss with..." to the Context menu available with right click on User List?

答:
I think you're looking at a pretty classic MVC pattern backed by services (RESTful I assume).  The key will be to separate the service(s) from the UI. This is not because you are introducing an alternative UI, but because gives you clarity in what your service interface should be.

So when you are thinking about the getPeople service, make sure you think about how a secondary (non-Swing) UI would interact with the service.  If you keep that in mind you'll come up with a fairly flexible/decoupled solution.

OwnerDisplayName: Destroyica


答:
Don't get too caught up on the State Pattern. This has a specific usage which I don't think necessarily applies in your game, at least not when you are manipulating the state of play.

Take, for example, a drawing application. In this case, the button pressed in the toolbar affects the way the drawing panel reacts to certain stimuli -- in this case, you don't want the application to know what it is going to do, you just want it to pass the stimulus to the State object and let it figure out what to do.

So, the rectangle drawing button is down, the application holds a RectangleDrawingState from which it can request a mouse-over pointer type or a mouse-down action or whatever. If you press the elipse-drawing button then that control switches out the RectangleDrawingState for an ElipseDrawingState and the application continues to ask for a mouse-over pointer type and a mouse-down action and gets completely different responses.

This is the kind of situation that makes for a good use-case for the State Pattern.

Now you may want this in your turn-based strategy game, to handle whether the attack button is pressed or the gather resources button is pressed. But you should handle the state of the game differently.

The state of the game should be handled as a single mutable object, which is manipulated at the end of each action. This object needs to be serializable in some form.

What you should do then is get a Command object by whatever means necessary and act on the mutable state-of-play object (it might be that your immutable State object, which depends on the action selected at any given time, returns a command which can act on the state-of-play object, for example).

Title: Proper OO design for State and Command

Body:
I'm working (a bit) on a (turn-based strategy) game. There are two classes relevant for the question:

State: This is an immutable class, which exposes all its fields (either via getters or another way, as I felt appropriate). The state is a bit complicated, so I decomposed it into several classes in the package ...state

Command: This is an abstract immutable class with a couple of subclasses like MoveCommand(Field from, Field to), PassCommand(), BidCommand(int amount), etc. in the package ...command. All of fields have public getters.

I need one of the two methods

State Command.applyTo(State) or

State State.apply(Command)

returning the new state (obtained by applying the command to the state).

Using the first method looks better at the first sight, since it dispatches to different implementations of applyTo in the subclasses of Command. Unfortunately, it forces me to fiddle with the many details of State in the class Command. In order to make it work, I need something like MutableState, or State.Builder, or a many-args constructor of State, or whatever.

Using the second method looks ugly, as it'd force me to use instanceof (or some other ugly way to simulate the virtual method dispatch). OTOH, it would concentrate the working with State in the class itself.

So I think the first method is the way to go. With Command and State each in its own package it means that MutableState (or whatever gets used for building the resulting State) need to be a public class since there are no friends in Java. No real problem, but not nice, is it?

So what is the proper design?


问:
Removing elements of an 'at least one' association
let's assume - regardless from technology and programming languages - you have a type and the type has an association to another type. This association has the complexity of 'at least one' (1..n). How would you specify the behavior, when removing elements from this association based on a predicate? Say, the predicate fits to all elements, thus the removal would violate the 1..n constraint, would you remove all elements but one or would you rather not remove any element in this case (and have a transactional-like behavior)?</p>

答:
If the criteria affects all occurrences of the (many) side, you should not proceed with the delete, otherwise, you'd violate the design.

However, there is 1 case where you are allowed (optionally) to delete all occurrences of the (many) side. This is the case when the parent (the one side) is deleted.

Example:

Say, you have an association between an invoice header and the invoice items on this invoice, so one invoice contains (1...n) items. If you delete the invoice, all the items have to go. If you attempt to delete the last invoice item, the system should warn you that if you do that, the entire invoice will be deleted.


答: It depends on the language and maybe on the implementation being used. The standard in C++ is that exceptions should be saved for truly exceptional events. On the other hand, in Python one of the guidelines is "it is easier to ask for forgiveness than for permission", so the integration of try/except blocks in program logic is encouraged.</p>

Title: Arguments for or against using Try/Catch as logical operators

Body:
I just discovered some lovely code in our companies app that uses Try-Catch blocks as logical operators.

Meaning, "do some code, if that throws this error, do this code, but if that throws this error do this 3rd thing instead".

It uses "Finally" as the "else" statement it appears.

I know that this is wrong inherently, but before I go picking a fight I was hoping for some well thought out arguments.

And hey, if you have arguments FOR the use of Try-Catch in this manner, please do tell.

For any who are wondering, the language is C# and the code in question is about 30+ lines and is looking for specific exceptions, it is not handling ALL exceptions.


答:
It sounds like you already know that Solution 2 is a bad plan. But solution 1 is giving you trouble as well.

I gather your classes end up looking like this:

```<code>class MoveCommand
{
   MoveCommand(Field from, Field to)
   {
      this->from = from;
      this->to = to;
   }

   State apply(State state)
   {
       MutableState mutable_state = new MutableState(state);
       Unit unit = mutable_state.GetUnit(from);
       mutable_state.RemoveUnit(from);
       mutable_state.PutUnit(to, unit);
       return mutable_state.AsState();
   }
}
</code>```

Firstly, you've designed your immutable objects wrong. The idea is not to switch back and forth between immutable and mutable objects. Rather, if you want to use immutable objects, then methods on your immutable object should return new objects. So your code should look more like this.

```<code>State apply(State state)
{
    Unit unit = state.GetUnit(from);
    state = state.RemoveUnit(unit);
    state = state.PutUnit(to, unit);
    return state;
}
</code>```

But immutability is great for small things like numbers, strings, etc. For handling the entire state of your game, it tends to get cumbersome. So really, I figure you should drop the immutable aspect and do:

```<code>void apply(State state)
{
    Unit unit = state.GetUnit(from);
    state.RemoveUnit(unit);
    state.PutUnit(to, unit);
}
</code>```

However, an argument can be made that this makes the MoveCommand have logic that belong somewhere else. Perhaps the code should look like:

```<code>void apply(State state)
{
    state.move(from, to);
}
</code>```

But this makes the whole MoveCommand class look a little pointless because it doesn't seem to really do anything. But I say: don't worry about it. Some commands will be trivially implemented using the game state objects. And that's a good thing.

Title: Proper OO design for State and Command

Body:
It sounds like you already know that Solution 2 is a bad plan. But solution 1 is giving you trouble as well.

I gather your classes end up looking like this:

class MoveCommand
{
   MoveCommand(Field from, Field to)
   {
      this->from = from;
      this->to = to;
   }

   State apply(State state)
   {
       MutableState mutable_state = new MutableState(state);
       Unit unit = mutable_state.GetUnit(from);
       mutable_state.RemoveUnit(from);
       mutable_state.PutUnit(to, unit);
       return mutable_state.AsState();
   }
}

Firstly, you've designed your immutable objects wrong. The idea is not to switch back and forth between immutable and mutable objects. Rather, if you want to use immutable objects, then methods on your immutable object should return new objects. So your code should look more like this.

State apply(State state)
{
    Unit unit = state.GetUnit(from);
    state = state.RemoveUnit(unit);
    state = state.PutUnit(to, unit);
    return state;
}

But immutability is great for small things like numbers, strings, etc. For handling the entire state of your game, it tends to get cumbersome. So really, I figure you should drop the immutable aspect and do:

void apply(State state)
{
    Unit unit = state.GetUnit(from);
    state.RemoveUnit(unit);
    state.PutUnit(to, unit);
}

However, an argument can be made that this makes the MoveCommand have logic that belong somewhere else. Perhaps the code should look like:

void apply(State state)
{
    state.move(from, to);
}

But this makes the whole MoveCommand class look a little pointless because it doesn't seem to really do anything. But I say: don't worry about it. Some commands will be trivially implemented using the game state objects. And that's a good thing.


问:
One-line functions that are called only once
Consider a parameterless (edit: not necessarily) function that performs a single line of code, and is called only once in the program (though it is not impossible that it'll be needed again in the future).

It could perform a query, check some values, do something involving regex... anything obscure or "hacky".

The rationale behind this would be to avoid hardly-readable evaluations:

if (getCondition()) {
    // do stuff
}
```

where getCondition() is the one-line function.

My question is simply: is this a good practice? It seems alright to me but I don't know about the long term...

答:
If the language supports it, I usually use labeled anonymous functions to accomplish this.

someCondition = lambda p: True if [complicated expression involving p] else False
#I explicitly write the function with a ternary to make it clear this is a a predicate
if (someCondition(p)):
    #do stuff...
```

<p>IMHO this is a good compromise because it gives you the readability benefit of not having the complicated expression cluttering the <code>if</code> condition while avoiding cluttering the global/package namespace with small throw-away labels. It has the added benefit that the function "definition" is right where its being used making it easy to modify and read the definition. </p>

<p>It doesn't have to only be predicate functions. I like to encase repeated boiler-plate in small functions like this as well (It works particularly well for pythonic list generation without cluttering the bracket syntax). For example, the following oversimplified example when working with PIL in python</p>

<pre class="lang-py prettyprint-override"><code>#goal - I have a list of PIL Image objects and I want them all as grayscale (uint8) numpy arrays
im_2_arr = lambda im: array(im.convert('L'))
arr_list = [im_2_arr(image) for image in image_list]
</code>```

Body:
If the language supports it, I usually use labeled anonymous functions to accomplish this.

someCondition = lambda p: True if [complicated expression involving p] else False
#I explicitly write the function with a ternary to make it clear this is a a predicate
if (someCondition(p)):
    #do stuff...

IMHO this is a good compromise because it gives you the readability benefit of not having the complicated expression cluttering the if condition while avoiding cluttering the global/package namespace with small throw-away labels. It has the added benefit that the function "definition" is right where its being used making it easy to modify and read the definition.

It doesn't have to only be predicate functions. I like to encase repeated boiler-plate in small functions like this as well (It works particularly well for pythonic list generation without cluttering the bracket syntax). For example, the following oversimplified example when working with PIL in python

#goal - I have a list of PIL Image objects and I want them all as grayscale (uint8) numpy arrays
im_2_arr = lambda im: array(im.convert('L'))
arr_list = [im_2_arr(image) for image in image_list]


问:
Can daily reports decrease a developer's productivity?
In another question, I asked about why developers might don't like daily scrum. We talked to developers and we decided to not hold daily scrum for a while (to give it a try and customized scrum in our first attempt). This is the output of consulting with developers directly.

On the other hand, we don't want to lose good parts of daily scrum, like getting a chance to coordinate developers everyday, or watching the work progress like a Key Performance Indicator, to take actions early.

As an alternative to daily scrum, we're thinking about asking developers to provide daily reports with the following conditions:

No need to follow any specific format. Each and every format is accepted.

Even if the work is not done, we want to hear the amount of progress.

There is no need to mention the time spent on each task.

Development obstacles and coordination requirements should be mentioned.

There is no need to be obsessed with daily reports. It's not taken that strict.

Do you think that this can decrease their productivity? Have you had any daily report experience? Do you have any suggestion for us, so that we can get sure that we're not micromanaging?

答:
I've done these in the past, but in the morning as opposed to the end of day. It generally took less than five minutes to fill out, so no, I can't see how there would be any decrease in a developer's productivity. The nice thing about doing it in the morning was that it made you think about what you're going to do for the rest of the day.

Having said that...

We found that it was more times than not, it wasn't the most effective method of communicating what we had done the previous day and what we were going to work on that day. Why? People generally didn't read them. It was a scheduled Outlook task, so everyone sent them out every day, but either they were glossed over or just missed altogether (other than by leads or management).

We found that having the daily stand-ups were much more valuable as people tended to listen to each other. Also, if there was a misunderstanding, it would be flushed out then and there, which is more apt to happen than someone replying to a daily status e-mail to ask further questions.


答:
As an alternative to daily scrum, we're thinking about asking developers to provide daily reports with the following conditions:

What a terrible idea.

Do you think that this can decrease their productivity?

Yes.

Why?  A verbal presentation at a meeting combines writing and n people "reading" the report into one concurrent activity. Talking plus Listening.  Over and done with.  Questions answered right away.

Writing a report is a waste of time because there will be questions and you'll have to review the report with folks who (a) have questions and (b) didn't really read it.

Daily reports, won't get read.  They rapidly devolve to in-box-noise.

"There is no need to be obsessed with daily reports".  In which case, why do them?

Do you have any suggestion for us, so that we can get sure that we're not micromanaging?

Yes.  Have a daily stand-up.  It takes a few minutes and you're done.

If your daily stand-up takes more than a few (15?) minutes, you're sharing way too much detail and need to schedule separate meetings for those details.  Daily stand-ups are easy to do.  After a 2-minute summary, everything else is probably details, not for the whole team, and needs to be pushed into a follow-up meeting.  The meeting moves on to the next person's focus for the day.

Title: Can daily reports decrease a developer's productivity?

Body:
In another question, I asked about why developers might don't like daily scrum. We talked to developers and we decided to not hold daily scrum for a while (to give it a try and customized scrum in our first attempt). This is the output of consulting with developers directly.

On the other hand, we don't want to lose good parts of daily scrum, like getting a chance to coordinate developers everyday, or watching the work progress like a Key Performance Indicator, to take actions early.

As an alternative to daily scrum, we're thinking about asking developers to provide daily reports with the following conditions:

No need to follow any specific format. Each and every format is accepted.

Even if the work is not done, we want to hear the amount of progress.

There is no need to mention the time spent on each task.

Development obstacles and coordination requirements should be mentioned.

There is no need to be obsessed with daily reports. It's not taken that strict.

Do you think that this can decrease their productivity? Have you had any daily report experience? Do you have any suggestion for us, so that we can get sure that we're not micromanaging?


答: If what you really want is a rough status and to make a note of any obstacles the best way is to ask them for a short "daily status email".  If you put too much emphasis on it, or make a list of what it should/should not contain then at least some of your devs will spend extra time crafting it to meet the requirements.  Instead of that, just ask for a simple email.  When things come up through the day say things like "oh, put that in your end of day email" and if you get a really long end of day email, mention casually "you don't need to be that detailed every day".</p>


答:
In all honesty, allowing anyone to report in without constraints seems a tad too far to the liberal side of the equation. Where I work, we go in a circle and each developer gives the following:

What was done the prior day. Not all the tiny details, but overall.

If the above is not finished, if not, what is needed to finish and how long it will take.

If the above is finished, what the next task is, what is required, and the time time it will take.

Blockers. If you're working on Foo, which depends on Bar, and Bar is not finished, this needs to be made clear.

Setting up a general schema for everyone to follow can make going through a given report easy. You can easily setup some method for everyone to get an email with the daily reports, and thus allow anyone to find out what is going on.


答:
Sometimes exceptions are fastest. I've seen cases where null object exceptions were faster even in Java than use of control structures (I cannot cite the study at the moment, so you'll have to trust me). The problem comes in when Java has to actually take the time and populate the stack trace of a custom exception class instead of using native ones (which seem to be at least partially cached). Before saying that something is unilaterally
faster or slower, it would be good to benchmark.

In Python it is not only faster, but it is much more correct to do something which might cause an exception and then handle the error. Yes, you can enforce a type system, but that goes against the philosophy of the language -- instead you should simply try to call the method and catch the result! (Testing whether a file is writable is similar -- just try writing to it and catch the error).

I've seen times when it is faster to do something stupid like query tables which weren't there than to figure out whether a table exists in PHP+MySQL (the question where I benchmark this is actually my only accepted answer with negative votes).

All of that said, use of exceptions should be limited for several reasons:

Accidental swallowing of nested exceptions. This is major. If you catch some deeply nested exception which someone else is trying to handle, you have just shot your fellow programmer (maybe even you!) in the foot.

Tests become non-obvious. A block of code which has an exception in it could have one of several things wrong with it. A boolean, on the other hand, while theoretically it could be annoying to debug, it generally isn't. This is especially true as the try...catch control flow adherents generally (in my experience) do not follow the "minimize code in try block" philosophy.

It does not allow for an else if block. Enough said (and if someone counters with a "But they could use different exceptions classes", my response is "Go to your room and don't come out until you've thought about what you've said.")

It is grammatically misleading. Exception, to the rest of the world (as in not adherents to the try...catch control-flow philosophy), means that something has entered an unstable (though perhaps recoverable) state. Unstable states are BAD and it should keep us all up at night if we actually have avoidable exceptions (it actually creeps me out, no lies).

It is not compliant with common coding style. Our job, both with our code and with our UI's is to make the world as obvious as possible. try...catch control-flow goes against what are commonly considered best practices. This means it takes more time for someone new to a project to learn the project, which means an increase in the number of man-hours for absolutely no gain.

This often leads to code duplication. Finally blocks, though this is not strictly necessary, need to resolve all of the dangling pointers which were left open by the interrupted try block. So do try blocks. This means you can have a try{ obj.openSomething(); /*something which causes exception*/ obj.doStuff(); obj.closeSomething();}catch(Exception e){obj.closeSomething();}. In a more traditional, if...else scenario, the closeSomething() is less likely (again, personal experience) to be a copy and paste job. (Admittedly, this particular argument has more to do with people I have met than the actual philosophy itself).


问:
How to describe framework/features of a java application for client presentation?
I have been asked to put down the architecture and features of our Java application (more from infrastructure/software point of view). It will go on a Powerpoint presentation, so I need to provide the list.

Please let me know how do I go about this.

答:
Know Your Audience

I would say that it depends on your client. If your client is a consumer/business using your software as a service, bear in mind that they care little about the technical aspects. If you were selling a POS ("Point of Sale" - something like a grocery checkout program) program, you might list features like so:

Can process credit cards at lightspeed.

Can scan users faces and bill them using the unique creases on their foreheads.

Can convince customers to buy the candy at the counter on impulse

If you were selling this to a technical client, for say, integration with another product, you might consider discussing the technical aspects. For example (I'm not a Java programmer, so excuse any mistaken false promises, I'm being facetious):

Can process a hundred threads in under thirty nanoseconds

Can process credit cards across securely using the  algorithm.

Know Your Subject

Since you seem to be leaning towards the technical side, you might want to list the programming paradigms that you use and some of the highlights of the architecture of your program. If I were presenting one of my iPhone apps, for example, I'd almost surely mention the Model-View-Controller paradigm.
I may also mention the delegation patterns used. You may want to discuss particular modularization or inheritance patterns as well as frameworks that you use.

Remember, regardless of what goes in to the presentation: if you don't know how your program works, you can't share that information with others.

Structure Your Presentation

I'd start with a bulleted list and go through the bullets one by one. If you're having trouble with layout and such, use a template that comes with Powerpoint. If  you're looking for inspiration for structuring your presentation, take a look at any one of Apple's presentations. You can watch a keynote, or a technology demo. Those are done really well.


答:
It's very helpful to be clear about the purpose of any meeting or report, especially one done by everyone every day.  You say the reason is:

we don't want to lose good parts of daily scrum, like getting a chance to coordinate developers everyday,

What do you mean by coordinate developers?  What kind of work needs coordination and isn't been ad-hoc coordinated by the developers and their managers when needed?  Is there perhaps some way you could identify tasks that will need coordination, and communicate in only those cases?

or watching the work progress like a Key Performance Indicator, to take actions early.

A many good KPIs (like site response time, or number of critical bugs) is going to be mechanically measurable, and you don't need to impose a cost on the developers to do it.


答: I think if you only have a few of them then it is okay but the issue comes up when there are a lot of them in your code. And when the compiler runs or the interpitor (depending on the language you use) It is going to that function in memory. So lets say you have 3 of them I dont think the computer will notice but if you start having 100's of those little things then the system has to register functions in memory that are only called once and then not destroyed.</p>

Title: One-line functions that are called only once

Body:
Consider a parameterless (edit: not necessarily) function that performs a single line of code, and is called only once in the program (though it is not impossible that it'll be needed again in the future).

It could perform a query, check some values, do something involving regex... anything obscure or "hacky".

The rationale behind this would be to avoid hardly-readable evaluations:

if (getCondition()) {
    // do stuff
}
```

where getCondition() is the one-line function.

My question is simply: is this a good practice? It seems alright to me but I don't know about the long term...


问:
Using an Apt Repository for Paid Software Updates
I'm trying to determine a way to distribute software updates for a hosted/on-site web application that may have weekly and/or monthly updates. I don't want the customers who use the on-site product to have to worry about updating it manually I just want it to download and install automatically ala Google Chrome. I'm planning on providing an OVF file with Ubuntu and the software installed and configured.

My first thought on how to distributed software is to create six Apt repositories/channels (not sure which would be better at this point) that will be accessed through SSH using keys so if a customer doesn't renew their subscription we can disable their account:

Beta - Used internally on test data to check the package for major defects.

Internal - Used internally on live data to check the package for defects (dog fooding stage).

External 1 - Deployed to 1% of our user base (randomly selected) to check for defects.

External 9 - Deployed to 9% of our user base (randomly selected) to check for defects.

External 90 - Deployed to the remaining 90% of users.

Hosted - Deployed to the hosted environment.

It will take a sign off at each stage to move into the next repository in case problems are reported.

My questions to the community are:

Has anyone tried something like this before?

Can anyone see a downside to this type of a procedure?

Is there a better way?

答: If i was to do it I would do it based on IP address. So when they come to download their ip address has to be on the allowed list to connect to that server otherwise they can't download. It sucks if they don't have dedicated ip but unlikely from what it sounds like you're talking about if it's server based if it's for work stations then you may be better off setting them up with there own apt server inhouse and then that downloads a copy via cron job or something over ftp and so on once a week and then there workstations download from there really up to you.</p>


答:
I've had to do daily reports in several different formats in the workplace.  Generally speaking, I think the daily reports tend to only add value for managers, not for the developers themselves.  While managers gain benefit from daily reports by being able to tell the overall status of each project and each employee's taskload in a short amount of time, in my experience most developers do not bother reading each others' status reports.

However, it seems like by not enforcing a format for your daily reports, you make the reports harder to read and process for both managers and fellow developers, thus exacerbating the issue of lost developer time.

If you decide to move forward with daily reports for your developers, might I suggest using an internal wiki instead of email reports?  That way you do not spam peoples' inboxes, while maintaining history of everyone's daily statuses.


答:
I just discovered some lovely code in our companies app that uses Try-Catch blocks as logical operators.
  Meaning, "do some code, if that throws this error, do this code, but if that throws this error do this 3rd thing instead".
  It uses "Finally" as the "else" statement it appears.
  I know that this is wrong inherently...

How do you know that?  I gave up all that sort of "knowledge" and now just believe that the simplest code is the best.  Suppose you want to convert a string to an Optional which is empty if the parse fails. There is nothing wrong with:

```<code>try {
    return Optional.of(Long.valueOf(s));
} catch (NumberFormatException) {
    return Optional.empty();
}
</code>```

I completely disagree with the usual interpretation of "Exceptions are for exceptional conditions".  When a function cannot return a usable value or a method cannot meet its post-conditions, throw an exception. It doesn't matter how often these exceptions are thrown until there is a demonstrated performance problem.

Exceptions simplify code, by allowing the separation of error handling from the normal flow.  Just write the simplest possible code, and if it is easier to use try-catch or to throw an exception, then do that.

Exceptions simplify testing by reducing the number of paths through the code.  A function with no branches will either complete or throw an exception.  A function with multiple if statements to check for error codes has many possible paths.  It is very easy to get one of the conditions wrong, or to forget one completely, so that some error condition is ignored.

Body:
I just discovered some lovely code in our companies app that uses Try-Catch blocks as logical operators.
  Meaning, "do some code, if that throws this error, do this code, but if that throws this error do this 3rd thing instead".
  It uses "Finally" as the "else" statement it appears.
  I know that this is wrong inherently...

How do you know that?  I gave up all that sort of "knowledge" and now just believe that the simplest code is the best.  Suppose you want to convert a string to an Optional which is empty if the parse fails. There is nothing wrong with:

try {
    return Optional.of(Long.valueOf(s));
} catch (NumberFormatException) {
    return Optional.empty();
}

I completely disagree with the usual interpretation of "Exceptions are for exceptional conditions".  When a function cannot return a usable value or a method cannot meet its post-conditions, throw an exception. It doesn't matter how often these exceptions are thrown until there is a demonstrated performance problem.

Exceptions simplify code, by allowing the separation of error handling from the normal flow.  Just write the simplest possible code, and if it is easier to use try-catch or to throw an exception, then do that.

Exceptions simplify testing by reducing the number of paths through the code.  A function with no branches will either complete or throw an exception.  A function with multiple if statements to check for error codes has many possible paths.  It is very easy to get one of the conditions wrong, or to forget one completely, so that some error condition is ignored.


答:
My team has been doing scrum for about one year now. Before that we were having two meetings a week, during which each team member reported about his / her activity in the previous 2, 3 days. Each meeting lasted between 30 minutes and 1 hour. In case we needed to exchange information and coordinate our work, we just used to go up to our colleagues and speak to them (which we still do, of course).

Now that we are doing scrum we often have the impression that one meeting a day (even though it only lasts 15 minutes) is too much. Often the reports of some members boil down to: "Nothing new since yesterday". We have often had the impression that the 2-meetings-per-week schema was more effective.

Another downside is that the daily meeting is a planned interruption
(see e.g. Paul Graham's article, point 1. Avoid distractions): since you know the interruption is going to come, you are not going to start anything difficult before the meeting (daily meetings may take place one to one and a half hours after one has started work).

Last but not least, while early feedback does have advantages ("Oh, you are working on that problem, we should discuss it!"), it is sometimes more effective to start a discussion only when you have already organized your ideas in your mind, you have specific questions, and you feel ready for discussion. Instead, daily reports can quickly cause a lot of unnecessary and unstructured brainstorming. So, beware of too early feedback: it can confuse you and slow you down.

So: in some cases daily reports did decrease our productivity. On average, I do not have the feeling that they made our work more effective.

UPDATE

I wrote my original answer a couple of years ago, and meanwhile I have switched teams. In my current team, we are doing daily meetings on-demand, i.e. when we feel we need a short status update. So, every day there is the possibility to have such a meeting but we do not do it if nobody requests it. We do have a weekly retrospective meeting. This is basically very similar to the approach we were originally using in my previous, non-agile team: fixed weekly meetings plus additional on-demand meetings during the rest of the week.


问:
Is an architecture description document a violation of the DRY Principle?
The DRY Principle (Don't Repeat Yourself) states that "every piece of knowledge must have a single, unambiguous, authoritative representation within a system."  Most of the time this refers to code, but it is often extended to documentation also.

It is said that every software system has an architecture whether you chose it or not.  In other words, the software you build has a structure and that "as built" structure is the architecture of the software.  Since a built software system comes with an architecture, is creating an architecture description of that system a violation of the DRY Principle?  After all, if you need to know the architecture then you could always just look at the code...

答:
If you date the document, it then describes the architecture at the time of writing.

Whereas the code represents the architecture at the present moment.

Two separate things - not the same knowledge.

As long as you state that the document represents the architecure at the time of writing, you're not duplicating knowledge IMO because its different knowledge if its about the system at another point in time.

ContentLicense: CC BY-SA 2.5


问:
With agile, what do when a user story doesn't get completed in an iteration?
Do you just move the story to a new iteration, or delay the next iteration?

It gets a bit tricky when you use something like Jira when you have to copy or move around stories between iterations as it effects calculations of velocity/points etc.

Is there a best-practice?

答:
If the story is not complete (as per in your definition of done), you should not receive any points from it.

In the the next sprint, create a new story based on what is left from the unfinished one, add it to the sprint backlog and estimate it. Possible merge it with another story if it is too small.

If your tool cannot handle this, you should probably look for something which can. I prefer low-tech tools myself.

OwnerDisplayName: codecompleting


答:
Perhaps you should separate Command (a request) from its affects (a response). You have a set of concrete Command classes and the State objects will behave differently for each, so you should consider using overloaded methods for each Command. This allows you to specifically handle each Command as only the State should know how to respond. You Command objects have no inherent behaviour, only the data needed for the request.

void State.Handle(MoveCommand)

void State.Handle(PassCommand)

void State.Handle(BidCommand)

The Handle methods are responsible for validating the Command against current state, and then raising appropriate domain events to affect the state of the model. The domain events contains the new data to be applied interested parties (e.g. 'MovedEvent' contains new position).

The Apply methods accept concrete domain event objects and change the state accordingly:

void State.Apply(MovedEvent)

void State.Apply(PassedEvent)

void State.Apply(BiddedEvent)

Domain events could also be routed to other affected objects.

Title: Proper OO design for State and Command


问:
What programming problems are best solved by using pointers?
Well, I basically understand how to use pointers, but not how best to use them in order to do better programming.

What are good projects or problems to resolve involving the use of pointers so I can understand them better?

答:
As your question is tagged C++, I will answer your question for that language.

In C++ there is a distinction between pointers and references, therefore there are two scenarios where pointers (or smart pointers) are necessary to facilitate certain behaviours. They can be used in other circumstances, however you ask how "best to use them", and in all other circumstances there are better alternatives.

1. Polymorphism

A base class pointer allows you to call a virtual method that is dependent on the type of object that pointer points to.

2. Creating persistent objects

Pointers are necessary when creating an object dynamically (on the heap instead of the stack). This is necessary when you want that objects lifetime to be longer than the scope in which it is created.

In terms of "good projects or problems to resolve", as others have said here already, any non-trivial project will make use of pointers.


问:
Why C++ cannot adopt D's approach for its concept implementation?
As many of you guys know, concepts, C++'s approach for constraining possible types for a template argument has failed to be included in C++11.

I learned that the D programming language 2.0 has a similar feature for its generic programming. Its solution seems to me quite elegant & simple.

So my question is why C++ cannot use a similar approach.

The C++ concept's goal might be bigger than what D's implementation provides?

Or C++'s legacy prevents it from adopting such an approach?

Or any other?

Thanks for your answers.

p.s. To see some examples of D's generic programming power, please refer to this: https://stackoverflow.com/questions/7300298/metaprogramming-in-c-and-in-d/7303534#7303534

答:
For the 2011 standard, C++ concepts were what was being worked on, and they were ultimately dropped from that standard, because they weren't "baked enough." Work continues on C++ concepts which may lead to them making it into the next standard. It could be, however, that some folks will work on a proposal for the next standard which is similar to D's template constraints. Whether that happens or not remains to be seen. As far as I know, there was no such proposal for the 2011 standard, so there was no chance for it to make it into that standard regardless of its merits, but what will or won't make it into the next standard is completely unknown at this point.

I'm not aware of any major reason why something similar to D's template constraints could not be implemented for C++, though given that C++ is generally more limited in what it can do at compile time, it might be harder to make them work quite as well as they do in D (though the introduction of stuff like constexpr certainly helps).

So really, I think that the short answer is that there's no technical reason why something similar to D's template constraints couldn't be in C++.

The question is whether such a proposal will be made for the next standard and how it will compare with whatever similar proposals are made (e.g. proposals relating to concepts). Assuming that an acceptable proposal can be made, I would fully expect that something similar to concepts or D's template constraints will make it into the next standard simply because there's a lot of desire for it. The question is whether anyone can come up with a proposal which is solid enough and "baked enough" to be acceptable.


问:
How often do you actually use design patterns?

Possible Duplicate:

  Are design patterns really essential nowadays?

I recently read a book on design patterns. A few of them seem very usefull in specific situations. Im not sure how much use they will be in everyday coding though. How often do you use design patterns in your everyday work? Should I be trying to find situations to apply them?

答:
I kind of use them in reverse. Mostly for documenting purposes. If I say that some class is a "singleton configuration holder", I can safely assume that most people will know what the class does/is.

I don't really try to fit the design patterns into my code. The only exception is the design phase, where it is mostly a discussion starter, ie. should this class be a factory (why yes?, or why not?).


答:
Design patterns are great, for the specific situations that need them. You should never need to try find a situation to apply them, as you'll often know when you need to apply them anyway by looking at a problem and thinking "This really fits with the singleton design pattern, maybe I should solve it that way".

They're not a one size fits all hat, but they are incredibly useful. As long as you understand what they do and why they're useful, and why they occasionally aren't, you'll see the situations where you can use them.

Title: How often do you actually use design patterns?

Body:
Possible Duplicate:

  Are design patterns really essential nowadays?

I recently read a book on design patterns. A few of them seem very usefull in specific situations. Im not sure how much use they will be in everyday coding though. How often do you use design patterns in your everyday work? Should I be trying to find situations to apply them?


答: Pointers are very useful for working with memory-mapped devices.  You can define a structure that reflects (say) a control register, then assign it to the address of the actual control register in memory and manipulate it directly.  You can also point directly to a transfer buffer on a card or chip if the MMU has mapped it into the system memory space.</p>

Title: What programming problems are best solved by using pointers?

Body:
Well, I basically understand how to use pointers, but not how best to use them in order to do better programming.

What are good projects or problems to resolve involving the use of pointers so I can understand them better?


答:
Generally if you design a system, you decide upon a couple locations where given "major" design patterns fit. Even a pretty big application will have 2-5 of them used at most. A medium one will utilize one or two. Smaller ones will often do away without them altogether, or stick to one old established standard like MVC or Observer.

Then there are "minor" design patterns. Like "single-use block", or "taint flag" or "timeout counter" or the likes, which are used all the time. I'd say roughly half of the functions in any program contain at least one of these minor design patterns.


问:
Recursion without factorial, Fibonacci numbers etc
Almost every article I can find about recursion includes the examples of factorial or Fibonacci Numbers, which are:

Math

Useless in real life

Are there some interesting non-math code examples to teach recursion?

I'm thinking divide-and-conquer algorithms but they usually involve complex data structures.

答: QuickSort would be the first one that jumps to mind. Binary search also is a recursive problem. Beyond that there are whole classes of problems that solutions fall out almost for free when you start working with recursion. </p>


答:
Towers of Hanoi is a good one to help learn recursion.

There are many solutions to it on the web in many different languages.

Title: Recursion without factorial, Fibonacci numbers etc

Body:
Almost every article I can find about recursion includes the examples of factorial or Fibonacci Numbers, which are:

Math

Useless in real life

Are there some interesting non-math code examples to teach recursion?

I'm thinking divide-and-conquer algorithms but they usually involve complex data structures.


答:
Design patterns put a name on specific code constructs that existed before the design pattern book was published.

You have to see it as a construction guide that helps people work together. And that help beginners to see what works for specific situations and what they can do.

Then, it's not because you used a pattern that your choice was correct and your design sound.


答:
A Palindrome Detector:

Start with a string : "ABCDEEDCBA" If starting & ending characters are equal, then recurse and check "BCDEEDCB", etc...


答:
There's a psychological phenomenon called "med-student's disease", in which a person who studies an ailment becomes convinced that he himself suffers from it.  Apparently, it's quite common.

Design patterns have a similar effect on programmers.  He learns about, say, the façade pattern and suddenly, every object needs a façade.  He's putting façades on top of his façades.  Madness.

I myself have been studying combinators for the last few weeks and -- by complete coincidence -- have been finding uses for them left and right.

You actually seem to have the opposite problem.  You are reading about patterns and thinking, "When the hell will I ever use these?"

I respectfully submit that, well, that maybe it's you.  Perhaps it's because you don't understand the patterns well enough, or because your programming experience has not been broad enough for you to have seen the patterns.  Something.

The notion of design patterns, and the patterns themselves, are popular with programmers because we actually have run into them, over and over.  The original patterns -- like functions and for-loops -- showed up in assembly language and then were built into higher-level languages.  The next group (mostly the GoF patterns) haven't made it into languages yet but they are common use and their names are in the common vocabulary of programmers.  On the horizon are concepts that have been floating around academia for a decade or two (monads, combinators) and are just starting to find acceptances in the commercial world.

My point, and I do have one, is that if it weren't for many, many programmers using design patterns every day, they wouldn't be design patterns; they'd just be some code that some guy wrote and then forgot about.


答:
Directory / File structures are the best example of a use for recursion, because everyone understands them before you start, but anything involving tree-like structures will do.</p>

```<code>void GetAllFilePaths(Directory dir, List<string> paths)
{
    foreach(File file in dir.Files)
    {
        paths.Add(file.Path);
    }

    foreach(Directory subdir in dir.Directories)
    {
        GetAllFilePaths(subdir, paths)
    }
}

List<string> GetAllFilePaths(Directory dir)
{
    List<string> paths = new List<string>();
    GetAllFilePaths(dir, paths);
    return paths;
}
</code>```

Body:
Directory / File structures are the best example of a use for recursion, because everyone understands them before you start, but anything involving tree-like structures will do.

void GetAllFilePaths(Directory dir, List<string> paths)
{
    foreach(File file in dir.Files)
    {
        paths.Add(file.Path);
    }

    foreach(Directory subdir in dir.Directories)
    {
        GetAllFilePaths(subdir, paths)
    }
}

List<string> GetAllFilePaths(Directory dir)
{
    List<string> paths = new List<string>();
    GetAllFilePaths(dir, paths);
    return paths;
}


答:
Look for things that involve tree structures. A tree is relatively easy to grasp, and the beauty of a recursive solution becomes apparent far sooner than with linear data structures such as lists.

Things to think about:

filesystems - those are basically trees; a nice programming task would be to fetch all .jpg images under a certain directory and all its subdirectories

ancestory - given a family tree, find the number of generations you have to walk up to find a common ancestor; or check whether two people in the tree belong to the same generation; or check whether two people in the tree can legally marry (depends on jurisdiction :)

HTML-like documents - convert between the serial (text) representation of a document and a DOM tree; perform operations on subsets of a DOM (maybe even implement a subset of xpath?); ...

These are all related to actual real-world scenarios, and they can all be used in applications of real-world significance.


答: A binary search algorithm sounds like what you want.</p>


问:
What can you do to decrease the number of deployment bugs of a live website?
I'm sure lots of you have experienced this problem. A website or web application is running and is live. You want to upload the next version, but you haven't figured out everything, like setting a value to false in configuration file, inserting another record into the database, and doing lots of minor stuff which can sometimes count to 20 or more parameters.

As soon as you upload the new version, everything breaks. Now, fixing the problem may only take up to 20 minutes, but the overall stress that you tolerate, and the financial and goodwill damage to the company are sometimes not forgettable.

What are the ways to reduce these types of bugs which arise from the initial configuration of new version deployment?

PS: Please don't mention check-lists, cause we already have them. The problem with check-lists is that, they should always get updated, but they won't.

答:
Two things:

Staging environment, as similar to the live environment where you do test deployments.

Ample testing of this environment after deployment. Automated and non-automated.

There are other things that can be done.

I suggest reading the 5 part blog series about automated deployment by Troy Hunt. The tooling he uses is MS stack specific, but the concepts are universal.


问:
How do you know if you've split your domain correctly
In DDD i struggle to understand whether or not my domain is split correctly into aggregate roots and then those aggregate roots are grouped correctly into bounded contexts. is there a way - like a set of rules/guidance i can use to decide whether or not i am placing things in the right AR/BC</p>

答:
They say that experience is the worst teacher because you get the test first and the lesson afterwards.

Your design decisions are ratified when the problem changes (or your understanding of the problem changes) and you don't have to rip out huge chunks of code and start over.

Of course, by then it's too late.

The best you can do proactively is ask yourself two questions:

Does my design really represent my problem, in that basic, fundamental concepts in the problem space are represented by basic, fundamental concepts in the design and trivial, contingent features of the problem are incidental to the design as well?

What if I'm wrong?  What if some of the assumptions I have made in the design turn out to be wrong, or stop being right?  What if an Employee is managed by a Contractor?  Can a Invoice be empty?  Is that just a new unit test or is it a major project?


答:
1) Deploy to the test site first and test your changes

2) Have all configuration in a configuration file (web config or similar). This config should then be specific to the application and never overwritten. Any changes are then delibrate rather than forgetting to change something that should be diffrent from test.

Title: What can you do to decrease the number of deployment bugs of a live website?

Body:
I'm sure lots of you have experienced this problem. A website or web application is running and is live. You want to upload the next version, but you haven't figured out everything, like setting a value to false in configuration file, inserting another record into the database, and doing lots of minor stuff which can sometimes count to 20 or more parameters.

As soon as you upload the new version, everything breaks. Now, fixing the problem may only take up to 20 minutes, but the overall stress that you tolerate, and the financial and goodwill damage to the company are sometimes not forgettable.

What are the ways to reduce these types of bugs which arise from the initial configuration of new version deployment?

PS: Please don't mention check-lists, cause we already have them. The problem with check-lists is that, they should always get updated, but they won't.


答:
Here are some more practical problems that come to my mind:

Merge Sort

Binary Search

Traversal, Insertion and Removal on Trees (largely used on database applications)

Permutations generator

Sudoku solver (with backtracking)

Spell-checking (again with backtracking)

Syntax analysis (.e.g, a program that converts prefix to postfix notation)


答:
https://stackoverflow.com/questions/105838/real-world-examples-of-recursion

modelling a contagious infection

generating geometry

directory management

sorting

https://stackoverflow.com/questions/2085834/how-did-you-practically-use-recursion

raytracing

chess

parsing source code (language grammar)

https://stackoverflow.com/questions/4945128/what-is-a-good-example-of-recursion-other-than-generating-a-fibonacci-sequence

BST search

Towers of Hanoi

palindrome search

https://stackoverflow.com/questions/126756/examples-of-recursive-functions

Gives a nice English-language story that illustrates recursion by a bedtime story.


问:
Using Visual Foxpro DBF with ASP.NET as opposed to SQL Server
I work in a small software company where my boss is a great fan of Visual Foxpro. We are working on an ASP.NET project but my boss is insisting to use Visual Foxpro DBF instead of SQL Server.

I want to know what may be the advantages and disadvantages of using a Foxpro database file with ASP.NET 3.5.

答: Your boss knows Visual Foxpro, thats its major advantage. Coders time is expensive and they can develop faster with a product they know.</p>


答:
Its a great idea to customise your Agile methods to make them suit you - so kudos for that.

So, daily reports instead, I'd say this isn't much better than a daily meeting, it's still the same "tell me what you're doing" approach, you've just made everyone write it down instead of speak it.

Here's an alternative approach: instead of using these 'polling' techniques where you ask each dev for their status, you use a 'push' technique instead. If the dev has nothing much to report, they don't, they should report any and all problems and progress as they occur however. So when they complete a module, they should email out to all the team that its finished, that its in SCM, where the documentation can be found, and a brief summary of what it is, how it works, and/or how to use it. If they have a problem, they should email the team asking for advice, help or any tips. (yeah, just like the old days where teams communicated well without the micromanagement we suffer today)

you'll find that this is much more productive, and constructive. You won't get meaningless reports for the sake of them and you will get a more motivated team as everyone likes to inform their peers of their work.


答:
Cant you extract this information from your other tools?

What are you currently working on? The tickets i have assigned.

What is your progress? For tickets i have longer than 1 day, see comments in ticket or commit messages of the branch. Tickets i have shorter: probably done tomorrow (you dont make big 5+ day tickets, yes?)

What is the general progress? see open/closed-tickets-ratio

What needs to be organized? the tickets you get assigned back, with the status feedback needed, and everything discussed in your team's IRC, Campfire Room, whatever.

When you have more specific questions to answer, i would see the need for specific reports, but without that your reports look a little like an end in itself.


答:
Yes, you need a test or staging environment where you go through all of the steps, but keeping separate configuration files for separate environments is a must.

```<code>Environments
|_property_files
    |_ dev
        |_ com.bla.util
        |    |_ example.properties
        |_ com.bla.beans
        |    |_ someconfig.xml
    |_ test
        ....
    |_ production
        ....
|_database_updates
    |_ dev
        |_ insert_new_static_data.sql
        |_ ...

...
</code>```

Basically in my build and deployment scripts I take an environment property that will fetch the environment specific meta data files like XML files and replace them in my build location before packaging. Further in my deployment scripts I will look for any SQL files in database updates and execute those on the configured database for that environment as well.

I could do this with a custom build task, but I actually just use some JUnit tests to do this for me. If any SQL exceptions occur then the test fails and thus the deployment fails. Generally speaking too the SQL scripts have intelligence, if the necessary data already exists in the environment then they skip the insert or update.

I also have a similar directory for batch or shell scripts that I need to run for a specific environment.

The tell all in your question is this: they should always get updated, but they won't.

These configurations drive your automated builds and deployments so if you DON'T update them then your builds fail and your manager gets emailed about it. It is just as important then for the team to maintain the build and deployment configurations for a specific release as it is for them to check in code that compiles. Either infraction breaks the build.

In short, greater adoption of continuous integration (CI) principles will help remove the pain of production releases.

Body:
Yes, you need a test or staging environment where you go through all of the steps, but keeping separate configuration files for separate environments is a must.

Environments
|_property_files
    |_ dev
        |_ com.bla.util
        |    |_ example.properties
        |_ com.bla.beans
        |    |_ someconfig.xml
    |_ test
        ....
    |_ production
        ....
|_database_updates
    |_ dev
        |_ insert_new_static_data.sql
        |_ ...

...

Basically in my build and deployment scripts I take an environment property that will fetch the environment specific meta data files like XML files and replace them in my build location before packaging. Further in my deployment scripts I will look for any SQL files in database updates and execute those on the configured database for that environment as well.

I could do this with a custom build task, but I actually just use some JUnit tests to do this for me. If any SQL exceptions occur then the test fails and thus the deployment fails. Generally speaking too the SQL scripts have intelligence, if the necessary data already exists in the environment then they skip the insert or update.

I also have a similar directory for batch or shell scripts that I need to run for a specific environment.

The tell all in your question is this: they should always get updated, but they won't.

These configurations drive your automated builds and deployments so if you DON'T update them then your builds fail and your manager gets emailed about it. It is just as important then for the team to maintain the build and deployment configurations for a specific release as it is for them to check in code that compiles. Either infraction breaks the build.

In short, greater adoption of continuous integration (CI) principles will help remove the pain of production releases.


答:
A. Put the story into the project backlog. If it's still the most important thing, it will be scheduled for the next sprint. If not, the product owner will schedule something more valuable.

B. You get no points for that story for this sprint. When you schedule the next sprint, Only count points for stories completed this sprint. (Yeah, you'll pull in a bonus story at the end of the next sprint. Great. But it's better to get a bonus story than to presume you'll get it done, then you'll have another unfinished story to account for.)

Title: With agile, what do when a user story doesn't get completed in an iteration?

Body:
Do you just move the story to a new iteration, or delay the next iteration?

It gets a bit tricky when you use something like Jira when you have to copy or move around stories between iterations as it effects calculations of velocity/points etc.

Is there a best-practice?


答:
I know of a company that is doing almost exactly what you have described. (Fewer tiers than you have described, and I don't know how they're authenticating.)

The largest problem they had is that some customers block internet access from their appliance. That means those customers are just locked down to the version that they installed. Maybe that's fine. I think they discussed opening up firewall rules with some of those customers. Others just upgraded manually.

Title: Using an Apt Repository for Paid Software Updates

Body:
I'm trying to determine a way to distribute software updates for a hosted/on-site web application that may have weekly and/or monthly updates. I don't want the customers who use the on-site product to have to worry about updating it manually I just want it to download and install automatically ala Google Chrome. I'm planning on providing an OVF file with Ubuntu and the software installed and configured.

My first thought on how to distributed software is to create six Apt repositories/channels (not sure which would be better at this point) that will be accessed through SSH using keys so if a customer doesn't renew their subscription we can disable their account:

Beta - Used internally on test data to check the package for major defects.

Internal - Used internally on live data to check the package for defects (dog fooding stage).

External 1 - Deployed to 1% of our user base (randomly selected) to check for defects.

External 9 - Deployed to 9% of our user base (randomly selected) to check for defects.

External 90 - Deployed to the remaining 90% of users.

Hosted - Deployed to the hosted environment.

It will take a sign off at each stage to move into the next repository in case problems are reported.

My questions to the community are:

Has anyone tried something like this before?

Can anyone see a downside to this type of a procedure?

Is there a better way?


答:
IMO any type of daily meeting/report decreases productivity because it, to be frank, stinks of micromanagement.  Yes, I'm aware of Scrum and the like and those aren't too bad provided they're short status updates ("Hey how is Project X coming?") but I firmly believe that it's insulting to professional developers to keep tabs on us at that low a level; it's akin to using timecards to make sure we're in the office 8 hours a day, or making sure there are no walls so you can spy on people's computers to see what windows they have open at a given time.

If you have to keep tabs on everyone to make sure they're working, it means you don't trust them.  If you don't trust them, there's a bigger issue at work than the one you are worrying about.


问:
question, the best data structure and algorithm
I have a question about implementing a data structure (with algorithm) that has these features:

There are too many places (like stores), and each place can store too many items, I want to store items in the places. The point is we need to have optimized insertion (or deletion) and optimized search feature.

Search can be done based on places (return items in the place) or base on items (return places that have the item)

I thought to use a hashmap for this, and use places ID as the key and store items as a collection (again a hashmap with item id for both key and value).

So based on this, the insertion of each item or place would be O(1) but get or remove of place will be O(n) and for item it will be O(n*k)! (assume we have "n" places and "k" items - I hope this is the correct calculation).

Is there any better data structure or algorithm for this problem?

答:
Why not use balanced trees? You would need one tree at each store, mapping item ID to some internal information, and one global tree, mapping item ID to the list of the nodes having the given item. Your operations will be O(log n + log k).

Edit:

the operations in this case would look like the following: (I use the fact that std::map and std::set are tree-based in C++)

```<code>using namespace std;

typedef int itemid_t;
typedef int storeid_t;

map<itemid_t, set<storeid_t>> itemID2storeList;

class Store
{
    storeid_t Id;

    // insert requires one lookup in the map (O(log k))
    // plus one insert into a set (O(log n)).
    void insert(itemid_t item)
    {
        itemID2storeList[item].insert(Id);
    }

    // the same as for insert
    void delete(itemid_t item)
    {
        itemID2storeList[item].erase(Id);
    }

    // search in a store requires one lookup in a map (O(log k))
    // and one search in a set (O(log n)).
    bool have(itemid_t item)
    {
        const set<storeid_t>& storesForItem = itemID2storeList[item];
        return storesForItem.find(Id) != storesForItem.end();
    }
}

class Central
{
    // getting the list of stores having the given item requires
    // one lookup in a map (O(log k))
    const set<storeid_t>& storesForItem(itemid_t item)
    {
        return itemID2storeList[item];
    }
}
</code>```

OwnerDisplayName: sander

Body:
Why not use balanced trees? You would need one tree at each store, mapping item ID to some internal information, and one global tree, mapping item ID to the list of the nodes having the given item. Your operations will be O(log n + log k).

Edit:

the operations in this case would look like the following: (I use the fact that std::map and std::set are tree-based in C++)

using namespace std;

typedef int itemid_t;
typedef int storeid_t;

map<itemid_t, set<storeid_t>> itemID2storeList;

class Store
{
    storeid_t Id;

    // insert requires one lookup in the map (O(log k))
    // plus one insert into a set (O(log n)).
    void insert(itemid_t item)
    {
        itemID2storeList[item].insert(Id);
    }

    // the same as for insert
    void delete(itemid_t item)
    {
        itemID2storeList[item].erase(Id);
    }

    // search in a store requires one lookup in a map (O(log k))
    // and one search in a set (O(log n)).
    bool have(itemid_t item)
    {
        const set<storeid_t>& storesForItem = itemID2storeList[item];
        return storesForItem.find(Id) != storesForItem.end();
    }
}

class Central
{
    // getting the list of stores having the given item requires
    // one lookup in a map (O(log k))
    const set<storeid_t>& storesForItem(itemid_t item)
    {
        return itemID2storeList[item];
    }
}

OwnerDisplayName: Vlad


答:
As suggested, use a staging system. This gives you the opportunity to test your changes in a live environment.

This brings up another point: have testers. Testing the stuff I wrote myself doesnt find as much bugs as when someone else tests my application.

Another thing: automate your deployment process. Do db migrations with ant migrate, deploy the newest version automatically from svn via capistrano etc. When you deploy something, you shouldnt have to do more then just a click and everything is automatic. Especially for websites which needs some configuration setup, manual steps required for deployment are a nightmare and the possibility that something goes wrong huge.


答:
I wonder, why no one mentioned Version control -- which is one of the most important ways to save you from trouble while updating/upgrading.

First, your deployment should be just a clone of the stable branch on your repository.
Everything including config files, SQL files, install/update scripts MUST be version controlled.

Second, you need to have "some sort of" staging area -- it could be anything -- a local server, a temporary virtual cloud server you just spawned, a very simple virtual host setup, or, a fully-fledged custom application that you maintain along with the main app. The difference between this "staging area" and your "development area" is that the former more closely models (or simulates) your actual deployment environment. For example, you can develop on PHP 5.3.x with Apache module, but since your host is PHP 5.2.x with FCGI, you staging area must be same.

Then, you first write and test your updates on your development environment. Merge those changes to the staging area repository, and again test. At this point you can make any changes to your config to suit your deployment -- since it's version controlled, nothing is going to be lost, and you can always revert back in case of problems.

Finally merge the staging area changes on your live deployment copy.

The complexity of your staging area should reflect the complexity and scope of your app. But in any case Version control is indispensable.

Of course if you don't use Version control -- none of this applies -- but then it's as naive as writing a database in Logo.


问:
Is there any work into the application of the Halstead complexity measures to determine software quality?
In 1977, Maurice Howard Halstead introduced his complexity measures for software systems, which included measurements of the program vocabulary, program length, volume, difficulty, effort, and an estimated number of bugs in a module. According to Wikipedia, difficulty relates to the difficulty of understanding the program when reading or writing it and effort can be translated into the time it takes to code an application where Time = (Effort / 18) seconds.

A measurement is useless unless the data and calculations relate to some aspect of software development. However, I haven't found any work which states that a difficulty of a certain value or higher tends to a statistically significant increase in defects or a relationship between difficulty and time to read code (a difficulty of N yields an average of M hours spent understanding the code base) or any analysis of being able to compute Time after the fact being useful in determining quality (especially since time to write should have been recorded as a measurement already). I'm especially interested in Halstead's bug estimation (which is not mentioned on Wikipedia) - the number of bugs in an application can be estimated by Volume/3000 or Effort^(2/3)/3000.

I'm looking for two things:

Has anyone used Halstead's software complexity measures in a real-world application to assess software quality? If so, how did you apply them and did they turn out to be a useful, valid, and/or reliable measurement?

Is there any academic research in the form of surveys, analyses, or case studies that discuss the validity (or invalidity) of Halstead complexity measures when applied to software quality?

Is there any academic research in the form of surveys, analyses, or case studies that demonstrate the use of Source Lines of Code (SLOC) to compute something similar to the Halstead metrics of Volume, Difficulty, Effort, Time, and Bugs? I would suspect that Volume might just correspond to a SLOC count and Difficulty might correspond to cyclomatic complexity (and possibly other measures). I'm also well aware that measuring effort, productivity, or time in SLOC is potentially misleading.

答: Microsoft Research has done some work in this area. Check out this page: http://research.microsoft.com/en-us/people/nachin/. Though not specifically based on Halstead, Nachi and his team have done some investigation using Halstead, cyclomatic complexity, code churn, and other measures to assess relative risk and fragility for making changes in areas of code. There's also an interesting paper about how organizational effectiveness also plays a big role but that's off topic. :)</p>


问:
Addressing a variable in VB
Why doesn't Visual Basic.NET have the addressof operator like C#? In C#, one can

```<code>int i = 123;
int* addr = &i;
</code>```

But VB has no equivalent counter part. It seems like it should be important.

UPDATE Since there's some interest, Im copying my response to Strilanc below.

The case I ran into didnt necessitate
  pointers by any means, but I was
  trying to trouble shoot a unit test
  that was failing and there was some
  confusion over whether or not an
  object being used at one point in the
  stack was the same object as an object
  several methods away.

答:
You can send a pointer to a certain variable in VB by specifiying the header of the function/sub in the following example:

```<code>Sub MySub(ByRef Var1 as String)
    Var1 = "Some Random Value"    'You can overwrite the value passed to the sub
End Sub
</code>```

Note the keyword ByRef which means that this Sub accepts address of a variable.
But assigning a new value to the variable does not need any special annotations.

but to make sure that you don't pass a copy of the Var1 to the sub, you need to call the sub like this:

MySub(AddressOf Var1)

instead of

MySub(Var1)

Although you are passing Var1 as input parameter, it will be overwritten the same ways as it would if you did something like:

```<code>Var1 = MySub()
</code>```

Title: Addressing a variable in VB

Body:
You can send a pointer to a certain variable in VB by specifiying the header of the function/sub in the following example:

Sub MySub(ByRef Var1 as String)
    Var1 = "Some Random Value"    'You can overwrite the value passed to the sub
End Sub

Note the keyword ByRef which means that this Sub accepts address of a variable.
But assigning a new value to the variable does not need any special annotations.

but to make sure that you don't pass a copy of the Var1 to the sub, you need to call the sub like this:

MySub(AddressOf Var1)

instead of

MySub(Var1)

Although you are passing Var1 as input parameter, it will be overwritten the same ways as it would if you did something like:

Var1 = MySub()


答:
Sort, defined recursively in Python.

```<code>def sort( a ):
    if len(a) == 1: return a
    part1= sort( a[:len(a)//2] )
    part2= sort( a[len(a)//2:] )
    return merge( part1, part2 )
</code>```

Merge, defined recursively.

```<code>def merge( a, b ):
    if len(b) == 0: return a
    if len(a) == 0: return b
    if a[0] < b[0]:
        return [ a[0] ] + merge(a[1:], b)
    else:
        return [ b[0] ] + merge(a, b[1:])
</code>```

Linear search, defined recursively.

```<code>def find( element, sequence ):
    if len(sequence) == 0: return False
    if element == sequence[0]: return True
    return find( element, sequence[1:] )
</code>```

Binary search, defined recursively.

```<code>def binsearch( element, sequence ):
    if len(sequence) == 0: return False
    mid = len(sequence)//2
    if element < mid:
        return binsearch( element, sequence[:mid] )
    else:
        return binsearch( element, sequence[mid:] )
</code>```

Body:
Sort, defined recursively in Python.

def sort( a ):
    if len(a) == 1: return a
    part1= sort( a[:len(a)//2] )
    part2= sort( a[len(a)//2:] )
    return merge( part1, part2 )

Merge, defined recursively.

def merge( a, b ):
    if len(b) == 0: return a
    if len(a) == 0: return b
    if a[0] < b[0]:
        return [ a[0] ] + merge(a[1:], b)
    else:
        return [ b[0] ] + merge(a, b[1:])

Linear search, defined recursively.

def find( element, sequence ):
    if len(sequence) == 0: return False
    if element == sequence[0]: return True
    return find( element, sequence[1:] )

Binary search, defined recursively.

def binsearch( element, sequence ):
    if len(sequence) == 0: return False
    mid = len(sequence)//2
    if element < mid:
        return binsearch( element, sequence[:mid] )
    else:
        return binsearch( element, sequence[mid:] )


问:
To branch or not to branch?
Till recently my development workflow was the following:

Get the feature from product owner

Make a branch (if feature is more than 1 day)

Implement it in a branch

Merge changes from main branch to my branch (to reduce conflicts during backward merging)

Merge my branch back to main branch

Sometimes there were problems with merging, but in general I liked it.

But recently I see more and more followers of idea to not make branches as it makes more difficult to practice continuous integration, continuous delivery, etc. And it sounds especially funny from people with distributed VCS background who were talking so much about great merging implementations of Git, Mercurial, etc.

So the question is should we use branches nowadays?

答:
But recently I see more and more followers of idea to not make branches as it makes more difficult to practice continuous integration, continuous delivery, etc.

Well does it make more difficult to practice continuous integration, continuous delivery, etc for you concretely?

If not, I see no reason to change your way of working.

Of course, it is good practice to follow what's going on and how the current best practices evolve. But I don't think we need to abandon our processes / tools / whatnot just because X (and/or Y and/or Z) said they aren't fad anymore :-)

Title: To branch or not to branch?


答:
You should absolutely use branches.  There are a number of strengths to that.

You can check in your work as you go if you are concerned about loosing work due to HD failure, loss of laptop etc. and it won't break the main CI.

You can still do CI, just setup your own local CI to watch your branch.

If the feature suddenly gets put on hold (that never happens does it) you can just park it.

Too hard is never an excuse.  It always take more effort to do it right.

Title: To branch or not to branch?

Body:
Till recently my development workflow was the following:

Get the feature from product owner

Make a branch (if feature is more than 1 day)

Implement it in a branch

Merge changes from main branch to my branch (to reduce conflicts during backward merging)

Merge my branch back to main branch

Sometimes there were problems with merging, but in general I liked it.

But recently I see more and more followers of idea to not make branches as it makes more difficult to practice continuous integration, continuous delivery, etc. And it sounds especially funny from people with distributed VCS background who were talking so much about great merging implementations of Git, Mercurial, etc.

So the question is should we use branches nowadays?


答:
In addition to the excellent suggestions above to have a pre-production environment and use automated testing:

Reduce the complexity of the codebase. Less code, generally, means fewer bugs and an easier time finding them. This is the philosophy behind refactoring, separation of concerns, and so forth.

Segment the codebase. One common approach is to separate it into:

a few core parts that change slowly and are shared across the site

many leaf parts that may change more quickly but each only impact a smaller part of the site

This understanding of your code base allows you to focus your development and testing on the core parts, since bugs there will have the most drastic effect.


答:
The main problem with branching is the difficulty with merging back into the main branch when development is complete.  Merging can be a manual and error prone process therefore it should be avoided most of the time.

Some notable exceptions where I prefer branching is for massive refactoring, giant features that take longer than a sprint to develop, or disruptive features that would interupt the development of other features during the majority of that sprint.

Title: To branch or not to branch?


答:
If you have several teams working on different features at the same time, there's no way you can omit branching. You should share (partly implemented) code with team members, preventing other teams from getting your not-finished features.

Branches are the easiest way to achieve that.

Though it's good to shorten the branches lifecycle and avoid working on the same module in two branches at the same time - you'll have no conflicts\merge problems then.

Title: To branch or not to branch?


问:
When should I use a 2-property class over a pre-built structure like a KeyValuePair?
When should you put Key/Value type of data in it's own class instead of using a pre-built generic structure, such as a KeyValuePair or a Tuple?

For example, most ComboBoxes I create contain a DisplayName and a Value. This is the kind of data I am trying to decide when to put in a new class, and when to just use a KeyValuePair.

I am currently working on something that uses iCalendar, and the selected user's data ultimately gets combined into a key1=value1;key2=value2; type of string. I started out by putting the data in a KeyValuePair<string,string>, but now I am wondering if that should be it's own class instead.

Overall, I am interested in finding out what guidelines are used when deciding to use an existing structure/class like a KeyValuePair over a 2-property object, and in what kind of situations you would use one over another.

答:
When we say key/value pair, I usually think of hash tables, or associative arrays, or simply a KeyValuePair object. I use all of them and there is no difference in when I use which.

I think the most important thing about a list of key/value pairs is that, keys should be unique (since it's a key after all), and all of the aforementioned structures really provide me with that functionality.

Other than that, I want to search by keys, or to do list (array) style actions like push and pop.

So, my answer is, NO, and I don't create objects explicitly for key/value pairs, since lots of built-in structures already do that for me.


答:
We do use branches, but not at the granular level of feature. We use branches for each sprint. Branching in essence is not a bad thing IMO, because it simulates the concept of SOC in the feature, or sprint layer. You easily can recognize and manage which branch belongs to which feature or sprint.

IMHO, then answer is, YES. We still should use branching.

Title: To branch or not to branch?