问:
How representative is Ohloh?
My colleague recently pointed me to Ohloh, a website providing statistics on FOSS based on versioning repositories. It's quite a fun procrastination tool, e.g. to compare programming languages by active projects:

Which makes me wonder: how representative is such a comparison? Can we draw conclusions from this such as "Javascript is the most used programming language in FOSS, followed closely by Python, Java and C++"? Or are there some big caveats to take into account?

答:
This is the problem with pretty graphs without context: you have no real way of telling of the correlations implied have any grounding in reality. JavaScript is an oddball because it used by projects whose primary language is any of the other options (e.g. a web application written in Python is more than likely to have some JavaScript with it). The only way you can compare apples to apples with JavaScript in that list is if you restrict it to server-side JavaScript.

The other thing to keep in mind is that programming language popularity does not tend to be an absolute the way Oloh makes it sound. For example, C++ remains heavily used in games, both commercial and open source, but far more web applications are written in Ruby or Python. Languages do not exist in a vacuum and tend to have greater or lesser popularity and applicability by domain.

Many of the broader takeaways are obviously true. Not many people are using FORTRAN anymore and virtually none without a paycheck. C++ is probably trending down on the whole with more and more applications development going to languages with managed memory. However, the graph itself is of very suspect usefulness.

Title: How representative is Ohloh?


问:
What is the difference between SOAP and Web Services?
Keep getting confused about these two.  Anyone care to explain the difference(s)?</p>

答:
Webservices are general term. They describe applications that return response to requests over web. These responses are usually something else than HTML.

SOAP is specific way to make a webservice. It usually consists of complex request and response objects, usually in form of XML files. Compare to REST, where requests and responses are usually simple, uses existing HTTP infrastructure and is generally using JSON files.

ContentLicense: CC BY-SA 3.0


问:
Can interface be not abstract?
Friend of mine said that not every interface is abstract. I haven't chance to discuss that with him but it get me thinking of not abstract interface in any type of language.

Is there a non abstract interfaces?

答:
No.

Interface from simple definition is abstraction of API that class can implement. If it is not abstract, then it is not an interface.

Title: Can interface be not abstract?


答:
Simple answer to your question : No, your friend is wrong.

An interface provides no implementation of the methods it defines. Would it make sense if we could instantiate one of those? Of course not. Interfaces are only that, an abstraction.

This is obviously assuming that when you say interface, you think about the interface language feature as defined by C#, Java, C++, etc with the interface keyword. In the case your friend means an API interface, then the question does not really make sense to me. APIs may allow you to extend functionality through subclassing or by adhering to a particular contract as defined by an interface or an existing class of the system.

Title: Can interface be not abstract?

Body:
Friend of mine said that not every interface is abstract. I haven't chance to discuss that with him but it get me thinking of not abstract interface in any type of language.

Is there a non abstract interfaces?


问:
Open source library, can the project owner change the license to be more restrictive?
A company releases a library with an open source MIT license.

If they wanted to, could they change the license to be very restrictive so competitors cannot use it?

What impact would this have on previous versions?

Meaning if on Nov. 1st they make it very restrictive to some other license, would all versions prior to Nov 1st be still on MIT?

答: IANAL but if the author of a piece of code licenses it under the MIT license and you use it in a program, the copyright holder cannot then change the license retroactively and (for example) sue you for copyright infringement. All they can do is license new versions under a different license. They can supply the original version under different license as well, but that does not invalidate the MIT license they granted to you already.</p>


答:
Yes.

The idea of an interface (ie, a description of facilities provided and their semantics) is inherently abstract.

However, the question appears to confuse this with the mechanism by which such an interface (small i) may be reified into certain languages which provide an Interface (big i) for this purpose.

Further, there is anyway more than one thing you may wish abstract:

polymorphism: you wish to hide multiple different types or behaviours behind a description of the things they have in common. In this case, the interface should be probably abstract

implementation: you wish to hide the details of a complex system behind a unifying abstraction. In this case there may never be more than one implementation, so the interface can itself be concrete

Title: Can interface be not abstract?


问:
Solutions for Project management

The team consists of 3 people.

The method of development is Scrum.

The language of the project is C++.

The project will be under the control of the git system.

The start up budget is 0.

The following things have to be chosen:

Build and Version Numbering

Project documentation ( file with the most common info for current stage of the project, which will be changed every time the new version or subversion of the project emerges )

Project management tool ( like Trac or Redmine, I cannot use them, because there is no hosting )

Code documentation ( I consider Doxygen )

The following questions have arisen:

What can you add to the above list of the main solutions for project management in the described project?

One of three project participants has linux os (No MS Office), one has Windows and MS Office (does not want to use Libre or Open Office), one has Windows, but does not have MS Office. What formats, tools can u suggest using for project documentation? The variant of using online wiki does not fit, it must be files.

OneNote mb is a good tool for project management, but because of the reason mentioned above it is not possible. What can you advise?

Offer a system for Build and Version Numbering.

答:
Semantic Versioning for version numbering.

You could use a wiki for developer information and that is not a bad idea, but with only three people I would probably just put it in the git repo and roll it into something else if/when the number of people grow.

I would normally say Redmine for project management, but if you do not have a server there are two other options. The first is to sign up for something on the web that does what you want. You could put your project on github (signing up for a private account, if necessary). If a server is completely out of the question I would use ditz. It plays nicely with git and puts all of the bug/task tracking information in your repository.

Doxygen seems reasonable enough for API docs. It isn't well suited to anything else, though.

What formats, tools can u suggest using for project documentation?

It may seem a little old school, but you could just use Markdown for project documentation. Everyone should be able to work with plain text. If you want something fancier, you could then run it through Pandoc to produce HTML, OpenOffice or MS Word versions of the document. If that is not an option, RTF should be supported by pretty much every format.

Title: Solutions for Project management


答:
Read the license. The MIT license is only a few lines long, and the answer to your question is contained in the license itself. Here's one version from Wikipedia:

Permission is hereby granted, free of charge, to any person obtaining
  a copy of this software and associated documentation files (the
  "Software"), to deal in the Software without restriction, including
  without limitation the rights to use, copy, modify, merge, publish,
  distribute, sublicense, and/or sell copies of the Software, and to
  permit persons to whom the Software is furnished to do so, subject to
  the following conditions...

So, if you obtain some software under the license above, you have permission to use it. If the copyright owner decides to stop granting that permission in the future, that's their business, but it doesn't change the fact that they've already granted permission to you, and furthermore they've also given you permission to publish, distribute, and so on provided you do so under the same terms. You can see for yourself that there's no provision for revoking that permission as long as you comply with the license.

Title: Open source library, can the project owner change the license to be more restrictive?

Body:
A company releases a library with an open source MIT license.

If they wanted to, could they change the license to be very restrictive so competitors cannot use it?

What impact would this have on previous versions?

Meaning if on Nov. 1st they make it very restrictive to some other license, would all versions prior to Nov 1st be still on MIT?


问:
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?

答:
Absolutely NOT!

A good writer is nothing more than a good writer. Ask a good writer to describe the concept of a database to a non-technical person. What do you think you will get...?

A good writer, writes. A good programer writes good code.

Code that others can read six months after it's been developed.

Code that makes sense at 2:00 AM in the morning when the system has failed and debuging is going on.

Code that everyone else likes to borrow because they understand it and can modify it easily

Code that works 24/7 365

I was going to go on and on but I'd rather spend my time answering other posts. I pretty much think you guys know where I stand on this issue.

ContentLicense: CC BY-SA 2.5

Title: Do poor writers make poor programmers?


问:
Does this happen in Common Lisp?
From Steve Yegge's "Lisp is Not an Acceptable Lisp":

```<code> Lisp has a little syntax, and it shows up occasionally as, for instance, '(foo)
 being expanded as (quote foo), usually when you least expect it.
</code>```

What is he talking about with '(foo) being expanded into (quote foo) in some situations?  (As opposed, I would imagine, to (quote (foo))).

答:
In PicoLisp, '(foo) is equivalent to (quote foo) and 'foo is equivalent to (quote . foo).

I didn't understand that paragraph either.  It's conceivable that Yegge was referring to PicoLisp (in the context of porting between Lisp dialects), or he could have been referring to a bug or corner case in a CL or Scheme implementation (though none that I am aware of.)

Title: Does this happen in Common Lisp?


问:
Is there a way to add unique items to an array without doing a ton of comparisons?
Please bare with me, I want this to be as language agnostic as possible becuase of the languages I am working with (One of which is a language called PowerOn).  However, most languanges support for loops and arrays.

Say I have the following list in an aray:

```<code>0x  0  Foo
1x  1  Bar
2x  0  Widget
3x  1  Whatsit
4x  0  Foo
5x  1  Bar
</code>```

Anything with a 1 should be uniqely added to another array with the following result:

```<code>0x  1  Bar
1x  1  Whatsit
</code>```

Keep in mind this is a very elementry example.  In reality, I am dealing with 10's of thousands of elements on the old list.  Here is what I have so far.

Pseudo Code:

```<code>For each element in oldlist
 For each element in newlist
  Compare
  If values oldlist.element equals newlist.element, break new list loop
  If reached end of newlist with with nothing equal from oldlist, add value from old list to new list
 End
End
</code>```

Is there a better way of doing this?  Algorithmicly, is there any room for improvement?  And as a bonus qeustion, what is the O notation for this type of algorithm (if there is one)?

答:
If you keep your newlist sorted, then you can use binary search to determine whether a duplicate exists.  This will only make a difference when your newlist starts to get large, so if it never gets longer than (say) 64 entries you may not see any improvement.  It may also not work if it's expensive to insert into the middle of an array -- shifting all the elements may eat up a lot of your time savings.  You could mitigate this somewhat by keeping multiple lists, maybe your starting  list and a separate list of the elements you've added.  You'll have to search each separately but with binary search that should be manageable.  Then, after your loops have finished, merge the new elements into the second list.

Another improvement might be to traverse your oldlist after inserting a new value into newlist and removing any duplicates.  Hard to say, though, without knowing anything about the data.


问:
Developing JSON API for a Carpool Engine
I am developing a new set of API methods for carpooling/cab booking, so if a developer needs to develop an app or webportal for carpooling, he can call my JSON API. Basically making it easy for developers.

My API current has:

AddVehicle

AddJourney

SearchJourney

SubscribeToThisJourney(journey)

SubscriberList(journey) to get list of people who have subscribed for this journey

AcceptSubscription(subscriber)

AcceptedSubcriberList

SubscriberList to get list of providers I have subscribed to

I need help with replacing subscriber with something else. It's difficult to remember, and confusing when you see 3 methods that mean very different things: SubscriberList, SubscribedToThisJourneyList and AcceptedSubscriberList. Confusing to remember.

One is a list of who I have subscribed to

Who has subscribed to me

Whose subscription I have accepted

How can I name these methods to make them easier to understand and remember?

答:
I do not see a problem with your chosen names, as the verb subscribe and the noun subscriber have very different (but rightly) related meanings in English.

Proper documentation is going to be key here.

OwnerDisplayName: Siddharth


问:
Greenspun's Tenth Rule, does every large project include a Lisp interpreter?
Greenspun's tenth rule (actually the only rule) states that:

Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.

My memory is that there are some papers on the topic, perhaps for Borland's Quattro (spreadsheet) project and possibly others.  Google is unhelpful, maybe the right search terms are not coming to mind.  I am looking for papers or articles supporting this claim, if any.

答:
Whether or not it was meant to be taken seriously, it is true of the largest C and C++ projects I have worked on.

What is not true is that the custom scripting languages resemble Common Lisp.  The positive examples resemble Scheme (because the smarter designers integrated Guile, SpiderMonkey and Lua instead of inventing their own language.)  The most DailyWTF-worthy examples were a Forth-like language and a MUMPS-like language.

Another example (not sure if it counts as Greenspunning, but certainly a WTF) was an XSLT interpreter used for general-purpose scripting.  This was more Lisp-like as they added a feedback loop where the output would be XSLT-transformed a second time - so now you effectively have macros.

The motive here though was not to get access to lispy features but to sidestep the company's code QA procedures (which added 3 weeks of latency to every bug fix.  XML was considered "data" and exempt from the process.)


答: Organize the second array as a binary tree.  It's simpler than implementing a hash table, and will run in O(n log n) time.</p>

Title: Is there a way to add unique items to an array without doing a ton of comparisons?

Body:
Please bare with me, I want this to be as language agnostic as possible becuase of the languages I am working with (One of which is a language called PowerOn).  However, most languanges support for loops and arrays.

Say I have the following list in an aray:

```<code>0x  0  Foo
1x  1  Bar
2x  0  Widget
3x  1  Whatsit
4x  0  Foo
5x  1  Bar
</code>```

Anything with a 1 should be uniqely added to another array with the following result:

```<code>0x  1  Bar
1x  1  Whatsit
</code>```

Keep in mind this is a very elementry example.  In reality, I am dealing with 10's of thousands of elements on the old list.  Here is what I have so far.

Pseudo Code:

```<code>For each element in oldlist
 For each element in newlist
  Compare
  If values oldlist.element equals newlist.element, break new list loop
  If reached end of newlist with with nothing equal from oldlist, add value from old list to new list
 End
End
</code>```

Is there a better way of doing this?  Algorithmicly, is there any room for improvement?  And as a bonus qeustion, what is the O notation for this type of algorithm (if there is one)?


答:
Interfaces need not be abstract. Example:

```<code>class Foo {
public:
    void printHello () {
         printf("Hello");
    }
};
</code>```

Here Foo is a concrete class with an interface printHello(). Foo is not abstract.

Title: Can interface be not abstract?

Body:
Interfaces need not be abstract. Example:

class Foo {
public:
    void printHello () {
         printf("Hello");
    }
};

Here Foo is a concrete class with an interface printHello(). Foo is not abstract.


问:
What is the origin of the phrase "SaaS"?
Recently I heard someone say they built a "SaaS" application.  At first I thought "this guy knows something new", and I figured SaaS was some hyped enterprise framework or design pattern, but after looking up the SaaS Wikipedia page I realized it's similar in meaning to "web app".

What is the origin of the phrase "SaaS"?  When was it first used?

答:
According to http://it.toolbox.com/wiki/index.php/SaaS:

The term "SaaS" was coined by John Koenig for the SDForum Software as a Service Conference in March of 2005 and has become the industry adopted reference term, generally replacing the earlier terms "On-Demand" and "ASP" (Application Service Provider).


答:
Depends much on what meaning your friend gave to the word interface.

Interface as the concept of an abstract contract on methods/properties

So this means the Interface types provided by diverse languages (like the
cited above: C#, Object Pascal (Delphi or FPC), Java, etc) so the answer is no.

In this case, the Interface is an contract on methods - without any form of implementation.

Interface as a contract on the description of facilities provided and their semantics

In this case, even an non-pure abstract class can be considered an interface. In this case, the designer even have how to implement default basic behavior (like throwing exceptions on non-implemented virtual methods which are not abstract) on that base class.

So, if it is the case, so yes those "interfaces" can be not abstract.

Title: Can interface be not abstract?


答:
The term replaces Application Service Provider and can be found in documents dating back to at least early 2001.

Software as a Service (SaaS), commonly referred to as the Application
  Service Provider (ASP) model, is  heralded by many as the new wave in
  application software distribution. Following the maxim that “the
  Internet changes everything,” many believe that traditional packaged
  desktop and enterprise applications will  soon be swept away by the
  tide of Web-based, outsourced products and services that remove the
  responsibility for installation, maintenance and upgrades from
  over-burdened MIS staff. Some analysts and  industry members believe
  that packaged software, as a separate entity will cease to exist.
  While such drastic  predictions have not yet happened, due to
  technical and business issues, the spirit of this change – the
  delivery, management and payment of software as a service rather than
  a product – is affecting all participants  in the software industry

It appears that the term was non-existent or not widely used before that point. An article from April of 2000 uses ASP.

Body:
Recently I heard someone say they built a "SaaS" application.  At first I thought "this guy knows something new", and I figured SaaS was some hyped enterprise framework or design pattern, but after looking up the SaaS Wikipedia page I realized it's similar in meaning to "web app".

What is the origin of the phrase "SaaS"?  When was it first used?


答:
Here are some suggestions for names for the three methods that you list as needing attention:

One is a list of who I have subscribed to - based on your earlier description for SubscriberList, I assume by 'who' you mean which providers, so a clearer version might be: ProvidersSubscribedTo(user)

Who has subscribed to me - assuming this is meant to list the subscribers who I, as a Provider, have not yet accepted: PendingSubscribers(provider)

Whose subscription I have accepted  - AcceptedSubscribers(provider)

I've used parameters to indicate the context of the method call, so depending on how the calls are made, they might not be required.

Title: Developing JSON API for a Carpool Engine

Body:
I am developing a new set of API methods for carpooling/cab booking, so if a developer needs to develop an app or webportal for carpooling, he can call my JSON API. Basically making it easy for developers.

My API current has:

AddVehicle

AddJourney

SearchJourney

SubscribeToThisJourney(journey)

SubscriberList(journey) to get list of people who have subscribed for this journey

AcceptSubscription(subscriber)

AcceptedSubcriberList

SubscriberList to get list of providers I have subscribed to

I need help with replacing subscriber with something else. It's difficult to remember, and confusing when you see 3 methods that mean very different things: SubscriberList, SubscribedToThisJourneyList and AcceptedSubscriberList. Confusing to remember.

One is a list of who I have subscribed to

Who has subscribed to me

Whose subscription I have accepted

How can I name these methods to make them easier to understand and remember?


问:
Why do old programming languages continue to be revised?
This question is not, "Why do people still use old programming languages?" I understand that quite well. In fact the two programming languages I know best are C and Scheme, both of which date back to the 70s.

Recently I was reading about the changes in C99 and C11 versus C89 (which seems to still be the most-used version of C in practice and the version I learned from K&R). Looking around, it seems like every programming language in heavy use gets a new specification at least once per decade or so. Even Fortran is still getting new revisions, despite the fact that most people using it are still using FORTRAN 77.

Contrast this with the approach of, say, the typesetting system TeX. In 1989, with the release of TeX 3.0, Donald Knuth declared that TeX was feature-complete and future releases would contain only bug fixes. Even beyond this, he has stated that upon his death, "all remaining bugs will become features" and absolutely no further updates will be made. Others are free to fork TeX and have done so, but the resulting systems are renamed to indicate that they are different from the official TeX. This is not because Knuth thinks TeX is perfect, but because he understands the value of a stable, predictable system that will do the same thing in fifty years that it does now.

Why do most programming language designers not follow the same principle? Of course, when a language is relatively new, it makes sense that it will go through a period of rapid change before settling down. And no one can really object to minor changes that don't do much more than codify existing pseudo-standards or correct unintended readings. But when a language still seems to need improvement after ten or twenty years, why not just fork it or start over, rather than try to change what is already in use? If some people really want to do object-oriented programming in Fortran, why not create "Objective Fortran" for that purpose, and leave Fortran itself alone?

I suppose one could say that, regardless of future revisions, C89 is already a standard and nothing stops people from continuing to use it. This is sort of true, but connotations do have consequences. GCC will, in pedantic mode, warn about syntax that is either deprecated or has a subtly different meaning in C99, which means C89 programmers can't just totally ignore the new standard. So there must be some benefit in C99 that is sufficient to impose this overhead on everyone who uses the language.

This is a real question, not an invitation to argue. Obviously I do have an opinion on this, but at the moment I'm just trying to understand why this isn't just how things are done already. I suppose the question is:

What are the (real or perceived) advantages of updating a language standard, as opposed to creating a new language based on the old?

答:
Backward Compatibility is your answer. A given language, particularly a widely used one like C may have code that is in operation, unaltered, for decades. If there needs to be maintenance, it helps to have compilers that can still target that kind of a platform whilst running on modern systems for development work. Standardizations and language version updates help keep programming practices current whilst providing a sense of familiarity for the veteran programmers who may be resistant to learning a whole "new" language.

Keep in mind that many of the updated languages are less updated so much as "have new shiny bits bolted on". The beasts of yore often still lurk within.

As far as Knuth goes, remember that he is an academic and that TeX is only proven correct, not updated.


问:
Why are errors named as "Exception" but not as "Error" in programming languages?
I've been thinking about that for quite a while actually. I am not a native English speaker myself but still, I have years of programming experience and I always asked myself this. Why is it named as Exception but not Error since they are errors?

It could be PageNotFoundError instead of PageNotFoundException!

答:
An error is something that has gone wrong in the execution of the program. Often this is dealt with by raising an exception, but

there is nothing that forces a programmer to handle an error by raising an exception, and

there is nothing that forces a programmer to raise exceptions only in the case of an error.

Error is a semantic concept: it is applied by the programmer or user, who comes to the program with expectations, to describe the difference between their expectations and reality. Only a person can say whether a routine is in an error state or not.

An exception is a syntactic concept: it is something in the program itself, independent of anyone's expectations about what that program is supposed to do. A routine either does or does not raise an exception, regardless of what anyone thinks.

ContentLicense: CC BY-SA 4.0


问:
Is comparing an OO compiler to a SQL compiler/optimizer valid?
I'm now doing a lot of SQL development at my new job where as before I was doing Object Oriented desktop app stuff. I keep running across very large scripts (thousands of lines) and wanting to refactor in some way. I am seeing that SQL is a different sort of beast and it's probably fine to have these big scripts for the most part but while explaining this to me people are also insisting that the whole idea of refactoring is bad. That stuff like the .NET compiler are actually burdened by refactored code and that a big wall of code is more efficient and better design than code designed for reuse, readability and scalability.

The other argument is that OO compilers are almost dangerously inefficient and don't have efficient memory management or runs too many CPU instructions compared to older "simpler" compilers and compared to SQL.

Are these valid complaints? Even if some compiler like a C compiler is modestly more "efficient" (whatever that means on this high of a level without seeing code) would you want to write applications in C over C# or Java? Is comparing an OO compiler to a SQL compiler/optimizer even valid?

答:
I don't think you will see larger trade-offs with: reuse, readability and scalability than in a RDBMS. Refactoring databases is not the same as other code bases.

Reuse - rarely will you work with a programmingn language where you turn a block of code into a method and take a noticable performance hit even within a long running loop. This is the opposite in sql, each rdbms has its own quirks where reusing functions (put in a select statement and you have yourself a loop) and views can drastically slow down performance and must be used with care.

Readability - let's assume the sql is consistently formated or at least close enough. Seeing lengthy stored procs that created all kinds of temp tables and performed data updates and inserts use to bother me because I wasn't use to it. If you want to snatch a knot in a DBA's sphincter, ask to change a table name in production because its purpose is not clear.

Scalability - you will not see many places where Reuse and Readability (cosmetic reasons excluded) will hinder scalability/performance like you will in sql. Along with improved code you'll need indexing, file management, and possibly clustering, but fixing code that runs poorly is a good place to start.

This doesn't mean you can't gain any benefits from database refactoring. If you can learn how to do it in a way the improves performance, it's not such a hard sell.


问:
Where is it permissible to add logging code in a MVC model?
Working on a C# WinForms program that is written in a MVC ( actually Model-View-Presenter)  style and I want to add a few lines of code that is responsible for logging some events. Where should I write two or three lines of code that I need? Should I write it in the Presenter section?

To get an idea, here is some lines of sample code that already exists in the Save() metohd in Company.MyApplication.Presenter.MyPresenter.cs  class:

he has written codes lie the following in this part of presenter:

```<code>private void Save(Helper.SaveStatusEnum status)
{
    if (notification.CheckLocks(orderIdCollection))
    {
        using (new HourglassController())
        {
            controller.FireActiveCellLeaving();
            ViewDocumentedValues();

            int result = saveController.Save(status);

            if (result == Helper.SAVE_SUCCESSFUL)
            {
                //  IS IT OK TO WRITE MY COUPLE LINES OF CODE IN HERE???????????
                model.Dirty = false;

                if ((model.CurrentStatus == Helper.OrderStatusEnum.Complete) || (model.CurrentStatus == Helper.OrderStatusEnum.Corrected))
                {
                    controller.EnableDisableSheet(false);
                }

                CheckApplicationState();
                SheetHelper.ClearUnsavedDataRowImage(view.ActiveSheet);
            }
            else
            {
                MessageBox.Show("An unexpected error occuring trying to save.");
            }
        }
    }
}
</code>```

答:
Probably the model would be the best place since it is the closest part to the system, and logging is done on the system (usually).

View and Presenter are more likely responsible with showing data to user and handling user actions.

EDIT:

If you want to add logging just for ad-hock debugging and than immediately remove it so that it doesn't get into production you can write it to wherever you want. However if I would want to add long-term logging I would add it in model.

But I don't see these things as absolute bad or good solutions. If you have no way, for some well understood reasons, to add it to the models you can add it to the presenter also. Probably the worst place the log could be is the view, so avoid it as much as you can.


答:
All above answers are correct. But this is how I understand it.

Interface are just definitions of service. E.g. You need to book a ticket for an air travel. Its an idea/concept that you 'book a ticket'. And not worry about how it is done physically.

A Class that implements it will define how it is done and what physical form it takes.

E.g. An Interface could be to book a ticket. You could then have various entities that provide you this service. A travel agent, online booking, or actual airline office.
 They all provide the service (Interface) to book a ticket.

Title: Can interface be not abstract?


答:
I recommend watching Putting your controllers on a diet by Jimmy Bogard. It's for MVC 2, but it's still very relevant in MVC 4. It's how I now code my MVC applications. It's simple and it creates separation of concerns.

Video Covers:

Dependency Injection

AutoMapper

Model Binding

Action Results

You can squeeze in logging wherever you want.. but the patterns described in the video result in efficient MVC development..

The beauty of the approach is it eliminates the nested if statements commonly found in validation and data-retrieval code in an application entry point (i.e. button clicks)

update

I just realized the question is for MVP in Windows Forms, I still believe that many of the idea's in Jimmy's video apply.

Title: Where is it permissible to add logging code in a MVC model?

Body:
Working on a C# WinForms program that is written in a MVC ( actually Model-View-Presenter)  style and I want to add a few lines of code that is responsible for logging some events. Where should I write two or three lines of code that I need? Should I write it in the Presenter section?

To get an idea, here is some lines of sample code that already exists in the Save() metohd in Company.MyApplication.Presenter.MyPresenter.cs  class:

he has written codes lie the following in this part of presenter:

```<code>private void Save(Helper.SaveStatusEnum status)
{
    if (notification.CheckLocks(orderIdCollection))
    {
        using (new HourglassController())
        {
            controller.FireActiveCellLeaving();
            ViewDocumentedValues();

            int result = saveController.Save(status);

            if (result == Helper.SAVE_SUCCESSFUL)
            {
                //  IS IT OK TO WRITE MY COUPLE LINES OF CODE IN HERE???????????
                model.Dirty = false;

                if ((model.CurrentStatus == Helper.OrderStatusEnum.Complete) || (model.CurrentStatus == Helper.OrderStatusEnum.Corrected))
                {
                    controller.EnableDisableSheet(false);
                }

                CheckApplicationState();
                SheetHelper.ClearUnsavedDataRowImage(view.ActiveSheet);
            }
            else
            {
                MessageBox.Show("An unexpected error occuring trying to save.");
            }
        }
    }
}
</code>```


答:
It depends on the goal you have with the logging. If the thing you want to log is a successful Save exactly and only at the position in your code you marked above, then it will obviously be the right place. But if you want to log every sucessful call to saveController.Save in your code, you better place the logging call within that method.

And don't think too much about the MVC architecture with logging - logging is a cross-cutting concern, which can make sense in any layer, depending on what you want to achieve. For example, if you are logging for debugging purposes, it could even make sense in the view layer.


问:
How do you use blank lines in your code?
There has been a few remarks about white space already in discussion about curly braces placements.

I myself tend to sprinkle my code with blank lines in an attempt to segregate things that go together in "logical" groups and hopefully make it easier for the next person to come by to read the code I just produced.

In fact, I would say I structure my code like I write: I make paragraphs, no longer than a few lines (definitely shorter than 10), and try to make each paragraph self-contained.

For example:

in a class, I will group methods that go together, while separating them by a blank line from the next group.

if I need to write a comment I'll usually put a blank line before the comment

in a method, I make one paragraph per step of the process

All in all, I rarely have more than 4/5 lines clustered together, meaning a very sparse code.

I don't consider all this white space a waste because I actually use it to structure the code (as I use the indentation in fact), and therefore I feel it worth the screen estate it takes.

For example:

```<code>for (int i = 0; i < 10; ++i)
{
    if (i % 3 == 0) continue;

    array[i] += 2;
}
</code>```

I consider than the two statements have clear distinct purposes and thus deserve to be separated to make it obvious.

So, how do you actually use (or not) blank lines in code ?

答:
Often

Use it for logical blocks of code that are processed similarly.  Once you add a comment to show that you're doing a different step - it's time to Extract Method.

Good Whitespace

```<code>{
    int x = computeX();
    x += ADJUSTMENT_FACTOR_X;

    int y = computeY();
    y += ADJUSTMENT_FACTORY_Y;

    setPosition(x, y);
}
</code>```

Bad Whitespace

```<code>{
    //Open a connection
    String serverAddress = lookupAddress();
    Connection connection = openConnection(serverAddress);
    connection.login(user, password);

    //Go get stuff from the server
    item1 = connection.get(1);
    item2 = connection.get(2);

    //Close connection
    connection.close();

    //log data
    log(item1);
    log(item2);

    //Update client
    gui.updateView(item1, item2);
}
</code>```

vs

```<code>{
    Connection connection = openConnection();
    updateData(connection);
    closeConnection(connection);
    logUpdate();
    updateGui();
}
</code>```

vs

```<code>{
     updateDataFromServer();
     logUpdate();
     updateGui();
}
</code>```

Body:
Often

Use it for logical blocks of code that are processed similarly.  Once you add a comment to show that you're doing a different step - it's time to Extract Method.

Good Whitespace

{
    int x = computeX();
    x += ADJUSTMENT_FACTOR_X;

    int y = computeY();
    y += ADJUSTMENT_FACTORY_Y;

    setPosition(x, y);
}

Bad Whitespace

{
    //Open a connection
    String serverAddress = lookupAddress();
    Connection connection = openConnection(serverAddress);
    connection.login(user, password);

    //Go get stuff from the server
    item1 = connection.get(1);
    item2 = connection.get(2);

    //Close connection
    connection.close();

    //log data
    log(item1);
    log(item2);

    //Update client
    gui.updateView(item1, item2);
}

vs

{
    Connection connection = openConnection();
    updateData(connection);
    closeConnection(connection);
    logUpdate();
    updateGui();
}

vs

{
     updateDataFromServer();
     logUpdate();
     updateGui();
}


答:
Logging is a cross-cutting concern.  There is no right place for logging; you do it where you need to.

MVC is agnostic in that regard; it has nothing to say about where you put lines of code that call your logger.


问:
Are there well-known PowerShell coding conventions?
Are there any well-defined conventions when programming in PowerShell?

For example, in scripts which are to be maintained long-term, do we need to:

Use the real cmdlet name or alias?

Specify the cmdlet parameter name in full or only partially (dir -Recurse versus dir -r)

When specifying string arguments for cmdlets do you enclose them in quotes (New-Object 'System.Int32' versus New-Object System.Int32

When writing functions and filters do you specify the types of parameters?

Do you write cmdlets in the (official) correct case?

For keywords like BEGIN...PROCESS...END do you write them in uppercase only?

It seems that MSDN lack coding conventions document for PowerShell, while such document exist for example for C#.

答:
@Robert Harvey referenced some good formal links. By way of a less formal document, my thoughts would be:

Use the real cmdlet name or alias?

Only use the alias if it is more clear than the full name. For example, I think most people would find dir or ls more clear in a script than Get-ChildItem based on previous experience (e.g. basically anyone writing a PowerShell script has one of those two many times in either DOS batch scripts or Unix scripting).

Specify the cmdlet parameter name in full or only partially (dir -Recurse versus dir -r)

In a script, I would fully spell out the name because (unlike the above example) I cannot think of a time where the shorter switch would actually be more clear than spelling it out. Shorter switch names are to save typing. At a command line, this is imperative. In a script, the extra keystrokes are well worth it for readability and maintainability.

When specifying string arguments for cmdlets do you enclose them in quotes (New-Object 'System.Int32' versus New-Object System.Int32

Enclosing string arguments in quotes seems much more clear when reading through the code, so I would include them.

When writing functions and filters do you specify the types of parameters?

Only when there is a need to do so to resolve ambiguity for the interpreter (which does happen). If you are going to try and put types on everything, you might as well go and write C# command line applications (which isn't always a bad thing, but it negates the time savings you get by scripting).

Do you write cmdlets in the (official) correct case?

You should. I usually do. When hurried I have been known to be a little lax on case since it does not syntactically matter.

For keywords like BEGIN...PROCESS...END do you write them in uppercase only?

No. This is not FORTRAN. I think most people find begin or Begin more readable than BEGIN. There is a reason we associate all caps with shouting online and shouting the most mundane portions of the program hinders readability by drawing one's attention to the parts that matter the least.

The guiding principal should be readability. Scripts, by their very nature as quick and dirty programs, veer towards write-only code. Your every decision should be made to ensure that you and your team can still understand the script in six months. Try to take yourself out of your own shoes when looking at your code and ask this question: "if I had started this job a week ago (and so was not really indoctrinated into the general culture) would I find the way this is written illuminating or confusing?"


答: I think the obvious answer is that progress is still being made in language design and system architecture, and enough people care about the older languages that they want to take advantage of newer techniques (multiple cores, better threading or memory models) that they get bolted on or baked into the language standard.  It also helps to have "one true way" to do things (e.g., XML parsing, DB access) that you can count on to be there no matter what compiler or platform you're on, as opposed to depending on some third-party library which may or may not be installed (and may or may not be the version you require, etc).</p>

Title: Why do old programming languages continue to be revised?

Body:
This question is not, "Why do people still use old programming languages?" I understand that quite well. In fact the two programming languages I know best are C and Scheme, both of which date back to the 70s.

Recently I was reading about the changes in C99 and C11 versus C89 (which seems to still be the most-used version of C in practice and the version I learned from K&R). Looking around, it seems like every programming language in heavy use gets a new specification at least once per decade or so. Even Fortran is still getting new revisions, despite the fact that most people using it are still using FORTRAN 77.

Contrast this with the approach of, say, the typesetting system TeX. In 1989, with the release of TeX 3.0, Donald Knuth declared that TeX was feature-complete and future releases would contain only bug fixes. Even beyond this, he has stated that upon his death, "all remaining bugs will become features" and absolutely no further updates will be made. Others are free to fork TeX and have done so, but the resulting systems are renamed to indicate that they are different from the official TeX. This is not because Knuth thinks TeX is perfect, but because he understands the value of a stable, predictable system that will do the same thing in fifty years that it does now.

Why do most programming language designers not follow the same principle? Of course, when a language is relatively new, it makes sense that it will go through a period of rapid change before settling down. And no one can really object to minor changes that don't do much more than codify existing pseudo-standards or correct unintended readings. But when a language still seems to need improvement after ten or twenty years, why not just fork it or start over, rather than try to change what is already in use? If some people really want to do object-oriented programming in Fortran, why not create "Objective Fortran" for that purpose, and leave Fortran itself alone?

I suppose one could say that, regardless of future revisions, C89 is already a standard and nothing stops people from continuing to use it. This is sort of true, but connotations do have consequences. GCC will, in pedantic mode, warn about syntax that is either deprecated or has a subtly different meaning in C99, which means C89 programmers can't just totally ignore the new standard. So there must be some benefit in C99 that is sufficient to impose this overhead on everyone who uses the language.

This is a real question, not an invitation to argue. Obviously I do have an opinion on this, but at the moment I'm just trying to understand why this isn't just how things are done already. I suppose the question is:

What are the (real or perceived) advantages of updating a language standard, as opposed to creating a new language based on the old?


答:
The fundamental concepts or goals a general purpose language is built around do not lose relevance; however minor changes in work environment or hardware demand that updates or small features be added to a language.

The way algorithms are expressed in a language will not change, even though it may need cleaner support for 64 bit types, or more standard regular expression support, or more robust support for new types of file systems.

There are a few cases where 'new' features are being added to existing languages, but in many cases those changes amount to simplifications of things people were already doing the hard way. (See C++ using high order functions instead of function pointers and functors.)


问:
Type of AI to tackle this problem?
I posted this on stackoverflow but want to get your recommendations as well as a user on overflow recommended I post it here.

I'm going to say from the beginning that I am not a programmer, I have a cursory knowledge of different types of AI and am just a businessman building a web app.

Anyways, the web app I am investing in to develop is for a hobby of mine. There are many part manufacturers, product manufacturers, upgrade and addon manufacturers etc. for hardware/products in this hobby's industry. Currently, I am in the process of building a crowd sourced platform for people who are knowledgeable to go in and mark up compatibility between those parts as its not always clear cut if they are for example:

Manufacturer A makes a "A" class product, and manufacturer B makes upgrade/part that generally goes with class "A" products, but is for one reason or another not compatible with Manufacturer A's particular "A" class product.

However, a good chunk (>60%-70%) of the products/parts in the database can have their compatibility inferred by their properties,

For example:

Part 1 is type "A" with "X" mm receiver and part 2 is also Type "A" with "X" mm interface and thus the two parts are compatible..

or

Part 1 is a 8mm gear, thus all bushings of 8mm from any manufacturer is compatible with part 1. Further more, all gears can only have compatibility relationships in the database with bushing and gear boxes, but there can be no meaningful compatibility between a gear and a rail, or receiver since those parts don't interface.

Now what I want is an AI to be able to learn from the decisions of the crowdsourced platform community and be able to infer compatibility for new parts/products based on their tagged attributes, what type of part they are etc.

What would be the best form of AI to tackle this? I was thinking a Expert System, but explicitly engineering all of the knowledge rules would be daunting because of the complex relations between literally tens of thousands of parts, hundreds of part types and many manufacturers.

Would a ANN (neural network) be ideal to learn from the many inputs/decisions of the crowdsource platform users?

Any help/input is much appreciated.

答:
NNs are often used for tasks where we're unsure about what "features" are important. I can recognize a handwritten "2" but it's difficult to describe the essence of a "2" given the enormous variation in hand writing. In your case, the important features of your items seem to be decided by the tags. Humans have already done the hard work.

Similarly NNs are often used to classify objects, i.e. image of hand writing -> number. From what you said it seems like something that's already been done for you. This isn't to say that NNs couldn't be applied but it seems like the areas where NNs excel have already been covered. That being said, your model does seem to provide a wonderful amount of training data.

One question, you say:

Manufacturer A makes a "A" class product, and manufacturer B makes upgrade/part that generally goes with class "A" products, but is for one reason or another not compatible with Manufacturer A's particular "A" class product.

What could "one reason or another" be? Is it something you could tell from the tags? from the picture? from playing with the physical parts? Unless it's something a human could tell from the tags it's probably going to be difficult for an AI to guess.

Title: Type of AI to tackle this problem?


问:
How to write good code with new stuff?
I always try to write easily readable code that is well structured.

I face a particular problem when I am messing around with something new. I keep changing the code, structure and so many other things. In the end, I look at the code and am annoyed at how complicated it became when I was trying to do something so simple.

Once I've completed something, I refactor it heavily so that it's cleaner. This occurs after completion most of the time and it is annoying because the bigger the code the more annoying it is the rewrite it.

I am curious to know how people deal with such agony, especially on big projects shared between many people ?

答:
I am curious to know how people deal with such agony, especially on big projects shared between many people ?

Acknowledge it exists.

Schedule time for prototyping.

Try to learn new things in hobby projects rather than production code.

Title: How to write good code with new stuff?


答:
So long as you are refactoring you are doing it right.

Consider this: at any point you can chart a solution to the problem. However, as time progresses you are finding out more and more about the problem which leads you to being able to come up with better solutions. The first iteration may be backwards, and the last one is hopefully elegent. If you keep refactoring as your knowledge grows then you will always end up with better results. There is no shortcut to jumping to the most elegant solution right away without going through the 'learning' steps unless you've already encountered a similar problem, are able to generalize from past problems, or get lucky.

Title: How to write good code with new stuff?

Body:
I always try to write easily readable code that is well structured.

I face a particular problem when I am messing around with something new. I keep changing the code, structure and so many other things. In the end, I look at the code and am annoyed at how complicated it became when I was trying to do something so simple.

Once I've completed something, I refactor it heavily so that it's cleaner. This occurs after completion most of the time and it is annoying because the bigger the code the more annoying it is the rewrite it.

I am curious to know how people deal with such agony, especially on big projects shared between many people ?


答:
Well, I haven't built too many AI systems before, but let's take a naive crack at this. If I were going to use a neural network for this, the assigned tags to new parts would be the input nodes, the (vast) list of items it could be compatible with would the the output nodes, and the hidden layer would be it's user-confirmed compatibilities or incompatibilities.

So if users make tags... "8mm", "gear", and assign them to some parts. And your users list these parts as compatible with a item #4215 (an 8mm bushing). Then new parts that were tagged "8mm" "dog" and "gear" "head" would both be listed as likely compatible with this 8mm bushing... And hopefully the vast quantities of data would fix that sort of thing.

And, of course, users have never disagreed when it comes to technical details like this...

Title: Type of AI to tackle this problem?

Body:
I posted this on stackoverflow but want to get your recommendations as well as a user on overflow recommended I post it here.

I'm going to say from the beginning that I am not a programmer, I have a cursory knowledge of different types of AI and am just a businessman building a web app.

Anyways, the web app I am investing in to develop is for a hobby of mine. There are many part manufacturers, product manufacturers, upgrade and addon manufacturers etc. for hardware/products in this hobby's industry. Currently, I am in the process of building a crowd sourced platform for people who are knowledgeable to go in and mark up compatibility between those parts as its not always clear cut if they are for example:

Manufacturer A makes a "A" class product, and manufacturer B makes upgrade/part that generally goes with class "A" products, but is for one reason or another not compatible with Manufacturer A's particular "A" class product.

However, a good chunk (>60%-70%) of the products/parts in the database can have their compatibility inferred by their properties,

For example:

Part 1 is type "A" with "X" mm receiver and part 2 is also Type "A" with "X" mm interface and thus the two parts are compatible..

or

Part 1 is a 8mm gear, thus all bushings of 8mm from any manufacturer is compatible with part 1. Further more, all gears can only have compatibility relationships in the database with bushing and gear boxes, but there can be no meaningful compatibility between a gear and a rail, or receiver since those parts don't interface.

Now what I want is an AI to be able to learn from the decisions of the crowdsourced platform community and be able to infer compatibility for new parts/products based on their tagged attributes, what type of part they are etc.

What would be the best form of AI to tackle this? I was thinking a Expert System, but explicitly engineering all of the knowledge rules would be daunting because of the complex relations between literally tens of thousands of parts, hundreds of part types and many manufacturers.

Would a ANN (neural network) be ideal to learn from the many inputs/decisions of the crowdsource platform users?

Any help/input is much appreciated.


问:
Microsoft Dev Centre accounts
Looks like Microsoft is offering a special offer of 95% of the yearly subscription for the Phone Dev Centre (I didn't say anything about desperate).

What I was wondering is do you need a seperate account to publish to the Windows Phone app centre and the Windows App Centre?

Also I heard some horror stories about the time it takes to get application published on the Windows phone marketplace, does anyone have any experience with this?

Windows Phone Dev Centre

Windows App Dev Centre

答:
It looks like they are two different subscriptions; I was able to make two separate registrations, and they both accepted the same "display name," and there are two different prices.  Really, they should have just made this one single store.

The Windows Phone App Store is $99 per year, although they say they will credit you back $91 if you apply in the next couple of weeks.  The Windows App Store is $50 per year.

I have no idea how long it takes to get an app approved.  I would imagine that it varies depending on the complexity of the application.

Title: Microsoft Dev Centre accounts


问:
What is the difference in a developer's years of experience with a language?
As stated by the title, what is the difference in years of experience in given language in terms of developers? For example, if one developer has had five years working with language A and the other developer has had two years working with language B followed by three years working with language A, would there be perceivable difference between them?</p>

答:
It depends.

I have a friend who tends to stick to one language, so if you considered him "programmer A" he's got 1 year of experience with that language, five times.

Different languages let you do different things. One essay I particularly like is called "Beating the Averages" by Paul Graham. In it he is trying to convince people to learn lisp, but he also makes some very useful points:

Programmers get very attached to their favorite languages, and I don't want to hurt anyone's feelings, so to explain this point I'm going to use a hypothetical language called Blub. Blub falls right in the middle of the abstractness continuum. It is not the most powerful language, but it is more powerful than Cobol or machine language.

And in fact, our hypothetical Blub programmer wouldn't use either of them. Of course he wouldn't program in machine language. That's what compilers are for. And as for Cobol, he doesn't know how anyone can get anything done with it. It doesn't even have x (Blub feature of your choice).

As long as our hypothetical Blub programmer is looking down the power continuum, he knows he's looking down. Languages less powerful than Blub are obviously less powerful, because they're missing some feature he's used to. But when our hypothetical Blub programmer looks in the other direction, up the power continuum, he doesn't realize he's looking up. What he sees are merely weird languages. He probably considers them about equivalent in power to Blub, but with all this other hairy stuff thrown in as well. Blub is good enough for him, because he thinks in Blub.

When we switch to the point of view of a programmer using any of the languages higher up the power continuum, however, we find that he in turn looks down upon Blub. How can you get anything done in Blub? It doesn't even have y.

Generally, my advice is to learn more than one language, and to learn what languages' strengths and weaknesses are.


答: It sounds like you want some sort of inference engine, which to me suggests an expert system.  I don't think populating one would be that difficult if you can break things down into proper categories (manufacturers, parts, assemblies, etc).  Then you can make general assertions ("gearboxes have multiple gears","gears need bushings","manufacturers make bushings"), have some code that classifies parts and assigns properties, then let your user base enter specific exclusions ("bushings from manufacturer X don't fit into gears from manufacturer Y").  It's not clear from your question what you will do with this system once you've got it, so it's hard to give any more specific examples, but you might want to search on "recommender systems" and see if that sounds like what you're trying to build.</p>

Title: Type of AI to tackle this problem?


答:
Well I do TDD with Unit tests.
The whole TDD mantra revolves around the following cycle:

Since I'm using TDD I am forced to write unit tests. If a test is hard to write then it's a sign that my design is too complicated and it needs to be simplified.

The cycle doesn't end unless you refactor to remove redundancy, so most of the time refactoring is done in small chunks and isn't time consuming. In addition, after each refactoring I run all test cases to make sure I haven't broken anything.

image source: http://www.javacodegeeks.com/2012/05/test-driven-development-win-win.html

Title: How to write good code with new stuff?


问:
Tracking work history in a git repo
Previous related questions:

Code bases for desktop and mobile versions of the same app

Git branching and tagging best practices

Question:

I have split my repo into three directories (swing, android, and common) as suggested by @KarlBielefeldt in response to my previous question. Now I am jumping back and forth between developing my Android port and tweaking/adding features to my original Swing app. All of my commits are linear (fast-forward) and only my commit messages give hints indicating whether I'm working on my Swing app or my Android app. Is there a better way to keep track of the work flow in my git repo?

答:
For the most part I would expect to be able to do well enough with targeted log commands. For example, running

git log path/to/android

If it were me I would look at all four areas as one project and not worry about it, but if you really want separate histories, git submodules would probably be your best bet. With this method, you would create separate git repositories for swing, android, and common. Then, you would create a fourth repository: the project repo. The project repo would then have the android, swing, and common versions as submodules that git pulls in from their separate repositories.

At this point, you have separate histories for each of your common areas.

Title: Tracking work history in a git repo


答: Everyone learns how to write a program by writing it.  Refactoring is part of the process, because you're better qualified to write it the second time through.  The trick is not to try to avoid the refactoring, but to do it sooner and more frequently.  Refactor as soon as you notice an issue, instead of waiting until the "end."</p>

Title: How to write good code with new stuff?


答:
I think the motivation for language designers to revise existing languages is to introduce innovation while ensuring that their target developer community stays together and adopts the new language: moving an existing community to a new revision of an existing language is more effective than creating a new community around a new language. Of course, this forces some developers to adopt the new standard even if they were fine with the old one: in a community you sometimes have to impose certain decisions on a minority if you want to keep the community together.

Also, consider that a general-purpose language tries to serve as many programmers as possible, and often it is applied in new areas it wasn't designed for. So instead of aiming for simplicity and stability of design, the community can choose to incorporate new ideas (even from other languages) as the language moves to new application areas. In such a scenario, you cannot expect to get it right at the first attempt.

This means that languages can undergo deep change over the years and the latest revision may look very different from the first one. The name of the language is not kept for technical reasons, but because the community of developers agrees to use an old name for a new language. So the name of the programming language identifies the community of its users rather than the language itself.

IMO the motivation why many developers find this acceptable (or even desirable) is that a gradual transition to a slightly different language is easier and less confusing than a jump into a completely new language that would take them more time and effort to master.
Consider that there are a number of developers that have one or two favourite languages and are not very keen on learning new (radically different) languages. And even for the ones who do like learning new stuff, learning a new programming language is always a hard and time consuming activity.

Also, it can be preferable to be part of a large community and rich ecosystem than of a very small community using a lesser known language. So, when the community decides to move on, many members decide to follow to avoid isolation.

As a side comment, I think that the argument of allowing evolution while maintaining compatibility with legacy code is rather weak: Java can call C code, Scala can easily integrate with Java code, C# can integrate with C++. There are many examples that show that you can easily interface with legacy code written in another language without the need of source code compatibility.

NOTE

From some answers and comments I seem to understand that some readers have interpreted the question as "Why do programming languages need to evolve."

I think this is not the main point of the question, since it is obvious that programming languages need to evolve and why (new requirements, new ideas). The question is rather "Why does this evolution have to happen inside a programming language instead of spawning many new languages?"


问:
Should comments say WHY the program is doing what it is doing? (opinion on a dictum by the inventor of Forth)
The often provocative Chuck Moore (inventor of the Forth language) gave the following advice[1]:

Use comments sparingly! (I bet that's welcome.) Remember that program
  you looked through - the one with all the comments? How helpful were
  all those comments? How soon did you quit reading them? Programs are
  self-documenting, even assembler programs, with a modicum of help from
  mnemonics. It does no good to say:

LA B . Load A with B

In fact it does positive bad: if I see comments
  like that I'll quit reading them - and miss the helpful ones. What
  comments should say is what the program is doing. I have to figure out
  how it's doing it from the instructions anyway. A comment like this is
  welcome:

COMMENT SEARCH FOR DAMAGED SHIPMENTS

Should comments say why the program is doing what it is doing?

In addition to the answers below, these two Programmers posts provide additional insight:

Beginner's guide to writing comments?

An answer to Why would a company develop an atmosphere which discourage code comments?

References

1. Programming a problem-oriented-language, end of section 2.4. Charles H. Moore. Written ~June 1970.

答:
I will get flamed for this, but in my experience, the most of the time the answer is NO.

Food for thought:

You are writing an essay. You write a paragraph of text. Would you then write another paragraph explaining what the first paragraph is all about? Unlikely. Is programming that much different from writing essays or novels? Some writers (programmers) are good and some are bad. Book authors write for people, when programmers write for people and machines. I would argue and say that code is written for both people and machines, so most of the time there should be no need in commenting (describing) what it does.

Comments that you write are always useful and make sense, don't they? How about comments written by your colleagues? What do you think they think about comments that you write? I hate some of my colleagues' comments. I bet they are not fond of mine too. Good that I have stopped commenting everything.

Could you not refactor (rename, restructure, reuse and whatever else you need to do) your code in a way so that it doesn't need comments? Most of the time you can do that. If not, then please post few code snippets in comments or in your answer - it would be interesting for community to try and refactor it so that there will be no need for further comments.

Do you like maintaining unnecessary things? I don't. Most of the comments that I have seen in non-public APIs were unneccessary.

Often people comment something that's broken. It's broken. Class is a mess, it does ten different things. I'll just comment it and it'll make me feel less guilty. Each time something breaks, people will look at my comment and it will make them feel better. No it won't. Bad code needs to be fixed on a spot, not commented. If you don't do it right away, than it will haunt you or your colleagues later. Guess what they will think of you?

I have been a software engineer for few years now and I went from "comment everything" to "no comments at all". Having said that, I would:

Comment public API, or any piece of code that will be given to a third party, otherwise they will probably spam you with complaints and support requests.

Regular expressions.

Something that's really complex. With all the frameworks out there, I hardly ever come across something really complex.

One of the answers here states that without comments it's easy to see what the program is doing, as opposed to why it's doing it. Why something is being done doesn't belong in code. It should be in a separate document, SharePoint, blog, napkin, but not in code.


问:
How to better integrate a unix development environment into Windows
I'm mostly a Windows user but I do most of my development (essentially web development) using unix tools and software. I've been going back and forth between using a dedicated lubuntu virtual machine on Virtualbox and using some tools directly in windows (msgit, python, django), but none of these approaches is entirely satisfactory.

I'd like to hear of ways other devs use to better integrate a unix workflow into windows. For instance tighter integration between a linux and vm and windows. The vagrant demo showed how a VM could work off of a windows project folder and I found that nice. I'd like to hear of other tools and tips that would help mimic the workflow one can find on OS X (of course I understand that it cannot be as tightly integrated on Windows as it doesn't have the same unix underpinnings).

PS: I have tried cygwin as well

EDIT for clarifications about What I find lacking (thanks to axblount for pointing that out) :
unix tools like msys et al do not work as well as their native unic counterparts. Many scripts, installers require further configuration or do not work at all. For instance getting virtualenvwrapper to work is not very straightforward.
virtualbox: ideally I would like to use windows software (photoshop, sublime text 2) seamlessly with linux. I mostly use a FTP client atm to move over files edited on the windows side which is a tedious process.

SUMMARY:
It seems there are no established solutions. As a temporary solution I will probably try to use the native versions of frameworks and libraries through the windows command line when possible and switch to a tool like vagrant for incompatible programs.

MORE INFO FROM REPLIES AND COMMENTS:
The case-sensitivy issue seems to work against windows as pointed out by @GlenPeterson

答:
If you're deploying your software on Linux servers, you should practice deploying your software on a Linux server (even in a VM). Make your deployment process automatic. The most important part is code distribution and deployment. You must consistently build and deploy on your target system type.

Find yourself a good terminal and learn to use it. I use Putty and have found it to be a lot better than cygwin and msys.

Some continuous integration systems allow you to run and test code remotely before it is allowed to be committed to your VCS. Using this functionality on your target system type can prevent a lot of problems.


问:
How to teach Exception Handling for New Programmers?
How do you go about teaching Exception Handling to Programmers. All other things are taught easily - Data Structures, ASP.NET, WinForms, WPF, WCF - you name it, everything can be taught easily.

With Exception Handling, teaching them try-catch-finally is just the syntactic nature of Exception Handling.

What should be taught however is - What part of your code do you put in the try block? What do you do in the catch block?

Let me illustrate it with an example.

You are working on a Windows Forms Project (a small utility) and you have designed it as below with 3 different projects.

UILayer

BusinessLayer

DataLayer

If an Exception (let us say of loading an XDocument throws an exception) is raised at DataLayer (the UILayer calls BusinessLayer which in turns calls the DataLayer), do you just do the following

```<code>//In DataLayer
try {
    XDocument xd_XmlDocument = XDocument.Load("systems.xml");
}
catch(Exception ex)
{
    throw ex;
}
</code>```

which gets thrown again in the BusinessLayer and which is caught in UILayer where I write it to the log file?

Is this how you go about Exception Handling?

答:
Pretend a monkey is using the keyboard

I used to tell my guys when they are writing code to pretend that a monkey will be sitting at the keyborad and using this application.

This taught them how to anticipate all kinds of things:

Missing data

Missing files

Alpha characters when you expect numbers

Division by zero

I think it was the word picture of having a monkey just banging keys and doing whatever it wanted instead of following along nicely that did the trick. It worked for me.


问:
Which statically typed languages support intersection types for function return values?

Initial note:

This question got closed after several edits because I lacked the proper terminology to state accurately what I was looking for. Sam Tobin-Hochstadt then posted a comment which made me recognise exactly what that was: programming languages that support intersection types for function return values.

Now that the question has been re-opened, I've decided to improve it by rewriting it in a (hopefully) more precise manner. Therefore, some answers and comments below might no longer make sense because they refer to previous edits. (Please see the question's edit history in such cases.)

Are there any popular statically & strongly typed programming languages (such as Haskell, generic Java, C#, F#, etc.) that support intersection types for function return values? If so, which, and how?

(If I'm honest, I would really love to see someone demonstrate a way how to express intersection types in a mainstream language such as C# or Java.)

I'll give a quick example of what intersection types might look like, using some pseudocode similar to C#:

```<code>interface IX { … }
interface IY { … }
interface IB { … }

class A : IX, IY { … }
class B : IX, IY, IB { … }

T fn()  where T : IX, IY
{
    return … ? new A()
             : new B();
}
</code>```

That is, the function fn returns an instance of some type T, of which the caller knows only that it implements interfaces IX and IY. (That is, unlike with generics, the caller doesn't get to choose the concrete type of T — the function does. From this I would suppose that T is in fact not a universal type, but an existential type.)

P.S.: I'm aware that one could simply define a interface IXY : IX, IY and change the return type of fn to IXY. However, that is not really the same thing, because often you cannot bolt on an additional interface IXY to a previously defined type A which only implements IX and IY separately.

Footnote: Some resources about intersection types:

Wikipedia article for "Type system" has a subsection about intersection types.

Report by Benjamin C. Pierce (1991), "Programming With Intersection Types, Union Types, and Polymorphism"

David P. Cunningham (2005), "Intersection types in practice", which contains a case study about the Forsythe language, which is mentioned in the Wikipedia article.

A Stack Overflow question, "Union types and intersection types" which got several good answers, among them this one which gives a pseudocode example of intersection types similar to mine above.

答:
You might be able to do what you want by using a bounded existential type, which can be encoded in any language with generics and bounded polymorphism, e.g. C#.

The return type will be something like (in psuedo code)

IAB = exists T. T where T : IA, IB

or in C#:

```<code>interface IAB<IA, IB>
{
    R Apply<R>(IABFunc<R, IA, IB> f);
}

interface IABFunc<R, IA, IB>
{
    R Apply<T>(T t) where T : IA, IB;
}

class DefaultIAB<T, IA, IB> : IAB<IA, IB> where T : IA, IB
{
    readonly T t;

    ...

    public R Apply<R>(IABFunc<R, IA, IB> f) {
        return f.Apply<T>(t);
    }
}
</code>```

Note: I haven't tested this.

The point is that IAB has to be able to apply an IABFunc for any return type R, and an IABFunc has to be able to work on any T which subtypes both IA and IB.

The intent of DefaultIAB is just to wrap an existing T which subtypes IA and IB. Note that this is different from your IAB : IA, IB in that DefaultIAB can always be added to an existing T later on.

References:

Existential types in C#

Body:
You might be able to do what you want by using a bounded existential type, which can be encoded in any language with generics and bounded polymorphism, e.g. C#.

The return type will be something like (in psuedo code)

IAB = exists T. T where T : IA, IB

or in C#:

interface IAB<IA, IB>
{
    R Apply<R>(IABFunc<R, IA, IB> f);
}

interface IABFunc<R, IA, IB>
{
    R Apply<T>(T t) where T : IA, IB;
}

class DefaultIAB<T, IA, IB> : IAB<IA, IB> where T : IA, IB
{
    readonly T t;

    ...

    public R Apply<R>(IABFunc<R, IA, IB> f) {
        return f.Apply<T>(t);
    }
}

Note: I haven't tested this.

The point is that IAB has to be able to apply an IABFunc for any return type R, and an IABFunc has to be able to work on any T which subtypes both IA and IB.

The intent of DefaultIAB is just to wrap an existing T which subtypes IA and IB. Note that this is different from your IAB : IA, IB in that DefaultIAB can always be added to an existing T later on.

References:

Existential types in C#


问:
How can I improve my skills while working on actual projects, in the absence of more experienced developers?
I'm the lead developer at a small company, working with C# and ASP.Net. Our team is small, 2-3 people, without much experience in development and design. I don't have the opportunity to learn from more senior developers, there is no one in my team to guide me and help me choose the best approaches, as I take care most of the projects myself.

How can I improve my software development skills while working on actual projects, in the absence of more experienced developers?

答: Practice solving problems. Read and work to understand others code (github is a great resource for this) and submit improvements to it. Doing consulting work can really help you broaden your skill set.</p>


问:
Is it possible to build a single game to run in Facebook & Google+?
I was asked by my customer to build a Facebook game. The game would be something similar to Mafiawars.com where the game is hosted on a server and run through a frame on Facebook.

The thing is after several days of negotiations with the customer and near the finalization of the requirements he mentioned something strange. He said that if the game was successful on Facebook then we may add it to Google+ too.

I thought he meant that we'll develop a new version for Google+, but he refused as he argued that the game should be able to support both sites and he won't pay for the same game twice.

Now I haven't developed neither Facebook nor Google+ games before, so I don't know if it is possible to build a single Facebook/Google+ game.

How would you react to such requirement? How would you design such an application?

Notes

I confirmed with the customer that he wasn't talking about using Open ID he wanted full integration (sharing post, friend requests,..etc.)

I really don't want to lose that customer for numerous reasons (He even agreed to extend the project time to compensate for the time I need to learn Facebook/Google+ APIs)

答:
I would react positively to such a requirement assuming customer is fully aware of what's required.

How will the game integrate with Facebook and Google+? Facebook offers one thing, when Google offers another. Their APIs change, new features get rolled out, when other features get removed as they aggravate users with spam or what-not. There is no way you can guarantee that both Facebook and Google+ version will be the same. There is no way you'll be able to target both platforms without extra work.

My colleague is currently working on a Facebook game. The backbone of the game is independent of Facebook. It runs in an IFrame, but it talks to Facebook to allow players to invite their friends, to purchase items etc.

Google+ have their own ecosystem so you'll have to adapt your game to that ecosystem too. In regards to implementation, you'll have to abstract interaction with Facebook and Google+.

I would consider implementing it in such a way that your game talks to the social platform (something you'll have to implement) and social platform talks to multiple social networks. Think of social platform as a layer of indirection. Your game doesn't want to know anything about Facebook, Google+ or Twitter. Once you achieve this, it'll be relatively easy to add or remove social networks from your Social platform.

If you do decide to implement this social platform, then try to make it independent from your game. Once again it's all about separation of concerns. Facebook and Google+ will be active for years to come. Once you write this platform, or a facade for talking to the social networks, you can re-use it in further projects.


问:
Should we exclude code for the code coverage analysis?
I'm working on several applications, mainly legacy ones.
Currently, their code coverage is quite low: generally between 10 and 50%.

Since several weeks, we have recurrent discussions with the Bangalore teams (main part of the development is made offshore in India) regarding the exclusions of packages or classes for Cobertura (our code coverage tool, even if we are currently migrating to JaCoCo).

Their point of view is the following: as they will not write any unit tests on some layers of the application (1), these layers should be simply excluded from the code coverage measure. In others words, they want to limit the code coverage measure to the code that is tested or should be tested.

Also, when they work on unit test for a complex class, the benefits - purely in term of code coverage - will be unnoticed due in a large application. Reducing the scope of the code coverage will make this kind of effort more visible...

The interest of this approach is that we will have a code coverage measure that indicates the current status of the part of the application we consider as testable.

However, my point of view is that we are somehow faking the figures. This solution is an easy way to reach higher level of code coverage without any effort.
Another point that bothers me is the following: if we show a coverage increase from one week to another, how can we tell if this good news is due to the good work of the developers, or simply due to new exclusions?

In addition, we will not be able to know exactly what is considered in the code coverage measure. For example, if I have a 10,000 lines of code application with 40% of code coverage, I can deduct that 40% of my code base is tested (2). But what happen if we set exclusions? If the code coverage is now 60%, what can I deduct exactly? That 60% of my "important" code base is tested? How can I

As far as I am concerned, I prefer to keep the "real" code coverage value, even if we can't be cheerful about it. In addition, thanks to Sonar, we can easily navigate in our code base and know, for any module / package / class, its own code coverage. But of course, the global code coverage will still be low.

What is your opinion on that subject? How do you do on your projects?

Thanks.

(1) These layers are generally related to the UI / Java beans, etc.

(2) I know that's not true. In fact, it only means that 40% of my code base

答:
I suggest reporting a set of metrics for each layer of your code. These metrics should include size information (e.g., LoC, number of libraries, number of classes or methods, etc.), testing information (e.g., coverage), and bug information (e.g., find and fix rates).

Your excluded layers will have 0% coverage, and your tested areas will have the 60% coverage you mentioned. The size information will let people understand how much is untested or tested. The bug information will inform you if you maybe should be creating tests for the excluded layers, and if your existing tests are working.

It is easy for software organizations to become too focused on the purity of metrics. We don't make metrics, we make good software. A metric that that helps you to deliver high-quality software in a timely manner is the most honest, pure metric there is.


答: Once you've written and debugged the code then set that code aside and write it again in a different way.  Vary the data structures.  Or the control structures.  Try wacky designs. Repeat.  Often the cleanest code structure isn't immediately obvious and by trying different appraoches you may stumble upon a better solution.</p>

Title: How to write good code with new stuff?


答: If you're running a recent version of Windows, take a look at SUA, the Subsystem for Unix Applications.  It has a shell (ksh) and supports over 300 common Unix commands and utilities.  Most of the docs talk about Server 2003 R2, but it installs on Windows 7 too.</p>

Title: How to better integrate a unix development environment into Windows

Body:
I'm mostly a Windows user but I do most of my development (essentially web development) using unix tools and software. I've been going back and forth between using a dedicated lubuntu virtual machine on Virtualbox and using some tools directly in windows (msgit, python, django), but none of these approaches is entirely satisfactory.

I'd like to hear of ways other devs use to better integrate a unix workflow into windows. For instance tighter integration between a linux and vm and windows. The vagrant demo showed how a VM could work off of a windows project folder and I found that nice. I'd like to hear of other tools and tips that would help mimic the workflow one can find on OS X (of course I understand that it cannot be as tightly integrated on Windows as it doesn't have the same unix underpinnings).

PS: I have tried cygwin as well

EDIT for clarifications about What I find lacking (thanks to axblount for pointing that out) :
unix tools like msys et al do not work as well as their native unic counterparts. Many scripts, installers require further configuration or do not work at all. For instance getting virtualenvwrapper to work is not very straightforward.
virtualbox: ideally I would like to use windows software (photoshop, sublime text 2) seamlessly with linux. I mostly use a FTP client atm to move over files edited on the windows side which is a tedious process.

SUMMARY:
It seems there are no established solutions. As a temporary solution I will probably try to use the native versions of frameworks and libraries through the windows command line when possible and switch to a tool like vagrant for incompatible programs.

MORE INFO FROM REPLIES AND COMMENTS:
The case-sensitivy issue seems to work against windows as pointed out by @GlenPeterson


问:
What's your favourite quote about programming?
What's your favourite quote about programming?

One quote per answer, and please check for duplicates before posting!

答: What you are asking me to do is like trying to put the toothpaste back in the tube. It doesn't work.</p>

LastEditorDisplayName: Roger Pate


答:
Scala has full intersection types built into the language:</p>

```<code>trait IX {...}
trait IY {...}
trait IB {...}

class A() extends IX with IY {...}

class B() extends IX with IY with IB {...}

def fn(): IX with IY = if (...) new A() else new B()
</code>```

Title: Which statically typed languages support intersection types for function return values?

Body:
Initial note:

This question got closed after several edits because I lacked the proper terminology to state accurately what I was looking for. Sam Tobin-Hochstadt then posted a comment which made me recognise exactly what that was: programming languages that support intersection types for function return values.

Now that the question has been re-opened, I've decided to improve it by rewriting it in a (hopefully) more precise manner. Therefore, some answers and comments below might no longer make sense because they refer to previous edits. (Please see the question's edit history in such cases.)

Are there any popular statically & strongly typed programming languages (such as Haskell, generic Java, C#, F#, etc.) that support intersection types for function return values? If so, which, and how?

(If I'm honest, I would really love to see someone demonstrate a way how to express intersection types in a mainstream language such as C# or Java.)

I'll give a quick example of what intersection types might look like, using some pseudocode similar to C#:

```<code>interface IX { … }
interface IY { … }
interface IB { … }

class A : IX, IY { … }
class B : IX, IY, IB { … }

T fn()  where T : IX, IY
{
    return … ? new A()
             : new B();
}
</code>```

That is, the function fn returns an instance of some type T, of which the caller knows only that it implements interfaces IX and IY. (That is, unlike with generics, the caller doesn't get to choose the concrete type of T — the function does. From this I would suppose that T is in fact not a universal type, but an existential type.)

P.S.: I'm aware that one could simply define a interface IXY : IX, IY and change the return type of fn to IXY. However, that is not really the same thing, because often you cannot bolt on an additional interface IXY to a previously defined type A which only implements IX and IY separately.

Footnote: Some resources about intersection types:

Wikipedia article for "Type system" has a subsection about intersection types.

Report by Benjamin C. Pierce (1991), "Programming With Intersection Types, Union Types, and Polymorphism"

David P. Cunningham (2005), "Intersection types in practice", which contains a case study about the Forsythe language, which is mentioned in the Wikipedia article.

A Stack Overflow question, "Union types and intersection types" which got several good answers, among them this one which gives a pseudocode example of intersection types similar to mine above.

Body:
Scala has full intersection types built into the language:

trait IX {...}
trait IY {...}
trait IB {...}

class A() extends IX with IY {...}

class B() extends IX with IY with IB {...}

def fn(): IX with IY = if (...) new A() else new B()


问:
Should you ever re-estimate user stories?
My current project is having a 'discussion' which is split down the middle- "this story is more complex than we originally thought, we should re-estimate" vs "you should never re-estimate as you only ever estimate up and never down".

Can anyone shed some light on whether you ever should re-estimate?

IMHO I'd imagine you could bring up an entirely new card for a new requirement or story, but going back and re-estimating on backlog items seems to skew the concept of relative sizing and will only ever 'inflate' your backlog.

答:
A core part of estimating stories in one team I worked on was the idea of a story which was 'too big' to estimate. That is - the workload implied by the story was beyond the scope of a single sprint.

As more information came to hand, or the team got a better grasp on what at first seemed a single beast of a story, we would often re-estimate the story down. In most cases, this might involve breaking the 'too big' story into smaller, achieveable stories and estimating those instead.

These 'too big' stories never went into sizing numbers or burn down charts.

As well, we might come back to a story down the track and with a better understanding of the requirements, we could re-estimate. You should not re-estimate a story simply because it has become easier to achieve (e.g; after building up a bunch of framework libraries, a dependant piece of work will be easier to achieve), because the whole idea is that as you become 'better', the team can achieve more in a sprint, but certainly I think it is valid to re-estimate stories if your understanding of them changes.

The following was going to be a comment but I got carried away...

Don't forget to distinguish between size and complexity in your estimating. You should estimate on size only, not complexity or difficulty. For example - adding a button to a screen should always be a '1', in that as far as the user is concerned, they are getting a button - size is very low. It doesn't matter if you actually implement it in C# (low complexity, very easy) or Assembly (high complexity, very difficult); the user story has the same size.

So, when I say that it's worthwhile re-estimating when understanding changes, it's not that your understanding of how to implement the feature has changed, it's your understanding of what the feature is which has changed.

So, "I want a button" is easy, but later you realise the user means "I want a clickable button, which turns green and pops up a message to the user, is now a more complex story, and so should be re-estimated.

Update; as requested, I'll try to elaborate on what I mean by estimating on 'size' rather than complexity.

I think it easiest to consider this distinction in terms of a new product. Your team is tasked with building a multi-screen system, where everything is new. Amongst your user stories, you have a series of stories like;

1) I want a button on Screen A, which when clicked will show an error to unauthorised users.
2) I want a button on Screen B, which when clicked will show a message if the current day is a weekend.
3) I want a menu oiption on Screen C, which when clicked will make the screen flash every 5 minutes.

Now, when the team estimates these stories, they agree that they are all roughly the same size, and estimate each one as a 'small' story, worth 5 points on their sprint velocity scale.

The sprints kick off, and for the first sprint, the team achieve none of these stories, because they spend the whole cycle setting up projects, infrastructure, core libraries, etc. And there's a new guy on the team who is still learning.

A few sprints in, and the team puts together a screen which fulfills Story #1 - happy days, they've now achieved 5 points of velocity. (With an average of say, 1 point per sprint, due to the unproductive sprints at the start).

Now, for the next sprint, the infrastructure is in place, the team has a screen template to re-use and the new guy is getting his head around things, and this sprint, the team knock off Story #2 & #3.

Now, they have achieved 10 points in a sprint, for an average of about 4 points per sprint.
This shows that team productivity is improving over time, which is entirely expected, as the project evolves, the team upskills, core code is reused (not rewritten).

This to me, is the ideal. Well estimated stories, demonstrating an icnrease in velocity over time (which, eventually will plateau you would assume, unless something major changes - like a new team member, etc).

On the other hand, if right at the start, the team looked at those stories and estimated them based on complexity, they would find that Story #1 is a BIG story, as they are factoring in all the ramp-up effort, plus the new guy needing training. Story #2 is a MEDIUM, because they figure they'll be at least on the way by then, and it should be easier. And finally, story #3 is a SMALL, because it'll be easy once #1 & #2 are done.

Now, what you've ended up with in this model is simply an obfuscated estimate of TIME; the estimates are factoring in how hard it will be and how long it will take to get a piece of work done, and as we know, this is difficult at best. In this model, velocity is evened out from the start, and you'll never be able to demonstrate an improvement in team performance. If you estimate on time, then you'll only ever be able to achieve 40 hours of work in a week. And you'd be silly to plan a sprint with any more or less work. If the team improves its capabilities, you can still only book 40 hours of work. You will only ever achieve 40 hours of work.

Hence, why I noted that a job in C# is easier than a job in Assembly (less complexity), but that the 'size' of the task should be estimated equivalently. That way, you can see that the choice to move languages, improvements in capability, (or adjustments to some other team dynamic) has a direct impact on velocity.

[Another Update: Addressing Prioritisation]

As for prioritisation, I believe this is a separate discussion to sizing/estimating. You don't prioritise the queue simply on the estimates of a story, else we would only ever do small jobs, and never the bigger, [possibly] more imporant, ones. In a team I led, we routinely had conversations about complexity when managing a sprint queue. The PO would be given to understand that, whilst some task is a "SMALL" task (in story points), it might be difficult to achieve because of X,Y,Z. At times, the team's velocity would take a hit, in order to implement some of these more complex stories. Other times, the PO would say "well, I'd rather have 5 other things this sprint, so we will put off the more complex jobs".

If we simply estimated stories in difficulty, then that would be hiding the velocity. Difficult or time-consuming tasks would always be given more weighting, in order to make velocity average out. As I noted before, this is just a different form of time-estimating, and there's no point tracking velocity if this is your estimation method, as you always have a fixed duration for a sprint, so your "velocity" would only change if you estimated incorrectly (e.g; an 8hour task took 1hour).

Hope that clears it up a liitle?


答: It seems like in this case, if the estimate was wildly wrong, that you would cancel the sprint and start over. This would, of course, be up to the scrum master and the owner. When there's no way to deliver anywhere close to the estimate we need to be honest with the boss and tell them sooner so decisions can be made.</p>

Title: Should you ever re-estimate user stories?

Body:
My current project is having a 'discussion' which is split down the middle- "this story is more complex than we originally thought, we should re-estimate" vs "you should never re-estimate as you only ever estimate up and never down".

Can anyone shed some light on whether you ever should re-estimate?

IMHO I'd imagine you could bring up an entirely new card for a new requirement or story, but going back and re-estimating on backlog items seems to skew the concept of relative sizing and will only ever 'inflate' your backlog.