答:
If you have a performance function of 6n + 4, the relevant question is, "6 what?".  As one comment asked:  what does your constant represent?  In physics terms, what are the units of your constant factor?

The reason why O() notation is so widely used to describe algorithm performance is that there is no portable way to answer that question.  Different processors will take a different number of clock cycles and different amounts of time to perform the same elementary computation, or they may lump the relevant elementary computations differently.  Different computer languages, or different formal and informal descriptions like pseudocode, will represent algorithms in ways that are difficult to compare directly.  Even implementations in the same language can represent the same algorithm in different ways -- trivial formatting details like the number of lines aside, you will generally have a wide variety of arbitrary structural choices to implement any given algorithm.

Look at it another way:  we use "algorithm" not to describe a particular implementation, but to describe an entire class of potential implementations of the same general procedure.  This abstraction ignores the details of implemention in favor of documenting something of general value, and the constant performance factor is one of these details.

That said, algorithm descriptions are often accompanied by folklore, notes, or even actual benchmarks that describe the performance of actual implementations on actual hardware.  This gives you a rough idea what kind of constant factor to expect, but it should also be taken with a grain of salt because the actual performance depends on things like how much work went into optimization of a given implementation.  Also, in the long term, the relative performance of comparable algorithms tends to drift as the architecture of the latest and greatest processors changes...


问:
What are the boundaries between the responsibilities of a web designer and a web developer?
I have been hired to do functional development for several web site redesigns.  The company I work for has a relatively low technical level, and the previous development of the web sites were completed by a graphic designer who is self taught as far as web development is concerned.

My responsibilities have extended beyond basic development, as I have been also tasked with creating the development environment, and migrating hosting from external CMS hosting to internal servers incorporating scripting languages (I opted for PHP/MySQL).

I am working with the graphic designer, and he is responsible for the creative design of the web.  We are running into a bit of friction over confusion between the boundaries of our respective tasks.

For example, we had some differences of opinion on navigation.  I was primarily concerned with ease-of-use (the majority of our userbase are not particularly web-savvy), as well as meeting W3 WAI standards (many of our users are older, and we have a higher than average proportion of users with visual impairment).  His sole concern was what looked best for the website, and I felt that the direction he was pushing for caused some functional problems.

I feel color choices, images, fonts, etc. are clearly his responsibility, and my expectation was that he would simply provide me with the CSS pages and style classes and IDs to use, but some elements of page layout also seem to fall more under the realm of "usability", which to me translates as near-synonymous with "functionality".

I've been tasked with selecting the tools we'll use, which include frameworks, scripting languages, database design, and some open source applications (Moodle for example, and quite probably Drupal in the future).  While these tools are quite customizable, working directly with some of the interfaces is beyond his familiarity with CSS, HTML, and PHP.  This limits how much direct control he has over the appearance, which has lead to some discussion about the tool choices.

Is there a generally accepted dividing line between the roles of a web designer and a web developer?  Does his relatively inexperienced background in web technologies influence that dividing line?

答:
In regards to your specific case, you ARE overstepping your bounds, according to the teams I've worked with (as both a designer and a dev). Here's your description of the roles:

I have been hired to do functional development ... My responsibilities
  have extended beyond basic development, as I have been also tasked
  with creating the development environment, and migrating hosting from
  external CMS hosting to internal servers incorporating scripting
  languages ... I am working with the graphic designer, and he is
  responsible for the creative design of the web.  ... but some elements
  of page layout also seem to fall more under the realm of "usability",
  which to me translates as near-synonymous with "functionality".

You are the Developer, he is the designer. You get to pick the framework (and he must adjust his HTML/designs accordingly) but HE gets to decide on the creative elements and is the ruler on any usability issues. "Usability" does not equal "functionality" in my book.

ContentLicense: CC BY-SA 3.0


问:
How to handle monetary values in PHP and MySql?
I've inherited a huge pile of legacy code written in PHP on top of a MySQL database. The thing I noticed is that the application uses doubles for storage and manipulation of data.

Now I came across of numerous posts mentioning how double are not suited for monetary operations because of the rounding errors. However, I have yet to come across a complete solution to how monetary values should be handled in PHP code and stored in a MySQL database.

Is there a best practice when it comes to handling money specifically in PHP?

Things I'm looking for are:

How should the data be stored in the database? column type? size?

How should the data be handling in normal addition, subtraction. multiplication or division?

When should I round the values? How much rounding is acceptable if any?

Is there a difference between handling large monetary values and low ones?

Note:
A VERY simplified sample code of how I might encounter money values in everyday life (various security concerns were ignored for simplification. Of course in real life I would never use my code like this):

```<code>$a= $_POST['price_in_dollars']; //-->(ex: 25.06) will be read as a string should it be cast to double?
$b= $_POST['discount_rate'];//-->(ex: 0.35) value will always be less than 1
$valueToBeStored= $a * $b; //--> any hint here is welcomed

$valueFromDatabase= $row['price']; //--> price column in database could be double, decimal,...etc.

$priceToPrint=$valueFromDatabase * 0.25; //again cast needed or not?
</code>```

I hope you use this sample code as a means to bring out more use cases and not to take it literally of course.

Bonus Question
If I'm to use an ORM such as Doctrine or PROPEL, how different will it be to use money in my code.

答:
A simple work around is to store them as integers. 99.99 stored as 9999. If this won't work (and there are many reasons why this could be a bad choice) you can use type Decimal. http://dev.mysql.com/doc/refman/5.0/en/precision-math-decimal-changes.html on the mysql side. On the php side i found this https://stackoverflow.com/questions/3244094/decimal-type-in-php which might be what you are after.

Bonus question: Hard to say. The orm is going to work based on the data types chosen. I would say that you could do some stuff with abstraction to help but this specific issue isn't addressed simply by moving to an ORM.


问:
What makes a project big?
Just out of curiosity what's the difference between a small, medium and large size project? Is it measured by lines of code or complexity or what?

Im building a bartering system and so far have about 1000 lines of code for login/registration. Even though there's lots of LOC i wouldnt consider it a big project because its not that complex though this is my first project so im not sure. How is it measured?

答:
A project size is probably best measured by the number of requirements the system has, where the requirements can't be reduced down further.

Of course, more requirements mostly means more complexity, but it's not always the case.

ContentLicense: CC BY-SA 2.5

Title: What makes a project big?


问:
Why doesn't Java's BigInteger class have a constructor capable of taking a numeric literal?
Why doesn't Java's BigInteger class have a constructor capable of taking a numeric literal? Every single time I use BigIntegers, and many times I merely think about them, I wonder this.

What reason could the designers of java have had to exclude one despite the overwhelming convenience of one should it exist?

答:
The answer lies in the JavaDoc of BigInteger.valueOf(long):

This "static factory method" is provided in preference to a (long) constructor because it allows for reuse of frequently used BigIntegers.

In other words: BigInteger.valueOf(long) does exactly what you ask the hypothetical BigInteger(long) constructor to do, except it is (or at least can be) slightly more efficient at it.


问:
Client-Side V.S. Server-Side Searching?
I am currently helping to design a web site and application in HTML. We would like the user to be able to search the site/app for desired content via a search bar. We would also like to include an advanced search ability to allow for different search options and more concentrated searches.

We are having trouble deciding whether to program the search function on the Client-Side (with JavaScript) or on the Server-Side (with PHP). What are the pros and cons of both and what would you recommend?

答:
As others have commented on your question, you need server-side functionality to provide effective and efficient search in a website; otherwise you would need to make all searchable content available to the client-side search engine; unless the volume of searchable content was very small, this would be troublesome.

Once you have the server-side functionality, yes, you can add AJAX to make searching niftier- esp. autocomplete functionality, quick filtering, etc., although that's also going to rely on the server-side functionality.

My personal point of view; if you do have the time to do AJAX and it adds speed, do so. But it is time-consuming and perhaps your time would be better spent some place else.

Title: Client-Side V.S. Server-Side Searching?


问:
Does 'Me' in VB.NET refer to the instantiated object only?
Does 'Me' in VB.NET refer only to an instantiation of the type?  Just occurred to me that since I can reference properties in my VB.NET class without using 'Me', that I don't see a reason for using it for this purpose.  Will referencing the variable either way always refer to the actual stored value for the property at runtime?</p>

答:
From the Me documentation on MSDN:

The Me keyword behaves like either an object variable or a structure variable referring to the current instance.

The use case described is that of passing  the current object to another one.


问:
How get and set accessors work
The standard method of implementing get and set accessors in C# and VB.NET is to use a public property to set and retrieve the value of a corresponding private variable.  Am I right in saying that this has no effect of different instances of a variable?  By this I mean, if there are different instantiations of an object, then those instances and their properties are completely independent right?  So I think my understanding is correct that setting a private variable is just a construct to be able to implement the get and set pattern?  Never been 100% sure about this.</p>

答:
if there are different instantiations of an object, then those instances and their properties are completely independent

Yes, you are right.

So I think my understanding is correct that setting a private variable is just a construct to be able to implement the get and set pattern?

Not sure what you mean by that.

Title: How get and set accessors work


问:
async & await - poll for alternatives
Now that we know what is in store for c#5, there is apparently still an opening for us to influence the choice of the two new keywords for 'Asynchrony' that were announced by Anders Heijsberg yesterday at PDC10.

```<code>async void ArchiveDocuments(List<Url> urls) {
    Task archive = null;
    for(int i = 0; i < urls.Count; ++i) {
        var document = await FetchAsync(urls[i]);
        if (archive != null)
            await archive;
        archive = ArchiveAsync(document);
    }
}
</code>```

Eric Lippert has an explanation of the choice of the current two keywords, and the way in which they have been misunderstood in usability studies. The comments have several other propositions.

Please - one suggestion per answer, duplicates will be nuked.

答:
Since we are dealing with Task<T>s, how about using start as a keyword preceding the statement, as in:

start var document = FetchAsync(urls[i]);

ContentLicense: CC BY-SA 4.0

Title: async & await - poll for alternatives


问:
Are elements returned by Linq-to-Entities query streamed from the DB one at the time or are they retrieved all at once?
Are elements returned by Linq-to-Entities query streamed from the database one at the time ( as they are requested ) or are they retrieved all at once:

```<code>    SampleContext context = new SampleContext(); // SampleContext derives from ObjectContext
    var search = context.Contacts;

    foreach (var contact in search)
    {
       Console.WriteLine(contact.ContactID); // is each Contact retrieved from the DB
                                             // only when foreach requests it?
    }
</code>```

thank you in advance

答:
They are retrieved using one query. Your example does simple select for all rows of Contacts table.

Streaming would be highly ineffective.

But this is only for query itself. There might be lazy loading involved for navigation entities stored in properties or collection of entities. Those are loaded on-demand as you access them. This might result in in-famous N+1 problem.


答:
You are correct up to this question:

So I think my understanding is correct that setting a private variable is just a construct to be able to implement the get and set pattern?

Quite the opposite is true. Ideally, only the encapsulating object should have direct access to the object(s) it encapsulates. This is known as the Law of Demeter.

In reality, following this "law" (like most programming laws) religiously can lead to over-engineering, but it is a very good principle to bear in mind.

Make the mental shift so you have to justify the existence of a getter, and separately a setter, before you blindly implement them for all private fields.

Title: How get and set accessors work

Body: The standard method of implementing get and set accessors in C# and VB.NET is to use a public property to set and retrieve the value of a corresponding private variable.  Am I right in saying that this has no effect of different instances of a variable?  By this I mean, if there are different instantiations of an object, then those instances and their properties are completely independent right?  So I think my understanding is correct that setting a private variable is just a construct to be able to implement the get and set pattern?  Never been 100% sure about this.</p>


问:
Are nested classes under-rated?
I'm not trying to say I know something everyone else doesn't but I've been solving more and more designs with the use of nested classes, so I'm curious to get a feeling for the acceptablilty of using this seemingly rarely used design mechanism.

This leads me to the question: am I going down an inherintly bad path for reasons I'll discover when they come back to bite me, or are nested classes maybe something that are underrated?

Here are two examples I just used them for: https://gist.github.com/3975581 - the first helped me keep tightly releated heirarchical things together, the second let me give access to protected members to workers...

答:
am I going down an inherintly bad path

I think in your second example (the worker subclasses) you definitely are.  You have mapped each subclass to a specific state in the super class.  So now each time you want to add a state to the super class you will need to make a change in three locations (add state to super class, add a new sub class, and change the constructor of derived class to add sub class to list).

The use of nested classes to access private members does appear to be a valid use (I have never personally done it) but your specific case does not work here.

As for the body part example.  Because all of the nested classes are public you aren't really doing much except namespacing.  If these classes grow to include more functionality you may just find that the nested classes just clutter the interfaces and you are sifting through code to find something specific.  I also notice that because you have nested classes you are forced to break naming conventions and name your classes with lower case (maybe this was a choice).  But these arguments are more superficial than anything actually wrong.

Unless, of course, you needed to implement a disembodied arm.  Then creating an arm by doing the following is confusing because there is no body/torso/side.  (Also notice the confusing casing).

```<code>arm newArm = new Body.torso.side.arm("");
</code>```

Title: Are nested classes under-rated?

Body:
am I going down an inherintly bad path

I think in your second example (the worker subclasses) you definitely are.  You have mapped each subclass to a specific state in the super class.  So now each time you want to add a state to the super class you will need to make a change in three locations (add state to super class, add a new sub class, and change the constructor of derived class to add sub class to list).

The use of nested classes to access private members does appear to be a valid use (I have never personally done it) but your specific case does not work here.

As for the body part example.  Because all of the nested classes are public you aren't really doing much except namespacing.  If these classes grow to include more functionality you may just find that the nested classes just clutter the interfaces and you are sifting through code to find something specific.  I also notice that because you have nested classes you are forced to break naming conventions and name your classes with lower case (maybe this was a choice).  But these arguments are more superficial than anything actually wrong.

Unless, of course, you needed to implement a disembodied arm.  Then creating an arm by doing the following is confusing because there is no body/torso/side.  (Also notice the confusing casing).

arm newArm = new Body.torso.side.arm("");


问:
AND is better or using Internal "IF"
In a situation like this:"

```<code>if ((metadata != null) && (metadata.TypeEnum != VariantInfoMetadata.CellTypeEnum.Status))
</code>```

do you recommend to keep the code as it is above?  Or is it better to make a nested "if" statement and breaks the condition into two sections where "outer if" makes sure metadata is not null and inner if does the rest of the checking.  I think a nested if takes care of possible null reference exception if value of metadata gets null.

答: The && and || in many languages (C, C++, Java, C#) are short-circuiting, which means that as soon as the answer is known, it stops evaluating. If your language is one of short-circuiting languages, you do not need a nested if, because as soon as metadata != null evaluates to false, the evaluation of the overall expression is going to stop, preventing the null referencing. In fact, short-circuiting (logical) ANDs and ORs were invented specifically to deal with situations like you describe without the need to create an additional level of nesting.

Title: AND is better or using Internal "IF"


答:
Another approach is to use the Null Object pattern.

Instead of explicit checks for null, you always return an instance, so in this case you'd have (pseudo-code):

```<code>public class NullMetadata
{
    VariantInfoMetadata TypeEnum { get; set; }

    public NullMetadata()
    {
        TypeEnum = VariantInfoMetadata.None
    }
}
</code>```

Then instead of

```<code>var metadata = null
</code>```

you'd have

```<code>var metadata = new NullMetadata()
</code>```

And the check for VariantInfoMetadata.CellTypeEnum.Status would always return false.

Title: AND is better or using Internal "IF"

Body:
In a situation like this:"

```<code>if ((metadata != null) && (metadata.TypeEnum != VariantInfoMetadata.CellTypeEnum.Status))
</code>```

do you recommend to keep the code as it is above?  Or is it better to make a nested "if" statement and breaks the condition into two sections where "outer if" makes sure metadata is not null and inner if does the rest of the checking.  I think a nested if takes care of possible null reference exception if value of metadata gets null.

Body:
Another approach is to use the Null Object pattern.

Instead of explicit checks for null, you always return an instance, so in this case you'd have (pseudo-code):

public class NullMetadata
{
    VariantInfoMetadata TypeEnum { get; set; }

    public NullMetadata()
    {
        TypeEnum = VariantInfoMetadata.None
    }
}

Then instead of

var metadata = null

you'd have

var metadata = new NullMetadata()

And the check for VariantInfoMetadata.CellTypeEnum.Status would always return false.


问:
Should I be involved in my project's business side?
Before my current job, I was always involved in the technical aspects of a project like:

architecture

design

performance

security

etc

Now I'm team lead of a project that's a game on a web site (not mine) and somehow got involved in the business side of the project:

what users expect

ads showing in which pages of the site

mechanics of the game

etc

But I quite don't agree with business people's (customer or product owner if you like) decisions of the directions of the site. Of course I raise my concerns, some of them are taken into account, most of them aren't.

I continue my work as usual as I like working here but I feel like the product would be better than what it is now. I think that's because my goal is to make an interesting and challenging game, and theirs is to attract as many people and earn money as possible (it's a paid game). Have you guys ever happened to be in this kind of situation? What are your experiences?

答:
In my experience, having a tech person on the business side of things can really be helpful to a company IF, and this is an important "if", the tech person takes the time to speak the business people's language.

Yes, technical awesomeness sometimes has to compromise with UX.  If you want users' money, you have to give them something they value.

It must sometimes compromise with business factors.  Uber-database-awesomeness may make the DB better or performance a bit better, but if licensing it costs more than the company has it can't be implemented.

However, if the technical awesomeness ever compromises (as it so often does) to the nontechnical leadership's lack of understanding, THEN you have a problem.  Either the business leadership isn't listening (in which case, find a new job), or you aren't doing your job -- part of which is learning to put your expertise into words that they can understand.


答:
I prefer to keep statements inside an if clause as concise as possible, many times limiting
them to boolean variables with meaningful names, such as:

```<code>bool isCellTypeStatus = //...
if (isCellTypeStatus) { ... }
</code>```

And the boolean variable declaration will span more than one line
so that programmer eye focus will not trail to far away characters.

```<code>bool isCellTypeStatus =
       metadata != null &&
       metadata.TypeEnum != VariantInfoMetadata.CellTypeEnum.Status;
</code>```

It separates two mental evaluations of the condition and the outcome,
to two separate statements, thus increasing the speed another programmer will
consume your code.

Title: AND is better or using Internal "IF"

Body:
I prefer to keep statements inside an if clause as concise as possible, many times limiting
them to boolean variables with meaningful names, such as:

bool isCellTypeStatus = //...
if (isCellTypeStatus) { ... }

And the boolean variable declaration will span more than one line
so that programmer eye focus will not trail to far away characters.

bool isCellTypeStatus =
       metadata != null &&
       metadata.TypeEnum != VariantInfoMetadata.CellTypeEnum.Status;

It separates two mental evaluations of the condition and the outcome,
to two separate statements, thus increasing the speed another programmer will
consume your code.


答: Another factor to add to dasblinkenlight (wich I think it's the best answer) I could add that is more readable to put sentences into a single if than nested if rules which are prone to errors </p>

Title: AND is better or using Internal "IF"


答:
There are two main pursoses for the Me keyword.

You can use it to unambiguously refer to a member of this class.  This allows local variables to use the same name, though this is poor practice.

```<code>Public Class MeExample

    Public Sub New(Name As String)
        Me.Name = Name
    End Sub

    Public Property Name As String
</code>```

And you can use it within the class to use this instance of the object as a parameter in a method call.

```<code>    Protected Overridable Sub OnNameChanged(e As EventArgs)
        NameChanged(Me, e)
    End Sub

    Public Event NameChanged As EventHandler
End Class
</code>```

And to complete the example, here's the full implementation of the Name property so that it raises the NameChanged event.

```<code>    Public Property Name As String
        Get
            Return _Name
        End Get
        Set(value As String)
            If _Name <> value Then
                _Name = value
                OnNameChanged(EventArgs.Empty)
            End If
        End Set
    End Property
    Private _Name As String
</code>```

Title: Does 'Me' in VB.NET refer to the instantiated object only?

Body: Does 'Me' in VB.NET refer only to an instantiation of the type?  Just occurred to me that since I can reference properties in my VB.NET class without using 'Me', that I don't see a reason for using it for this purpose.  Will referencing the variable either way always refer to the actual stored value for the property at runtime?</p>

Body:
There are two main pursoses for the Me keyword.

You can use it to unambiguously refer to a member of this class.  This allows local variables to use the same name, though this is poor practice.

Public Class MeExample

    Public Sub New(Name As String)
        Me.Name = Name
    End Sub

    Public Property Name As String

And you can use it within the class to use this instance of the object as a parameter in a method call.

    Protected Overridable Sub OnNameChanged(e As EventArgs)
        NameChanged(Me, e)
    End Sub

    Public Event NameChanged As EventHandler
End Class

And to complete the example, here's the full implementation of the Name property so that it raises the NameChanged event.

    Public Property Name As String
        Get
            Return _Name
        End Get
        Set(value As String)
            If _Name <> value Then
                _Name = value
                OnNameChanged(EventArgs.Empty)
            End If
        End Set
    End Property
    Private _Name As String


答:
What you have there is perfect.  It's clear and simple.

If you had several cases testing for null, I'd combine them.  This is bad as it tests for (metadata != null) repeatedly.

```<code>if ((metadata != null) && (metadata.TypeEnum != CellTypeEnum.Status))
{ ... }
else if ((metadata != null) && (metadata.TypeEnum != CellTypeEnum.Info))
{ ... }
else if ((metadata != null) && (metadata.TypeEnum != CellTypeEnum.Blank))
{ ... }
</code>```

This is better:

```<code>if (metadata != null)
{
    if (metadata.TypeEnum != CellTypeEnum.Status)
    { ... }
    else if (metadata.TypeEnum != CellTypeEnum.Info)
    { ... }
    else if (metadata.TypeEnum != CellTypeEnum.Blank)
    { ... }
}
</code>```

Or even better for enums:

```<code>if (metadata != null)
{
    switch (metadata.TypeEnum) {
        case CellTypeEnum.Status:
            //do stuff
            break;
        case CellTypeEnum.Info:
            //do stuff
            break;
        case CellTypeEnum.Blank:
            //do stuff
            break;
    }
}
</code>```

Title: AND is better or using Internal "IF"

Body:
What you have there is perfect.  It's clear and simple.

If you had several cases testing for null, I'd combine them.  This is bad as it tests for (metadata != null) repeatedly.

if ((metadata != null) && (metadata.TypeEnum != CellTypeEnum.Status))
{ ... }
else if ((metadata != null) && (metadata.TypeEnum != CellTypeEnum.Info))
{ ... }
else if ((metadata != null) && (metadata.TypeEnum != CellTypeEnum.Blank))
{ ... }

This is better:

if (metadata != null)
{
    if (metadata.TypeEnum != CellTypeEnum.Status)
    { ... }
    else if (metadata.TypeEnum != CellTypeEnum.Info)
    { ... }
    else if (metadata.TypeEnum != CellTypeEnum.Blank)
    { ... }
}

Or even better for enums:

if (metadata != null)
{
    switch (metadata.TypeEnum) {
        case CellTypeEnum.Status:
            //do stuff
            break;
        case CellTypeEnum.Info:
            //do stuff
            break;
        case CellTypeEnum.Blank:
            //do stuff
            break;
    }
}


答:
I'll try to put my experience in this:

Things I'm looking for are:

How should the data be stored in the database? column type? size?

I've been using DECIMAL(10,2) for mysql without problems (8 completes and 2 decimals == 99.999.999,99 == huge amount), but this depends on the money range you'll need to cover. Huge amounts should be taken with extra care (OS max float values for example). On the decimal part I use 2 values to avoid truncate nor rounding values. Taking about money there're few cases where you need more decimals (in which case you need to make sure the user will work with all of them, otherwise is useless data)

How should the data be handling in normal addition, subtraction. multiplication or division?

Work with one currency and a exchange table (with dates). This way you ensure that you'll always have the correct amount saved. An extra: save complete values and create a view with calculation results. This will help you fixing values on the fly

When should I round the values? How much rounding is acceptable if any?

Again, depends on your system money range. Always think in KISS terms unless you need to fall in the currency exchange's mess

Is there a difference between handling large monetary values and low ones?

Depending on your OS and programming languages you always need to check you max and min values

Title: How to handle monetary values in PHP and MySql?

Body:
I've inherited a huge pile of legacy code written in PHP on top of a MySQL database. The thing I noticed is that the application uses doubles for storage and manipulation of data.

Now I came across of numerous posts mentioning how double are not suited for monetary operations because of the rounding errors. However, I have yet to come across a complete solution to how monetary values should be handled in PHP code and stored in a MySQL database.

Is there a best practice when it comes to handling money specifically in PHP?

Things I'm looking for are:

How should the data be stored in the database? column type? size?

How should the data be handling in normal addition, subtraction. multiplication or division?

When should I round the values? How much rounding is acceptable if any?

Is there a difference between handling large monetary values and low ones?

Note:
A VERY simplified sample code of how I might encounter money values in everyday life (various security concerns were ignored for simplification. Of course in real life I would never use my code like this):

```<code>$a= $_POST['price_in_dollars']; //-->(ex: 25.06) will be read as a string should it be cast to double?
$b= $_POST['discount_rate'];//-->(ex: 0.35) value will always be less than 1
$valueToBeStored= $a * $b; //--> any hint here is welcomed

$valueFromDatabase= $row['price']; //--> price column in database could be double, decimal,...etc.

$priceToPrint=$valueFromDatabase * 0.25; //again cast needed or not?
</code>```

I hope you use this sample code as a means to bring out more use cases and not to take it literally of course.

Bonus Question
If I'm to use an ORM such as Doctrine or PROPEL, how different will it be to use money in my code.


答:
If there are multiple conditions for a "success" I prefer it if the conditions are checked in one if block, rather than in nested statements.

But.....

For readability sometimes I prefer this:

```<code>isOfOAge = age >= 16;
isSober = bloodAchohol = 0; // this calculated is wasteful if `isOfOAge` is false
canDrive = isOfAge && isSober;
if(canDrive).......
</code>```

The readability does make for a wasteful check on isSober even if isOfAGe is false. Assuming the boolean calculations are very expensive a nested if could provide for nice variable names as well as the short circuit effect.

My recommendation is DO NOT put this into a coding standard. It's not wrong to nest. It's not wrong to use short circuiting. Both could lead to better readability in certain situations.

Title: AND is better or using Internal "IF"

Body:
If there are multiple conditions for a "success" I prefer it if the conditions are checked in one if block, rather than in nested statements.

But.....

For readability sometimes I prefer this:

isOfOAge = age >= 16;
isSober = bloodAchohol = 0; // this calculated is wasteful if `isOfOAge` is false
canDrive = isOfAge && isSober;
if(canDrive).......

The readability does make for a wasteful check on isSober even if isOfAGe is false. Assuming the boolean calculations are very expensive a nested if could provide for nice variable names as well as the short circuit effect.

My recommendation is DO NOT put this into a coding standard. It's not wrong to nest. It's not wrong to use short circuiting. Both could lead to better readability in certain situations.


问:
How is time calculation performed by a computer?
I need to add a certain feature to a module in a given project regarding time calculation. For this specific case I'm using Java and reading through the documentation of the Date class I found out the time is calculated in milliseconds starting from January 1, 1970, 00:00:00 GMT. I think it's safe to assume there is a similar "starting date" in other languages so I guess the specific implementation in Java doesn't matter.

How is the time calculation performed by the computer? How does it know exactly how many milliseconds have passed from that given "starting date and time" to the current date and time?

答:
There are 60 seconds in a minute, 60 minutes in an hour, and 24 hours in a day.  That's 86400 seconds in a day.  Multiply that by 1000, and you've got the number of milliseconds in a day.

You should now be able to work out the number of days from the beginning of time (January 1, 1970, 00:00:00 GMT).  Multiply that by the number of milliseconds in a day, and you now have the internal number that the computer clock stores to represent the current date/time.


答: The BIOS stores the time for you on the system clock. The OS provides a system function to retrieve the time in their format (Unix systems, match the Java framework, Windows uses a different "Epoch" --the start date-- but the Java Runtime Translates the result to match what it expects.</p>

Title: How is time calculation performed by a computer?

Body:
I need to add a certain feature to a module in a given project regarding time calculation. For this specific case I'm using Java and reading through the documentation of the Date class I found out the time is calculated in milliseconds starting from January 1, 1970, 00:00:00 GMT. I think it's safe to assume there is a similar "starting date" in other languages so I guess the specific implementation in Java doesn't matter.

How is the time calculation performed by the computer? How does it know exactly how many milliseconds have passed from that given "starting date and time" to the current date and time?


答:
I think it's safe to assume there is a similar "starting date" in other languages so I guess the specific implementation in Java doesn't matter.

Pretty much all computers use this or a similar variation of Unix time.

How is the time calculation performed by the computer? How does it know exactly how many milliseconds have passed from that given "starting date and time" to the current date and time?

Typically, a computer includes one or more hardware devices that count time, usually based on a crystal oscillator (the same as used in most modern clocks). There are serveral variations/standards for such devices:

Programmable Interval Timer

Real-Time Clock

High Precision Event Timer

These timer devices usually have a separate battery that allows them to continue running when the computer is switched off. The computer interacts with them in two ways:

When it boots up, it reads the current time from the device

At regular intervals, the device causes a hardware interrupt that is handled by the OS to do any time-dependant tasks.

However, the crystal oscillators used in the hardware timers have limited precision and over time drift away from the correct time. For applications where it's important to have an accurate clock (or just to avoid the hassle of having to manually adjust it), computers
regularly synchronize their time via the Network Time Protocol with a time server, which is connected (directly or indirectly) to a high-precision atomic clock.


问:
Why aren't young programmers interested in mainframes?
A key issue with mainframes is that the cohort of supporting programmers is dwindling. While normally this wouldn't be a problem in that a falling supply of programmers would be offset by an increasing amount of salary those causing a rising supply of programmers via the law of supply and demand, I'm not sure this is really happening for mainframes.

While they still form critical infrastructure for many businesses, the simple fact is there isn't an adequate number of young programmers coming up along to keep the support population populated.

Why is this? What makes mainframes unattractive to young programmers?

答:
Two reasons to consider joining the mainframe workforce:

It pays well

There are tons of openings

The greying workforce in the mainframe field is, and will be creating huge numbers of openings in the field.

I work for a large financial company, and within the next 5 years, we'll be losing about 30% of our workforce to retirement.  That number will increase exponentially in 10-15 years.

More reasons:

I've been in the field for 25+ years and have never been bored.

Less competition for jobs.

Stop complaining about the technology (see some posts above)... it may be old, but in many ways it's light years ahead of open systems.  HTML - give me a break.  It's so similar to Basic which I took 30 years ago in college.  We're way beyond that.

The mainframe is fast and reliable, tried and true.

Try Systems Programming if you're very bright and love trouble shooting.

As a team leader, I wish I could find young, trained technicians to fill openings.

Did I mention it pays well?

Other mainframe career options besides software development - hardware engineers, storage techs, networking, and more.

It's fun, exciting, challenging, and there's great career growth.

Stop thinking of mainframe as just old technology - check it out and verify all that I've said.

Also check out IBM's System z Academic Initiative.


答:
In short, for C# language it is better to keep it as is.

The evaluation of your mentioned statement will stop and get false value once metadata is null.

Nested if statements are hard to maintain, and it is better to skip them if application logic does not require them. Or in another words, there might be a number of ways how to formulate nested if statements in more readable and maintainable syntax.

Title: AND is better or using Internal "IF"


答:
So I think my understanding is correct that setting a private variable is just a construct to be able to implement the get and set pattern?

It is not true. Private setters are encapsulating value and DO NOT allow direct access to the property of the class. It is one of the programming principles widely used in  Domain driven development.

Title: How get and set accessors work


答:
I'd measure a project's size by how difficult it is to see the whole project as a single big picture.  For example, I have an exploratory/prototyping codebase for a machine learning problem I'm working on.  It's only 5k lines of code, but it feels like a huge project.  There are tons of configuration options that interact in unpredictable ways.  You can find just about every design pattern known to man somewhere in the codebase to manage all that complexity.  The design is often suboptimal because the thing grew a lot by evolution and isn't refactored as often as it should be.  I'm the only one that works on this codebase, yet I'm often surprised by how things interact.

On the other hand, one of my hobby projects has about 3-4x as much code, and yet it feels a lot smaller because it's basically a library of mathematical functions that are mostly orthogonal to each other.  Things don't interact in complex ways, and it's pretty to understand each function in isolation.  It's easy to see the big picture to the extent that there is one, because there's not much of one to see.

Title: What makes a project big?

Body:
Just out of curiosity what's the difference between a small, medium and large size project? Is it measured by lines of code or complexity or what?

Im building a bartering system and so far have about 1000 lines of code for login/registration. Even though there's lots of LOC i wouldnt consider it a big project because its not that complex though this is my first project so im not sure. How is it measured?


问:
Should curly braces appear on their own line?
Should curly braces be on their own line or not? What do you think about it?

```<code>if (you.hasAnswer()) {
    you.postAnswer();
} else {
    you.doSomething();
}
</code>```

or should it be

```<code>if (you.hasAnswer())
{
    you.postAnswer();
}
else
{
    you.doSomething();
}
</code>```

or even

```<code>if (you.hasAnswer())
    you.postAnswer();
else
    you.doSomething();
</code>```

Please be constructive! Explain why, share experiences, back it up with facts and references.

答:
Simple answer: what is easier to debug ?

```<code>// Case 1:
void dummyFunction() {
  for (i = 0; i != 10; ++i) {
    if (i <= 10)
      std::cout << "i is: " << i << "\n";
      std::cout << 10 - i << " steps remaining\n";

      // Some hard work here
      // which is really hard
      // and does take some screen estate
    }
    else
      std::cout << "We'll never get there";
  }
} // COMPILER ERROR HERE

// Case 2:
void dummyFunction()
{
  for (i = 0; i != 10; ++i)

    if (i <= 10)
    {
      std::cout << "i is: " << i << "\n";
      std::cout << 10 - i << " steps remaining\n";

      // Some hard work here
      // which is really hard
      // and does take some screen estate
    }
    else
      std::cout << "We'll never get there\n";
  }
} // COMPILER ERROR HERE
</code>```

In which case did you diagnose the issue first ?

I don't care much for personal preferences (there are many other styles, including whitesmith and al.) and I don't care much... as long as it doesn't hamper my ability to read the code and debug it.

As to the "waste space" argument, I don't buy it: I tend to add blank lines between logical groups anyway to make the program clearer...

Body:
Simple answer: what is easier to debug ?

// Case 1:
void dummyFunction() {
  for (i = 0; i != 10; ++i) {
    if (i <= 10)
      std::cout << "i is: " << i << "\n";
      std::cout << 10 - i << " steps remaining\n";

      // Some hard work here
      // which is really hard
      // and does take some screen estate
    }
    else
      std::cout << "We'll never get there";
  }
} // COMPILER ERROR HERE

// Case 2:
void dummyFunction()
{
  for (i = 0; i != 10; ++i)

    if (i <= 10)
    {
      std::cout << "i is: " << i << "\n";
      std::cout << 10 - i << " steps remaining\n";

      // Some hard work here
      // which is really hard
      // and does take some screen estate
    }
    else
      std::cout << "We'll never get there\n";
  }
} // COMPILER ERROR HERE

In which case did you diagnose the issue first ?

I don't care much for personal preferences (there are many other styles, including whitesmith and al.) and I don't care much... as long as it doesn't hamper my ability to read the code and debug it.

As to the "waste space" argument, I don't buy it: I tend to add blank lines between logical groups anyway to make the program clearer...


问:
Single statement if block - braces or no?
Which is better/more generally accepted?

This:

```<code>if(condition)
{
  statement;
}
</code>```

Or:

```<code>if(condition)
  statement;
</code>```

I tend to prefer the first one, because I think it makes it easier to tell what actually belongs in the if block, it saves others from adding the braces later (or creating a bug by forgetting to), and it makes all your if statements uniform instead of some with braces and some without.  The second one, however, is still syntactically correct and definitely more compact.  I'm curious to see which is more generally preferred by others though.

答: No braces. If some other programmer adds a second statement to my code it's no more my fault than if I let someone drive my car and they went over a cliff.</p>


问:
How do you check bugs on your client's PC's?
It seems like there are a plethora of methods for dialing in and checking out what's going on on a client's PC.  But they seem to boil down to just 2. Dialing in and checking it out with VNC and Remote Desktop.

VNC seems abysmal with more graphics laden OS's and it sometimes is too much to ask to get a access to a terminal server (especially when the client doesn't have one).

What other methods are out there for connecting with clients to diagnose and fix bugs they they can reproduce, but may not necessarily be able to adequately describe over the phone.

Alternatives to VNC and Remote Desktop are appreciated, but really looking for a better way to do it than just to dial in and check it out - or the most effective way to use VNc and Remote Desktop.

答: I've been in a situation when there is nobody to even describe you what happened: ATM's (cash machines) running Windows. The best way of diagnosing problems for us was very, very detailed logging. One way is shipping two versions of the binary, one of which is with logging enabled. You switch the binaries when needed. For environments like C# and Java I believe there are tools that can provide non-intrusive function call journalling (i.e. you don't need to modify the code).</p>


问:
Most logically consistent way to create methods of the form a affects b?
I have a common scenario where I have an object (a) that logically affects another object (b), like a makes a note on b, or a marks b as disabled (usually a is a user object of the system and b is some kind of business object like a customer or an appointment).

In the past, the method was on the affected object like:

```<code>customer.Disable(user); // user is marking the customer as disabled
</code>```

... but it doesn't read well (it appears backwards). The opposite:

```<code>user.Disable(customer);
</code>```

... reads better, but there's something about it that I can't put my finger on that just doesn't seem right. The only other option is to have a static intermediary:

```<code>ThirdPartyClass.DisableCustomer(customer, user);
</code>```

... but the domain objects end up becoming more like DTOs and I prefer the domain model approach because it makes more sense.

So the question is: which makes the most sense? Is there an option I haven't considered? Who actually owns an operation like this?

Edit

With the second option, the actionable objects in the system (users usually) end up becoming huge because the users of the system are the ones that pretty much do and affect everything.

答:
If your user objects are taking on so many responsibilities that it feels like they have too many "user.DoFooOnBar(bar)" methods, then you may be looking at a god object.  You might feel better by either using interfaces to break up the roles of user into domain-specific pieces, or using composition to do the same.

Interfaces

You'd have an ICustomerController interface that User implements, then when you need the users to disable customers, you cast the customer into an ICustomerControl and can use ICC.DisableCustomer(customer).  That provides a move natural reading because the customer is being manipulated, not by a user, but by "something which manipulates customers."

It also leaves you more flexible to let things that aren't users update customers, if you needed to.

Composition

Just an extension from the last idea: instead of users being ICustomerControllers (IS-A) they would own an ICustomerController (HAS-A).  So now the call reads as user.CustomerController.Disable(customer).  Again, this makes it clear that users are acting in a certain capacity (to affect customers) and only against that one domain of objects (customers).

You hadn't mentioned that problem, but a method like user.Disable() could seem to affect anything, even the user itself.  Either of the above corrects that.


答:
How about

```<code>customer.SetDisabledBy(user);
</code>```

or if using C# 4.0 or a different language with similar capabilities:

```<code>customer.SetDisabled(by: user);
</code>```

or if you're using C# 3.5 or newer, you can write the following:

```<code>user.DisableCustomer(customer);
</code>```

while having the DisableCustomer method be an extension method sitting in a class called CustomerActions which sits together with the Customer class. That way, when you're using the Customer namespace, User will have that extension method. When you're not using it, it's gone. User is no longer a god object but the intermediary class is nowhere to be found in the code. You might also have an OrderActions class which will provide user.CancelOrder(order), etc.

Good question, made me think!

Title: Most logically consistent way to create methods of the form a affects b?

Body:
I have a common scenario where I have an object (a) that logically affects another object (b), like a makes a note on b, or a marks b as disabled (usually a is a user object of the system and b is some kind of business object like a customer or an appointment).

In the past, the method was on the affected object like:

```<code>customer.Disable(user); // user is marking the customer as disabled
</code>```

... but it doesn't read well (it appears backwards). The opposite:

```<code>user.Disable(customer);
</code>```

... reads better, but there's something about it that I can't put my finger on that just doesn't seem right. The only other option is to have a static intermediary:

```<code>ThirdPartyClass.DisableCustomer(customer, user);
</code>```

... but the domain objects end up becoming more like DTOs and I prefer the domain model approach because it makes more sense.

So the question is: which makes the most sense? Is there an option I haven't considered? Who actually owns an operation like this?

Edit

With the second option, the actionable objects in the system (users usually) end up becoming huge because the users of the system are the ones that pretty much do and affect everything.

Body:
How about

customer.SetDisabledBy(user);

or if using C# 4.0 or a different language with similar capabilities:

customer.SetDisabled(by: user);

or if you're using C# 3.5 or newer, you can write the following:

user.DisableCustomer(customer);

while having the DisableCustomer method be an extension method sitting in a class called CustomerActions which sits together with the Customer class. That way, when you're using the Customer namespace, User will have that extension method. When you're not using it, it's gone. User is no longer a god object but the intermediary class is nowhere to be found in the code. You might also have an OrderActions class which will provide user.CancelOrder(order), etc.

Good question, made me think!


问:
Is a university education worth it for a good programmer?
I've been doing design and programming for about as long as I can remember. If there's a programming problem, I can figure it out. (Though admittedly Stack Overflow has allowed me to skip the figuring out and get straight to the doing in many instances.) I've made games, esoteric programming languages, and widgets and gizmos galore. I'm currently working on a general-purpose programming language. There's nothing I do better than programming.

Is a university education really more than just a formality?

答:
Allow me to relate my story in condensed form.

I started programming at an early age.  Seemed to have a natural aptitude for it, certainly enjoyed it.  Learned by struggling through stuff all through middle & high school.

Got out of high school and did .. um .. other things.  Manual labor, living a young person's life, etc.

A few years later I decided to re-focus.  Worked on my 2 year degree in spare time, aced that (literally).  Got employed back in the field, making a decent wage - nothing great in any sense, but considerably better than manual labor.

Decided to go to our state's major university, good technical program.  Enrolled for Computer Engineering, so as to indulge my electronics fascination more and avoid too much repetitive programming stuff I already knew.

Well ... let me just say ... holy tedious.  Now, some of this could simply be ascribed to me and how I handled it, but the year I spent in that college was a huge waste of time and money.

I spent the year doing learning nothing and spending my time "completing" homework that was so far below my skill level it was absurd.  I spoke to several professors and college guidance counselors and across the board the word was, in effect, "toe the line, go through the motions, sorry that's just the way it works" or "maybe you don't know as much as you think you do and should pay more attention." (though if I do say so myself the latter point was totally invalid).

At the end of the year, I reviewed my progress towards my degree.  Having already completed an A.A. degree, with an abundance of credits, and now having completed a full year in the university, I was still - realistically, due to how I had to schedule classes, prerequisites, etc. - 3 full years away from my B.S. in Comp Eng. Not to mention $10,000 in debt (for year 1, it was only going to get worse each additional year [less grants vs loans]).

So I quit.

And I don't look back.  And I won't go back.

I've remained employed in my field throughout and since then.  Never has my lack of a degree been a barrier to finding employment, and I feel the jobs I've been able to get are for quality shops with above average wages.

So .. long story short again, sounds like school might not be the thing for you, like it wasn't for me.


问:
What makes a project big?
Just out of curiosity what's the difference between a small, medium and large size project? Is it measured by lines of code or complexity or what?

Im building a bartering system and so far have about 1000 lines of code for login/registration. Even though there's lots of LOC i wouldnt consider it a big project because its not that complex though this is my first project so im not sure. How is it measured?

答:
LOC is notoriously inaccurate for a lot of measurements, but I think you're trying to measure something that there really isn't an accurate way to measure.  Perhaps an alternative might be cyclomatic complexity.

Ultimately though, I think "bigness" of a project is difficult to quantify.  It's almost like asking how you determine if a dog is big or not.  Not only are there multiple ways to measure it (mass, volume, etc), but I personally don't find it very useful.  Reality is that my criteria is probably going to be something like "How likely am I to run from this dog if I see it in a dark alley?"

And for the record, I generally wouldn't consider 1k lines of code to be a lot.  It would be a sizable chunk of code, but it wouldn't be that much in the grand scheme of things.  Of course, I suppose it does depend on the language.  For instance, 1k lines of code is much less code in a language like C than it is in a language like Pyhon.

Title: What makes a project big?


问:
How is your working time distributed between coding and thinking?
...in percentage. For example 60/40 or 90/10 or 100/0.

My hypothesis is that the bigger the proportion of time you spend thinking the smaller your code can be as a result (and the less time will be needed to write it down). Think more, write less, in other words. Do you think it is true?

As a side note, I think in typical software companies thinking is not part of the culture anyway: you are usually supposed to be sitting there at your computer typing something. You will almost definitely be noticed by your managers if you wander about with a blank look thinking over your next steps with your code. Too bad.

答:
How is your working time distributed between coding and thinking?

THEY ARE THE SAME

END TRANSMISSION


问:
What is the best objective way to measure language popularity trends? (What's better than TIOBE?)
The best way to get data on computer language popularity that I know is the TIOBE index.  But everyone knows that TIOBE is hopelessly flawed.  (If someone provides a link to support this, I'll add it here.)

So is there any data on programming language popularity that is generally considered meaningful?  The only other option I know is to look at the trends at indeed.com, which is inherently flawed, being based on job postings.

It isn't like I would make a future language decision solely based on an index, but it might provide a useful balance to the skewed perspective one obtains by talking to ones friends and colleagues.

To illustrate that bias, I'll point out that based on the experience of those I personally know, the only languages used professionally today (in order of popularity) are Java, C#, Groovy, JavaScript, Ruby, Objective C, and Perl.  (Though it is evident that C, C++ and PHP were used in the past.)

So my question is, everyone bashes TIOBE, but is there anything else?  If so, can anyone explain how we know the alternative has better methodology?  Thanks.

答:
The only way I can see is general survey of the population.  Something like a phone survey used by political pollsters.  You'd probably have to call 100,000 random people to reach enough people who report themselves as programmers to make the result valid.  Then ask them what they use.

The reason you need to do this is that every online indicator is self-selecting and thus incorrect.  Tiobe, google searches, SO posts, whatever.  Nor can you look at coference attendence or magazine subscriptions.

If you want actual usage statistics, you need to survey the general population.


问:
Language agnostic programming books
Are there any great programming or software development books that are language agnostic?  Why should I read it?</p>

答:
Code - Microsoft Press.

It's an excellent causal computer book that takes you from Morse code to Binary and back.

Title: Language agnostic programming books


答: Its strange, reading a lot of these answers I find I view the size of a project very differently. Perhaps it is my working in a large corporation but I tend to view the size of a project as more of a scale of its visibility/desirability to its clients (depending on your area of work these can be coworkers or actual paying customers).</p>

Title: What makes a project big?


答:
Team Viewer is nice for the informal, occasional support call without having to poke firewall holes etc.  http://www.teamviewer.com/

A mechanism which can send you the latest logs in case of problems (either automatically when an exception happens, or manually when the user press a button) is really nice.  This can be done as email, over Instant Messenger (like jabber or msn) or an upload site e.g. at Google Application Engine.

I do Java, and the single most important thing to get is the Exception stack trace from the point of failure, and the second most important to get the arguments passed on the way down in the stack trace (but that requires careful programming with try-catch around all methods).

Title: How do you check bugs on your client's PC's?

Body:
It seems like there are a plethora of methods for dialing in and checking out what's going on on a client's PC.  But they seem to boil down to just 2. Dialing in and checking it out with VNC and Remote Desktop.

VNC seems abysmal with more graphics laden OS's and it sometimes is too much to ask to get a access to a terminal server (especially when the client doesn't have one).

What other methods are out there for connecting with clients to diagnose and fix bugs they they can reproduce, but may not necessarily be able to adequately describe over the phone.

Alternatives to VNC and Remote Desktop are appreciated, but really looking for a better way to do it than just to dial in and check it out - or the most effective way to use VNc and Remote Desktop.


答:
It'd be interesting to survey a bunch of major open source code repositories and measure how many lines of new code in each language are committed each week.  Not sure the actual numbers would tell you anything, but the trend over time could be very revealing.

I like this as a measure as it's more to do with how much actual real work is getting done in the language rather than how confused people are by shiny-new-thing (which is what google/SO search/question rates are heavily influenced by I think).

Of course there are all sorts of problems with my proposed metric too; FOSS-world is a subset of real world, some languages gravitate towards particular repositories (which you might miss), some languages are more efficient, and all the other problems associated with LOC metrics.  Maybe just "number of commits" in each language would be more useful.

Anyone know if such statistics are available anywhere today ?  Seems like something Ohloh/Koders/Krugle should be able to do.

Title: What is the best objective way to measure language popularity trends? (What's better than TIOBE?)

Body:
The best way to get data on computer language popularity that I know is the TIOBE index.  But everyone knows that TIOBE is hopelessly flawed.  (If someone provides a link to support this, I'll add it here.)

So is there any data on programming language popularity that is generally considered meaningful?  The only other option I know is to look at the trends at indeed.com, which is inherently flawed, being based on job postings.

It isn't like I would make a future language decision solely based on an index, but it might provide a useful balance to the skewed perspective one obtains by talking to ones friends and colleagues.

To illustrate that bias, I'll point out that based on the experience of those I personally know, the only languages used professionally today (in order of popularity) are Java, C#, Groovy, JavaScript, Ruby, Objective C, and Perl.  (Though it is evident that C, C++ and PHP were used in the past.)

So my question is, everyone bashes TIOBE, but is there anything else?  If so, can anyone explain how we know the alternative has better methodology?  Thanks.


答:
Complexity which may be estimated in a few ways:

Budget.  A project with a budget of $10,000,000+ is probably quite different from one that is under $10,000 for example.  This can include labor, software, hardware, and other costs incurred in doing a project.

Person hours of work to complete the project.  Will it take a million hours or something else?  This could also be seen as a time line factor where some projects may take years that I'd say were big compared to others that may take less than a week.  Note that the person hours can be misleading as someone may think by doubling the staff so there are twice as many working on the project then the schedule can be sliced in half which rarely would work to my mind.

Amount of hardware, other systems and people using what the project is building.  If something is tying into 101 systems then it is likely to be more complicated that if it stands alone and doesn't tie into anything else.

While requirements can sound like a nice way to measure this, there are often more requirements that will be found as a project is done assuming a non-Waterfall methodology I believe.

Title: What makes a project big?


答:
I think you only need to (and arguably only should) be familiar enough with the business side to be able to get into the business user's head.  What you're experiencing isn't necessarily any fundamental difference between code and product.  It's a matter of varying objectives.

Business people generally have the objective of building a product that people want.  Technies have the objective of building maintainable, non-buggy code that can scale with the company.

In other words, business types will scoff at technical requirements because that's their job.  They don't get paid to make sure good code gets written.  They get paid to build a cool product.  You, on the other hand, aren't paid to create a cool product.  You're paid to ensure good code gets written.

My advice is to take a note from the business people.  You need to focus on doing your job correctly.  If you cut corners and put out a buggy product to suit them, you're going to get the blame.  In fact, I'd argue that you deserve the blame.  It's your job to stick up for technical requirements.

Now, it's tempting to blame the business people for not listening to you.  They are treating you unfairly, but that's not really the point.  The point is how you react to that situation.  Let me share a secret of working for software companies with you:  the code is the product.  That might sound obvious, but we forget it so many times.  Thus, the key is to realize that you're helping business people to make a better product.  Once you realize that, it becomes easy to phrase things in their terms:  "We can do that, but it will make a buggy product that no one will buy," or "We can do that, but it will jeopardize our ability to put products out faster in the future".

I'm not suggesting that bad work environments where you can never get the business people to listen to you don't exist.  I'm suggesting that the way to handle this situation is to stick to your guns while realizing that the other side has differing goals from you.   The correct way to handle it is to find a solution that benefits both sides.

Title: Should I be involved in my project's business side?

Body:
Before my current job, I was always involved in the technical aspects of a project like:

architecture

design

performance

security

etc

Now I'm team lead of a project that's a game on a web site (not mine) and somehow got involved in the business side of the project:

what users expect

ads showing in which pages of the site

mechanics of the game

etc

But I quite don't agree with business people's (customer or product owner if you like) decisions of the directions of the site. Of course I raise my concerns, some of them are taken into account, most of them aren't.

I continue my work as usual as I like working here but I feel like the product would be better than what it is now. I think that's because my goal is to make an interesting and challenging game, and theirs is to attract as many people and earn money as possible (it's a paid game). Have you guys ever happened to be in this kind of situation? What are your experiences?


答:
We have had good success teaching end users to respond to unhandled exceptions (which are thankfully rare, but which plagued one installation because of networking issues) with these steps (Windows only)

press Shift+PrntScrn

Open Word

press Ctrl+V

Return to the application and click the More Info button

Click in all the words that don't make any sense, and press Ctrl+A Ctrl+C

Return to Word

Click below the picture and press Ctrl+V

Save the file and email it to me.

This lets you see the exception, what they were doing in the background, what data they were looking at (employee id or store id or whatever) and other useful information. I have debugged a lot of things after the fact armed with these screenshots and the stack trace.

The big difference between this and GoToMeeting, WebEx etc (which we use with these clients for demos and training) is that they don't need to repro the bug on demand. When they are working away and the bad thing happens, they follow these steps and we make it all better. (Sometimes by calling their IT rather than changing our code, but honestly the end users don't care.) The impact on them is minimal.

If I needed to, I might also teach them Problem Steps Recorder on Windows 7 which is way cool if you've never used it. But the screenshot and stack track approach carries a LOT of information.


问:
The Art of Computer Programming - To read or not to read?
There are lots of books about programming out there, and it seems Code Complete is pretty much at the top of most people's list of "must-read programming books", but what about The Art of Computer Programming by Donald Knuth?  I'm a busy person, between work and a young family I don't have a ton of free time, so I have to be picky about how I use it.

I'm wondering - has anybody here read 'TAOCP'?  If so, is it worth making time to read or would some other book or more on-the-side programming like pet projects or contributing to open source be a better use of my time in terms of professional development?

DISCLAIMER - For those of you who sport "Knuth is my homeboy" t-shirts, don't get me wrong - I want to read it, but I'm just wondering if it should be right at the top of my priority list or if something else should come first.

答:
TAOCP is an utterly invaluable reference for understanding how the data structures and algorithms that we use every day work and why they work, but undertaking to read it cover-to-cover would be an extraordinary investment of your time.

As one family man to another, spend the time with your kids.


答:
It's probably more important that you do that problems in the book than you just read it.  That will require a lot of time.

He's up to like 4 volumes and 5 fascicles (whatever those are) so completing the books would be probably better than a university course in the fundamentals of computer science and make you nearly the best programmer ever.

Since you've got a young family, like me, you gave me a pretty swell idea. I'd buy the books one at a time and teach through'em to your kids.

Title: The Art of Computer Programming - To read or not to read?

Body:
There are lots of books about programming out there, and it seems Code Complete is pretty much at the top of most people's list of "must-read programming books", but what about The Art of Computer Programming by Donald Knuth?  I'm a busy person, between work and a young family I don't have a ton of free time, so I have to be picky about how I use it.

I'm wondering - has anybody here read 'TAOCP'?  If so, is it worth making time to read or would some other book or more on-the-side programming like pet projects or contributing to open source be a better use of my time in terms of professional development?

DISCLAIMER - For those of you who sport "Knuth is my homeboy" t-shirts, don't get me wrong - I want to read it, but I'm just wondering if it should be right at the top of my priority list or if something else should come first.


答:
If you are curious, then do it, but it takes quite some time to digest so you need to take your time.

Do you have a commute where you can read - that would be perfect.

EDIT:  You might find this preview of a small part of Volume 4 interesting:  http://www-cs-faculty.stanford.edu/~uno/fasc1a.ps.gz

(note:  compressed postscript)


答: Having recently undertaken this very task, I can say that the way he writes is very enjoyable and the problems are labeled (according to difficulty) very aptly.  Get the first volume and read chapters 1 and 2 and see how you like it.</p>


答:
+10 on the family/children comment.  I try and do most reading whilst enduring on red-eye flights to customers.

But...yes, very much worth the read.  No reason to read linearly, instead skim and choose a few topics of interest.


答:
Substitute "the encyclopedia" in your question for every reference to TAOCP, and I think the answer should be obvious.  Because in a lot of respects, that's what TAOCP is.

There's a (possibly apocryphal) story about Steve Jobs meeting Knuth.  The first thing Jobs said to him was "It's a pleasure to meet you Dr. Knuth.  I've read all your works!". Knuth's response was "You're full of shit":  http://www.folklore.org/StoryView.py?project=Macintosh&story=Close_Encounters_of_the_Steve_Kind.txt


问:
How should I create lo-fi (non-interactive) UI prototypes?
I'm currently working on throwing together some basic prototypes, partly to gather requirements and partly to design the final UI.

At the moment I'm trying building up the screen using Post-it notes, with yellow notes for information and pink for actions (buttons or menus). The idea being that you can easily move, remove and add information. But I'm sure there are more efficient methods out there.

What is the recommended way for developers to efficiently create non-interactive UI prototypes?

And why?

I tried some pen, paper and Post-it note versions and they went down like a lead balloon (likely my drawing skills). In the end I used Balsamiq, which thus far is liked by most users and they get it is prototype. Alas, some people are still having problems with the idea that first one should get an idea of what the application should do via some lo-fi prototypes and really want to "see something on the screen" before committing to anything.

答:
The Pencil Project is a Firefox addin that does nice and simple mockups.

Pencil provides various built-in shapes collection for drawing different types of user interface ranging from desktop to mobile platforms. Starting from 2.0.2, Pencil is shipped with Android and iOS UI stencils pre-installed. This makes it even easier to start protyping apps with a simple installation.

Popular drawing features are also implemented in Pencil to simplify the drawing operations...


问:
Which library/framework did you ditch as being too complex for the problem it is solving?
... and coded the functionality "manually"?

As a rather metaphorical example, you'd hardly need a library for solving quadratic equations, although such libraries do exist and someone takes them seriously.

As a more questionable case, depending on the circumstances I may ditch jQuery (for example when I don't need to support some stone age browsers): it does simplify some things but it adds another layer of complexity and unreliability to DOM. And overusing jQuery leads to absurd problems, such as one seen recently on SO: how do I assign an empty href to an a tag with jQuery? Turned out it was a HTML question, not even JavaScript.

Another absurd case and yet non-obvious for many is using some templating engine/language built on top of another templating system: PHP. Third level of templating anyone?

And another one: sometimes just spitting out XML with (figurally) printf is far easier than doing it with some monstrous XML engine.

Any other cases from your experience?

答:
Log4Net

The library is good, but the documentation is horrendous.  It was overkill for what I wanted to do.

I used Trace instead.


答:
As was stated in other questions, this is a personal decision, and as to if a University degree is worth it for you depends on what you want to do.

My personal story, just turned 50, I make a good living programming, and I've yet to get a degree.  So the truth is you don't "need" a degree to make a living programming.  That being said, I'm still pursuing a degree, even though I have kids older than many of the students in the class.  Let me rephrase that, I'm pursuing "education", whether I get the degree or not has little importance at this point.

What I want to do is learn.  You can always learn on your own, but the limits to being able to do this increase as the complexity of the subject increases.  Taking classes allows me to push myself further than I would do on my own.  As I go along I find I'm just not as interested in learning yet another language, rather I want to learn deeper concepts.  One goal I have is to be able to answer questions in https://cstheory.stackexchange.com/ Heck, I'd be happy to just be able to understand most of them.  This area may not interest many programmers.

One important factor to consider when weighing over your choices is how much harder it gets to follow through with going back to school as you get older.  Life starts getting in the way, relationships, kids, mortgages, etc. hamper your ability to make these kind of choices.

Title: Is a university education worth it for a good programmer?

Body:
I've been doing design and programming for about as long as I can remember. If there's a programming problem, I can figure it out. (Though admittedly Stack Overflow has allowed me to skip the figuring out and get straight to the doing in many instances.) I've made games, esoteric programming languages, and widgets and gizmos galore. I'm currently working on a general-purpose programming language. There's nothing I do better than programming.

Is a university education really more than just a formality?


答:
Much of MS enterprise library and most 3rd party controls for .net have left me with this feeling after a bit of use.

Your mileage may vary

Title: Which library/framework did you ditch as being too complex for the problem it is solving?

Body:
... and coded the functionality "manually"?

As a rather metaphorical example, you'd hardly need a library for solving quadratic equations, although such libraries do exist and someone takes them seriously.

As a more questionable case, depending on the circumstances I may ditch jQuery (for example when I don't need to support some stone age browsers): it does simplify some things but it adds another layer of complexity and unreliability to DOM. And overusing jQuery leads to absurd problems, such as one seen recently on SO: how do I assign an empty href to an a tag with jQuery? Turned out it was a HTML question, not even JavaScript.

Another absurd case and yet non-obvious for many is using some templating engine/language built on top of another templating system: PHP. Third level of templating anyone?

And another one: sometimes just spitting out XML with (figurally) printf is far easier than doing it with some monstrous XML engine.

Any other cases from your experience?


答:
No, it should not be at the top of your priority list. I've got a full set and I have NOT read the whole thing. I've used it (so far) as a good reference on certain problems (it was invaluable in my understanding of randomness and the testing of random generators, for instance). Whenever a CS topic comes up that I don't have a REALLY good handle on, I tend to grab the relevant bit of TAOCP as a good step in my understanding.

If you do decide to read it, more power to you, and I definitely recommend taking it in small chunks. Don't be afraid to skip around and look at whatever is most interesting first.


答:
If you aren't involved in the business side, you're doing only what other people tell you to.  If you are, then you have at least some slight influence on the project requirements.

You really should have some idea of how what you do fits into your business (and your client's business, if you're doing software for a client), if you want to make intelligent suggestions.  If you are perceived as making impractical suggestions, you'll just have more trouble getting any practical ones accepted.  Some people have the social skills to deal with that situation, but the typical techie, the one most likely to have this problem, almost certainly doesn't.

It also depends on what you want to do with your career.  If you want to develop software for the rest of your life, that's cool.  It's what I like.  If you ever want to move into management, including software management, you will have to understand the business.


答:
Recently I've been working on a scripting language compiler that I can use within my applications.  I've used others, but none do exactly what I need them to do.  So I figured why not try to write my own?  It may be a year or two before its really suitable for general use, but thats ok.  Plus, its a great learning experience.

Another 'roll my own' solution is the pieces used to translate my applications.  There's existing libraries, but I didnt like any of them.  So I made my own.

And Delphi's database components.  I hate'em.  Always have.  So I made my own database interface that works the way I want one to work (and exactly as the one I made for PHP works, making coding across languages easier).

Basically, when given an option, I typically end up making my own library.


答:
The later versions of vnc have some options to correct many of the conflicts with excessive fancy render features.

On the other hand, I have not had to do that in a long time as I have been doing web development, so some good logging and an htmlfilter that can intercept the html sent to the client is usually all I need.


答:
Spitting out HTML on a debug port on an app. I needed some simple way to get some current data (with automatic refreshing). Pulling in a library to format it would have been good, but it was easier to just printf it.

I've also rejected on library for another: We use a large, complex XML library in most of our stuff. After spending 4 hours one day trying to get it working in a new app, I just said 'bag it', and pulled in TinyXML. It's no where near as powerful, but it takes a LOT less effort to make it do simple stuff.


答:
In the distant past I worked at a game company.  They had all the clever technology to develop something with the mass market appeal of Quake (and ahead of that product being released) but due to a lack of any marketing input/control chose to develop the kind of game the developers wanted to play; a geektastic extravaganza with a convoluted literary plot and where almost every key (ok, exaggeration) on the keyboard did something.  The game was well received critically and is now generally regarded as a classic; the creating team can certainly be applauded for remaining true to their vision... but they never managed to create the blockbuster game the company actually really needed to indulge this sort of "artistic integrity" project (they're not around any more).

I've worked for other "better mousetrap" companies too (hint: the world doesn't need a better mousetrap) which thought they could prevail in the market by superior technology and development skills alone.  None of them have succeeded with what they were trying to do (not with their original idea, anyway).  Believe me: listen to and respect your marketing people (the good, experienced ones at least), and they'll listen to and respect you.


答: ASP.NET WebForms - Although as .NET web developer it's been my bread and butter for a long time, since I started using the MVC framework (and coming from a PHP / Smarty Template environment) -- you realize that sometimes there are just better ways to do web development and the abstraction that it uses is overkill and leaky.


问:
What non-programming books should a programmer read to help develop programming/thinking skills?
There are a lot of questions about what programming books should be on the programmer's bookshelf. How about non-programming related books that can help you become a better programmer or developer? It would also be interesting to know why they would help.

My first choice would be Sun Tzu's "Art of War" (however cliché), because it made it obvious that the success of any project depends on the strength of its weakest link (and warfare is a big project).

答:
I'm going to recommend a triplet of books that are about being a programmer (rather than programming), or a leader of programmers. While all are over 30 years since their original publication all are (especially with updates, commentary in their anniversary editions):

"The Mythical Man Month", Brooks.

"Peopleware", BeMarco & Lister.

"The Psychology of Computer Programming", Weinberg (the PL/1 code is easy to follow, and can easily be applied to edge cases of any programming language).


答:
System.Text.RegularExpressions

Regex is so complex and so slow.  I'll very rarely use Regex and usually write my own text parsing and matching.

Occasionally I'll find Regex useful for really complex matching.


答:
We use webex for this purpse; we start the meeting, make them presenter and then they can share the desktop.  Haven't had any problems with it.

There was another program that a customer insisted on using one time that had lots of problems with "special" characters being typed - like slash.  I want to say gotomeeting, but don't quote me on it.


答:
TOACP is an essential read -- at some point.  Depending on what you do daily, it may not be your most urgent one.

It's one of those books (well, collections of books) that is good to read early in your career because it really gives you good insights you normally wouldn't get to until later, but it's not essential to survival until you graduate to that part of your career where you don't just code, you choose the toolbox.  This is the point where you really want to study algorithms, hopefully already understand language design a bit, and have a very broad understanding of what tools, languages, and systems are out there, and how each one fits into the ecosystem of things you can draw on for a particular project.

In other words: it's big-picture learning, so if you are obsessive like me read it now, if you aren't, it's okay to put it off until you start yearning to move up the ladder and become a big picture guy.


答:
Not that Delphi4PHP needs any bad press, but I tried it (version 2.0) and it was extremely hard to bend it to my will.  I wanted to use it to make a youtube style web app for clients to view training videos, but it was too cumbersome and when I tried it to combine PHP frameworks (VCL4PHP, Zend, Smarty and Recess) I ran into the inevitable, gotta rename everything because there's no namespaces in PHP 5 problem.

That being said, I didn't roll my own in the end.  I used just learned from my mistakes and decided to keep it very simple and use CodeIgniter and FlowPlayer (with JQuery).

I've got a hankering that whatever frameworks make it out of PHP 5 alive, PHP 6 is going to have some awesome frameworks which might actually play nice together.


问:
How effectively "sell" a good design in large meetings
Many times I have witnessed a sad tragedy.  Here's what happens:

A team design review for a new project.

I see a simple design that has quite a few holes.

I casually mention the holes and ways to avoid them.

The warnings are ignored with comments like "that 'never' happen in real life"

Eventually the things that "will 'never' happen" happen

An emergency team design review for a broken project.

So what do I do?  Copping the "I told you so" attitude is not going to win friends and influence people.  Sometimes years go by and the comments from step 3 are forgotten anyway.  I definitely don't want to be the annoying pest reminding the world of the gotchas.  I often sit back and watch the Titanic sail off to Europe.

It's frustrating to see bad designs move forward.  It's also frustrating that I can't seem to convince others of the pending peril of the current path.  I do worst on team meetings where everyone has different ways of understanding different terms.  Also, egos tend to win of reason and thought.  I'm looking for good tactics to convince groups people to use some new and complicated ideas.

答:
The "casual" in "casually mention the holes" seems to be a problem.
Try to use (or bring in if it doesn't exist) some written-down process for analysing project risks.
Typically the output of a risks analysis meeting is a simple two column table: the risk, and what the agreed strategy for mitigating the risk is ("we think that never happens" is an acceptable mitigation; the important thing is to record the current thinking on the issue at the time).  Make sure your issues are recorded as risks.  Risks should be regularly reviewed; chances are quite a few people will have come round to your point of view long before the crisis actually happens and a risks review will act as an "OMG that does happen; we'd be insane to carry on like this" catalyst.  Longer term, a paper trail is useful evidence for saying "look, we seem to have an institutional problem here" and getting attitudes to design or whatever changed.


答:
TAOCP is a great work, but reading it would be a terrible time investment for a practicing software developer.
If you do it you will be sacrificing couple of years (thats how long will it takes) of your professional self-improvement budget to learn too much about too little.

I would recommend to work through one or several less "ultimate" books about algorithms, my favorite in this area is The Algorithm Design Manual by Steven S. Skiena

Then if you feel that you need/want more move up to the Knuth.

At the same time you can buy one or several volumes of TAOCP, look it through to understand what areas does Knuth covers in it, and keep it in your library in case you will actually need some information from it in your day-to-day work.
My educated guess is that you wouldn't and that is another reason why I do not advise trying to read. But if you will find yourself referencing it often enough, then you will know that it is well worth your time to read it cover to cover.


答:
Windows Communication Foundation

The fact that it's got a picture of a Swiss Army knife on the homepage kind of sums it all up for me. Imagine the XML configuration is about four times as long as the actual code that you write, and it's still very difficult to write SOAP services that are interoperable between C#, Java, PHP, Python and all those other languages that it was "supposed to" be interoperable with...

In all future projects, I'm just going to stick with REST.


问:
What is abstraction?
Is there a generally agreed upon definition for what a programming abstraction is, as used by programmers? [Note, programming abstraction is not to be confused with dictionary definitions for the word "abstraction."] Is there an unambiguous, or even mathematical definition? What are some clear examples of abstractions?

答:
Here, an unmathematical answer:

Abtracting away in programming is pretending you don't care about the details now, whereas in fact you do and you should care about them all the time. It's basically pretending.

Title: What is abstraction?


答:
Weka

I do a lot of machine learning work, and if I ever just need something simple like Naive Bayes or logistic regression, I love ditching Weka.  It has good implementations of some fairly complicated machine learning algorithms, but the API is a crufty overengineered excessively object-oriented old-school (pre-generics) Java API.  Things that annoy me about it:

It rolls its own resizeable array that nothing else uses, guaranteeing busywork converting back and forth.

Lots of sequential coupling where methods have to be called in a specific order and unless you really RTFM carefully, you won't realize it.

Every instance has to be an Instance object, and I have to declare explicitly with an Attribute object whether it's nominal or numeric.  This leads to lots of busywork converting data to the form Weka wants.  This is especially annoying since the Weka API throws so many exceptions that code compiling does not mean it's likely to work anyhow.  If I were designing the API, I'd be liberal in what I accepted (maybe just take an array of Object) and just introspect the data to figure out what I got and what the right thing to do with it is.


答:
Remote Control

We have thousands of computers connected to http://www.logmein.com/. It is absolutely free, but the paid-for upgrades, like a management dashboard to be able to roll out updates to all your machines, are excellent and pay for themselves over time.

We've found the performance to be excellent - very little hit on the remote machine until you connect to it and even then, the draw is fairly low. We have used it to remotely view full-screen MPEG movies playing in large digital out-of-home displays and to troubleshoot touch-screen apps in supermarkets and shopping malls.

It runs on Windows and Mac and can be controlled from Window, Mac or a smart phone. It is a background service, so does not get in the way of the user but can be configured to ask their permission, etc

I highly recommend it.

If you want to just walk one customer through an issue, consider Adobe Acrobat Connect which uses Adobe Flash on both your and their computers to do full-screen remote viewing. You can do up to three-way viewing with the free version.

Other Techniques

Here's a list of some of the other items we use in conjunction with Remote Control to work out what has been going wrong:

All the software we put onto the remote machines logs activity to C:\Logs or similar, rotating the logs every 28 days. Make sure the logs are named by date and have time stamps for output. When guiding the customer through a problem, note the time (and timezone!).

An agent service on the remote machines checks that the main application processes are running, not leaking, not hung and not crashed. It restarts bad-behaving processes after sending notification (see below).

We have agent scripts that can grep these logs for nasty-looking errors and SMTP them to the development team. Obviously, we get Inbox-full pain when we ship buggy code, but its' useful.

Not all customer environments are happy with automated outgoing SMTP (looks like spamware) so we use a HTTP web service to upload the things we need.

If bandwidth is good, upload a ZIP of the days logs overnight every night until the machine is healthy.

If bandwidth is not so good, cherry-pick what you upload, or upload a grep of logs.

Keep crash dumps (upload if possible) for diagnosis. You need to have excellent release discipline to ensure you have the exact binary for the particular crash.

If you only have outgoing connections and you need to talk to the remote computers some times, consider using the Hamachi VPN service - it's slow, but free and works.

Microsoft has a tool named 'collector' which will enumerate all the installed software on a machine, a bit like 'Add/Remove Programs' window. This is invaluable for finding differences between client machines.

On Windows, you can automate the Windows Installer engine to interrogate what is installed in terms of products, patches, service packs, etc.


问:
Do poor writers make poor programmers?
I'm reading Coders at Work by Peter Seibel, and many a time it has been mentioned that programmers who can't write generally make poor programmers - it's been claimed by Douglas Crockford, Joshua Bloch, Joe Armstrong, Dijkstra (and I've only read half the book).

What's your view of this? Is an inability to express yourself in writing in a natural language such as English a hindrance of writing good code?

答: Does someone unable to express precisely a system organisation or an idea be able by writing it would be able to write code - that are precise instructions - correctly interpreted by (very) dumb computer?</p>

Title: Do poor writers make poor programmers?


答:
There's much more to programming than 'writing code'. A big part of being a successful programmer involves communication; Being able to connect with customers, understand their needs, translate them into the technical realm, express them in code, and then explain the result back to the customers.

Programmers who have a hard time expressing themselves clearly in writing may not be able to communicate well in general, whereas those who have a good grasp of language and writing can generally translate those skills to the code they write.

I think being unable to write well, and thus communicate well, will keep one from being a very good programmer.

As Jason Fried and David Heinemeier Hansson (of 37signals) say in their book Rework:

If you're trying to decide among a few people to fill a position, hire the best writer.

Being a good writer is about more than writing. Clear writing is a sign of clear thinking. Great writers know how to communicate.

Title: Do poor writers make poor programmers?

Body:
I'm reading Coders at Work by Peter Seibel, and many a time it has been mentioned that programmers who can't write generally make poor programmers - it's been claimed by Douglas Crockford, Joshua Bloch, Joe Armstrong, Dijkstra (and I've only read half the book).

What's your view of this? Is an inability to express yourself in writing in a natural language such as English a hindrance of writing good code?


答: I don't think it's a major hindrance for a code monkey (I am assuming a certain basic level/ability to express one's self in their native language).  However I do think it can quickly become a major hindrance as you (the developer) has to begin to better articulate designs/arch/plans to a non-technical audience.  In my experience getting something across to someone else who is roughly on the same technical level as myself is my easier and takes considerably less (natural) language skills then it does to articulate something to a client and/or manager.  At the same token even when it's a technical audience as the subject matter becomes less concrete the person who is writing about it (or talking for that matter) has to be fairly articulate.</p>

Title: Do poor writers make poor programmers?


答:
If you can't explain something well enough you probably don't understand it well enough
Being a smart person means you will work with other smart people and you will have to communicate with them effectively.

Any great idea you have is useless if exists only in your head

Being able to communicate your ideas effectively is a sign of great understanding. This applies to more than just the field of programming.

Title: Do poor writers make poor programmers?