答:
While you might not run into issues now if you stick to 32 bit, there certainly will be issues in the near future. The lesson learned from the desktop-world is that a transition will be a lengthy and painfull process. So you should start with it sooner rather then later.

It was even surprising to me that smartphones weren't 64 bit bit from the get go.

Title: What is the benefit of 64 bit A7 in iPhone

Body:
I'm trying to figure out why going to 64 bit processors is such a big deal in an iPhone. I understand that there will be twice as many registers so the processor can work with twice as much data which should increase performance.

However I don't see many phones going to more than 4GB of memory any time soon. It seems like overkill and it would negatively impact battery life.

Another problem that I see is that most variables now need twice as much memory. This will create problems in a mobile environment with small amounts of memory.

I believe that the folks at Apple are intelligent and they probably have great reasons for doing this, I'm just trying to understand them.

EDIT

Don't know much about GPU's but I was told that with 64 bit registers 2 pixels can be loaded into each register and operations can be performed on them individually. Is there a graphical advantage regarding 64 bit?


问:
C# Delegates are immutable - but why does that matter?
This is a followup question to this other question.

Background

Working from the MSDN Delegates Tutorial (C#), I see the following:

Note that once a delegate is created, the method it is associated with never changes — delegate objects are immutable.

And then, in the code sample, I see this (Spread out a little througout the code):

```<code>public delegate void ProcessBookDelegate(Book book);

bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(PrintTitle));
bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(totaller.AddBookToTotal));
</code>```

The Question

Now obviously, the way the code is written here a new delegate is created for each
process. I am guessing the immutability is relevant if you try to do stuff like

```<code>ProcessBookDelegate thisIsATest = new ProcessBookDelegate(PrintTitle);
ProcessBookDelegate thisIsATest = new ProcessBookDelegate(totaller.AddBookToTotal);
</code>```

which should... still compile when thisIsATest is immutable? So what problem has Microsoft solved by making it immutable? What problems would we run into if C# 6 made delegates mutable?

EDIT

I believe the immutability will prevent this:

```<code>ProcessBookDelegate thisIsATest = new ProcessBookDelegate(PrintTitle);

thisIsATest.ChangeTheDelegateInABadFashion();

someFunction(thisIsATest); //This function works as normal
                           //because the delegate is unchanged
                           //due to immutability
</code>```

but the immutability will NOT prevent this:

```<code>ProcessBookDelegate thisIsATest = new ProcessBookDelegate(PrintTitle);

thisIsATest = new ProcessBookDelegate(ChangeTheDelegateInABadFashion());

someFunction(thisIsATest); //This function works weird now because
                           //it expected the unchanged delegate
</code>```

Am I correct in this understanding?

答:
Reasons in short:

An immutable object can be in exactly one state, the state in which it was created (security)

Are thread safe can be used freely

Memory optimization

Performance is better

Check out these two questions on Stack Overflow for more info:

Why .NET String is immutable?

Why can't strings be mutable in Java and .NET?

ContentLicense: CC BY-SA 3.0


问:
What is the benefit of 64 bit A7 in iPhone
I'm trying to figure out why going to 64 bit processors is such a big deal in an iPhone. I understand that there will be twice as many registers so the processor can work with twice as much data which should increase performance.

However I don't see many phones going to more than 4GB of memory any time soon. It seems like overkill and it would negatively impact battery life.

Another problem that I see is that most variables now need twice as much memory. This will create problems in a mobile environment with small amounts of memory.

I believe that the folks at Apple are intelligent and they probably have great reasons for doing this, I'm just trying to understand them.

EDIT

Don't know much about GPU's but I was told that with 64 bit registers 2 pixels can be loaded into each register and operations can be performed on them individually. Is there a graphical advantage regarding 64 bit?

答:
There is no "4GB wall" on ARMv7, as many ARMv7 cores support LPAE (Large Physical Address Extension), which is a concept symilar to PAE on x86, except LPAE uses 40-bit addressing. Meaning, that LPAE equipped ARMv7 can address up to 1TB of RAM.

It's also important to mention that upcoming ARMv8 cores, including A7, will not use 64-bit physical addressing. Most likely A7 will use either 40-bit or 44-bit physical addressing. Later giving access to at most 16TB RAM.

Of course either with LPAE on ARMv7 or in AArch32 mode on ARMv8, applications are still 32-bit, so the application itself can only access 4GB at a time. But I don't think it would be an issue on mobile devices any time soon.

You worry that apps will use more memory (64-bit pointers), but that won't be the case it the apps run in 32-bit mode (AArch32).

On the other hand ARMv8 provides other architectural improvements over ARMv7, which are not related to AArch64.

TL,DR: 64-bitness of A7 is marketing gimmick. Even on systems with more than 4GB RAM it provides no significant advantage over LPAE for 32-bit apps. And 64-bit apps aren't coming anytime soon.

Update: It's been confirmed by Qualcomm marketing executive (currently former executive, as he was demoted for these comments).

"I know there's a lot of noise because Apple did [64-bit] on their
  A7," said Anand Chandrasekher, senior vice president and chief
  marketing officer at Qualcomm, in an interview. "I think they are
  doing a marketing gimmick. There's zero benefit a consumer gets from
  that."

A benefit of 64-bit is more memory addressability, but that is not
  relevant in today's smartphones or tablets, Chandrasekher said. The
  iPhone 5s has only 1GB of DRAM.

"Predominantly... you need it for memory addressability beyond 4GB.
  That's it. You don't really need it for performance, and the kinds of
  applications that 64-bit get used in mostly are large, server-class
  applications," said Chandrasekher, who previously ran Intel's mobile
  platforms group. (source)


问:
Who owns modifications to open-source software?
Suppose a piece of software is distributed under some permissive license, e.g. BSD. Now, I modify this software and want to distribute my derivative work. My questions:

Who is the owner of the derivative? Is it the original author, the new author or there is joint ownership?

Is a copyright notice (say under the original copyright) sufficient to establish the new ownership?

答:
Under the Berne Convention, everyone owns their own work.  So you own your changes, and the original authors own theirs.  You can't change their ownership.

If you really care, you should add your copyright to the copyright notice for any file you modify, leaving all other copyrights in that file and in all other files intact.


问:
How to write "good" unit tests?
Triggered by this thread, I (again) am thinking about finally using unit tests in my projects. A few posters there say something like "Tests are cool, if they are good tests". My question now: What are "good" tests?

In my applications, the main part often is some kind of numerical analysis, depending on large amounts of observed data, and resulting in a fit function that can be used to model this data. I found it especially hard to construct tests for these methods, since the number of possible inputs and results are too large to just test every case, and the methods themselves are often quite longish and can not be easily be refactored without sacrificing performance. I am especially interested in "good" tests for this kind of method.

答:
Good unit tests is essentially the specification in runnable form:

describe the behavior of the code corresponding to use cases

cover technical corner cases (what happens if null is passed) - if a test is not present for a corner case, the behavior is undefined.

break if the code tested change away from the specification

I have found Test-Driven-Development to be very well suited for library routines as you essentially write the API first, and THEN the actual implementation.

ContentLicense: CC BY-SA 2.5

Title: How to write "good" unit tests?


答:
I think you're mixing up what immutability means.

What Immutability Isn't

Take a look at this example:

```<code>string s = "Hello";
s = "World";
</code>```

Are strings immutable? Yes.

Will this compile? Yes.

Have we in any way changed the string instance? No.

We are not making any changes to "Hello". We are creating a string, assigning it to the variable s, then we are creating a new string, and overwriting the variable s with this new string.
Immutability does not play a part here.

What Immutability Is

If we were to try something like this:

```<code>s.MutateInSomeWay();
</code>```

where MutateInSomeWay is a method which changes the string "Hello" (the value of s) itself, that would not be valid due to string immutability.

Any methods of string which change it in any way are not really changing it, they are creating a new string with the changed value and returning it to the caller.

but the immutability will NOT prevent this:

```<code>ProcessBookDelegate thisIsATest = new ProcessBookDelegate(PrintTitle);
thisIsATest = new ProcessBookDelegate(ChangeTheDelegateInABadFashion());
someFunction(thisIsATest); //This function works weird now because
//it expected the unchanged delegate
</code>```

Am I correct in this understanding?

Yes, immutability will not prevent it because it's perfectly valid, you have not mutated any object. Of course, you are not entirely clear on what is ChangeTheDelegateInABadFashion(), so it's hard to be specific.

Title: C# Delegates are immutable - but why does that matter?

Body:
This is a followup question to this other question.

Background

Working from the MSDN Delegates Tutorial (C#), I see the following:

Note that once a delegate is created, the method it is associated with never changes — delegate objects are immutable.

And then, in the code sample, I see this (Spread out a little througout the code):

```<code>public delegate void ProcessBookDelegate(Book book);

bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(PrintTitle));
bookDB.ProcessPaperbackBooks(new ProcessBookDelegate(totaller.AddBookToTotal));
</code>```

The Question

Now obviously, the way the code is written here a new delegate is created for each
process. I am guessing the immutability is relevant if you try to do stuff like

```<code>ProcessBookDelegate thisIsATest = new ProcessBookDelegate(PrintTitle);
ProcessBookDelegate thisIsATest = new ProcessBookDelegate(totaller.AddBookToTotal);
</code>```

which should... still compile when thisIsATest is immutable? So what problem has Microsoft solved by making it immutable? What problems would we run into if C# 6 made delegates mutable?

EDIT

I believe the immutability will prevent this:

```<code>ProcessBookDelegate thisIsATest = new ProcessBookDelegate(PrintTitle);

thisIsATest.ChangeTheDelegateInABadFashion();

someFunction(thisIsATest); //This function works as normal
                           //because the delegate is unchanged
                           //due to immutability
</code>```

but the immutability will NOT prevent this:

```<code>ProcessBookDelegate thisIsATest = new ProcessBookDelegate(PrintTitle);

thisIsATest = new ProcessBookDelegate(ChangeTheDelegateInABadFashion());

someFunction(thisIsATest); //This function works weird now because
                           //it expected the unchanged delegate
</code>```

Am I correct in this understanding?

Body:
I think you're mixing up what immutability means.

What Immutability Isn't

Take a look at this example:

string s = "Hello";
s = "World";

Are strings immutable? Yes.

Will this compile? Yes.

Have we in any way changed the string instance? No.

We are not making any changes to "Hello". We are creating a string, assigning it to the variable s, then we are creating a new string, and overwriting the variable s with this new string.
Immutability does not play a part here.

What Immutability Is

If we were to try something like this:

s.MutateInSomeWay();

where MutateInSomeWay is a method which changes the string "Hello" (the value of s) itself, that would not be valid due to string immutability.

Any methods of string which change it in any way are not really changing it, they are creating a new string with the changed value and returning it to the caller.

but the immutability will NOT prevent this:

ProcessBookDelegate thisIsATest = new ProcessBookDelegate(PrintTitle);
thisIsATest = new ProcessBookDelegate(ChangeTheDelegateInABadFashion());
someFunction(thisIsATest); //This function works weird now because
//it expected the unchanged delegate

Am I correct in this understanding?

Yes, immutability will not prevent it because it's perfectly valid, you have not mutated any object. Of course, you are not entirely clear on what is ChangeTheDelegateInABadFashion(), so it's hard to be specific.


答:
The short answer is that you can only claim ownership/copyright for that what you have created yourself.

The longer answer is that if you contribute to an open source project, then you can claim copyright for the modifications you have made and the copyright on the rest of the code remains with their respective authors.

A source code license does not give you ownership of (the copy of) the code, but it only gives you certain rights on what you can do with the code.

How to indicate that you have contributed to the code depends a bit on the license under which the code is released and the project itself. Sometimes all the contributers to a file are mentioned in the copyright statement in that file, and sometimes there is a file called AUTHORS (or something similar) that lists all the contributers to the entire project.

If you are unsure how to claim your attribution, first check how it is done in the project you are contributing to, then check if there are any requirements imposed by the license and if that still doesn't help you, add your name to the copyright statement in the files you modified.

Title: Who owns modifications to open-source software?

Body:
Suppose a piece of software is distributed under some permissive license, e.g. BSD. Now, I modify this software and want to distribute my derivative work. My questions:

Who is the owner of the derivative? Is it the original author, the new author or there is joint ownership?

Is a copyright notice (say under the original copyright) sufficient to establish the new ownership?


答: It makes things easier when handling large numbers. Large numbers are extremely important in cryptography (after PRISM having a secure mobile phone has become very important) and scientific applications. </p>


问:
Until what point should I refactor?
What do you think until what point should a programmer refactor the code?

Basically having

```
def method
  do_something
end
```

Pieces of code would be handy, but they increase spaghetti code until the point where you have to remember the path of more than 8-10 methods. So wouldn't be easier to have no more than 3 methods spaghetti code, despite the fact that the method is longer than it suppose to be

答:
I think what you're struggling with is the notion of cohesion.

Cohesion is easy to define and hard to understand.  It's the notion that things that belong together should be near each other.

A big part of refactoring is removing duplication.  This generally leads to decoupling code, which may also reduce cohesion.

A decent analogy is the idea that cohesion is like glue, the parts really resist being pulled apart because they're integral to the structure as a whole.  Coupling is like screws, it allows you to put together two very unlike items, and those items don't resist being separated (with a screwdriver).

Maintenance/Readability is really the biggest driver in this conversation - something that never EVER needs to change can be tightly intertwined in something else - who cares?  But the fact that you've started on refactoring almost always means that you changed or were looking to change this code.  What changes will make this easiest to change in the future?  Since you can't know that in a lot of cases, the default solution is to make it as simple and understandable as possible.

One thing to think about - a one line method is often ok because you can name it much more meaningfully for your domain.  If I've written a class to count the words in a phrase, being to name a method called words that splits my phrase into words is great for readability.  It works especially well in ruby since methods and local variables "feel" interchangeable.

```<code>def words
  scan(/\w+/).map { |w| w.downcase }
end
</code>```

Title: Until what point should I refactor?

Body:
I think what you're struggling with is the notion of cohesion.

Cohesion is easy to define and hard to understand.  It's the notion that things that belong together should be near each other.

A big part of refactoring is removing duplication.  This generally leads to decoupling code, which may also reduce cohesion.

A decent analogy is the idea that cohesion is like glue, the parts really resist being pulled apart because they're integral to the structure as a whole.  Coupling is like screws, it allows you to put together two very unlike items, and those items don't resist being separated (with a screwdriver).

Maintenance/Readability is really the biggest driver in this conversation - something that never EVER needs to change can be tightly intertwined in something else - who cares?  But the fact that you've started on refactoring almost always means that you changed or were looking to change this code.  What changes will make this easiest to change in the future?  Since you can't know that in a lot of cases, the default solution is to make it as simple and understandable as possible.

One thing to think about - a one line method is often ok because you can name it much more meaningfully for your domain.  If I've written a class to count the words in a phrase, being to name a method called words that splits my phrase into words is great for readability.  It works especially well in ruby since methods and local variables "feel" interchangeable.

def words
  scan(/\w+/).map { |w| w.downcase }
end


问:
How to indicate reliability when reporting availability of competencies
We have employees with competencies:

```<code>Pete      Welder
          Carpenter
Melissa   Carpenter
</code>```

Assume they both work 40 hours/week, and have not yet been assigned work.

We need to report the availability of these competencies, expressed in hours.

As far as I can see now, we can report this in two ways:

Method A. When someone has multiple competencies, count them both.

```<code>Welder    40 hours
Carpenter 80 hours
</code>```

Method B. When someone has multiple competencies, count an equal division of hours for each

```<code>Welder    20 hours
Carpenter 60 hours
</code>```

Method A has our preference:

- A good planner will know to plan the least available competency first. If 30 hours of welding is planned, we will be left with 10 welder, 50 carpenter.

- Method B has the disadvantage that the planner thinks he cannot plan the job when 30 hours of welding is required.

However, if we report this we would like to give an estimate of the reliability of the numbers for each competency, i.e. how much are these over-reported?

In my example A, would I say that carpenter is 100% over-reported, or 50%, or maybe another number?

How would I calculate this for large numbers of competencies?

I'm sure we are not the first ones dealing with this, is there a 'usual' way of doing this in planning?

Additionally:

- Would there be an even better method than A or B?

- Optionally, we also have an preference order of competencies (like: use him/her in this order), Pete could be 1. welder 2. carpenter. Does this introduce new options?

答:
Thanks to Sign's suggestion we decided to go with a range of values.

The maximum value is the total number of hours available for the competencies, just counting multiple times.

The minimum value is the total number of hours from the employees who have only that one competency.

No amount of planning for other competencies can take away from that competency's hours.

See the screenshot for eamples:

We will call the minimum value the hard availability, and the range from min to max soft. We can then present the availability for each competency (per time period) as follows:

dark blue = hard

light blue = soft

red line = number of hours required

In situation a the requirement for that competency can always be fulfilled.

In situation b the requirement for that competency X can be fulfilled, if you make sure not to fully allocate people who have competency X to other competencies that they also have.

In situation c the requirement can never be fulfilled.


问:
Auto - incremental ID in Domain Object
I read a lot about auto-incremental id (guid, interlocked.increment, ObjectIdGenerator...) but don't find nothing for my situation.

In my domain model user ask to have an automatic progressive numeric Id for each Activity they create.

Since it's a user request I want to put it in my domain model, but the mode I usually do it in older application without good architecture ) is accessing database, retrieve the max and add 1; so I can't do it in my object since domain layer must not be aware of db.

Don't like db identity for lack of control (sometimes db administrator have to change the id for user error on creation of activity).

interlocked.increment look fine but my application is installed on every user machine so I can't use it

Since it must be intelligible and progressive I can't use guid

I find a good idea in Lev Gorodinski article about Service Domain in Domain-Driven-Design: define the interface of a GenerateActivityId in domain layer as a Domain Service, but I don't find a way to make a good implementation of it.

Any suggestion?

EDIT:
Lev Gorodinski idea:

```<code>public class Activity {
  public int Id {get; private set;}
  public string Description {get;set;}

  public Activity (string description){
    this.Description = description
    this.Id = generator.GenerateId()
  }
}

public interface IIdGenerator{
  int GenerateId()
}
</code>```

but i don't see where "generator" is defined and don't found IIdGenerator implementation: where should i put the implementation?
In ActivityRepository? If yes i can omit IIdGenerator for the IActiviryRepositoryInteface ?

答:
Separate the user's need for some order number from the Primary Key/ID in the database. Make sure you identify why they want this numbering system and what they plan on doing with it.

If this represents the order they've entered their Activities, how do you handle a deletion? Do you leave a gap in the numbering? If order of entry is the driving force, save the date/time of entry and then you can create an order number / ID on the fly. This can even be a part of a select statement from a database using some type of Row_Number function if you don't want to do it in your app. They're very efficient, but you would have to perform this on all the records and then retrieve a subset of those records. If performance becomes a problem, you're going to have to save the values and then have some a ReOrdering function after a deletion.

If gaps in the numbering system are OK, then you can make this number permanant. To add a new number, you just need to query the database and get the last one. It's no different than retreiving any other value. DBs are pretty efficient at getting Max() values.

EDIT:
I don't see any reason why this can't be generated in the database. It doesn't have to be the primary key just auto incremented. I know a DBA might change PK's if this app grows into some replicated environment or someone wants to put some intelligence in the number. The users need to understand by changing these numbers they run the risk of not being able to reference them the same way in their future meetings (Assuming someone keeps all the paper copies.).

Title: Auto - incremental ID in Domain Object


问:
Is over-engineering a warning sign?
So we present a straightforward coding exercise to new candidates with some well defined requirements. Occasionally we receive solutions which don't really solve the problem at hand, but are over-engineered to solve a perceived problem - often outside the bounds of the exercise.

Now my question is, is this a warning sign?

EDIT: Quite a lot of the discussion is based on the test being flawed - which is a fair point. As I described in a comment, the basic premise of the test is to show how you can read the data from the file in a sensible way (and you'd be amazed at the variety of approaches we see), and how to match the items before calculating the latency between the updates. Now for this to work, certain assumptions have to be made about the data, and we look for these assumptions, and we also state explicitly that we want to see the approach you take (including OO approach etc.) All this in a two hour time frame.

IMHO, when I was interviewing it was the most complete exercise I came across.

The particular scenario which I'm pondering about is where a candidate, rather than reading from the file, accepted "network" input in a multi-threaded application, which clearly is not in scope.

答:
I would say that this is a clear warning sign, but not necessarily disqualifying for a candidate.

There are two separate problems that candidates seem to be having:

Missing the point of the exercise - This is fairly alarming.  All of the programming skill in the world won't create a good result if someone is unable to cast the problem that they are solving properly.  I have found that the most productive engineers are the ones that are able to identify the true problem to be solved, even if it isn't exactly the problem posed.  Having the ability to think critically about the question being asked, and perhaps reformulate it into something that is simpler to solve is a critical skill.  Missing the point when the problem is being clearly stated should be a big red flag.

Overengineering the solution - This is a secondary issue and is often the result of the first issue.  There a couple of different pathologies that can have this result.  First, not properly understanding the problem, or casting it too broadly can result in a solution that is just too complex.  This is clearly related to the first point above.  Second, trying to "show off" by thinking through future scenarios that might not really be relevant. This can be problematic because it indicates that the candidate hasn't understood the value of simplicity in solutions and deferring complexity until it is truly necessary.  This is something that can be corrected with good guidance, but is a watch out when bringing someone into the organization.

I would suggest following up with the candidate about their answer during the course of the process.  Rather than simply looking at their result, try to ascertain what led them to the result, and given some guidance, how they would respond and change their answer.  This will probably be more revealing about their capabilities than just their direct response to the problem. The "whys" of their approach can give you a sense of whether they are just not getting it, or if their understanding was just slightly off in how they chose to respond.  This kind of follow up will also reveal more about their overall approach to problem solving.

Also, reexamine the problem itself and see if maybe it is unclear and perhaps causing folks to get on the wrong track as they formulate their answers.

Title: Is over-engineering a warning sign?


答:
IMHO the answer is clearly yes, it is a warning sign, if

the coding exercise had a clear task

has well defined (ans also well-written) requirements,

the candidates had a chance to ask questions to make sure they solve the correct problem.

you want people who are smart and get things done in your team, not architecture astronauts.

Title: Is over-engineering a warning sign?

Body:
So we present a straightforward coding exercise to new candidates with some well defined requirements. Occasionally we receive solutions which don't really solve the problem at hand, but are over-engineered to solve a perceived problem - often outside the bounds of the exercise.

Now my question is, is this a warning sign?

EDIT: Quite a lot of the discussion is based on the test being flawed - which is a fair point. As I described in a comment, the basic premise of the test is to show how you can read the data from the file in a sensible way (and you'd be amazed at the variety of approaches we see), and how to match the items before calculating the latency between the updates. Now for this to work, certain assumptions have to be made about the data, and we look for these assumptions, and we also state explicitly that we want to see the approach you take (including OO approach etc.) All this in a two hour time frame.

IMHO, when I was interviewing it was the most complete exercise I came across.

The particular scenario which I'm pondering about is where a candidate, rather than reading from the file, accepted "network" input in a multi-threaded application, which clearly is not in scope.


答:
A good unit test doesn't mirror the function it is testing.

As a greatly simplified example, consider you have a function that returns an average of two int's. The most comprehensive test would call the function and check if a result is in fact an average. This doesn't make any sense at all: you are mirroring (replicating) the functionality you are testing. If you made a mistake in the main function, you will make the same mistake in the test.

In other words, if you find yourself replicating the main functionality in the unit test, it's  a likely sign that you are wasting your time.

Title: How to write "good" unit tests?

Body:
Triggered by this thread, I (again) am thinking about finally using unit tests in my projects. A few posters there say something like "Tests are cool, if they are good tests". My question now: What are "good" tests?

In my applications, the main part often is some kind of numerical analysis, depending on large amounts of observed data, and resulting in a fit function that can be used to model this data. I found it especially hard to construct tests for these methods, since the number of possible inputs and results are too large to just test every case, and the methods themselves are often quite longish and can not be easily be refactored without sacrificing performance. I am especially interested in "good" tests for this kind of method.


答:
Not nearly as big of a warning sign as not solving the problem at hand. The fact that he failed the quiz and didn't provide the correct solution is a warning sign. It's not necessarily a no-go scenario because it depends on how and why he didn't provide the correct solution.

A lot of times the question is complete crap and simply unanswerable. Don't pretend that interviewers never make mistakes. It's still a failure on his part to suss out why the question is crap. If you're hiring an engineer who is expected to help make requirements, this is a problem. If you're hiring a coder, you just don't expect him to do that.

Presuming that the coding exercise isn't horribly messed up, it appears that the way he failed it was misinterpreting the problem and going off into the weeds trying to solve a problem that wasn't there. Yes, that's a warning sign.

Title: Is over-engineering a warning sign?


答:
The biggest advantage over 32 bit for 64 bit processors is the movement of memory, and not the size of memory. While it's true that 32 bit can impose a 4GB limit on direct access. There are many hardware/software solutions to get around that limit.

64 bit processors can simply read/write more data in a single processor operation. It allows the assembly code to perform operations on 8 byte blocks. This can have a great performance advantage over 32 bit processors. Floating point calculations are faster on 64 then 32, and when the CPU uses dual registers it can operate on 128 bit data blocks.

64 bit processors also have wider bandwidths to physical memory. If you have a camera that records 1080p and want to edit that video. Performing an operation on a 1GB video file will simply be faster on 64-bit.

All the above is true even if the Ghz of the processor remains the same.

If 64-bit is so good, then why not 128 bit?

The more bits you add to the pipeline of a CPU the more data that the CPU has to move. The CPU can not narrow that bandwidth down to 16 or 32. So this creates a problem for software developers. Most software (your calendar, notes, etc..) don't depend upon a lot of data, and as a result 128 bits would involve a lot of wasted bandwidth. This can start to hinder performance and battery life. So the CPU manufactures have to find a balance between bandwidth and software requirements.

I'm amazed that Apple released a new 64 processor so soon in the life of mobile computing. I think their real motivation for this is 3D graphics. With a 64 bit processor the phone can move more data to the GPU quickly. This will allow for fast 3D games and more impressive graphics. You'll really start to see the advantages of 64-bit in real-time 3D because that process depends greatly on data.


问:
Creating a web application to concatenate strings to unify naming conventions
I've been tasked with creating a small web application, where users have a series of forms (I can't currently think of a better way of doing this) which will contain, either a)text input fields or b)drop down lists. The form will look as follows:

form1
input box input box drop down box

form2
input box input box drop down box input box

form3
input box dropdown box input box drop down box

Now for each form, I would need to concatenate the resulting string stored within each box (drop down or input). Seems fairly simple and I already have a working prototype. Problem is for each form there can be multiple rows.

What would be the easiest way to approach this? My skills are limited to HTML, CSS, JavaScript and some (light) JQuery. The working prototype I currently have the user fills out all the fields and then presses a "generate" button which generates all the conctenated strings. Is this approach that you would take?

答:
I think for this kind of application, a generate button would probably be undesirable from a UX perspective, especially if the operation performed is as trivial as you make it sound.

Here's what I hacked together in a few minutes, for what I think you are approximately describing:

http://jsfiddle.net/qtY38/4/

(Is jsfiddle still en-vogue?)

The meat being:

```<code>function processRecords (form){
    var result="";

    var inputs = form.elements;
    for(var i=0; i<inputs.length; ++i){
        var input = inputs[i];
        result += input.value;
    }

    var target = document.getElementById(form.dataset.target);
    target.textContent = result;
}
</code>```

The nice thing about this function is that it assumes nothing about your form other than the fact that it has inputs, and a data-target attribute with the id of the element you want to populate with the result. In addition, it's so cheap to run, that you can do this:

http://jsfiddle.net/CBjPL/1/

The difference being I've removed all submit buttons and added the following snippet:

```<code>setInterval(function(){
    var forms = document.forms;
    for(var i=0; i<forms.length; ++i){
        processRecords(forms[i]);
    }
}, 100);
</code>```

Which just automagically actively updates the outputs no matter how the user updates them. This is faster/easier for the user, and as a bonus has a better "wow factor" for the higher-ups.

This may seem kind of wasteful, actively looping and updating text areas that aren't changing, but listening for input changes is kind of a tedious thing in HTML, and this gets the job done easily for moderately sized pages. Especially since all you're doing is walking around the DOM and fiddling with rows. There's probably an optimization to be had in not updating the DOM if you don't have to, but it's not clear to me that that would even be worth it for such a trivial computation. Optimize second!

I'm not sure what you're referring to with respect to "multiple rows per form". If you mean you want to embed multiple collections of inputs/outputs in one  element, my gut reaction is... why? As described, you don't really seem to be using the forms as anything other than a trivial wrapper, and it's not like  elements introduce a massive overhead.

Body:
I think for this kind of application, a generate button would probably be undesirable from a UX perspective, especially if the operation performed is as trivial as you make it sound.

Here's what I hacked together in a few minutes, for what I think you are approximately describing:

http://jsfiddle.net/qtY38/4/

(Is jsfiddle still en-vogue?)

The meat being:

function processRecords (form){
    var result="";

    var inputs = form.elements;
    for(var i=0; i<inputs.length; ++i){
        var input = inputs[i];
        result += input.value;
    }

    var target = document.getElementById(form.dataset.target);
    target.textContent = result;
}

The nice thing about this function is that it assumes nothing about your form other than the fact that it has inputs, and a data-target attribute with the id of the element you want to populate with the result. In addition, it's so cheap to run, that you can do this:

http://jsfiddle.net/CBjPL/1/

The difference being I've removed all submit buttons and added the following snippet:

setInterval(function(){
    var forms = document.forms;
    for(var i=0; i<forms.length; ++i){
        processRecords(forms[i]);
    }
}, 100);

Which just automagically actively updates the outputs no matter how the user updates them. This is faster/easier for the user, and as a bonus has a better "wow factor" for the higher-ups.

This may seem kind of wasteful, actively looping and updating text areas that aren't changing, but listening for input changes is kind of a tedious thing in HTML, and this gets the job done easily for moderately sized pages. Especially since all you're doing is walking around the DOM and fiddling with rows. There's probably an optimization to be had in not updating the DOM if you don't have to, but it's not clear to me that that would even be worth it for such a trivial computation. Optimize second!

I'm not sure what you're referring to with respect to "multiple rows per form". If you mean you want to embed multiple collections of inputs/outputs in one  element, my gut reaction is... why? As described, you don't really seem to be using the forms as anything other than a trivial wrapper, and it's not like  elements introduce a massive overhead.


答:
The problem is the test is skewed.  You're asking someone to demonstrate their ability to write complex, enterprise-level software using a simple exercise taking only a few minutes.  There are other interviewers at other companies who complain that candidates don't show enough skill in object oriented design with these exercises, so people tend to overcompensate.  It doesn't necessarily mean your candidate is incapable of using simpler code when the situation warrants it.

If you want to know if that's the case with your candidate, just ask them to redo it, giving them some specific guidelines.  Say, "I can see you were showcasing your object oriented design skills, but it seems overkill for such a simple problem.  Can you rewrite it using only two small functions?"

Title: Is over-engineering a warning sign?


问:
How can I limit access for automatically generated files to specific users in a MVC setup?
I have a typical MVC based website, and I'd like to give some registered users the abillity to extract data from the database (in a variety of formats). The workflow is very simple:

User logs in,

User clicks export,

A file is generated,

User downloads the file.

I'm trying to figure out a way to secure the last step and limit access to the file. In order for the user to be able to download the file, it should be in a publicly accessible folder. That, however, means that the file is accesible to everyone else that has access to its full url.

I thought of a few possible solutions:

Email the export file

Instead of having the user download the file, I could simply email it to their email (the one they used to register on the site). This seems like a decent option when the export files are small, but I don't think it'll be optimal for larger files.

.htaccess magic

I could automagically generate an .htaccess in the export dir that would only let the user who requested the export access it. Also a decent option, but it's webserver specific and IP based. I don't know if Apache will always be the webserver of choice for the project, and I'm not sure an IP based solution is actually secure.

Store the export file in a private folder and have the user fetch it through ftp

Secure, but not particularly user friendly.

All my options seem to have problems, and I'm at that point where I'm completely stuck and can't shake the feeling I'm missing something obvious. Am I? Is there a better workflow?

I'm more interested in a high level overview than technical details, the project is still in its early days and technical requirements haven't yet stabilized (e.g. we may not use Apache after all). The project is build in PHP, but I don't think that matters (does it?).

Thanks.

答:
You could serve the file via your PHP script, which checks if the user is authentificated.

E.g. pseudocode

```<code>if session.user is loggedIn
    filename = url.filename
    if filename belongs to session.user
        fetchfile(filename)
    else
        "you are not authorized to download this file"
else
    "please log in"
</code>```

so only the user requested the export is able to download it. If another user gets the url he cannot download anything.

Body:
You could serve the file via your PHP script, which checks if the user is authentificated.

E.g. pseudocode

if session.user is loggedIn
    filename = url.filename
    if filename belongs to session.user
        fetchfile(filename)
    else
        "you are not authorized to download this file"
else
    "please log in"

so only the user requested the export is able to download it. If another user gets the url he cannot download anything.


答:
Maybe.

Not solving the problem is of course a clear cut warning sign that something is wrong. What went wrong? Either they misunderstood the problem, or they made a bad solution. A bad solution for something simple is a clear sign that the candidate is poor.

If they misunderstood the problem, then take a long look at your requirements. Even things that seem crystal clear to you may be unclear to others unfamiliar with a domain, or from a different background (locale, age, upbringing). If the candidate was there in the room with you, or offered an opportunity to ask questions and still failed, I would consider that a failure on their part. If the requirements were thrown over the wall, I would likely give them the benefit of the doubt (and think about fixing the interview process).

If the solution was correct, then it becomes less clear. Personally, I think that a number of people take YAGNI too far. If you can take a specific problem and create a general solution without increasing complexity or harming maintainability then why not make the general solution? (Think reversing a string vs. reversing any collection) That sort of "over-engineering" is clearly good in my opinion.

Everything else is that grey middle ground. Does the solution address likely axes of change? Does the solution add complexity or harm maintainability? Adding a little complexity to solve future problems that are nearly guaranteed to a win. Harming maintainability greatly to account for something that is totally unlikely is not.

Being a good software engineer means striking the right balance here. Being a good interviewer means striking the right judgement/inferrence about how and why the candidate chose that balance, often using other parts of the interview to evaluate.

Title: Is over-engineering a warning sign?


问:
SBCL development on Windows, including CFFI
I have been asked to automate the operation of a Windows (WinForms) application, performing some fairly complicated statistical analysis along the way.

My first thought was the usual suspects: .NET, C# and White or AutoItX.

Then it occured to me that I could try an alternative stack: SBCL, CFFI, and AutoItX.  That way, I could write in a language I like (Common Lisp), using my native Linux development tools via SLIME and Swank.

Hence my question: is there some reason I shouldn't try this?  I'm a Common Lisp newbie, and have essentially zero experience in CL FFI or SBCL on Windows.  The learning curve isn't a problem, though.  I'm worried that someone may have tried something like this in the past and discovered insurmountable issues.  My list of concerns includes:

stability / completeness of CFFI on SBCL on Windows

getting SLIME on Linux talking to SBCL running on a Windows box

Any experience, advice or warnings on any aspect of my proposed stack would be greatly appreciated.

答:
Here is half of an answer.

Clozure Common Lisp (CCL) is the "best" Common Lisp implementation for windows. It works great with Emacs/SLIME. I haven't had any issues but I don't get to use Lisp beyond tinkering. Not sure about CFFI.

To save you a bit of searching....
On my windows XP box I had to add CCL to the path. When you set the inferior-lisp-program it does not assume an absolute path.

Start -> right click "My computer" -> Properties -> Advanced -> Environment variables -> click "PATH" -> edit -> add path to CCL into the ";" separated list.

Then add this to .emacs:

```<code>(set-language-environment "utf-8") ;for clozure cl
(setq inferior-lisp-program "wx86cl.exe -K utf-8") ;clozure cl
(add-to-list 'load-path "~/.emacs.d/slime/") ; your SLIME directory
(require 'slime)
(setq slime-net-coding-system 'utf-8-unix)
(slime-setup '(slime-fancy))
</code>```

Body:
Here is half of an answer.

Clozure Common Lisp (CCL) is the "best" Common Lisp implementation for windows. It works great with Emacs/SLIME. I haven't had any issues but I don't get to use Lisp beyond tinkering. Not sure about CFFI.

To save you a bit of searching....
On my windows XP box I had to add CCL to the path. When you set the inferior-lisp-program it does not assume an absolute path.

Start -> right click "My computer" -> Properties -> Advanced -> Environment variables -> click "PATH" -> edit -> add path to CCL into the ";" separated list.

Then add this to .emacs:

(set-language-environment "utf-8") ;for clozure cl
(setq inferior-lisp-program "wx86cl.exe -K utf-8") ;clozure cl
(add-to-list 'load-path "~/.emacs.d/slime/") ; your SLIME directory
(require 'slime)
(setq slime-net-coding-system 'utf-8-unix)
(slime-setup '(slime-fancy))


问:
Generic name for types and values
In computer science, what is the abstract common name of types and values (I mean an abstract "something" that can be a type or a value) ?

To be more specific:

If we have template <typename X> or template <int X> what is the abstract name of X?

答:
Microsoft uses "type parameter" for C++ and C#.  But that's Microsoft and not necessarily representative.

C# calls it a generic type parameter.  See this MSDN article for details.

In a generic type or method definition, a type parameters is a placeholder for a specific type that a client specifies when they instantiate a variable of the generic type.

[emphasis added]

C++ calls it a type parameter.  See this MSDN article for more details.

Templates, which are sometimes called parameterized types, are mechanisms for generating functions and classes based on type parameters.

[emphasis added]

Just to prove others use different terms, this article uses "type parameter" as well as "template parameter."

Recall that the standard containers actually have at least two parameters: the element type and an allocator type.

and then later on:

Notice that we've left out the name of template parameter in the declaration of List, above.

It's worth pointing out though that generics are not templates as explained in the linked article.

I think the key difference is:

Generics are generic until the types are substituted for them at runtime. Templates are specialized at compile time so they are not still parameterized types at runtime

Title: Generic name for types and values


答:
A lot of this could be attributed to how you word the question and how you've put the entire interview into perspective.

It's like, "Let's see how creative you are. What is 2 + 2?" Four? All you could come up with is the most simple, obvious and accurate answer? Young / entry level developers who are so eager to impress during an interview will take the "We want to test your coding skills or see how good of a programmer you are." to mean "do something very sophisticated." We all like to think simple is best except when it makes things more difficult.

There are ways to see if someone is prone to always be over-engineering things. Give a code example of something that was too complex and ask for a simpler solution. When someone provides a solution that you don't think will work, this is a great opportunity to see how they react to criticism. Personally, I'd like to see someone be open to new ideas and recongnize a better solution than someone who is going to make the same mistakes over and over again.

And in reality, don't we always have an opportunity to change our code when it doesn't work? You can under design or over design initially. Once you've recognized the simple solution, shouldn't it be easier to implement?

Title: Is over-engineering a warning sign?


答:
Don't generate a file prior to authorizing request. This might be an expensive operation. First make sure that user has the necessary permissions and then generate files accordingly.

Since you are generating files on the fly, why store them? Can you not just serve files through response object and forget about them?

Title: How can I limit access for automatically generated files to specific users in a MVC setup?

Body:
I have a typical MVC based website, and I'd like to give some registered users the abillity to extract data from the database (in a variety of formats). The workflow is very simple:

User logs in,

User clicks export,

A file is generated,

User downloads the file.

I'm trying to figure out a way to secure the last step and limit access to the file. In order for the user to be able to download the file, it should be in a publicly accessible folder. That, however, means that the file is accesible to everyone else that has access to its full url.

I thought of a few possible solutions:

Email the export file

Instead of having the user download the file, I could simply email it to their email (the one they used to register on the site). This seems like a decent option when the export files are small, but I don't think it'll be optimal for larger files.

.htaccess magic

I could automagically generate an .htaccess in the export dir that would only let the user who requested the export access it. Also a decent option, but it's webserver specific and IP based. I don't know if Apache will always be the webserver of choice for the project, and I'm not sure an IP based solution is actually secure.

Store the export file in a private folder and have the user fetch it through ftp

Secure, but not particularly user friendly.

All my options seem to have problems, and I'm at that point where I'm completely stuck and can't shake the feeling I'm missing something obvious. Am I? Is there a better workflow?

I'm more interested in a high level overview than technical details, the project is still in its early days and technical requirements haven't yet stabilized (e.g. we may not use Apache after all). The project is build in PHP, but I don't think that matters (does it?).

Thanks.


问:
How to properly structure a collection of immutable constants
I'm in the design stages of a program that based upon input received, would select a particular category, and action within that category. The category, the action within in, and the value(s) related to that action are all immutable values, along with the relationship between category and action.

Normally I'd just assign it all into a multidimensional array or collection, but that strikes me as both messy and unnecessarily complex to search and sort. Constants don't allow me the luxury of defining relationships between them (aka you can't have constant A bound to subConstant B for example), and being a desktop app, having a user setting up a database server isn't appealing. Was thinking of having everything in xml files, but core rules of the application isn't appealing due to being able to easily edit, and hence change the primary functionality of the program that I wouldn't wish to be editable.

Anyone ever ran into something like this, and if so, what was the setup that you used for your solution?

EDIT: Let me see if I can explain this better with an example. Say I have the following structure

```<code>category A
  -- action AB
      -- result 1
      -- result 2
      -- result 3
      -- result 4
      -- result 5
      -- result 6
</code>```

where if I selected category A, and action AB, a one dice roll would select the result to be returned. The category, action, and result will never change both in name and in relationship (action AB will always be bound to category A, results within action AB will be bound to action AB, and the result contents will never change)

EDIT: No network usage would be expected for this application, as it was asked in one of the responses.

答:
Even though the question is a little bit fuzzy, I can try to propose a solution.

As already mentioned by Neil, tree-like data structure can be useful here. I guess, if changing values is not needed (those are constants?), then it's just a matter of not exposing them to the end user.

The lightweight solution could be binary serialization of hashes (objects, dictionaries, associative arrays - terminology depends on your language/framework/platform). If you need to keep them apart from the program, there are simple and efficient key-value storages (like Berkeley DB). It's possible to use SQL-based approach even with sqlite - if I am not mistaken, even Firefox browser uses one under the hood: No database server needed. With sqlite, even full text search is possible. Sqlite works well even with in-memory backend, in case this is what is needed.

What is even better, user preferences can be also stored in the sqlite, in a different file.

Nowhere there is a mention that those constants need to be shared over the network, but even then serialization approach can be used.


问:
How is data integrity maintained in a clustered environment when schema changes?

Scenario

A clustered environment running N identical application nodes interacting with a single relational database.

Problem

Is it possible to upgrade the nodes to a new application version, which requires a new database schema and maintain data integrity in the database without any downtime in the application and without losing any data or ending up with data in an inconsistent state?

答:
I guess, in general the answer is "no". However, if the new application version can work with old database OR old application version can work with the new schema - then it is possible.

For example, if the changes (to DB schema) are additive (like adding one more field), then it's possible to update database first.

If the new application senses older database and adjust to it, then it's possible to update app server instance first.

One more approach would be making a transition version of the app, which will work with both schemas, and make transition in two steps.

In other words, if changes to app AND database schema are not very big, it's possible.


问:
Why don't RDBMSes return joined tables in a nested format?
For example, say I want to fetch a User and all of his phone numbers and email addresses. The phone numbers and emails are stored in separate tables, One user to many phones/emails. I can do this quite easily:

```<code>SELECT * FROM users user
    LEFT JOIN emails email ON email.user_id=user.id
    LEFT JOIN phones phone ON phone.user_id=user.id
</code>```

The problem* with this is that it's returning the user's name, DOB, favorite color, and all the other information stored in the user table over-and-over again for each record (users×emails×phones records), presumably eating up bandwidth and slowing down the results.

Wouldn't it be nicer if it returned a  single row for each user, and within that record there was a list of emails and a list of phones? It would make the data much easier to work with too.

I know you can get results like this using LINQ or perhaps other frameworks, but it seems to be a weakness in the underlying design of relational databases.

We could get around this by using NoSQL, but shouldn't there be some middle ground?

Am I missing something? Why doesn't this exist?

* Yes, it's designed this way. I get it. I'm wondering why there isn't an alternative that is easier to work with. SQL could keep doing what it's doing but then they could add a keyword or two to do a little bit of post-processing that returns the data in a nested format instead of a cartesian product.

I know this can be done in a scripting language of your choice, but it requires that the SQL server either sends redundant data (example below) or that you to issue multiple queries like SELECT email FROM emails WHERE user_id IN (/* result of first query */).

Instead of having MySQL return something akin to this:

```<code>[
    {
        "name": "John Smith",
        "dob": "1945-05-13",
        "fav_color": "red",
        "email": "johnsmith45@gmail.com",
    },
    {
        "name": "John Smith",
        "dob": "1945-05-13",
        "fav_color": "red",
        "email": "john@smithsunite.com",
    },
    {
        "name": "Jane Doe",
        "dob": "1953-02-19",
        "fav_color": "green",
        "email": "originaljane@deerclan.com",
    }
]
</code>```

And then having to group on some unique identifier (which means I need to fetch that too!) client-side to reformat the result set how you want it, just return this:

```<code>[
    {
        "name": "John Smith",
        "dob": "1945-05-13",
        "fav_color": "red",
        "emails": ["johnsmith45@gmail.com", "john@smithsunite.com"]
    },
    {
        "name": "Jane Doe",
        "dob": "1953-02-19",
        "fav_color": "green",
        "emails": ["originaljane@deerclan.com"],
    }
]
</code>```

Alternatively, I can issue 3 queries: 1 for the users, 1 for the emails, and 1 for the phone numbers, but then the email and phone number result sets need to contain the user_id so that I can match them back up with the users I previously fetched. Again, redundant data and needless post-processing.

答:
It's returning exactly what you asked for: a single record set containing the Cartesian product defined by the joins.  There are plenty of valid scenarios where that's exactly what you would want, so saying that SQL is giving a bad result (and thus implying that it would be better if you changed it) would actually screw a lot of queries up.

What you're experiencing is known as "Object/Relational Impedance Mismatch," the technical difficulties that arise from the fact that the object-oriented data model and the relational data model are fundamentally different in several ways.  LINQ and other frameworks (known as ORMs, Object/Relational Mappers, not coincidentally,) don't magically "get around this;" they just issue different queries.  It can be done in SQL too.  Here's how I'd do it:

```<code>SELECT * FROM users user where [criteria here]
</code>```

Iterate the list of users and make a list of IDs.

```<code>SELECT * from EMAILS where user_id in (list of IDs here)
SELECT * from PHONES where user_id in (list of IDs here)
</code>```

And then you do the joining client-side.  This is how LINQ and other frameworks do it.  There's no real magic involved; just a layer of abstraction.

ContentLicense: CC BY-SA 4.0

Body:
It's returning exactly what you asked for: a single record set containing the Cartesian product defined by the joins.  There are plenty of valid scenarios where that's exactly what you would want, so saying that SQL is giving a bad result (and thus implying that it would be better if you changed it) would actually screw a lot of queries up.

What you're experiencing is known as "Object/Relational Impedance Mismatch," the technical difficulties that arise from the fact that the object-oriented data model and the relational data model are fundamentally different in several ways.  LINQ and other frameworks (known as ORMs, Object/Relational Mappers, not coincidentally,) don't magically "get around this;" they just issue different queries.  It can be done in SQL too.  Here's how I'd do it:

SELECT * FROM users user where [criteria here]

Iterate the list of users and make a list of IDs.

SELECT * from EMAILS where user_id in (list of IDs here)
SELECT * from PHONES where user_id in (list of IDs here)

And then you do the joining client-side.  This is how LINQ and other frameworks do it.  There's no real magic involved; just a layer of abstraction.


问:
Why did Microsoft abandon IronRuby and IronPython?
Several years ago, Microsoft announced that Ruby and Python were coming to .net.  The projects were called IronRuby and IronPython, respectively.  Microsoft said that the projects would be built on top of the .net DLR.

WIKIpedia indicates that for all intents and purposes, these projects have been abandoned by Microsoft.

Why did Microsoft abandon these projects?

答:
They are open source and not made by MS. IronPython is still in existence, built in .NET and under active development, however, only for Python 2.7, not 3.3 (yet?). A fresh version was released a few days ago. I don't know about IronRuby.

Additionally, in combination with Python Tools for Visual Studio (PTVS), you can use Visual Studio for IronPython development.


答:
The problem with this is that it's returning the user's name, DOB, favorite color, and all the other information stored

The problem is that you are not being selective enough. You asked for everything when you said

```<code>Select * from...
</code>```

...and you got it (including DOB and favourite colours).

You probably should been a little more (ahem) ...selective, and said something like:

```<code>select users.name, emails.email_address, phones.home_phone, phones.bus_phone
from...
</code>```

It's also possible you might see records that look like duplicates because a user might join to multiple email records, but the field that distinguishes these two is not in your
Select statement, so you might want to say something like

```<code>select distinct users.name, emails.email_address, phones.home_phone, phones.bus_phone
from...
</code>```

...over-and-over again for each record...

Also, I notice you're doing a LEFT JOIN. This will join all records on the left of the join (i.e. users) to all records on the right, or in other words:

A left outer join returns all the values from an inner join plus all values in the left table that do not match to the right table.

(http://en.wikipedia.org/wiki/Join_(SQL)#Left_outer_join)

So another question is do you actually need a left join, or would an INNER JOIN have been sufficient? They are very different types of joins.

Wouldn't be nicer if it returned a single row for each user, and within that record there was a list of emails

If you actually want a single column within the result set to contain a list that is generated on-the-fly, that can be done but it varies depending on which database you're using. Oracle has the listagg function.

Ultimately, I think that your problem might be solved if you rewrite your query close to something like this:

```<code>select distinct users.name, users.id, emails.email_address, phones.phone_number
from users
  inner join emails on users.user_id = emails.user_id
  inner join phones on users.user_id = phones.user_id
</code>```

Title: Why don't RDBMSes return joined tables in a nested format?

Body:
For example, say I want to fetch a User and all of his phone numbers and email addresses. The phone numbers and emails are stored in separate tables, One user to many phones/emails. I can do this quite easily:

```<code>SELECT * FROM users user
    LEFT JOIN emails email ON email.user_id=user.id
    LEFT JOIN phones phone ON phone.user_id=user.id
</code>```

The problem* with this is that it's returning the user's name, DOB, favorite color, and all the other information stored in the user table over-and-over again for each record (users×emails×phones records), presumably eating up bandwidth and slowing down the results.

Wouldn't it be nicer if it returned a  single row for each user, and within that record there was a list of emails and a list of phones? It would make the data much easier to work with too.

I know you can get results like this using LINQ or perhaps other frameworks, but it seems to be a weakness in the underlying design of relational databases.

We could get around this by using NoSQL, but shouldn't there be some middle ground?

Am I missing something? Why doesn't this exist?

* Yes, it's designed this way. I get it. I'm wondering why there isn't an alternative that is easier to work with. SQL could keep doing what it's doing but then they could add a keyword or two to do a little bit of post-processing that returns the data in a nested format instead of a cartesian product.

I know this can be done in a scripting language of your choice, but it requires that the SQL server either sends redundant data (example below) or that you to issue multiple queries like SELECT email FROM emails WHERE user_id IN (/* result of first query */).

Instead of having MySQL return something akin to this:

```<code>[
    {
        "name": "John Smith",
        "dob": "1945-05-13",
        "fav_color": "red",
        "email": "johnsmith45@gmail.com",
    },
    {
        "name": "John Smith",
        "dob": "1945-05-13",
        "fav_color": "red",
        "email": "john@smithsunite.com",
    },
    {
        "name": "Jane Doe",
        "dob": "1953-02-19",
        "fav_color": "green",
        "email": "originaljane@deerclan.com",
    }
]
</code>```

And then having to group on some unique identifier (which means I need to fetch that too!) client-side to reformat the result set how you want it, just return this:

```<code>[
    {
        "name": "John Smith",
        "dob": "1945-05-13",
        "fav_color": "red",
        "emails": ["johnsmith45@gmail.com", "john@smithsunite.com"]
    },
    {
        "name": "Jane Doe",
        "dob": "1953-02-19",
        "fav_color": "green",
        "emails": ["originaljane@deerclan.com"],
    }
]
</code>```

Alternatively, I can issue 3 queries: 1 for the users, 1 for the emails, and 1 for the phone numbers, but then the email and phone number result sets need to contain the user_id so that I can match them back up with the users I previously fetched. Again, redundant data and needless post-processing.

Body:
The problem with this is that it's returning the user's name, DOB, favorite color, and all the other information stored

The problem is that you are not being selective enough. You asked for everything when you said

Select * from...

...and you got it (including DOB and favourite colours).

You probably should been a little more (ahem) ...selective, and said something like:

select users.name, emails.email_address, phones.home_phone, phones.bus_phone
from...

It's also possible you might see records that look like duplicates because a user might join to multiple email records, but the field that distinguishes these two is not in your
Select statement, so you might want to say something like

select distinct users.name, emails.email_address, phones.home_phone, phones.bus_phone
from...

...over-and-over again for each record...

Also, I notice you're doing a LEFT JOIN. This will join all records on the left of the join (i.e. users) to all records on the right, or in other words:

A left outer join returns all the values from an inner join plus all values in the left table that do not match to the right table.

(http://en.wikipedia.org/wiki/Join_(SQL)#Left_outer_join)

So another question is do you actually need a left join, or would an INNER JOIN have been sufficient? They are very different types of joins.

Wouldn't be nicer if it returned a single row for each user, and within that record there was a list of emails

If you actually want a single column within the result set to contain a list that is generated on-the-fly, that can be done but it varies depending on which database you're using. Oracle has the listagg function.

Ultimately, I think that your problem might be solved if you rewrite your query close to something like this:

select distinct users.name, users.id, emails.email_address, phones.phone_number
from users
  inner join emails on users.user_id = emails.user_id
  inner join phones on users.user_id = phones.user_id


答:
You have to decide where the bottlenecks exist. The bandwidth between your database and application is usually pretty fast. There's no reason most databases couldn't return 3 separate datasets within one call and no joins. Then you get to join it all together in your app if you want.

Otherwise, you want the database to put this dataset together and then remove all the repeated values in each row that are the result of the joins and not necessarily the rows themselves having duplicate data like two people with the same name or phone number. Seems like a lot of over-head to save on bandwidth. You would be better off focusing on returning less data with better filtering and removing the columns you don't need. Because Select * is never used in production-well that depends.


答:
Queries always produce a rectangular (un-jagged) tabular set of data. There are no nested sub-sets within a set. In the world of sets everything is a pure un-nested rectangle.

You can think of a join as putting 2 sets side-by-side. The "on" condition is how the records in each set are matched up. If a user has 3 phone numbers, then you'll see a 3-time duplication in the user info. A rectangular un-jagged set must be produced by the query. It's simply the nature of joining sets with a 1-to-many relationship.

To get what you want, you must use a separate query like Mason Wheeler described.

```<code>select * from Phones where user_id=344;
</code>```

The result of this query is still a rectanglar un-jagged set. As is everything in the world of sets.

Body:
Queries always produce a rectangular (un-jagged) tabular set of data. There are no nested sub-sets within a set. In the world of sets everything is a pure un-nested rectangle.

You can think of a join as putting 2 sets side-by-side. The "on" condition is how the records in each set are matched up. If a user has 3 phone numbers, then you'll see a 3-time duplication in the user info. A rectangular un-jagged set must be produced by the query. It's simply the nature of joining sets with a 1-to-many relationship.

To get what you want, you must use a separate query like Mason Wheeler described.

select * from Phones where user_id=344;

The result of this query is still a rectanglar un-jagged set. As is everything in the world of sets.


答:
You could use a built in function to concatenate the records together.  In MySQL you can use the GROUP_CONCAT() function and in Oracle you can use the LISTAGG() function.

Here is a sample of what a query might look like in MySQL:

```<code>SELECT user.*,
    (SELECT GROUP_CONCAT(DISTINCT emailAddy) FROM emails email WHERE email.user_id = user.id
    ) AS EmailAddresses,
    (SELECT GROUP_CONCAT(DISTINCT phoneNumber) FROM phones phone WHERE phone.user_id = user.id
    ) AS PhoneNumbers
FROM users user
</code>```

This would return something like

```<code>username    department       EmailAddresses                        PhoneNumbers
Tim_Burton  Human Resources  hr@m.com, tb@me.com, nunya@what.com   231-123-1234, 231-123-1235
</code>```

Body:
You could use a built in function to concatenate the records together.  In MySQL you can use the GROUP_CONCAT() function and in Oracle you can use the LISTAGG() function.

Here is a sample of what a query might look like in MySQL:

SELECT user.*,
    (SELECT GROUP_CONCAT(DISTINCT emailAddy) FROM emails email WHERE email.user_id = user.id
    ) AS EmailAddresses,
    (SELECT GROUP_CONCAT(DISTINCT phoneNumber) FROM phones phone WHERE phone.user_id = user.id
    ) AS PhoneNumbers
FROM users user

This would return something like

username    department       EmailAddresses                        PhoneNumbers
Tim_Burton  Human Resources  hr@m.com, tb@me.com, nunya@what.com   231-123-1234, 231-123-1235


答:
Who is the owner of the derivative? Is it the original author, the new author or there is joint ownership?

You own the copyright to the portion of the code that you modified.

The previous contributors own the copyright to the portions they created*

Joint ownership is a good way of looking at the copyright on the source code for the project.  Keep in mind that copyright is separate from the license of the project.  In this case, copyright is ownership of code.  License is the rules others have to follow in order to use that code.

Is a copyright notice (say under the original copyright) sufficient to establish the new ownership?

Yes, although it is not necessarily required under the Berne Convention.

The caveat to all of the above is that some projects may require you to assign copyright to the project before they'll accept your contribution in the main branch.  This note from the US Copyright office discusses how copyright may be transferred to another.

Since it sounds like you're forking the project, there probably isn't any concern about the original project requesting copyright ownership of your modifications.  I primarily wanted to point out that copyright can be transferred.


答:
No, not during a job interview.  Too many interviewers do things like intentionally underspecify the requirements and expect the interviewee to ask further questions, or look at attention to real-world issues not explicitly mentioned.

Here are some things, off the top of my head, that your requirements probably didn't mention:

Coding standards

Comments

Exception handling

Descriptive names of variables, classes, methods

Following idiomatic usage of the language

Proper object oriented design

Attention to possible concurrency issues

Writing test cases for the code

Did you pay attention to a single one of these things without explicitly stating it?  How would the candidate know which ones you care about, and which you don't?

An interview is a highly artificial environment.  The interviewer is often trying to "trick" the candidate a little bit in order to make it difficult for the interviewee to tell him whatever he wants to hear, and the interviewee is trying to guess what the interviewer really wants.

Generally, making a mistake on that guess is pretty different than making a mistake on real world design decisions.  If you want to know if someone over-engineers things you probably have to talk about design rather than look at a very artificial coding exercise.

Title: Is over-engineering a warning sign?


问:
Design document for project in C
I have had some experience in documenting the design for project developed in OOP languages. I made classes and used class diagrams to showcase the overall design structure of the implementation when I used OOP languages.

Problem : I am about to begin a project in C language. How am I supposed to go about writing the design document now ?

Q. Shouldn't the design document be independent of language of implementation ? But I am not able to figure out, with no classes involved in my implementation, how and between what will I show relations ?

Q. Is there any standard way to document C projects ?

I am totally confused as to what exactly am I supposed to show in the design document ? Functions ? How will I related them ?

Will appreciate link to any open source C project which might have such a documentation for reference ?

P.S. : Project is minimal kernel development in C language.

答:
Shouldn't the design document be independent of language of implementation ? But I am not able to figure out, with no classes involved in my implementation, how and between what will I show relations ?

Often, an architectural design will be independent of language, to the extent possible. If any technology decisions have been made in advance, they may be included in the system architecture. Detail designs to tend to consider the development language so that the notations used are relevant to the people building and/or maintaining the system. If you're creating a detail design and you know the application will be written in C, use the terminology and constructs from C.

Is there any standard way to document C projects ?

There are many ways to document C projects. Some constructs from UML can be used, keeping in mind that some of the object-oriented terms don't apply and therefore shouldn't be used. Class diagrams, activity diagrams, component diagrams, and sequence diagrams can be used, to varying extents, often using a subset of the complete UML language. Alternatively, data flow diagrams, data structure diagrams, or JSP diagrams can be used. Textual representations (including creating pseudocode before implementing algorithms) are also valid.

Something to keep in mind is the purpose of the design documentation. All design documents should indicate how the system is going to fulfill the requirements. The rest depends on the audience. If you're going to be designing and implementing the system, then the documentation can serve as a guide for future developers and testers. IF you are just designing the system, you need to be far more explicit in inputs and outputs so that, given only the models and descriptions of the system, someone can build something that meets your needs.

Title: Design document for project in C


答:
If the programmer didn't solve the problem, then all of the extra code is the coder's attempt to obfuscate the non-answer.  It's the same technique used on an essay test by a student who doesn't know much about the subject.  He or she will ramble on about a compelling, but unrelated issue in hopes his ignorance is masked by word count.

If the programmer did solve the issue but added a great deal more code, consider the programmer's background, as some areas of programming require greater tolerances than others.

For example, code running the auto-pilot in a commercial passenger jet has much less tolerances for failure than a free Android game.  A developer used to programming embedded devices that are hard to reach and almost impossible to update will tend to code more what-if's then a developer that can push out 15 updates in a day.

Title: Is over-engineering a warning sign?


答:
It depends, but generally no.

Design in general is a skill learned with experience. Aaronaught's description of that progression linked by Marjan is generally a good one.

Communication in any form also depends a lot on context. What may seem perfectly clear to mean one thing in one context, may just as clearly mean something else within a different context. Knowing which questions to ask is also something that comes with experience.

Their thought process and how they reason about their decisions is far more important than their solution. Without reviewing their solution and their decisions with them you cannot fully assess the context it was developed under.

Given the progression above, a candidate with the over-engineered solution may well be further along than the candidate with the simple one.

Also: What level position are you hiring for? Over-engineering out of an entry or intermediate level candidate is less of an issue than over-engineering out of a senior level candidate.

Title: Is over-engineering a warning sign?


答:
Write the design document as normal, with classes and objects.

C still has user-defined data types: they're just declared with the struct keyword instead of class.

C still has encapsulation and data-hiding: you just don't have the private keyword to make the compiler enforce it for you. Group functions operating on the same data types into a module, and just don't expose the private data outside that module.

C can still have abstraction, and even inheritance if you really want it (although it's a lot of work unless you're sure it's really essential).

At implementation time, you'll have to decide how to implement each of those classes and objects.

A class might be implemented as a struct plus a cloud of related functions for the methods. Apart from losing some syntactic sugar, it works the same unless you need polymorphism.

Title: Design document for project in C

Body:
I have had some experience in documenting the design for project developed in OOP languages. I made classes and used class diagrams to showcase the overall design structure of the implementation when I used OOP languages.

Problem : I am about to begin a project in C language. How am I supposed to go about writing the design document now ?

Q. Shouldn't the design document be independent of language of implementation ? But I am not able to figure out, with no classes involved in my implementation, how and between what will I show relations ?

Q. Is there any standard way to document C projects ?

I am totally confused as to what exactly am I supposed to show in the design document ? Functions ? How will I related them ?

Will appreciate link to any open source C project which might have such a documentation for reference ?

P.S. : Project is minimal kernel development in C language.


答:
I've seen lots of cases where people invest a tremendous amount of effort writing tests for code that is seldom entered, and not writing tests for code that is entered frequently.

Before sitting down to write any tests, you should be looking at some kind of a call graph, to make sure you plan adequate coverage.

Additionally, I don't believe in writing tests just for the sake of saying "Yeah, we test that". If I'm using a library that is dropped in and will remain immutable, I'm not going to waste  a day writing tests to make sure the innards of an API that will never change works as expected, even if certain parts of it score high on a call graph. Tests that consume said library (my own code) point this out.

Title: How to write "good" unit tests?


问:
Python -- when should a class have-a rather than be-a?
This is related to "Extends is evil" vs. OCP? but separate because the idea of "implement the interface" doesn't exist in Python.

I'm writing a class to pull some data off a webpage. It's going to need to hold on to a cookie for authentication, so I'm going to use a requests.Session object in some form. I'm never sure how to approach this -- what's the appropriate choice here?

```<code>class FooFetcher(requests.Session):
    def __init__(self):
        super.__init__()
</code>```

or

```<code>class FooFetcher(object):
    def __init__(self):
        self.session = requests.Session()
</code>```

?

The former seems to end up with FooFetcher having way more public methods than it needs to. The latter looks like it might be unnecessarily convoluted, since pretty much every method of FooFetcher is going to involve a call to a method of that Session object, plus maybe some parsing of JSON that it finds.

答: The trick is to look at the calling code.  Is there any code that currently uses a requests.Session object that you want to be able to pass in a FooFetcher instead?  If not, then use composition.


问:
What is the gain from 64-bit architecture?
I played with 8-bit machines (C64), I used 16-bit machines (Win 3.1), I enjoyed flat 32-bit address space (Linux).

Every time as a user (which was also means being a developer for fun or profit) I felt the need for more bits and welcomed the next wider bit architecture. Accessing to bigger memory space got easier, graphics got better and sound was a bliss after 8-bit.

However when marketing drums started to kick in for 64-bit some years ago I thought, "ok, this is Internet age, they can use this kind of power to do more calculations easier and commodity hardware manufacturers want to spread their portfolio for this kind of market".

Professionally I became a "system programmer" working for mobile devices which some what means being an "embedded programmer" as well. Working mostly on 32-bit from the start ARM architecture based products, it was a while I forgot about different architectures other than being 32-bit.

Also when ARM announced a new 64-bit architecture towards end of 2011, I read it as ARM wants to go into server market, increasing their portfolio. Which makes sense.

Now with new iPhone 5S claiming to be the first 64-bit processor ever used on a smartphone, thoughts became a little bit unsettled in my head again. Mobile devices, being the ultimate personal devices are becoming 64-bit.

So I wonder, is there something I'm missing? What does being 64-bit offers to the users including programmers?

答:
It's important to distinguish between 64-bit architectures in general and the 64-bit architectures we commonly see.  In an abstract sense, a 64-bit architecture just gives you wider registers (bigger numbers and more addressable memory).  Looking at concrete examples of architectures, you see that the 32 to 64-bit jump was used as an opportunity to make significant, incompatible, improvements in processor design.

The first one that comes to mind, looking at both x86_64 and ARMv8, you see a significant increase in the number of registers available.  Both architectures have doubled the number of general-purpose registers on the processor.  This greatly increases the opportunities for optimization of software.  Similarly, they have improved vector processing capabilities.  Moving to a new, incompatible, architecture gives designers to opportunity to remove little used features that were dragged along through the years for the sake of backwards compatibility.


问:
Correctly value a development?
I started a discussion on StackOverflow earlier this week about one of my work project and how to lead it correctly.

But it seems that this stack is a more appropriate place to ask those sort of questions, so here is my last question about my project:

How do you value your work? / How do you rate it in a financial way?

I'm working on a quite cool project with two other friends and people that we know ask us for an earlier access and how many it would cost per month for us to access it.

Unfortunately, I was not able to answer this simple question due to the fact that I'm not agree with my friends on this specific topic.

For me a bill of 80$/month/contract seems to be reasonable and appropriate for our targeted market (Institutions and Corporations) but my partner would rather count a charge of 500$/month/contract.

Our project is an asset manager in SAAS mode, and I don't really think that our potential clients would be ready to pay more than 90$/month/contract even if they have a lot of money due to their situation.

So, I would really like to have some opinions and advices on this kind of question.

PS: If my post is not on the appropriate stack, feel free to tell me.
PS2: I'm quite sorry if I'm not totally crystal clear, I'm not a native english, if you do not understand something, as above, feel free to notice me and I'll rephrase.

答:
If the project isn't ready for widespread use, the first users are beta testers.  Unless you can promise them that there won't be major bugs, downtime and data loss, you probably shouldn't charge them anything.  Having real users before trying to launch to paying customers is worth far more than any amount of money they could bring in.  Their value is in helping you find bugs, suggest features that actual users want & understand the actual value of your software.  If you only have 4-5 customers, even $500/mo isn't worth the trouble of setting up billing/accounting/contracting.

Just make sure that you set the expectation that the software isn't finished, isn't reliable & isn't going to be free forever.

Title: Correctly value a development?


问:
Programming puzzle with constant selection
THE QUESTION:

There is an event where there are N contestants. There are three tasks in the event: A,B,C (say). Each participant takes part in the events in the listed order: i.e a contestant must first complete A and B before beginning C.

However, in event A only one person can participate at a time. Any number of people may simultaneously participate in B and C.

So the event works as follows. At time 0, the first contestant begins A, while the remaining citizens wait for the first person to finish. As soon as the first person is done, he or she proceeds to event B, and the second citizen begins A. In general whenever a person completes A, the next person begins A. Whenever a person is done with A, he or
she proceeds to B immediately, regardless of what the other contestants do. The whole event ends as soon as all the contestants finish all 3 events.

So the basic question is given the number of participants N, and the time taken by each person for each of the 3 events, calculate the minimum time in which the whole event might be completed.

MY ATTEMPT:

This is the algorithm I came up with:

LeastTime(people (2d array [n][3] with time of each person for each event, n, front_chosen = false)

```<code>    The least time for n people can be broken up into 2 cases:
    1. The current guy seated first for event A
        1.1 We take t1_1 -> time for current guy in event A + time taken for the rest of the people to finish the whole event with the front taken
        1.2 We take t1_2 -> time for current guy in event A + time for his remaining events
        1.3 The time taken for the whole event in this case is t1 = max{t1_1,t1_2}.

    2 The current guy is not seated first for event A
        2.1 We modify people such that the first element is placed last
        2.2 t2 -> LeastTime(people, n, false)
    3. We return min {t1,t2}
</code>```

So that is what I came up with. What are some better i.e more efficient solutions? Even Alternate Solutions will be helpful.

答:
Given the time taken by all participants in all events, the time spent on event A is invariant; therefore, the shortest possible overall event duration can be found by focusing on the person who is slowest at the combination of B+C and optimizing the event A ordering to maximize the overlap between (B+C) time and (A) time.

Reorganize input into person[n][2] where Person N's time on event A is in person[N][1] and their time on events B and C combined is in person[N][2].

Sort descending on column 2 and then on column 1.

The time at which each person finishes is then the sum of all A's up to and including their own A, plus their BC.

The time at which the event ends is the maximum of the finishing times.

e.g. for people who have times of:

```<code>(A,B,C)
[1,2,3]
[2,2,2]
[1,5,6]
[5,1,1]
[4,5,6]
</code>```

reorganize into:

```<code>(A,(B+C))
[1,5]
[2,4]
[1,11]
[5,2]
[4,11]
</code>```

sort into:

```<code>[4,11]
[1,11]
[1,5]
[2,4]
[5,2]
</code>```

Then finish times are:

```<code>4 + 11                 = 15
4 + 1 + 11             = 16
4 + 1 + 1 + 5          = 11
4 + 1 + 1 + 2 + 4      = 12
4 + 1 + 1 + 2 + 5 + 2  = 15
</code>```

And the earliest possible completion of the event overall is 16 minutes.

Body:
Given the time taken by all participants in all events, the time spent on event A is invariant; therefore, the shortest possible overall event duration can be found by focusing on the person who is slowest at the combination of B+C and optimizing the event A ordering to maximize the overlap between (B+C) time and (A) time.

Reorganize input into person[n][2] where Person N's time on event A is in person[N][1] and their time on events B and C combined is in person[N][2].

Sort descending on column 2 and then on column 1.

The time at which each person finishes is then the sum of all A's up to and including their own A, plus their BC.

The time at which the event ends is the maximum of the finishing times.

e.g. for people who have times of:

(A,B,C)
[1,2,3]
[2,2,2]
[1,5,6]
[5,1,1]
[4,5,6]

reorganize into:

(A,(B+C))
[1,5]
[2,4]
[1,11]
[5,2]
[4,11]

sort into:

[4,11]
[1,11]
[1,5]
[2,4]
[5,2]

Then finish times are:

4 + 11                 = 15
4 + 1 + 11             = 16
4 + 1 + 1 + 5          = 11
4 + 1 + 1 + 2 + 4      = 12
4 + 1 + 1 + 2 + 5 + 2  = 15

And the earliest possible completion of the event overall is 16 minutes.


答:
You could also price the product based on the term it will be used. Charge $250/mo for single months, but charge closer to $80/mo if they sign up for a multi-year contract (with cancellation fee)

Or, depending on the nature of your product, offer service in tiers; $80 for the 'basic' tier and closer to $250 for high-end tiers.

Another thing I would consider doing is approaching this formulaically (this is grossly simplified); What will it cost to continue running, what did you invest, what do you want to profit, how much will it be in an ongoing cost basis, what would expansion cost (e.g. if you have to upgrade to a new office) and what sort of emergency fund do you need. With all that in mind, have your money man crunch those numbers and find out what you'll need to charge to meet those expectations.E.g. "In 6 months we want to have enough money saved to cover $XXXX in case of emergency."

With those numbers, try to assess interested clients. If you have only 3 or 4 potential clients, they may need to be charged more. But if you have dozens of companies that may be interested, you can charge less. Assume that only a small percentage of the potential clients bite, and divide the costs you calculated by how much you believe you'll need, and you'll have a baseline. Add a small margin (10-20%) to that and you'll have your profitable price-point. If you think it'll cost $3000/mo to operate developing this software, and you think you'll get 12 clients minimum then you need at least $250/mo. If you have $5000 in the company pot available, you can likely lower your price for the first year and operate at a loss if you felt more customers in the long run would be better.

Also consider that many entrepreneurs fail because they get 'my baby' syndrome. They inflate the value of their product because they believe it is worth more than its value. On the other hand, it may be under-valued; "I know X Y and Z cost us nothing - so we shouldn't charge for them" when in fact they may be very valuable. So, at least in the beginning plan the pricing to the product on a "we will need $X to live off this product"; once you have that baseline down and you see the customer reaction, you can begin to gauge how much you should raise/lower the price to new/renewing customers.

And as usual, check to see if you have competitors and find out how they make profit. More importantly, check to see who FAILED and try to pinpoint why they may not have succeeded. "Oh, all the successful companies have an additional support contracts available, and all of the failures didn't have adequate support at all."

Title: Correctly value a development?

Body:
I started a discussion on StackOverflow earlier this week about one of my work project and how to lead it correctly.

But it seems that this stack is a more appropriate place to ask those sort of questions, so here is my last question about my project:

How do you value your work? / How do you rate it in a financial way?

I'm working on a quite cool project with two other friends and people that we know ask us for an earlier access and how many it would cost per month for us to access it.

Unfortunately, I was not able to answer this simple question due to the fact that I'm not agree with my friends on this specific topic.

For me a bill of 80$/month/contract seems to be reasonable and appropriate for our targeted market (Institutions and Corporations) but my partner would rather count a charge of 500$/month/contract.

Our project is an asset manager in SAAS mode, and I don't really think that our potential clients would be ready to pay more than 90$/month/contract even if they have a lot of money due to their situation.

So, I would really like to have some opinions and advices on this kind of question.

PS: If my post is not on the appropriate stack, feel free to tell me.
PS2: I'm quite sorry if I'm not totally crystal clear, I'm not a native english, if you do not understand something, as above, feel free to notice me and I'll rephrase.