问:
Development methodologies when hundred of developers are working on one single solution?
We are an organisation consisting of around 200 developers that are working continuously on one single product (using the revision control Git) which is planned to be released at a certain date.

Due to the huge number of developers, we are trying to create "cross functional" teams with around 10 developers in each team, resulting in around 20 development teams in the organisation.

Since we would like to maintain a continuously "high standard" (meaning when developer does a pull, the product should at least be compilable, etc) of the product in the main repository, we would like to use some kind of quality gates.

I am a bit unsure how to phrase the question, but I am wondering if I could get some advice of development methodologies for such a large group of developers working on a single product.

In our opinion, one end of the spectrum is to allow each developer to commit directly to the main repository, however we fear that due to the high number of developers / commits that the "main repository" might constantly be in a broken stage, due to we can't have a demanding "quality gate" for each commit.

The other end of the spectrum might be like (we think Linus Torvalds / Linux does it) a tree or a pyramid structure, where the "main repository" only has three pull sources, these three only has a handful of trusted pull sources, etc. However, we feel that with a structure like that changes have a long chain to climb in order to come into the "main repository". Plus that if a merge conflict occurs, the problem lands on another developer than the "original developer".

With all this background information and opinions stated, how can we learn and read recommended development methodologies for so many developers? How do large organisations (Microsoft, Facebook, Ubuntu, etc?) structure up their development?

答:
Clearly, with a 200 person development team, you must have some sort of hierarchical structure.  An individual or a small group of people is making decisions about the design of the software product.  Your development process should reflect this: you need code reviews and testing in place to make sure the software being created actually matches what you wanted to create (as well as for quality purposes).

Even the small teams need leaders to guide the teams and review their work as they develop individual components.  Their should be quality control processes in place at the team level, as well.

So, yes, you should follow a hierarchical structure with regard to the repository.  This is to match the hierarchical structure of the project overall.

Individual components should be built and tested to a certain level of adequacy before you even think about putting them all together.  Allowing 200 people to commit directly to the main project would be chaos.  You should have separate areas for each group where individuals can commit their changes on a day-to-day basis, without affecting the main build of the project.

It is a very good thing if "changes have a long chain to climb in order to come into the main repository" because this chain allows you to ensure the quality.  It may seem faster if all the changes immediately apply to the main repository, but in fact this will just be a huge headache, as you will have a constantly buggy and unusable main build of your software.

It is also a good thing that "if a merge conflict occurs, the problem lands on another developer"--specifically, a higher level developer should be the one to decide how to resolve a conflict.


答:
I have worked on an enormous system which had several hundred developers working on it simultaneously with about 150M SLOC. This was on a mainframe, so we're not talking Visual Studio, but the principles can still be adopted.

First of all, if you're using Java, I would definitely say use Maven. If you're using VS, you could also use Nuget although I'm not quite sure as to whether or not it's there with Maven yet (it is also somewhat different). Using a system like this will allow you to pull your dependencies and allow them to function individually. You'd have a build script pull the relevant dependencies and build as a batch.

Given that you're not directly asking a question but asking for a methodology, I'll tell you how my previous employer handled it.

The system was broken into clusters. Clusters represented business areas and system infrastructure areas. I'm not going to name them, but for a huge retail business you could think of things such as marketing, retail operations, online operations, procurement, distribution. System infrastructure represented things such as customers and security. Within each cluster, there were components. Using the previous analogy, you could consider components of security for example - single sign on, directory services, auditing, reporting, etc. Each component had its relative routines stored within it.

As a namespace or package you'd have Organisation.Security.DirectoryServices, for example. By containing all logic to its relevant areas, the teams worked fairly autonomously. Obviously large projects requiring input from multiple teams happened but they were largely smooth operations.

I hope this helps.

ContentLicense: CC BY-SA 3.0

Title: Development methodologies when hundred of developers are working on one single solution?

Body:
We are an organisation consisting of around 200 developers that are working continuously on one single product (using the revision control Git) which is planned to be released at a certain date.

Due to the huge number of developers, we are trying to create "cross functional" teams with around 10 developers in each team, resulting in around 20 development teams in the organisation.

Since we would like to maintain a continuously "high standard" (meaning when developer does a pull, the product should at least be compilable, etc) of the product in the main repository, we would like to use some kind of quality gates.

I am a bit unsure how to phrase the question, but I am wondering if I could get some advice of development methodologies for such a large group of developers working on a single product.

In our opinion, one end of the spectrum is to allow each developer to commit directly to the main repository, however we fear that due to the high number of developers / commits that the "main repository" might constantly be in a broken stage, due to we can't have a demanding "quality gate" for each commit.

The other end of the spectrum might be like (we think Linus Torvalds / Linux does it) a tree or a pyramid structure, where the "main repository" only has three pull sources, these three only has a handful of trusted pull sources, etc. However, we feel that with a structure like that changes have a long chain to climb in order to come into the "main repository". Plus that if a merge conflict occurs, the problem lands on another developer than the "original developer".

With all this background information and opinions stated, how can we learn and read recommended development methodologies for so many developers? How do large organisations (Microsoft, Facebook, Ubuntu, etc?) structure up their development?


问:
What arguments exist against ever using the keyword substitution feature in many version control systems?
Are there any arguments out there against using the keyword substitution (i.e. replacing $Revision$ with $Revision: 5$) feature in many version control systems?  Are there any overall bad practices that using the feature encourages?  Are the any pervasive and hard-to-solve problems that it causes when you do use it?

Here an argument against using it:

Keyword Substition: Why You Don't Need It

It's succinct, and I think the argument about the problems it causes for binary files is cogent, but I don't find it compelling.

答:
This is an artifact from the old days, where files were versioned on an individual basis (think RCS, SCCS, and CVS) where modern version control systems think in atomic commits and not individual files.  This means that in the old days it made sense to keep track on a file level basis and the best way to do this was in a way that could make its way to binary code.  Hence expandable keywords which could go in strings that could go in the object file.

These days, you have a single commit identifier which only need to be registered once for any binary and which can be explicitly scripted to go in a file instead of the versioning system expanding keywords.

This is better, simply because it means that the sources only change when YOU edit them.

ContentLicense: CC BY-SA 2.5


答: In addition to the other answers suggesting a hierarchical structure: that implies you will have to schedule 'integration' points in time where the focus is entirely on moving the code up in the hierarchy and 'putting it all together'. This is not much different from smaller projects with a final phase where no other work is done than testing and bug fixing, only more frequently. Since you are working in a large group striving for high standards most of that (frame of mind) will probably be in place already.</p>


答:
You should certainly consider splitting the product into modules with interface team(s) bringing those constituent modules together into a product.  This in turn would mean splitting the repositories to match the module partitioning and hierarchy.   If it appears that you can't do this then the project will probably grind to a merge-induced halt considering the number of developers contributing.

If you are planning to use Git for version control then I would recommend using a code review system (like Gerrit) to improve transparency and ensure quality for each repository.  That way all work would have to be approved before being merged into any authoritative repository.  In this scenario it makes sense to grant certain trusted individuals permissions to push from a repo under a code review system to another repository (also possibly under a code review system).  If used correctly this should be a fast and greatly beneficial process that doesn't hinder the development process.

Regarding build verification you would need a continuous integration (CI) server whose purpose is to automatically build and verify code.  By verify code I mean that the code successfully compiles and tests pass.  Infact Jenkins (CI Server) can be linked to Gerrit code review system as part of the Gerrit verification stage, fully automating the process.

In addition to these integration tools it is important to strive for frequent integration as part of the development methodology, to minimise time merging.

It may be worth considering an Agile development process like Scrum whose purpose is to break a complex product it into manageable chunks of product increment (called Sprints).  These would provide integration opportunities between repositories.


问:
Open source software with good code documentation to improve design skill
As I'm trying to get better at designing good software I'm wondering if there are out there good (as in well written) open source software with lot of code documentation that aims to explain details about why this or that design choice was made in the context of that specific problem set. I'm interested in OOP and I don't really care much about the language (php / java / c# are preferred tho :))

Example:

Problem: X

Possible way to handle this problem: A, B, C.

We choose B because... (technical details about the implementation, pros and cons, code comments etc)

答:
I would advice reading two books.

For me this first one is THE BEST BOOK ON PROGRAMMING EVER! :) (And it doesn't matter if you don't use C#, you can still read it)

Agile Principles, Patterns, and Practices in C#

Clean Code

I really think first one should be read by every programmer.

Edit:
Those books are great resource for people that are trying to get better at designing good software. People looking for good (as in well written) open source software/code examples with lot of code documentation that aims to explain details about why this or that design choice was made in the context of that specific problem set.
Plus it has big section on organizing your assemblies. I haven't seen this in any programming book. And I have read probably 30.


问:
How can robots beat CAPTCHAs?
I have a website e-mail form. I use a custom CAPTCHA to prevent spam from robots. Despite this, I still get spam.

Why? How do robots beat the CAPTCHA? Do they use some kind of advanced OCR or just get the solution from where it is stored?

How can I prevent this? Should I change to another type of CAPTCHA?

I am sure the e-mails are coming from the form, because it is sent from my email-sender that serves the form messages. Also the letter style is the same.

 For the record, I am using PHP + MySQL, but I'm not searching for a solution to this problem. I was interested in the general situation how the robots beat these technologies. I just told this situation as an example, so you can understand better what I'm asking about.

答:
Other have discussed how spammers circumvent CAPTCHAs. Here are some tips on
How can I prevent this:

Note there is no silver bullet and spammers seem to be 1 step ahead of the game. So you will have to use a combination of multiple techniques

Use a honey pot form

Use a CAPTCHAs or Logic question. Basic questions like "apple, fish, hand, six - which  of these is a body part"

Have a delay. If the form is posted within 5 seconds of the page loading ignore the request, most robots will post within less than a second

Have some IP address monitoring - if you notice a spider crawling your website which is not in a white-list (google, bing)  then blacklist and ban its IP address. Preferably this would be dynamic/automated in code/software

Title: How can robots beat CAPTCHAs?


答:
When you have something big and (as a consequence) unmanageable the way out is dividing it into smaller and manageable pieces.

There are several steps that would help you maintain the team and the project better:

divide functionality into modules. The functionality should be divided into independent maximally modules using the high cohesion, low coupling and dependency inversion principles. The first principle will help you create logically consistent modules. The second one will help keep these modules as independent as possible. The third one will help develop dependent modules simultaneously (if module A depends on module B, B should provide an interface that A can use even when B is not completely ready).

have clear documentation. When there are so many people working together, things can easily be forgotten or misunderstood. So you need to pay special attention to all the documentation from requirements to architectural solutions.

people for tasks (never tasks for people). After dividing the functionality into smaller sets, create teams to work on these sets. Creating teams will be easier at this stage, because you already know what each team is to work on. And tasks such as code reviews would be done inside each team.

clear system of tasks. Each of the 200 developers should clearly know what to work on. This will help you keep track of what is already done, what is each person working on and how much work is left.

source control. (I think this is outlined in other answers quite well)))

And finally, try to create as simple a structure of teams and modules as possible. You can't afford complexity with such a huge project.


问:
How do I prove to management that our programmers could work more productively?
Backstory

I graduated less than a year ago with a degree in Computer Science (with extra courses in software engineering), and another degree in Software Engineering. I'd like to think that I'm familiar with modern software development methodologies (CI, Scrum, XP, etc).

The problem

I got my first (and current) job at a medium sized game development company. The company has been around for several years, has multiple successful titles under its belt, and is full of talented and dedicated people. However, software development happens in an entirely ad hoc way. We use SVN and a bugtracker, but beyond that there's very little planning, no automated testing, and you'd be hard pressed to find a UML diagram anywhere in the office.

I can think of two possible reasons for this:

Programmers are simply not given enough time to do things properly. Sadly, upper management has a tendency to set deadlines without consulting the programmers, which has led to many an all-nighter.

The programmers themselves lack the education / motivation to employ proper techniques.

The question

I recently spoke to management about this, and I was encouraged to suggest alternatives. I figure the first thing to do would be to rule out the second possibility listed above: that is, give management some evidence that if the programmers were given more breathing space, they could become much more productive. However, I'm not quite sure how to go about that. My best idea so far is to conduct a survey among programmers about what software development methodologies they know, as well as their attitudes towards code quality and such.

tl;dr

How can I assess whether our programmers are able/willing to employ modern software development methods, and prove to management that this would lead to increased productivity?

EDIT

I obviously failed to bring my point across properly, so let me elaborate on the situation a little.

First, I am fully aware that this looks like a bright-eyed fresh grad trying to save the world with his l33t education and changing the wicked ways of those grumpy old fossils who just don't know any better. I also understand that there is always a difference between theory and practice, and what they teach you in school is never what happens in real life. That is exactly why I'm being incredibly cautious here, trying to get a feel for the current situation instead of charging in going "Hai guise, let's all do teh unit tests from now on!"

Second, @psr raises a very good point. Let me name some of the reasons why I think that there is room for improvement:

Our senior developer, who's a bit of a maverick but ultimately a skilled and reasonable guy, agrees that at this point in the company's history, we should have more sophisticated and repeatable development processes in place.

One of the programmers who's much more experienced than me and has used modern methods agrees with me that we could be more productive if we used some of them.

In some cases, throwing features together during an all-nighter and then hunting down all the bugs takes a ridiculous amount of time; I cannot imagine that doing things any other way could be any worse.

The lack of planning, design, refactoring and documentation leads to poor code quality. Perhaps more importantly, it leads to programmers forgetting how their own code works in a matter of months (while they're still working on the same project!), and no way to find out apart from trial and error or wading through the spaghetti.

Even management suffers, as the only quantifiable measure of progress in a project is the number of unresolved bugs. But since anything is liable to break at any time (due to the reasons above), this is a very unreliable figure.

Third, I don't actually believe that my colleagues lack the knowledge of modern methods or the willingness to use them, it's just that at this point, I cannot rule it out as a possibility. Which is kind of the reason why I came here asking what's the best way to find out what they know (besides lengthy personal interviews, obviously).

Fourth, don't take those comments about UML and automated testing too seriously, they were just examples. The fact is, code is produced on the immediate whims of designers/upper management without any kind of software design, and only ever tested by a couple guys pressing buttons to see if anything breaks. Perhaps I'm still wearing my university-issued rose tinted glasses, but that strikes me as garage-development at its finest.

tl;dr

I'm trying really hard not to be arrogant about this, but both my fellow programmers and management seem to be expressing a desire for more predictable and productive ways of developing software. How can I find a solution that could make for an easy transition?

答:
My experience has been that before my suggestions for process changes are even heard, I have had to develop a reputation with the group involved.  The system the groups have had worked -- maybe not well, but good enough for products to get shipped for many years.  Asking people to change to the unknown based on the word of someone with an unknown track record was a big ask.

"The status quo is working.  Why change it?  Why should we listen to
  you?"

I've been down this road before.  So what did I do?  Lots of things (20 years in SW development is a long time), but this seems to have worked best: I started by building my reputation.  I showed myself accomplished in doing the tasks assigned.  I also learned their systems and the reasons behind them.  (Steven Covey presents the idea of a bank account.  Asking for a change is equivalent to asking for a withdrawal from the account.  Before you can make a big withdrawal, you have to put enough in to cover it.)

Once I had established my reputation, I would wait for opportunities to suggest small improvements:

"What would happen if we could automatically make a build of the code
  set every time it changed and have the results mailed to developers?"

"Now that we have the code building automatically, what if we had unit
  tests run with every build?"

"You know, instead of spending a month
  of everyone's time doing code reviews at the end of the development
  cycle, why don't we review every commit, before we have to re-work
  major sections?"

Did it work?  Yes.  A team that resisted the idea of checking in code more than once a week now commits multiple times a day.  If the CI system is down for as little as an hour, I get calls.  All of the source code is now under unit tests (95+% coverage!) for each build.  The team now is doing "Continuous Code Reviews" as changes are committed.

And me, well, I'm starting to build my reputation again.  They already like the idea of having integration builds with every commit...  If only there was a way to make that happen... :-)


答:
In addition to hotpotato's answer (which is directly on the mark IMHO), I would also suggest implementing some source control gates, as you suggest. When we moved a large team and code base to git for SCM, we decided to use what is called the "benevolent dictator" method, similar to the model you described.

In this scenario there are lots of various branches of the full code base that are regularly updated from their source branch, but responsibility for promoting code into more visible/public areas lies with a single person (or small group of people), and is typically tied to a code review process. With a well-organized branching structure, this can work REALLY well. For more information, check out this link.


问:
Why there are no compound assignment operators for logical operators (such as ||, && etc)?
According to ECMA-262, part 11.13, following is the exhaustive list of compound assignment operators: *= /= %= += -= <<= >>= >>>= &= ^= |=.

According to the part 11.11, var c = a || b will put a value into c if ToBoolean(a) is true and will put b value into c otherwise. As such, the logical OR is often used as the coalesce operator, e.g.

```<code>function (options) {
    options = options || {};
}
</code>```

Frequently enough, coalesce is used to specify the default value for the variable, as was shown above: a = a || b.

It seems that compound assignment operator ||= would be really useful, allowing to write the code above in a shorter and cleaner fashion: a ||= b. However, it is not there (although *=, += and other compound assignment operators are).

The question is, why?

答:
You are right that ||= is a useful construct.  It exists in Perl.

In fact Perl makes all of these available:

```<code>**=    +=    *=    &=    <<=    &&=   -=    /=
|=     >>=   ||=   .=    %=     ^=    //=   x=
</code>```

Some of these are great (.= adds something to the end of a string), others less so (&&=??? I suppose the variable would get set to the right side if both it and the variable are true.  But why would you ever do this?)

What is included in a language is really a feature of its design philosophy.

OwnerDisplayName: penartur

Body:
You are right that ||= is a useful construct.  It exists in Perl.

In fact Perl makes all of these available:

**=    +=    *=    &=    <<=    &&=   -=    /=
|=     >>=   ||=   .=    %=     ^=    //=   x=

Some of these are great (.= adds something to the end of a string), others less so (&&=??? I suppose the variable would get set to the right side if both it and the variable are true.  But why would you ever do this?)

What is included in a language is really a feature of its design philosophy.


问:
Java Swing ActionListener design
I have a form that includes an area for putting in address information and a table that shows the addresses that have been added.  I've separated out the ActionListener for the "add address" button on the form into it's own top level class and I'm finding it tricky and cumbersome to refer back to the form that has the text boxes and the table.

From a design perspective, is it a bad idea to put the class that implements the ActionListener for the add address button as an inner class in the form class?  The ActionListener class will be specifically tied to the parent form alone, so I'm figuring that an inner class might be the better route to go.  I'm going to perform any business logic outside of the form class, of course...

答: Swing listeners are the typical example for inner classes, possibly even the reason that language feature was added. So go ahead and implement it like that. From the design perspective, the action listener behaviour is really part of the form.</p>

Title: Java Swing ActionListener design


答:
These books offer some high-level perspective on how and why certain open-source software is designed the way it is:
The Architecture of Open Source Applications

There are two volumes that cover a wide variety of open-source projects, both old and new.  For example:

The article on bash covers a number of decision points and even has a section near the end about "What I would have done differently" to provide a retrospective.

The article on Eclipse provides several diagrams, code snippets, and discusses some of the evolution through the various major versions it has been released under.

Title: Open source software with good code documentation to improve design skill

Body:
As I'm trying to get better at designing good software I'm wondering if there are out there good (as in well written) open source software with lot of code documentation that aims to explain details about why this or that design choice was made in the context of that specific problem set. I'm interested in OOP and I don't really care much about the language (php / java / c# are preferred tho :))

Example:

Problem: X

Possible way to handle this problem: A, B, C.

We choose B because... (technical details about the implementation, pros and cons, code comments etc)


答:
I find your question quite daring! I understand completely what you mean, I also share some parts of what you experience, that's why I reply.

About the methods, I guess you'd have to adapt to the way they do because it's going to fire back to you. If you put yourself in their shoes they might think "a just graduated guy is going to tell me (>5 years development) how to work, if I got promotions and rises by doing what I'm doing the way I did it until now", as you can understand, pretty dangerous statement that can develop to not nice situations with your co-workers, something I always avoid because you need to learn first the ways they use and later try to improve without confrontation.

The reply from your management I understand it as "show me the money or keep it quite", that's also not good, that puts you in the spotlight without knowing 100% what are you dealing with (meaning how effective the previous methodologies are being profitable to them).

In my case, the way I deal is applying the methods I know only to myself, I use UML with the code I need to maintain (currently I do it out of working hours) and I tend to explain why I did it without implying that's the correct way.
(As you know UML is for a code as a map for an explorer. You can explorer without map, but don't complain if you make 2 extra km in the way back home :) )

Currently I'm getting more questions about the code than the original creator, mostly because I'm fresh with the code, but also because I also add a nice map (UML) with some notes on how to change something, in a short time (the owner of the code also keep making changes).

My advice use what you know for yourself, and if you become more efficient, they will move the spotlight towards you, THEN you can start talking about effectiveness, before you may put your credibility in jeopardy.

Title: How do I prove to management that our programmers could work more productively?

Body:
Backstory

I graduated less than a year ago with a degree in Computer Science (with extra courses in software engineering), and another degree in Software Engineering. I'd like to think that I'm familiar with modern software development methodologies (CI, Scrum, XP, etc).

The problem

I got my first (and current) job at a medium sized game development company. The company has been around for several years, has multiple successful titles under its belt, and is full of talented and dedicated people. However, software development happens in an entirely ad hoc way. We use SVN and a bugtracker, but beyond that there's very little planning, no automated testing, and you'd be hard pressed to find a UML diagram anywhere in the office.

I can think of two possible reasons for this:

Programmers are simply not given enough time to do things properly. Sadly, upper management has a tendency to set deadlines without consulting the programmers, which has led to many an all-nighter.

The programmers themselves lack the education / motivation to employ proper techniques.

The question

I recently spoke to management about this, and I was encouraged to suggest alternatives. I figure the first thing to do would be to rule out the second possibility listed above: that is, give management some evidence that if the programmers were given more breathing space, they could become much more productive. However, I'm not quite sure how to go about that. My best idea so far is to conduct a survey among programmers about what software development methodologies they know, as well as their attitudes towards code quality and such.

tl;dr

How can I assess whether our programmers are able/willing to employ modern software development methods, and prove to management that this would lead to increased productivity?

EDIT

I obviously failed to bring my point across properly, so let me elaborate on the situation a little.

First, I am fully aware that this looks like a bright-eyed fresh grad trying to save the world with his l33t education and changing the wicked ways of those grumpy old fossils who just don't know any better. I also understand that there is always a difference between theory and practice, and what they teach you in school is never what happens in real life. That is exactly why I'm being incredibly cautious here, trying to get a feel for the current situation instead of charging in going "Hai guise, let's all do teh unit tests from now on!"

Second, @psr raises a very good point. Let me name some of the reasons why I think that there is room for improvement:

Our senior developer, who's a bit of a maverick but ultimately a skilled and reasonable guy, agrees that at this point in the company's history, we should have more sophisticated and repeatable development processes in place.

One of the programmers who's much more experienced than me and has used modern methods agrees with me that we could be more productive if we used some of them.

In some cases, throwing features together during an all-nighter and then hunting down all the bugs takes a ridiculous amount of time; I cannot imagine that doing things any other way could be any worse.

The lack of planning, design, refactoring and documentation leads to poor code quality. Perhaps more importantly, it leads to programmers forgetting how their own code works in a matter of months (while they're still working on the same project!), and no way to find out apart from trial and error or wading through the spaghetti.

Even management suffers, as the only quantifiable measure of progress in a project is the number of unresolved bugs. But since anything is liable to break at any time (due to the reasons above), this is a very unreliable figure.

Third, I don't actually believe that my colleagues lack the knowledge of modern methods or the willingness to use them, it's just that at this point, I cannot rule it out as a possibility. Which is kind of the reason why I came here asking what's the best way to find out what they know (besides lengthy personal interviews, obviously).

Fourth, don't take those comments about UML and automated testing too seriously, they were just examples. The fact is, code is produced on the immediate whims of designers/upper management without any kind of software design, and only ever tested by a couple guys pressing buttons to see if anything breaks. Perhaps I'm still wearing my university-issued rose tinted glasses, but that strikes me as garage-development at its finest.

tl;dr

I'm trying really hard not to be arrogant about this, but both my fellow programmers and management seem to be expressing a desire for more predictable and productive ways of developing software. How can I find a solution that could make for an easy transition?


问:
Should we validate a state transition before attempting it in the State Pattern?
When applying the State Pattern illegal transitions should result in an exception being thrown (or at least that's what I understood from the pattern)

I know exceptions are for "unexpected behavior" where an action isn't supposed to happen. Errors would be more appropriate if the required action is common (ex: user enters a wrong password)

Now picture this, I have an admin panel where a list of orders are shown and each order has 3 buttons (Refund, Cancel, Reorder) where each one of them changes the state of the order if the operation is allowed.

The 3 buttons are enabled by default (I'm simplifying my case here as my real system is much more complex than that). Now a user can for example push the cancel button for an order with state (Cancelled) which is an invalid state transition.

Since I expected that this illegal transition action to occur would a validation before attempting to Cancel the line be more appropriate?

If I validate before transition do I still need exceptions in the model?

Is there a better approach to the whole problem (ignoring disabling the buttons and client side validation)

答:
Is there a better approach to the whole problem (ignoring disabling the buttons and client side validation)

Yes. The pattern is not being implemented correctly from what I'm reading.

Your "list of orders" screen should have it's own state-handling object.

This is a context class/object as seen in the state pattern class diagram.

The OrdersList sets its overall state based on user selections, button clicks, etc. Every user UI interaction triggers the OrdersList state object to validate - because after all the UI state just changed - and set internal booleans that tell us what states are OK now. Each specific boolean is wired into the UI via the context object, so selecting a (cancelled) order triggers context validation which knows cancel is not a valid next state and sets the "cancel boolean" to false. This boolean directly sets the Cancel button and voila.

States Do Not know how or if to allow other States

That's part of the point of the state pattern.

A given state knows how to validate itself. But how can it know what the next valid states are without some context? That context is the "list of orders" screen. Other screens in your app are also "context" of another kind. How in the world can every State object/class know about every button and user interaction possibility for the whole application? They cannot! Each context may have differing rules about what states are allowed. That's what the context class is about.

If I validate before transition do I still need exceptions in the model?

In the model / context object yes. In each State, no.

Since I expected that this illegal transition action to occur would a validation before attempting to Cancel the line be more appropriate?

The question is moot now that we see every screen as having it's own state. So: The user doing anything in the UI changes then we must validate its new state - that's the context object in action here. That context object validation sets UI controls so that only valid things are allowed.

A key is that all validation, all of it, is in your Model

The UI, client side, may have a modicum of validation but all logic necessary for determining state must be in your "behind the UI" model. Your context object looks at what's been clicked, selected, etc. and the context decides what to do.

If you're thinking that context might also be the Controller in the MVC pattern, I suspect you're right


问:
What could an algorithm look like that iterates through all combinations of two variables to aim at a certain number of entries?
For background information, see "Some background" further down.

I have a list that looks like this:

```<code>Start-Time-In-Seconds;End-Time-In-Seconds
1;2
4;6
12;15
...
</code>```

This works together with a wave file by acting as a cutlist. So the desired parts are 1->2, 4->6, 12->15, ...

If the distance between End-Time-In-Seconds of the previous element and Start-Time-In-Seconds of the current element is below a threshold of seconds(I call it Pausendauer) I merge those two, ie if the threshold is 3 seconds then the list will be

```<code>Start-Time-In-Seconds;End-Time-In-Seconds
1;6
12;15
...
</code>```

If the distance between Start-Time-In-Seconds and End-Time-In-Seconds is below a threshold of seconds(I call it Minimallänge) I discard this sample, ie if the threshold is 4 seconds then the list will be

```<code>Start-Time-In-Seconds;End-Time-In-Seconds
1;6
...
</code>```

What could an algorithm look like that iterates (intelligently) through all combinations of Minimallänge and Pausendauer to aim at a certain number of entries? Example:

The number of entries should be 3. Given the number 3 the algorithm should iterate (intelligently) through all combinations of Minimallänge and Pausendauer to output something like this:

```<code>Start-Time-In-Seconds;End-Time-In-Seconds
1;12
18;20
50;100
</code>```

And that should be all. You notice I did not add "..." to it as the final list is to only consist of three entries.

Some background: The wave file contains several interviews being recorded continuously with pauses in between. A VAD gave me areas where it presumes voice to be. As I know the number of total conversations(f.i. 3, usually more which is why this makes sense) my goal is to determine them automatically. The cutlist is the raw output of my VAD which I want to turn into a usable cutlist for ffmpeg.

PS: If you can, share an algorithm in c#.

答:
I think this is an interesting question, and I don't have the solution.  However, bear with me, this is going to be long, and not an implementation or even an answer (I deserve the downmodding in advance) but a rephrasing of the question with additional remarks and observations to attempt to condition the problem, which may lead you on the path to finding an implementation.

Remark: I wrote this before the explanation of the actual problem was added in the comments, so this may be overly generic, but I'll still post it.

Consider an ordered list of non-overlapping time chunks with a start and end time (where end time > start time).

We have a given filter with parameters pause_threshold and minimal_length that, in order:

Merges all time chunks t0 and t1 where t1.starttime - t0.endtime < pause_threshold.
This can be done in one pass, the merges do not affect the distance between merged time  chunks.

Discards all time chunks t0 where t0.endtime - t0.starttime < minimal_length.

This also can be done in one pass, but I am assuming here that this must be done after the merge pass, because that one definitely affects the length of time chunks.

The actual question is: devise an algorithm for the following: For a given finite time-chunk list L and count c,  determine pause_threshold and minimal_length such that after the two passes the list contains exactly c entries.

Observations:

A valid upper bound for pause_threshold is slightly larger than the largest time between two adjacent time chunks in L.  This is easy to see: using this value for pass 1 of the algorithm would merge all the chunks resulting in only one entry, which is already overkill.

The total set of pause_thresholds to try is finite: it is the set of all unique distances between time chunks in L.

Similarly the minimal_length parameter is also bound.  If you choose it as slightly larger than the length of the longest chunk, all chunks will be discarded, so that is an upper bound for the minimal_lengths to try.  A bounded finite set of minimal_lengths to try is the set of unique chunk lengths in L plus 0 (the "no discards" value).

Now you know the problem is bound - you can simply try all possible combinations from the two sets and see if any of them arrive at a solution (i.e. the number of entries in the resulting list after applying the filter is equal to c).

This analysis does not reveal if an answer is always possible: it's trivially easy to prove that it's not the case in general:  just consider a starting list L with fewer than c entries.

That observation leads to another angle of attack on the algorithm: the inductive attack.

If L has less than c entries, there is no solution possible.

If L has c entries it's already trivially correct so you want no merges or discards.  A valid (but not unique) solution is pause_threshold and minimal_length 0.

If L has n > c entries, then n-c entries will have to be eliminated either through merging or discarding.  A merge and discard have exactly the same effect: they reduce the number of chunks in the list by 1.  Therefore you need n-c merges, n-c discards, or n-c merges + discards.  This is where it becomes tricky, because you may not have unique pause lengths between chunks, nor unique lengths of chunks (before or after merges).

The reason it gets tricky with non-unique lengths or pauses is because you won't have a unique mapping of threshold values to the number of items eliminated.  For example consider a chunk list with lengths [1 3 3 5 7].  Pick minimal_length value 2 and you eliminate 1 value.  Pick 4 and you eliminate 3.  There is no value you can pick to eliminate just 2, so you cannot solve it with discards alone.

...
I'm going to have to cut it short here, but I hope this can be the start of constructive community work on an interesting question!


答:
Your company uses SVN and a bugtracker? Consider yourself lucky!  I just graduated and started a new job, my new company version controlled their >100 one-off, ~10 kLOC VB6 and VB.NET apps with ZIP files with dates in the file name.  However, my situation is slightly different because they hired me with the expectation that I could help improve the development process, and it was just 3-5 previous developers, and all but one of these developers have moved on. Also, I have 1.5 years of internships at another, similar company with far better development practices to gauge my present employer against.

I readily acknowledge that as a junior developer I am not experienced enough to make major changes based on what I've read in my textbooks and heard from professors.  Instead, draw on the wisdom of people with more experience: Professors with real-world experience, mentors from previous internships, and other developer's blogs.  I found the following articles from Joel Spolsky insightful and applicable: The Joel Test: 12 Steps to Better Code, and Getting Things Done When You're Only a Grunt.

The Joel Test comprises the following questions:

Do you use source control?

Can you make a build in one step?

Do you make daily builds?

Do you have a bug database?

Do you fix bugs before writing new code?

Do you have an up-to-date schedule?

Do you have a spec?

Do programmers have quiet working conditions?

Do you use the best tools money can buy?

Do you have testers?

Do new candidates write code during their interview?

Do you do hallway usability testing?

It sounds like you score at least a 2, with your source control and bugtracker.  My company scored a zero.  Honest to goodness, a zero. Read the next line carefully: The truth is that most software organizations are running with a score of 2 or 3.  My company has been profitable while operating at a Joel Test level of zero. A huge number of profitable, successful companies (like yours!) are making money and writing software with a process at or below the level of your company.

Next, "Getting Things Done When You're Only a Grunt" could be copied and pasted as an answer to your question.  I've paraphrased it and made some adaptations for our situation here:

Just Do It: Use good software engineering practices personally, even if they're not official.  I run a VCS, Jenkins CI and Redmine on my local machine. I work hard to eliminate bugs when I find them, to test my code well, and to do usability testing when possible. I write my own spec and schedule even though I can't influence them.  I close my door, wear headphones, and apply a little focus. I brought in a spare second monitor, a couple sticks of RAM, and an SSD from home, and use a lot of open-source or free software to have better tools. You can give yourself a lot of the personal benefits of good software engineering even if your team doesn't want them,

Harness the Power of Viral Marketing: Allow change to spread organically rather than by executive fiat. I'm going to make a bold statement here: This is the only appropriate way to make changes as a <1 year junior developer.  Don't email the entire department with a survey.  Don't ask your managers to read research papers on software engineering.  Let them ask you how you do your work so well.  When you get some seniority, then you can consider making changes directly.

Create a Pocket of Excellence: Use good software engineering practices to write more and better code than other areas of the organization.  As an individual developer, you pass the first ten tests on your own.  I don't have the domain knowledge of my coworkers, but I can write good code.  This is #1 applied to a small group.

Neutralize The Bozos: Minimize the damage that poor programmers can cause to your projects. This isn't really our place as new employees. You should probably ignore this one unless you're really good with people.

Get Away From Interruptions: Find a place and time that you can get good work done.  Headphones can be helpful here, if they're OK with management.

Become Invaluable: Write lots of really good code so that you're respected (which helps #2 and #3 tremendously).  This does not mean writing terrible code to give yourself job insurance.  That is the opposite of invaluability and job insurance work.  Being valuable does, and gives you career insurance, which is better than job insurance.

Read the article in full, it's gold. I'm about 6 months into the process, and the organization scores about a 1.5, which is infinitely better than the zero we had when I started.  I consider that great progress, and will be ecstatic if we can get up to 2 or 3 by the time I've been here a year.


问:
what is a proper way to register eventHandler
I was showing some of my code to a junior programer, and he asked me why am I registering functions for event handling like this:

```<code>button1.Click += new RoutedEventHandler(button1_Click);
</code>```

and not like this:

```<code>button1.Click += button1_Click;
</code>```

The only thing I could say was: because you just write += and press tab two times...

What is the difference between those two metods (if there is a difference)?

答:
Personally, if what you're doing in the handler is really short and not shared with any other events, I like this form:</p>

```<code>button1.Click += (sender, e) =>
{
    DoSomethingAwesome(e.RoutedEvent);
    e.Handled = true;
};
</code>```

Body:
Personally, if what you're doing in the handler is really short and not shared with any other events, I like this form:

button1.Click += (sender, e) =>
{
    DoSomethingAwesome(e.RoutedEvent);
    e.Handled = true;
};


问:
Explicitly defining variable data types vs. using the keyword 'var'?
In C#, am I encouraged to use the all-purpose var keyword for every variable declaration? If yes, do I have to mention those special characters for literal values within the variable declaration like the M for decimal in the following statement:

```<code>var myDecimal = 14.5M;
</code>```

If it makes a difference, I'm trying to do some web development with C#.

答:
For me I don't use var for the following cases :

When I want to be sure of the type of my variable (for example to be sure that the type used is double and not decimal, and this is a big deal trust me !)

Polymorphic code like Fruit foo = new Apple();. In this case, I think var is to avoid and using the parent class (here Fruit) is better by allowing a better understanding of the code logic and limitation of the probable bugs (With var, no check of the polymorphic concept !)

For the rest, I think it depend of the case and of the background of the developer.
Some people from the PHP world will prefer not taking care of the variable types, and some people from the Java world will just think var is an heresy and the more verbose it is the better it is.

You will have to make your personal opinion :)


问:
Is bash "finished"?
Should bash be expected to change in ways that break non-trivial amounts of existing scripts at some point in the (near/<5y) future? How much change has it gone trough in the last ten years compared to, say, python or perl?</p>

答:
bash has been around since 1989, and its syntax is largely compatible with that of the much older Bourne shell, which was released in 1977. Huge swaths of core functionality in many operating systems (most Linux distros, OS X, and indeed most POSIX-compatible operating systems), and many real-world systems (make systems, automated tests, initialization scripts, etc.) depend on its functionality.

Bash isn't going anywhere, because if it did break existing scripts, it would cause huge problems. To the contrary, Bash has gone out of its way to preserve backwards compatibility with every new syntax addition.

Title: Is bash "finished"?


答:
The syntax of bash is unlikely to change significantly.  Changes to it could have catastrophic effects across unix systems (startup scripts not working after the upgrade).

One can see that things are progressing forward with bash, and various distributions are slowly updating code to remove backwards comparability with earlier versions of bash.

If you are upgrading a system and see that bash is upgrading, it may be necessary to test those ancient scripts to make sure everything is still running correctly.  It probably will, but I wouldn't want to be the one doing a "OMG Fix everything yesterday!" when something is doesn't work right after trusting that everything will.

In theory, if people followed best practices for the bash scripts, it should work, but then again, please don't take my word for it.

Perl and Python keep backwards compatibility within major version numbers.  Something written for perl 5.001 (1995) still runs correctly in perl 5.16.1 (August 9, 2012).  A script for perl 5 will need to run in compatibility mode with perl 6.

Python appears to follow a similar "nothing breaking within a major version".  Also give Python 2 or 3 a look for python backwards compatibility between major versions.

Title: Is bash "finished"?

Body: Should bash be expected to change in ways that break non-trivial amounts of existing scripts at some point in the (near/<5y) future? How much change has it gone trough in the last ten years compared to, say, python or perl?</p>


答:
Let n be the number of entries in the initial list.

Then, there are n-1 gaps between adjacent entries. The Pausendauer determines which gaps are closed and which ones are not, and so there are at most n-1 useful possibilities for the Pausendauer (values between "useful" possibilities don't change the set of closed gaps, so they need not be tested).

After the Pausendauer step closes some number of gaps, the Minimallänge discards some number of segments. Because we have a specific target of output segments, Minimallänge must be set such that it discards all but k of the segments. Therefore, you can find Minimallänge simply by looking for the length of the kth largest segment and setting Minimallänge equal to that, minus one.

Therefore, we have an algorithm that will run in at most O(n2 log n) time: it tests each of the Pausendauer possibilities, and for each Pausendauer it will sort the segments by length and find the kth largest segment to set Minimallänge.

Observe that this means that, for any Pausendauer, there is always a Minimallänge that produces the desired number of outputs (ignoring ties). Therefore, you may want to slap on an additional constraint to minimize the parameters, e.g. to find the solution (P, M) that minimizes P + M, or something like that.

The algorithm is:

```<code>Let A = input array of segments
Let gaps = []
for i in 1..n-1
    gaps[i] = A[i+1].start - A[i].end
end

sort gaps

for P in gaps
    Let A' = segment array after merging with Pausendauer = P
    sort A' by segment length (.end - .start), decreasing order
    Let M = A'[k].start - A'[k].end - 1
    # P, M is now a possible solution.
end
</code>```

Title: What could an algorithm look like that iterates through all combinations of two variables to aim at a certain number of entries?

Body:
For background information, see "Some background" further down.

I have a list that looks like this:

```<code>Start-Time-In-Seconds;End-Time-In-Seconds
1;2
4;6
12;15
...
</code>```

This works together with a wave file by acting as a cutlist. So the desired parts are 1->2, 4->6, 12->15, ...

If the distance between End-Time-In-Seconds of the previous element and Start-Time-In-Seconds of the current element is below a threshold of seconds(I call it Pausendauer) I merge those two, ie if the threshold is 3 seconds then the list will be

```<code>Start-Time-In-Seconds;End-Time-In-Seconds
1;6
12;15
...
</code>```

If the distance between Start-Time-In-Seconds and End-Time-In-Seconds is below a threshold of seconds(I call it Minimallänge) I discard this sample, ie if the threshold is 4 seconds then the list will be

```<code>Start-Time-In-Seconds;End-Time-In-Seconds
1;6
...
</code>```

What could an algorithm look like that iterates (intelligently) through all combinations of Minimallänge and Pausendauer to aim at a certain number of entries? Example:

The number of entries should be 3. Given the number 3 the algorithm should iterate (intelligently) through all combinations of Minimallänge and Pausendauer to output something like this:

```<code>Start-Time-In-Seconds;End-Time-In-Seconds
1;12
18;20
50;100
</code>```

And that should be all. You notice I did not add "..." to it as the final list is to only consist of three entries.

Some background: The wave file contains several interviews being recorded continuously with pauses in between. A VAD gave me areas where it presumes voice to be. As I know the number of total conversations(f.i. 3, usually more which is why this makes sense) my goal is to determine them automatically. The cutlist is the raw output of my VAD which I want to turn into a usable cutlist for ffmpeg.

PS: If you can, share an algorithm in c#.

Body:
Let n be the number of entries in the initial list.

Then, there are n-1 gaps between adjacent entries. The Pausendauer determines which gaps are closed and which ones are not, and so there are at most n-1 useful possibilities for the Pausendauer (values between "useful" possibilities don't change the set of closed gaps, so they need not be tested).

After the Pausendauer step closes some number of gaps, the Minimallänge discards some number of segments. Because we have a specific target of output segments, Minimallänge must be set such that it discards all but k of the segments. Therefore, you can find Minimallänge simply by looking for the length of the kth largest segment and setting Minimallänge equal to that, minus one.

Therefore, we have an algorithm that will run in at most O(n2 log n) time: it tests each of the Pausendauer possibilities, and for each Pausendauer it will sort the segments by length and find the kth largest segment to set Minimallänge.

Observe that this means that, for any Pausendauer, there is always a Minimallänge that produces the desired number of outputs (ignoring ties). Therefore, you may want to slap on an additional constraint to minimize the parameters, e.g. to find the solution (P, M) that minimizes P + M, or something like that.

The algorithm is:

Let A = input array of segments
Let gaps = []
for i in 1..n-1
    gaps[i] = A[i+1].start - A[i].end
end

sort gaps

for P in gaps
    Let A' = segment array after merging with Pausendauer = P
    sort A' by segment length (.end - .start), decreasing order
    Let M = A'[k].start - A'[k].end - 1
    # P, M is now a possible solution.
end


问:
What "sublicense" actually means?
First, it is clear that the right to sublicense doesn't give you the right to relicense.

Let's say that we have a library licensed under the MIT license(1 file), someone adds some features to the library but puts them under GPL(in the same 1 file). Or, if someone wants to sublicense, do they have to separate the code?

If someone wants to use the library, how are the licenses handled?

Let's say that the developers use only the MIT licensed code, without directly using some features under the GPL license, that are inside the same file.

Do they have to GPL their application because of the GPL licensed code?

Do they have to remove the GPL code in order to be free of the GPL restrictions or they can just use the library under the MIT permissions/restrictions as long as they don't use the GPL code?

答:
someone adds some features to the [MIT] library but puts them under GPL(in the same 1 file).  If someone [else] wants to "sublicense," [do] they have to separate the code?

If by sublicense you mean use the code under the less-restrictive MIT license, then yes.  The person GPL'ing their new code is basically saying, "You can't use my code unless your code is also distributed under the terms of GPL."

Does [the sublicensor] have to remove the [newly-licensed] GPL code in order to be free of the GPL restrictions?

Yes.

ContentLicense: CC BY-SA 4.0

Title: What "sublicense" actually means?


问:
Why are software schedules so hard to define?
It seems that, in my experience, getting us engineers to accurately estimate and determine tasks to be completed is like pulling teeth. Rather than just giving a swag estimate of 2-3 weeks or 3-6 months... what is the simplest way to define software schedules so they are not so painful to define? For instance, customer A wants a feature by 02/01/2011. How do you schedule time to implement this feature knowing that other bug fixes may be needed along the way and take up additional engineering time?</p>

答:
There are "known unknowns" and "unknown unknowns." :-)

Estimates often become deadlines.

Nobody want to miss a deadline and become headline!

Requirements change (often rationally) and the programmer cannot veto it.

Programmer do/may not have control on factors such as

Availability of code she is depedent on

Quality of code she is dependent on

Overall architecture and design of the system

APIs to access other parts of the system


问:
Basic hardware for iPhone development
I am new to Mac. If I want to start a iPhone development, what is the basic hardware I require? Would Mac Mini be good enough?</p>

答:
A Mac mini will serve you just fine. I taught a course last semester that did iPod touch programming (another college had iPod touches available for educational use, so I figured programming them would be educational). The only thing I needed was to buy four Mac minis to put in the lab. The Macs didn't need to be advanced, just new.

One note: Prepare for some major headaches getting your first "Hello, World!" app over the wire and onto your iPhone. Doing so requires the proper public/private keys and certificates. I used a university license program, but you will probably need to spend the $100 on the single developer kit. The development tools themselves are free, and you can work on the simulator right away.

Title: Basic hardware for iPhone development


问:
Command pattern design
I have this old implementation of the Command pattern. It is kind of passing a Context through all the DIOperation implementation, but I realized later on, in the process of learning and learning (that never stops), that is not optimal. I also think that the "visiting" here doesn't really fit and just confuses.

I am actually thinking of refactoring my code, also because a Command should know nothing about the others and at the moment they all share the same key-value pairs. It is really hard to maintain which class owns which key-value, sometimes leading to duplicate variables.

An Example of use case: let's say CommandB requires UserName which is set by CommandA. Should CommandA set the key UserNameForCommandB=John? Or should they share a common UserName=John key-value? What if the UserName is used by a third Command?

How can I improve this design? Thanks!

```<code>class DIParameters {
public:
   /**
    * Parameter setter.
    */
    virtual void setParameter(std::string key, std::string value) = 0;
    /**
    * Parameter getter.
    */
    virtual std::string getParameter(std::string key) const = 0;

    virtual ~DIParameters() = 0;
};

class DIOperation {
public:
    /**
     * Visit before performing execution.
     */
    virtual void visitBefore(DIParameters& visitee) = 0;
    /**
     * Perform.
     */
    virtual int perform() = 0;
    /**
     * Visit after performing execution.
     */
    virtual void visitAfter(DIParameters& visitee) = 0;

    virtual ~DIOperation() = 0;
};
</code>```

答:
I don't know if this is the right way to handle this on Programmers (in which case I apologize), but, after having checked all the answers here (@Frank's in particular). I refactored my code this way:

Dropped DIParameters. I'll have individual (generic) objects as DIOperation's input (immutable). Example:

```
class RelatedObjectTriplet {
private:
    std::string const m_sPrimaryObjectId;
    std::string const m_sSecondaryObjectId;
    std::string const m_sRelationObjectId;

    RelatedObjectTriplet& operator=(RelatedObjectTriplet other);

public:
    RelatedObjectTriplet(std::string const& sPrimaryObjectId,
                         std::string const& sSecondaryObjectId,
                         std::string const& sRelationObjectId);

    RelatedObjectTriplet(RelatedObjectTriplet const& other);

    std::string const& getPrimaryObjectId() const;
    std::string const& getSecondaryObjectId() const;
    std::string const& getRelationObjectId() const;

    ~RelatedObjectTriplet();
};
```

New DIOperation class (with example) defined as:

```
template <class T = void>
class DIOperation {
public:
    virtual int perform() = 0;

    virtual T getResult() = 0;

    virtual ~DIOperation() = 0;
};

class CreateRelation : public DIOperation<RelatedObjectTriplet> {
private:
    static std::string const TYPE;

    // Params (immutable)
    RelatedObjectTriplet const m_sParams;

    // Hidden
    CreateRelation & operator=(CreateRelation const& source);
    CreateRelation (CreateRelation const& source);

    // Internal
    std::string m_sNewRelationId;

public:
    CreateRelation(RelatedObjectTriplet const& params);

    int perform();

    RelatedObjectTriplet getResult();

    ~CreateRelation();
};
```

It can be used like this:

```
RelatedObjectTriplet triplet("33333", "55555", "77777");
CreateRelation createRel(triplet);
createRel.perform();
const RelatedObjectTriplet res = createRel.getResult();
```

Thanks for the help and I hope I haven't made mistakes here :)

OwnerDisplayName: Kap

Title: Command pattern design

Body:
I don't know if this is the right way to handle this on Programmers (in which case I apologize), but, after having checked all the answers here (@Frank's in particular). I refactored my code this way:

Dropped DIParameters. I'll have individual (generic) objects as DIOperation's input (immutable). Example:

class RelatedObjectTriplet {
private:
    std::string const m_sPrimaryObjectId;
    std::string const m_sSecondaryObjectId;
    std::string const m_sRelationObjectId;

    RelatedObjectTriplet& operator=(RelatedObjectTriplet other);

public:
    RelatedObjectTriplet(std::string const& sPrimaryObjectId,
                         std::string const& sSecondaryObjectId,
                         std::string const& sRelationObjectId);

    RelatedObjectTriplet(RelatedObjectTriplet const& other);

    std::string const& getPrimaryObjectId() const;
    std::string const& getSecondaryObjectId() const;
    std::string const& getRelationObjectId() const;

    ~RelatedObjectTriplet();
};

New DIOperation class (with example) defined as:

template <class T = void>
class DIOperation {
public:
    virtual int perform() = 0;

    virtual T getResult() = 0;

    virtual ~DIOperation() = 0;
};

class CreateRelation : public DIOperation<RelatedObjectTriplet> {
private:
    static std::string const TYPE;

    // Params (immutable)
    RelatedObjectTriplet const m_sParams;

    // Hidden
    CreateRelation & operator=(CreateRelation const& source);
    CreateRelation (CreateRelation const& source);

    // Internal
    std::string m_sNewRelationId;

public:
    CreateRelation(RelatedObjectTriplet const& params);

    int perform();

    RelatedObjectTriplet getResult();

    ~CreateRelation();
};

It can be used like this:

RelatedObjectTriplet triplet("33333", "55555", "77777");
CreateRelation createRel(triplet);
createRel.perform();
const RelatedObjectTriplet res = createRel.getResult();

Thanks for the help and I hope I haven't made mistakes here :)


问:
Is memory management in programming becoming an irrelevant concern?
Background

I revisited an old (but great) site I had not been to for ages - the Alioth Language Shootout (http://benchmarksgame.alioth.debian.org/).

I started out programming in C/C++ several years ago, but have since then been working almost exclusively in Java due to language constraints in the projects I have been involved in. Not remembering the figures, I wanted to see, approximately, how well Java fared against C/C++ in terms of resource usage.

The execution times were still relatively good, with Java at worst performing 4x slower than C/C++, but on average around (or below) 2x. Due to the nature of the implementation of Java itself, this was no surprise, and it's performance time was actually lower than what I expected.

The real brick was the memory allocation - at worst, Java allocated:

a whopping 52x more memory than C

and 25x more than C++.

52x the memory ... Absolutely nasty, right? ... or is it?  Memory is comparatively cheap now.

Question:

If we do not speak in terms of target platforms with strict limits on working memory (i.e. embedded systems and the like), should memory usage be a concern when picking a general purpose language today?

I am asking in part because I am considering migrating to Scala as my primary language. I very much like the functional aspects of it, but from what I can see it is even more expensive in terms of memory than Java. However, since memory seems to be getting faster, cheaper and more plentiful by the year (it seems to be increasingly hard to find a consumer laptop without at least 4GB of DDR3 RAM), could it not be argued that resource management is becoming increasingly more irrelevant as compared to (possibly implementation-wise expensive) high-level language features which allow for faster construction of more readable solutions?

答:
Memory management is absolutely relevant in today's world. However, not in the way you might expect. Even in garbage collected languages you have to ensure you don't have a reference leak

You're doing something wrong if this is your code:

```<code>static List<string> Cache;

...
Cache.Add(foo); //and then never remove anything from Cache
</code>```

Garbage collection can't magically know you will never use some reference ever again unless you make it so you can't use it again, ie by doing Cache=null, you effectively alert the garbage collector that "hey I'm not going to be able to access it anymore. Do what you will with it"

It's more complicated than that, but reference leaks are just as, if not more, harmful than traditional memory leaks.

There are also some places where you can't fit a garbage collector into. For instance, the ATTiny84 is a microcontroller with 512 bytes of code ROM, and 32 bytes of RAM. Good luck! That's an extreme, and probably wouldn't be programmed in anything but assembly, but still. Other cases you might have 1M of memory. Sure, you could fit a garbage collector, but if the processor is very slow (either by limitations, or to preserve battery), then you're not going to want to use a garbage collector cause it's too expensive tracking what a programmer could know.

It also gets significantly more difficult to use garbage collection when you need guaranteed response times. Like, if you have a heart monitor or something and when it receives a 1 on some port, you need to guarantee you can respond to it with a proper signal or something within 10ms. If in the middle of your response routine the garbage collector needs to make a pass and it ends up taking 100ms to respond, that might be someone dead. Garbage collection is very difficult, if not impossible, to use when timing requirements need to be guaranteed.

And of course, even on modern hardware, there is some cases where you need that extra 2% of performance by not worrying about the overhead of a garbage collector.

Body:
Memory management is absolutely relevant in today's world. However, not in the way you might expect. Even in garbage collected languages you have to ensure you don't have a reference leak

You're doing something wrong if this is your code:

static List<string> Cache;

...
Cache.Add(foo); //and then never remove anything from Cache

Garbage collection can't magically know you will never use some reference ever again unless you make it so you can't use it again, ie by doing Cache=null, you effectively alert the garbage collector that "hey I'm not going to be able to access it anymore. Do what you will with it"

It's more complicated than that, but reference leaks are just as, if not more, harmful than traditional memory leaks.

There are also some places where you can't fit a garbage collector into. For instance, the ATTiny84 is a microcontroller with 512 bytes of code ROM, and 32 bytes of RAM. Good luck! That's an extreme, and probably wouldn't be programmed in anything but assembly, but still. Other cases you might have 1M of memory. Sure, you could fit a garbage collector, but if the processor is very slow (either by limitations, or to preserve battery), then you're not going to want to use a garbage collector cause it's too expensive tracking what a programmer could know.

It also gets significantly more difficult to use garbage collection when you need guaranteed response times. Like, if you have a heart monitor or something and when it receives a 1 on some port, you need to guarantee you can respond to it with a proper signal or something within 10ms. If in the middle of your response routine the garbage collector needs to make a pass and it ends up taking 100ms to respond, that might be someone dead. Garbage collection is very difficult, if not impossible, to use when timing requirements need to be guaranteed.

And of course, even on modern hardware, there is some cases where you need that extra 2% of performance by not worrying about the overhead of a garbage collector.


问:
NoSQL Document Database as a Message Queue
I am considering using a NoSQL Document database as a messaging queue.

Here is why:

I want a client to post a message (some serialized object) to the server and not have to wait for a synchronous response.

I want to be able to pull messages off of the "queue" based on some criteria, which may be more sophisticated than just a priority level (I am working on a hosted web app, so I want to give all of my customers a fair amount of "computing time", and not let one customer hog all of the processing).

I want the queue to be durable - if the server goes down I want any remaining messages to be handled when it comes back up.

So, I am considering using MongoDB or RavenDB as a message queue.  The client can post the message object to a web service which writes it to the database.  Then - the service doing the work can pull the various message types based on any criteria that may arise.  I can create indexes around the scenarios to make it faster.

So - I am looking for someone to shoot a hole in this.  Has anybody successfully done this?  Has anybody tried this and failed in some way?

答:
Check out the accepted answer on this question: https://stackoverflow.com/questions/4745911/nosql-databases

My take on having worked with both types of databases is that the real advantages of NoSQL lie in their scalability. They are well suited for ever-growing blobs of stuff that needs to exist on many nodes. After all, these are the applications that they were born out of (Facebook, Google...).

They have downsides also, and they are specific to implementation. Personally, I've suffered with some replication errors when multiple nodes would delete and re-populate objects within a short amount of time. I'm not necessarily suggesting that it is always pervasive, but the speed advantage often comes with less guarantees of consistency (ie, you will have eventual consistency, but you don't want to depend on it).

If all you're doing is building a queue, then I don't see anything specific to NoSQL that makes them a preferred choice. The speed/reliability/efficiency of it will come down more to the configuration of whatever implementation it is that you decide to go with.


答:
In addition to all the things named, I see these two things as some of the biggest problems. First you estimate the final date based on every devloper being available for the full 8 hours a day  5 days a week. This is incorrect and will virtually 100% guarantee that the end date is missed on any project that is not trivial. People take time off, attend company (or non-project-based) meetings , fight with HR over health insurance claims, take breaks, etc. Never assume more than a 6-hour availability per developer per day. </p>

<p>Next devlopers notoriously forget to estimate all the non-development tasks like meetings and emails concerning the project, deployment, QA support, UAT support, writing unit tests, research, documentation etc. Once we added these types of task to our estimation spreadsheet, our estimates got way better. </p>

Title: Why are software schedules so hard to define?

Body: It seems that, in my experience, getting us engineers to accurately estimate and determine tasks to be completed is like pulling teeth. Rather than just giving a swag estimate of 2-3 weeks or 3-6 months... what is the simplest way to define software schedules so they are not so painful to define? For instance, customer A wants a feature by 02/01/2011. How do you schedule time to implement this feature knowing that other bug fixes may be needed along the way and take up additional engineering time?</p>

Body:
In addition to all the things named, I see these two things as some of the biggest problems. First you estimate the final date based on every devloper being available for the full 8 hours a day  5 days a week. This is incorrect and will virtually 100% guarantee that the end date is missed on any project that is not trivial. People take time off, attend company (or non-project-based) meetings , fight with HR over health insurance claims, take breaks, etc. Never assume more than a 6-hour availability per developer per day.

Next devlopers notoriously forget to estimate all the non-development tasks like meetings and emails concerning the project, deployment, QA support, UAT support, writing unit tests, research, documentation etc. Once we added these types of task to our estimation spreadsheet, our estimates got way better.


问:
What proportion of programming is done for embedded systems?
What proportion of programming is done for embedded systems? More generally, please share any interesting statistics on programmers by domain, e.g. real-time/business/UI/gaming/…

How you define the domain boundaries (e.g. what is an embedded system) is up to you, but please give a few words to explain your definition.

答:
Well, there are many orders of magnitude more embedded processors than general purpose computers.
About 250 million PC produced per year.

Many billions of embedded processors produced per year.

Global embedded software market is worth about 3.4 billion dollars per year.
http://www.slideshare.net/pboulet/socdesign

Embedded systems (with hardware added) worth 88 billion dollars per year in 2009.

(Now, PC's are worth more than 350 each, so there's more money in PC hardware.)

Lots of embedded processors are doing "the same thing", but embedded is hard, costly and cost constrained, so there is a lot of pressure in the "consumer embedded" space to reuse code.

The mainstream software industry is worth about 300 billion per annum.
(from wikipedia.)

The bottom line About 100 times less money in embedded than "normal" software.

But programmers for embedded are often Electronic engineers, getting paid less; or in Asia, where they are paid 5x less than in, the USA for example.
Electronic engineers in Australia often get paid 20% less then software engineers.

So probably about 1/30th as much programming work is embedded.


答:
"predictable... ways of developing software."

Pure processes have predictable results. But software creation is literally the creation a process, not just the following of a process. An analogy to manufacturing: Software development is like designing a factory to create widgets; not the day-to-day running of the widget factory.

All software creation processes are impure. (outside of automatically-generated solutions)

Impure processes do not have the predictability of pure process. The more on-the-fly creative action that occurs in the process the less pure it is.

Purity does not imply good or bad.


问:
What's the best programming language to learn for solving partial differential equations?
I have to create a program that compares two or three different methods (FEM FVM FDM) for solving an easy pde. Is there a program language in which I could do this easily?
(i need to operate with vectors/matrix and perform inversions on matrix)</p>

答: I think nowadays it doesn't matter which language you use. I would recommend Fortran + IMSL library, C# + some math library (there are several of them distributed under GNU license) or C++ with boost or NR. MATLAB might be better choice but to me it seems much more expensive.</p>


问:
python random with a skew
I am trying to create a very simple evolution algorithm for a creature simulator, what I would like to have is, both creatures have a trait and a dominance level, both noted by ints. their child's trait will be a random number between creature A's trait and creature B's trait then skewed to the more dominant. So if A has a trait of 5 and dominance of 2 and B has a trait of 10 and a dominance of 7, the skew will be -5 so it skews more towards B. Their child is more likely to have a trait of 8 than 6. Is there a good way to do this?
I visualise it ending up like this:
A5-6--7---8----9-----10B

I can't figure out how much the skew should be until I am able to test the results, so for the time being it's kind of arbitrary.

Thank you everyone for taking the time to help me.

答:
You can do this by generating two random numbers.

Say you have trait A.  The first 'parent' has a value of 2.  The second a value of 8.  You thus want a range of 2 to 8.  Normally you'd generate a random number between 0 and 1.0, and multiply that by (8 - 2) and add it to 2, like:

```<code>N = (rand() * (8-2)) + 2;
</code>```

Simple enough, but it doesnt trend in a particular direction.

Instead, generate two random numbers.  Lets say you want the 8 (the high value) to be the 'dominant' trait.  Generate two random values between 0 and 1.0, and use the highest of the two when calculating the new child's value.  That will 'trend' you towards 8.

If you wanted the low value to be dominant, do the same, using the lower of the two randomly generated numbers.

Title: python random with a skew

Body:
You can do this by generating two random numbers.

Say you have trait A.  The first 'parent' has a value of 2.  The second a value of 8.  You thus want a range of 2 to 8.  Normally you'd generate a random number between 0 and 1.0, and multiply that by (8 - 2) and add it to 2, like:

N = (rand() * (8-2)) + 2;

Simple enough, but it doesnt trend in a particular direction.

Instead, generate two random numbers.  Lets say you want the 8 (the high value) to be the 'dominant' trait.  Generate two random values between 0 and 1.0, and use the highest of the two when calculating the new child's value.  That will 'trend' you towards 8.

If you wanted the low value to be dominant, do the same, using the lower of the two randomly generated numbers.


答:
Sure, that's quite simple to do.

Just take the sum of both dominance values and take a random.randrange() value of these.

If that value is lower than the dominance value of parent A, you picked that parent's trait, otherwise it's parent B's trait you picked:

```<code>import random

if random.randrange(parentA.dominance + parentB.dominance) < parentA.dominance:
    trait = parentA.trait
else:
    trait = parentB.trait
</code>```

In other words, it's a very simple weighted random selection between two options.

For your specific example, the sum of the dominances is 9, so the randrange() value is one between 0 and 8; if 0 or 1 is picked, parent A's trait is selected, if 2, 3, 4, 5, 6, 7 or 8 is picked then parent B's trait is selected instead.

If instead you are talking about picking a trait on a range from parent A's trait value up to and including parent B's trait value where traits are treated as a range, then your dominance values are used to 'pull' a trait value towards one or the other parent.

It basically comes down to a tug-of-war between the parents. With balanced dominance, the trait picked would, on average, come down to the average value of the two traits. But with one parent dominating over the other, the trait value picked 'shifts' towards the dominating parent.

This translates in a chance that the values below the midpoint are picked for parent A have a chance of parentA.dominance in (parentA.dominance + parentB.dominance), while the values above the midpoint have a chance of parentB.dominance in (parentA.dominance + parentB.dominance) of being picked.

```<code>import random

pick = random.random()

# sort parents by trait; smallest trait first
parents = sorted((parentA, parentB), key=attrgetter('trait'))
average = (parents[0].trait + parents[1].trait) / 2.0
weights = []
slots = (parents[1].trait - parents[0].trait + 1.0) * (parents[0].dominance + parents[1].dominance)
for i in range(parents[0].trait, parents[1].trait + 1):
    if i <= average:
        weights.append(sum(weights) + (parents[0].dominance / slots))
    else:
        weights.append(sum(weights) + (parents[1].dominance / slots))
    if weights[-1] > pick:
        return i
</code>```

A quick demo picking traits between parent A and parent B using the above calculation:

```<code>>>> for i in range(40): print pickTrait(),
...
9 9 9 10 6 9 8 10 7 9 9 8 8 8 9 8 9 9 7 5 8 8 9 5 9 9 10 10 10 10 5 5 9 9 8 9 10 7 8 9
</code>```

Title: python random with a skew

Body:
I am trying to create a very simple evolution algorithm for a creature simulator, what I would like to have is, both creatures have a trait and a dominance level, both noted by ints. their child's trait will be a random number between creature A's trait and creature B's trait then skewed to the more dominant. So if A has a trait of 5 and dominance of 2 and B has a trait of 10 and a dominance of 7, the skew will be -5 so it skews more towards B. Their child is more likely to have a trait of 8 than 6. Is there a good way to do this?
I visualise it ending up like this:
A5-6--7---8----9-----10B

I can't figure out how much the skew should be until I am able to test the results, so for the time being it's kind of arbitrary.

Thank you everyone for taking the time to help me.

Body:
Sure, that's quite simple to do.

Just take the sum of both dominance values and take a random.randrange() value of these.

If that value is lower than the dominance value of parent A, you picked that parent's trait, otherwise it's parent B's trait you picked:

import random

if random.randrange(parentA.dominance + parentB.dominance) < parentA.dominance:
    trait = parentA.trait
else:
    trait = parentB.trait

In other words, it's a very simple weighted random selection between two options.

For your specific example, the sum of the dominances is 9, so the randrange() value is one between 0 and 8; if 0 or 1 is picked, parent A's trait is selected, if 2, 3, 4, 5, 6, 7 or 8 is picked then parent B's trait is selected instead.

If instead you are talking about picking a trait on a range from parent A's trait value up to and including parent B's trait value where traits are treated as a range, then your dominance values are used to 'pull' a trait value towards one or the other parent.

It basically comes down to a tug-of-war between the parents. With balanced dominance, the trait picked would, on average, come down to the average value of the two traits. But with one parent dominating over the other, the trait value picked 'shifts' towards the dominating parent.

This translates in a chance that the values below the midpoint are picked for parent A have a chance of parentA.dominance in (parentA.dominance + parentB.dominance), while the values above the midpoint have a chance of parentB.dominance in (parentA.dominance + parentB.dominance) of being picked.

import random

pick = random.random()

# sort parents by trait; smallest trait first
parents = sorted((parentA, parentB), key=attrgetter('trait'))
average = (parents[0].trait + parents[1].trait) / 2.0
weights = []
slots = (parents[1].trait - parents[0].trait + 1.0) * (parents[0].dominance + parents[1].dominance)
for i in range(parents[0].trait, parents[1].trait + 1):
    if i <= average:
        weights.append(sum(weights) + (parents[0].dominance / slots))
    else:
        weights.append(sum(weights) + (parents[1].dominance / slots))
    if weights[-1] > pick:
        return i

A quick demo picking traits between parent A and parent B using the above calculation:

>>> for i in range(40): print pickTrait(),
...
9 9 9 10 6 9 8 10 7 9 9 8 8 8 9 8 9 9 7 5 8 8 9 5 9 9 10 10 10 10 5 5 9 9 8 9 10 7 8 9


答:
When it comes to time estimation for tasks which can take longer then a few hours I try my best to use this rules:

Don't ever try to predict when other people will finish their job if you happen to depend on it. Speak only for yourself.

First analyse the task, then estimate. By analysing I mean at least writing down (and not trying to keep everything in you head!) a list of subtasks with estimation for each one of them.

If a task is complex enough, estimate the time for such analysis itself. Let the estimation be a separate process. You may also make sure your boss knows about that.

Don't estimate under pressure. Make it clear that it takes time to make a reasonable estimation and just tell them something like "I will name a date tomorrow by 11:00 when I'll finish analysing the task". I know some customers/managers can press hard, but they shall not pass. Put your busy face on and claim your time!

Ask a little more time than you think you'll need because you probably forgot to add a coffee break time (and othe distrctions) in your estimation.

For big tasks ask even more - there will probably be more than one coffee break.

If you really can't estimate (the task is too difficult/unfamiliar) or really unsure - ask someone capable for help with your analysis.

There's probably more rules than that, but I actually don't have a poster with this rules on my wall. I just formulated them now, but they come from my experience (so it may not work for you).

The only reliable way to schedule software development I can think of (but I haven't actually tried it) is Evidence Based Scheduling which is basically the Monte Carlo method used to count probability of a ship date based on historical records about tasks that you've accomplished before. It feels nice because it doesn't try to use any metrics other than estimated and actual time. However, it requires a lot of experience to split big tasks into smaller ones beforehand and you have to have a big set of historical data to make it work precise enough.


答:
For this kind of data processing I would really recommend R (note that I'm a heavy R user, so I might be biased. But let me break it down a bit. I would definitely go for a high level language like Python + numpy, Matlab or R, and not Fortran or C++. These languages are powerful I know from experience, but also more complex. If it is not strictly needed I would stick to a simpler language, this will enable you to spend more time analyzing data and less programming.

In choosing a high level language, I'd go for R. It is free and open source, has powerful data processing routines built-in, awesome visualisation tools, and a very large user community that provides even the most exotic analysis methods. Although you'd probably also work happily with some other high level language.

Title: What's the best programming language to learn for solving partial differential equations?

Body:
I have to create a program that compares two or three different methods (FEM FVM FDM) for solving an easy pde. Is there a program language in which I could do this easily?
(i need to operate with vectors/matrix and perform inversions on matrix)</p>


答: My suggestion would be to use Python.  The SciPy package allows for solving PDE really simply.  I used it for the projects involved in my honours thesis and found it really easy to learn and simple.  Have a look at http://scipy-lectures.github.com/intro/scipy.html#numerical-integration-scipy-integrate .   </p>


答:
From what I see, you need a weighted random selection, from range(parent_a.trait, parent_b.trait).

To distribute the weights linearly, the simplest thing you could do is construct a range of floats in such a way that the sum() of the range is 1.0, and each step would represent a probability of choosing that one step.

Example:

```<code>trait_delta = abs(pacent_a.trait - trait_b.trait)
trait_delta_sum = trait_delta * (trait_delta+1.) / 2.
weights = [x/trait_delta_sum for x in range(1, trait_delta+1)]
</code>```

As I said above, the sum of the weights should be equal to one:

```<code>assert sum(weights) == 1.
</code>```

Then generate a cumulative sum of the weights:

```<code>cumulative_weihts = [sum(weights[:x]) for x in range(trait_delta)]
</code>```

Now just pick a random number, and find the index of the largest number that is smaller than said random number:

```<code>rand = random.random()
shift = sum[-1 for x in cumulative_weightn if r<x])
</code>```

Finally, use the skew as an offset from the trait with the bigger dominance:

```<code>if parent_a.dominance > parent_b.dominance:
    trait = parent_a.dominance + skew
else:
    trait = parent_b.dominance + skew
</code>```

Title: python random with a skew

Body:
From what I see, you need a weighted random selection, from range(parent_a.trait, parent_b.trait).

To distribute the weights linearly, the simplest thing you could do is construct a range of floats in such a way that the sum() of the range is 1.0, and each step would represent a probability of choosing that one step.

Example:

trait_delta = abs(pacent_a.trait - trait_b.trait)
trait_delta_sum = trait_delta * (trait_delta+1.) / 2.
weights = [x/trait_delta_sum for x in range(1, trait_delta+1)]

As I said above, the sum of the weights should be equal to one:

assert sum(weights) == 1.

Then generate a cumulative sum of the weights:

cumulative_weihts = [sum(weights[:x]) for x in range(trait_delta)]

Now just pick a random number, and find the index of the largest number that is smaller than said random number:

rand = random.random()
shift = sum[-1 for x in cumulative_weightn if r<x])

Finally, use the skew as an offset from the trait with the bigger dominance:

if parent_a.dominance > parent_b.dominance:
    trait = parent_a.dominance + skew
else:
    trait = parent_b.dominance + skew


问:
Looking to build a 2 java applications. should it be web-based application or standalone application?
The first application (web-based) will be located at site1 and once the information is processed, it will be sent to the second application(web-based) located at site2. Application2 needs to be able to do the same thing as application1. Because of this, there has to be a way to share the database to keep data in sync. I wanted to go web-based for these two applications, but the issue arises, what if the internet is down? If application1 goes down due to a blackout or lost of internet, application2 should still be able to do what it needs to. I was thinking the database/server will be on Amazon EC2.

Even if I go with a standalone application for site1 and site2, it still needs some sort of internet connection to talk to a shared database/server right, possiblity through tcp connection? Because of this, I dont see why it shouldn't just be a web-based applicatin then. This the disagreement I'm having with my team.

I want to know the pros and cons of making these two application either being a stand-alone or web-based.

答: It sounds like it should be one web application with multiple modules based on functionality. Users would enter under different domains and access certain data based on roles and privileges. If you create separate code bases, you'll likely have a lot of wasted time and effort (and therefore wasted money) from creating redundant code.</p>


答:
I have learned a lot from this book:

Software Estimation: Demystifying the Black Art

In short to get better estimation results we do this:

all but trivial tasks are estimated by more then one person (two in our case)

we divide task into smaller task. The more tasks you have the more likely your estimation will be good - law of large numbers if I remember correctly from the boo

we estimate worst, best and most likely scenario. Sometimes each of us estimates those tree scenarios totally differently. That means we have to talk and usually it turns out that one of us did not understand the task. Had that one person estimated the task alone it would be estimated wrong.

we put 3 numbers from above point into equation and receive estimation (excell)
k

After work task is finished and our estimate was wrong we try to find reasons why. And we incorporate this knowledge into next estimation process. So far this is the best process I have used for estimation of bigger tasks. When I say task I mean jobs that take from about 50-500 hours.


答:
If I understand your question correctly, you want a probability distribution function somewhat like below.  The y axis is your dominance value and the x axis is the trait value.

To generate a value in this distribution, you basically take the area under the curve, 12.5 in this case.  Choose a uniform random number between 0 and 12.5, fill in that much area starting from the left side, and see where it falls on the x axis.  For example, say you chose 4.5.  The area under the curve between 5 and 8 is 4.5, so your child's trait is 8.

If my math is right, given a as the value between 0 and 12.5 you chose, d1 and d2 are the respective dominances, and t1 and t2 are the respective traits, your child's trait is given by:

```<code>t1 + sqrt(2*a*(d2-d1)/(t2-t1))
</code>```

Title: python random with a skew

Body:
If I understand your question correctly, you want a probability distribution function somewhat like below.  The y axis is your dominance value and the x axis is the trait value.

To generate a value in this distribution, you basically take the area under the curve, 12.5 in this case.  Choose a uniform random number between 0 and 12.5, fill in that much area starting from the left side, and see where it falls on the x axis.  For example, say you chose 4.5.  The area under the curve between 5 and 8 is 4.5, so your child's trait is 8.

If my math is right, given a as the value between 0 and 12.5 you chose, d1 and d2 are the respective dominances, and t1 and t2 are the respective traits, your child's trait is given by:

t1 + sqrt(2*a*(d2-d1)/(t2-t1))


问:
Why is "working with files" is an important subject when learning Objective C?
I'm reading a book on Objective C, and I was wondering how important the subject Working with files for learning to develop iOS in particular?

On you tube the tutorials are very short, maybe 10 min of video that teaches you how to do stuff with files and URL's. But in the book its a very long chapter with lot's of detail. The basics of working with files and URL's if very clear and simple, so I was wondering when I be really need this and this information become handy, and if I need to dig that deep in this topic right now?

The main question is, if I know the basics, can I move on and come back when I need it? or it's a really crucial to dig in right now?

答:
It really depends on your application.  I can go years without needing to read from a file, then have a task where I'm doing it all the time.

However, when you do end up needing it, you will probably want to learn it in detail, and not just gloss over parts you think are trivial.  There are some subtleties that even trip up veterans sometimes, like the exact sequence of detecting the end of a file from a while loop.  But you can safely wait to cross that bridge until you get to it.