问:
Moving to Python (SciPy and NumPy) for Scientific Computing
Just read a presentation about using Python for Scientific Computing. I am currently using MATLAB (student license FTW, which will expire when I graduate soon).

So I was wondering how matured SciPy and NumPy are with respect to relying on them for all the Scientific Computing I need to do. The advantage is that it's free. I am mainly focused on Signal Processing, Audio, Acoustics kind of computing.

I can imagine that the NumPy and SciPy projects are evolving with respect to the support for more complex techniques. So, how fast are they evolving, are there large communities behind them?

Finally, are there other solutions?

答:
Python with SciPy/NumPy is a pretty mature platform for scientific computing.

The one place where arguably it's pretty weak is upper level statistics - I haven't been terribly impressed with the offerings in that area, and despite my deep love for Python have not adopted it as a statistics workbench at all. The good news is you can get around this by calling R from Python.

With the addition of R (or another statistics language - the only other one I'd consider unless you really had a specific requirement would be SAS, and that's pricey), the combination of the two is a very solid, open-source and actively developing platform. R does work a little bit differently than most programming languages, because of a slightly different philosophy. It's designed for how statisticians think, rather than programmers. Hence things like indices starting at one - that's often because that's also "Subject 1", "ID0001" etc.


问:
Binaries in source control
When developing for embedded devices and other odd worlds, it's very likely your build process will include multiple proprietary binaries, using very specific versions of them.
So the question is, are they part of your source control? My offices goes by the rule of "checking out from source control includes everything you need to compile the code" and this has led to some serious arguments.

The main arguments I see against this is bloating the source control DB, the lack of diffing binary files (see prior questions on the subject). This is against the ability to check out, build, knowing you have the precise environmental the previous developer intended and without hunting down the appropriate files (with specific versions no less!)

答:
This reminds me of the "jars in repository" problem that some time ago Java had. People building java apps were used to push their dependencies (binary jar files) into repositories. Everybody were happy with this, because we you would have "one click" build system and disk space is cheap, so who cares. Then came Maven and you could get rid of all that binary cruft and with local cache-only repository still maintain bullet-prof builds. Still you have "one click" build system, but source control doesn't have to shuffle around binary files that make no sense there.

So yeah, you can get binary files out of the source control, but this will require you to tweak the build system, to get them at build time. Without dedicated software (like Maven) this might be a lot of effort to just get them out.

ContentLicense: CC BY-SA 3.0

Title: Binaries in source control


答:
The idea of VERSION CONTROL (misnomer: source control) is to allow you to roll back through history, recover the effect of changes, see changes and why made. This is a range of requirements, some of which need binary thingies, some of which don't.

Example: For embedded firmware work, you will normally have a complete toolchain: either a proprietary compiler that cost a lot of money, or some version of gcc. In order to get the shipping executable you need the toolchain as well as the source.

Checking toolchains into version control is a pain, the diff utilities are horrible (if at all), but there is no alternative. If you want the toolchain preserved for the guy who comes to look at your code in 5 years time to figure out what it does, then you have no choice: you MUST have the toolchain under version control as well.

I have found over the the years that the simplest method to do this is to make a ZIP or ISO image of the installation CD and check this in. The checkin comment needs to be the specific makers version number of the toolchain. If gcc or similar, then bundle up everything you are using into a big ZIP and do the same.

The most extreme case I've done is Windows XP Embedded where the "toolchain" is a running Windows XP VM, which included (back then) SQL Server and a stack of configuration files along with hundreds and hundreds of patch files. Installing the whole lot and getting it up to date used to take about 2-3 days. Preserving that for posterity meant checking the ENTIRE VM into version control. Seeing as the virtual disk was made up of about 6 x 2GB images, it actually went in quite well. Sounds over the top, but it made life very easy for the person who came after me and had to use it - 5 years later.

Summary: Version control is a tool. Use it to be effective, don't get hung up about things like the meaning of words, and don't call it "source control" because its bigger than that.

Title: Binaries in source control

Body:
When developing for embedded devices and other odd worlds, it's very likely your build process will include multiple proprietary binaries, using very specific versions of them.
So the question is, are they part of your source control? My offices goes by the rule of "checking out from source control includes everything you need to compile the code" and this has led to some serious arguments.

The main arguments I see against this is bloating the source control DB, the lack of diffing binary files (see prior questions on the subject). This is against the ability to check out, build, knowing you have the precise environmental the previous developer intended and without hunting down the appropriate files (with specific versions no less!)


问:
Knowledge base / questionarie / desicion-tree / decision-making platform
I am looking for a software platform/programming framework which can do the following:

INPUT: a user inputs some text

PROCESS/REFERENCE DATA: the user is then asked to answer a list some questions regarding the INPUT and attribute the answers either to the whole INPUT or to some parts of the INPUT

OUTPUT: the list of answers attributed to the original INPUT

Some clarifications:

re: REFERENCE DATA: the list of questions should allow for a sub/follow-up question

re: PROCESS: the answering process should be as flexible as possible (user should be able to skip questions, provide his or her own answers, etc)

this is NOT meant to be an automatic/machine learning tool - the user (the human) will be classifying the INPUT himself/herself based on the REFERENCE DATA

答:
This is a huge field, with a lot of methodologies involved:

taxonomy

guided search

faceted search

ontology

semantic web.

Three exemplary platforms, each quite different, are http://www.endeca.com/en/products/Endeca-InFront/Faceted-Search-Navigation.html, http://www.ontotext.com/kim and http://www.thinkmap.com/thinkmapsdk.jsp;jsessionid=E9F7B78CABB9190A900E687793874823.

So I think you should refine what kind of platform you are looking for. For Java, maybe you'll find something useful from the list http://www.searchtools.com/tools/tools-java.html.

Update

Reading your comment, I think some text tagging and afterwards guided search should do the job.

This paper about Generic Text Processing is quite old, but might lead you in a helpful direction.


问:
What kinds of copyright or privacy issues apply to tweets?
If I want to use the data on Twitter in my application, what are the restrictions? What user data should I avoid touching?

For example, if I want to collect information from certain type of tweets about users and use this information on my site as profiles for these users in my site, does this require permission from the users first or can I directly go and get the information?

Technically, from anyone with a public account on twitter, we can get data of his/her tweets and create profile information for him/her, but does twitter privacy policy allow this? If you published some tweet on Twitter, am I allowed to take that tweet content and put it in my site (stating that it is written by you) but without asking you for permission?

I found this in the Twitter Terms of Service:

Tip We encourage and permit broad re-use of Content. The Twitter API
  exists to enable this.

But also found this on the Twitter API Terms:

You may not use Twitter Content or other data collected from end users
  of your Client to create or maintain a separate status update or
  social network database or service.

答: As far as i can see public profiles are all public, which means you can use all the information as you want. But another thing to notice here that twitter makes some constrants on reaching the data you are searching for through API's.</p>


答:
There are a few issues that might come into play here. But, IANAL, so if you want to be very sure, consult a professional:

For a work to qualify for copyright, it usually needs to be sufficiently distinctive, so a tweet may be too short to qualify in most cases

Profile pictures definitely do qualify for copyright, so you'll need to check whether you are allowed to use them (perhaps the user has given permissions through twitter through their terms of service)

Twitter will have terms of service which you will need to comply with

Depending on jurisdiction, the kind of processing you suggest may fall under the personal data protection laws, which restrict what kind of data you can produce, store, process and publish. Note that this can even apply if the data you base this on is fully public.

Title: What kinds of copyright or privacy issues apply to tweets?

Body:
If I want to use the data on Twitter in my application, what are the restrictions? What user data should I avoid touching?

For example, if I want to collect information from certain type of tweets about users and use this information on my site as profiles for these users in my site, does this require permission from the users first or can I directly go and get the information?

Technically, from anyone with a public account on twitter, we can get data of his/her tweets and create profile information for him/her, but does twitter privacy policy allow this? If you published some tweet on Twitter, am I allowed to take that tweet content and put it in my site (stating that it is written by you) but without asking you for permission?

I found this in the Twitter Terms of Service:

Tip We encourage and permit broad re-use of Content. The Twitter API
  exists to enable this.

But also found this on the Twitter API Terms:

You may not use Twitter Content or other data collected from end users
  of your Client to create or maintain a separate status update or
  social network database or service.


答:
From the ToS (you should get your lawyer to review this):

You retain your rights to any Content you submit, post or display on
  or through the Services. By submitting, posting or displaying Content
  on or through the Services, you grant us a worldwide, non-exclusive,
  royalty-free license (with the right to sublicense) to use, copy,
  reproduce, process, adapt, modify, publish, transmit, display and
  distribute such Content in any and all media or distribution methods
  (now known or later developed).

Which means (AFAICT, IANAL, E&OE) that either you enter a sub-licensing agreement with Twitter, or you ask each individual poster whether you may use their content.


答:
Neal Ford argues in The Productive Programmer that you should keep binaries in source control:

Why keep binaries? Projects today depend on a swath of external tools
  and libraries. Let’s say you are using one of the popular logging
  frameworks (like Log4J or Log4Net). If you don’t build the binaries
  for that logging library as part of your build process, you should
  keep it in version control. That allows you to continue to build your
  software even if the framework or library in question disappears (or,
  more likely, introduces a breaking change in a new version). Always
  keep the entire universe required to build your software in version
  control (minus the operating system, and even that is possible with
  virtualization; see “Use Virtualization,” later in this chapter). You
  can optimize retaining binaries by both keeping them in version
  control and on a shared network drive. That way, you don’t have to
  deal with them on an hourly basis, but they are saved in case you need
  to rebuild something a year later. You never know if you will need to
  rebuild something. You build it until it works, then forget about it.
  It is panic inducing to realize you need to rebuild something from two
  years ago and don’t have all the parts.

I couldn't agree more; while this is arguably subverting the VCS for a task it wasn't
designed for ( keeping binaries ), I think the benefits outweigh the potential drawbacks. But, as the author notes later, sometimes keeping the binaries in VCS might not be a practical solution, so other options should be considered - like keeping them on a mapped network drive.

If the binaries aren't too big, I would definitely keep them in VCS. This seems to be even more true in your case, since the binaries are probably small, and you work with very specific versions. They might also be hard to find, due to a variety of reasons ( the authors shut down their website, or the version you need is no longer listed for downloading ). Although unlikely, you never know what will happen in a few years.

I wish I read this book a few years ago, when I was working on a game using a graphics library ( which was dll file ); I interrupted the development for a while, and when I wanted to continue I couldn't find the dll again because the project died.

Title: Binaries in source control


问:
State machines vs threads
Alan Cox once said "A Computer is a state machine. Threads are for people who can't program state machines".

Since asking Alan directly is not an option for humble me, I'd rather ask here:  how does one achieve multi-threading functionality in high-level language, such as Java, using only one thread and state machine? For example, what if there are 2 activities to perform (doing calculations and doing I/O) and one activity can block?

Is using "state-machine only" way viable alternative to multi-threading in high-level languages?

答:
what if there are 2 activities to perform (doing calculations and doing I/O) and one activity can block?

Well I honestly can not imagine how to handle blocking I/O without threads. It's called blocking afterall just because code that invokes it has to wait.

Per my reading of original Cox' email (below) he points out though that threading doesn't scale well. I mean, what if there are 100 I/O requests? 1000? 10000? Cox is pointing out that having large number of threads may lead to severe problems:

From: Alan Cox (alan@lxorguk.ukuu.org.uk)

  Date: Fri Jan 21 2000 - 13:33:52 EST

the IBM paper), that if your application depends on huge numbers of
    threads, you're always going to keep bumping up against the
    scheduler?
    a lot of people throw lots of threads at a problem and it can really
    be bad design.

That is the least of your worry. 1000 threads is 8Mb of kernel stacks,
  and enough switching of tasks to be sure you might as well turn most
  of your cache off. A computer is a state machine. Threads are for
  people who cant program state machines.

There are plenty of cases Linux is most definitely not helping the
  situation notably asynchronous block I/O.

Alan

source: Re: Interesting analysis of linux kernel threading by IBM (linux-kernel mailing list archives)

Title: State machines vs threads


问:
A description for a changing-wording-of-a-website framework
I have built a Ruby gem, which allows programmer (or whoever) to change wording on their Rails website.

When the edit mode is activated, every text on the website will have an edit icon. User can click on that edit icon and change the corresponding text immediately.

It works with text, attributes of any element, select element, and string in Javascript.

Now I don't know how to describe it succinctly.

Right now the description is "WhowishWord facilitates the process of changing wording of a website".

I think the description is bad and vague. Maybe there is a regular keyword for this kind of task (changing wording) that I do not know.

Could someone help me, please?

答:
Your current wording "Have you ever been bored when a project manager (or marketing department) keeps changing wording on a website? WhowishWord facilitates the process of changing wording on a website." requires changing a bit.

I would suggest that you divide your description into several logically ordered paragraphs. Also mention the cost and where from could people get it.

0 - Contains a short description as you did but without the word "bord" and without specifying actors who ask for the change since every case is usually different.

1 - List who would be interested in this tool: Web site designers, admins, etc.

2 - List the technology that your tool demands and the technology you used to build it (if important)

3 - List the features your product has.

4 - Ask for feedback (give the address)

5 - Possibly attach a video showing how it works


问:
Value of maintaining debug outputs
A developer on our team litters his code with debug outputs. He passes many parameters into methods that are only used for debugging.

Personally I find this clutters up the code. If I need to debug something I prefer to use breakpoints and the watch window instead of reading through all the debug output.

I am making major changes to several classes written by this other developer, should I maintain his debug outputs or can I justify removing them?

I have only been in this team for a few months and don't want to upset this developer but also I expect he will rarely be updating this part of the system.

答:
Would branching be an option for your source control ? That way this developer could have a local branch where he can have his debug outputs without polluting the shared codebase.

However for the long term, it imho would be good to show him the benefits of using breakpoints-type debugging as well (one on one or during a "Lunch and Learn") and that gives him a chance to show the benefits of his method as well, but that can be tricky (e.g. if it's a senior developer who is well anchored into his own ways).

Title: Value of maintaining debug outputs


问:
My customer wants me to record a video of how I develop his software product
Working as a freelancer, I often see strange requests from my customers, some of which can negatively affect my daily work¹, and others trying to set some sort of control. I usually encounter those things during preliminary negotiations, so it's easy enough at this stage to explain to the customer that I do care about my work and productivity and expect my customers to trust my work.

Things were much harder² on a project I just accepted, since it's only after the end of the negotiations (the contract has already been signed and did not mention anything about video tracking) and after I started to work on the project that my customer requested that I record a video of all I do on my machine when working on his project, that is, a video which will show that I move the cursor, type a character, open a file, move a window, etc.

I work in my own company, using my own PCs.

I answered to this customer that such request cannot be accepted, since:

Hundreds of hours of work on a dual-screen PC will require a large amount of disk space for the recorded videos. If I don't care about space, I do care about this customer wasting my bandwidth downloading those videos.

Recording a video can affect the overall performance and decrease my productivity (which is not actually true, since the machine is powerful enough to record this video without performance loss, but, well, it still looks like a valid argument).

I can't always remember to turn the video recording on before starting the work, and off at the end.

It may be a privacy concern. What if I switch to my mails when recording the video? What if, to open the directory with the files about this customers project, I first open the parent directory containing the list of all of my customers?

Such video cannot be a reliable source to track the cost of a project (I'm paid by the hour), since some work is done with just a pencil and a paper (which is actually true, since I do lots of draft work without using the PC).

Despite those points, the customer considers that if I don't want to record the video, it's because I have something to hide and want to lie about the real time spent on his project³.

How to explain to him that it is not usual practice for freelancers to record videos of their daily work, and that such extravagant requests must be reserved for exceptional circumstances⁴?

¹ The most frequent example is to be requested to work through Remote Desktop on a more-than-slow server which uses a more-than-slow Internet connection, or to be forced to use outdated software such as Windows Me without serious justification such as legacy support.

² In fact, I already did a lot of management and system design related work, which is essential, but usually misunderstood by customers and perceived as a waste of time and money. Observing the concerned customer, I'm pretty sure that he will refuse to pay a large amount of money for what was already done, since there is actually zero lines of code. Even if legally I can easily prove that there was a lot of work undertaken on the design level, I don't want to end my relation with this customer in a court.

³ Which is not as risky as it could be, since I gave this customer the expected and the maximum cost of the project, so the customer is sure to never be asked to pay more than the maximum amount, specified in the contract, even if the real work costs more.

⁴ One case when I effectively record on my own initiative the video of actions is when I have to do some manipulations directly on a production server of a customer, especially when it comes to security issues. Recording those steps may be a good idea to know precisely what was done, and also ensure that there were no errors in my work, or see what those errors were.

First update

Since the question attracted much more attention and had many more answers than I expected, I imagine that it can be relevant to other people, so here is an update. First, to summarize the answers and the comments, it was suggested to (ordered randomly):

Suggest other ways of tracking, as shown in Twitter Code Swarm video, or deliver a "short milestone with a simple, clear deliverable, followed by more complex milestones", etc.

Explain that video is not a reliable source and can be faked, and that it would be difficult to implement, especially for support.

Explain that video is not a reliable source since it shows only a small part of the work: a large amount of work is done without using a computer, not counting the extra hours spent thinking about a solution to a problem.

Stick with the contract; if the customer wants to change it, he must expect new negotiations and a higher price.

Do the video, "but require that the customer put [the] entire fee into an escrow account", require a lawyer to video tape all billable time, etc., in other words, "operate in an environment void of trust", requiring the customer to support the additional cost.

Search for the laws which forbid this. Several people asked in what country I live. I'm in France. Such laws exist to protect the employees of a company (there is a strict regulation about security cameras etc., but I'm pretty sure nothing forbids a freelancer to sign consciously a contract which forces him to record the screen while he works on a project.

Just do it and send the videos: the customer will "watch a few ten second snippets of activity he won't understand", then throw those videos away.

Say no. After all, it's my business, and I'm the only one to decide how to conduct it. Also, the contract is already signed, and has nothing about video tracking.

Say no. The processes and practices I employ in my company can be considered as trade secrets and are or can be classified.

Quit. If the relation starts like this, chances are it will end badly sooner or later. Also, "if he's treating you like a thief - and that is what he's suggesting - then it's just going to get worse later when XYZ feature doesn't work exactly the way he envisioned".

While all those suggestions are equally valuable, I've personally chosen to say to my customer that I accept to do the videos, but in this case, we must renegotiate the contract, keeping in mind that there will be a considerable cost, including the additional fee for copyright release. The new overall cost would be on average three times the actual cost of the project. Knowing this customer, I'm completely sure that he would never accept to pay so much, so the problem is solved.

Second update

The customer effectively declined the proposal to renegotiate the original contract, taking into account the considerable additional cost. He agreed to continue the project without video recording.

The project continued without video recording. Eventually, the customer seemed satisfied by the final result and cost, so the video recording was not mentioned again.

答:
"How to explain to him that it is not an usual practice for the
  freelancers to record the videos of their daily work, and that such
  extravagant requests must be reserved to exceptional circumstances"⁴

Ask your customer: if you were an employee and not a contractor, would he stand over your shoulder and watch your work all day, every day?  The answer is obviously no.  It is a waste of time (yours and his) to record everything that happens on your screen.

You need to address the root cause of the problem.  Your customer apparently doesn't trust you and thinks you are ripping him off.  Since you've already quoted him a likely and a maximum price, you need to tell him: "You signed a contract based on a known price.  That's how much it is going to cost you regardless of what you perceive my productivity to be."

Give him an option to buy out your contract based on the time you've spent so far.  If he is that concerned about you ripping him off, he might consider that sunk cost to be worth it.

ContentLicense: CC BY-SA 4.0


答:
Good example of a proper state machine usage instead of threads: nginx vs apache2.
Generally you can assume that nginx handles all connections in one thread, apache2 makes a thread per connection.

But to me using state machines vs threads is quite similar using perfectly hand crafted asm vs java: you may achieve increadible results, but it takes a lot of programmers efforts, a lot of discipline, make the project more complex and worths only when used by a lot of other programmers. So if you are the one who wants to make a fast web server - use state machins and async IO. If you are writing the project(not the library to be used everywhere) - use threads.

Title: State machines vs threads

Body:
Alan Cox once said "A Computer is a state machine. Threads are for people who can't program state machines".

Since asking Alan directly is not an option for humble me, I'd rather ask here:  how does one achieve multi-threading functionality in high-level language, such as Java, using only one thread and state machine? For example, what if there are 2 activities to perform (doing calculations and doing I/O) and one activity can block?

Is using "state-machine only" way viable alternative to multi-threading in high-level languages?


问:
How often do you use DI container in your ASP.NET MVC application
While reading a book, I came across DI(dependency Injector) and the subsequent DI Container tool. Previously, I developed an application following a tutorial on asp.net website which never used such tool. So, my question can be summed-up in following two concerns :-

How often do you use DI Container ?

What requirements make you do so ?

EDIT : Examples with and without DI Container. I have written the codes to understand which is better approach.

Without DI Container --

```<code>LinqValueCalculator lc = new LinqValueCalculator();
ShoppingCart sc = new ShoppingCart(lc);
decimal total = sc.CalculateStockValue();
Console.WriteLine("Total: {0:c}", total);
</code>```

With DI Container -- (Ninject is used in this example)

```<code>IKernel ninjectKernel = new StandardKernel();
ninjectKernel.Bind<IValueCalculator>().To<LinqValueCalculator>();

IValueCalculator calcImpl = ninjectKernel.Get<IValueCalculator>();
ShoppingCart cart = new ShoppingCart(calcImpl);
Console.WriteLine("Total: {0:c}", cart.CalculateStockValue());
</code>```

I will be honest, I feel that writing first code was easier and seemed natural. But, your views are what counts as i am just learning the MVC.

答:
I used to write C# asp.net application with all these best practices previously.
DI is very usefull for C# language, that is out of the question. With proper design of your classes and interfaces you can make it less coupled and test / develop easier.

Year ago I switched to dynamic languages like ruby and python. My first idea was to find a DI libraries for them, but then I gave up cause I 've realized that DI is a perfect pattern for solving static language problems.


问:
What's a neat project to help me get used to the modern environment?
I haven't been programming for almost a decade. I used to be able to program in QBasic, Turbo Pascal, C, C++, Visual Basic and Assembly. I have no knowledge in any other programming language (other than HTML).

I want a project (in some programming language) to help me acquaint myself with the new environment (unix, python, perl, java, flash?) in a way that would give me the feeling that I've gained a mini-super-power. By that I mean something that give me the feeling of hacking (not actually learn about hacking, but just like learning C for the first time feels like hacking). Something that would put my programming skills to use in a way that the programming languages I do (did) know don't.

答:
I would start with a blog engine in just about any modern language (C#, Java, etc).

A blog engine helps you learn new concepts by making you implement:

A web-based UI

CRUD operations to a database (blog posts, comments, etc)

Authentication (logging in/logging out and posting as a user)

These three things are the foundation of most applications that you'll write in the real world.  Also, writing a blog gives you the freedom of design and future changes.  You could go on to implement a module framework, or just add new functionality as you see fit.  The best part is you have a solid idea of what a blog engine does, so you have specific and concrete requirements to practice toward.  If you can write a blog engine, you'll be well on your way to learning your new language.

OwnerDisplayName: Shannon

LastEditorDisplayName: Shannon

ContentLicense: CC BY-SA 2.5


问:
How do you annotate code changes and code authorship
What is the best way to annotate who authored a file and subsequent changes that were made?

I'm a contractor on a new project, one that's just starting, which is using Subversion. The other day I noticed a team member had updated a script written by an outside consultant, and he updated the header from "Written by X" to "Writen by Y and X" (since he had made a decent number of updates).

I didn't think this was a good idea, because others after us may update that script with small or large changes and it'd be unclear when to update the "Written by" header (or how to order the names). I pitched the way I had done it at my previous company (with an edit log at the top of each file - which was enforced by whoever verified the changes, we were using Clear Case so changes wouldn't be pushed up until they were verified), but then he mentioned we could just use the "svn log" command to see edits and it'd be hard to enforce an edit log.

So now I'm not so sure what the best way to annotate authorship and changes is. Files can completely change over time, so I don't like the idea of a stale "Written by" header. And a "Written by" header that just includes a long list of people with no context doesn't seem useful. There's removing the authorship header, and simply using the subversion change log, but then what do you do about "Written by" headers from code that's given to you (from consultants, old code bases, downloaded from the net, etc)? How do other teams handle this?

答:
I don't like the idea of a stale "Written by" header.

Correct.  It's useless.

And a "Written by" header that just includes a long list of people with no context doesn't seem useful.

Correct.  They're all dead, BTW.  Or won the lottery.  They're at sea and cannot be contacted.  Why list them?

My favorite is using initials.  Added 12/7/91 SRP.  Who's that? And how will you find out?  If they were a contractor, you'd have to pull all the invoices from around that date, call all the contracting firms that are still in business so they can pull all their personnel records.

what do you do about "Written by" headers from code that's given to you (from consultants, old code bases, downloaded from the net, etc)?

Ignore it.


答:
In development, yes, the use of a debugger and stepping through code, watching variables is the preferred method. It's a matter of code quality. Adding variables to method signatures and other debugging output is messy and introduces variability into the code. There have been defects that have been hidden (or revealed) just because an extra variable was introduced or a console print statement added.

However, there is something to be said for the use of logging to capture debug information, as long as that logging can be adjusted to the appropriate level of verbosity. I typically use something like log4j and various levels of logging. Based on what I'm currently doing, I adjust that level. During normal execution and use, I log at INFO or WARN. If I'm testing, I'll log at TRACE or DEBUG to get more information. This, coupled with the ability to watch variables and set breakpoints is invaluable.

Title: Value of maintaining debug outputs

Body:
A developer on our team litters his code with debug outputs. He passes many parameters into methods that are only used for debugging.

Personally I find this clutters up the code. If I need to debug something I prefer to use breakpoints and the watch window instead of reading through all the debug output.

I am making major changes to several classes written by this other developer, should I maintain his debug outputs or can I justify removing them?

I have only been in this team for a few months and don't want to upset this developer but also I expect he will rarely be updating this part of the system.


答:
Yuck, delete them and when you find a few hundred more delete them too. Especially if they're commented out. It's unlikely you're going to have debug exactly the same thing as your colleague did however many years ago he added them and all they do is make everything more difficult to read.

In the interests of peace in the workplace it might be best to ask your colleague first if that's okay as you're making major changes.

Title: Value of maintaining debug outputs


答:
Can we do without them?

Yes, but you lose the ability to easily unit test your application.  Mocking the different layers/tiers of your application are much easier when you use DI.

How often do I use them?

Always in an MVC app.  StructureMap (for me) has made it so easy to easily set up default conventions that I really don't lose any development time for the gains that it gets me.

BTW, I do DI like this, using Constructor Injection (make unit testing easier):

```<code>public class HomeController : Controller
{
    private readonly IService _service;

    public HomeController(IService service)
    {
        _service = service;
    }

    public ActionResult Index()
    {
        return View(_service.Method());
    }
}
</code>```

Title: How often do you use DI container in your ASP.NET MVC application

Body:
While reading a book, I came across DI(dependency Injector) and the subsequent DI Container tool. Previously, I developed an application following a tutorial on asp.net website which never used such tool. So, my question can be summed-up in following two concerns :-

How often do you use DI Container ?

What requirements make you do so ?

EDIT : Examples with and without DI Container. I have written the codes to understand which is better approach.

Without DI Container --

```<code>LinqValueCalculator lc = new LinqValueCalculator();
ShoppingCart sc = new ShoppingCart(lc);
decimal total = sc.CalculateStockValue();
Console.WriteLine("Total: {0:c}", total);
</code>```

With DI Container -- (Ninject is used in this example)

```<code>IKernel ninjectKernel = new StandardKernel();
ninjectKernel.Bind<IValueCalculator>().To<LinqValueCalculator>();

IValueCalculator calcImpl = ninjectKernel.Get<IValueCalculator>();
ShoppingCart cart = new ShoppingCart(calcImpl);
Console.WriteLine("Total: {0:c}", cart.CalculateStockValue());
</code>```

I will be honest, I feel that writing first code was easier and seemed natural. But, your views are what counts as i am just learning the MVC.

Body:
Can we do without them?

Yes, but you lose the ability to easily unit test your application.  Mocking the different layers/tiers of your application are much easier when you use DI.

How often do I use them?

Always in an MVC app.  StructureMap (for me) has made it so easy to easily set up default conventions that I really don't lose any development time for the gains that it gets me.

BTW, I do DI like this, using Constructor Injection (make unit testing easier):

public class HomeController : Controller
{
    private readonly IService _service;

    public HomeController(IService service)
    {
        _service = service;
    }

    public ActionResult Index()
    {
        return View(_service.Method());
    }
}


问:
How can a team apply the Scrum methodology without a clear customer?
Our team is trying to understand and adapt Scrum and other agile practices, but we can not figure out how to deal with customer feedback when there is no customer. Every document about the subject emphasizes how important is having the customer involved in every sprint and how having early feedback helps correcting problems fast and maximizes satisfaction to both sides. I understand clearly this point.

In our case, we have no single customer. We develop a website and a smartphone app for an already established and growing audience. I am sure this is a fairly common case so I would like to know some real world experience about how to apply and manage Scrum in this case. Do you just decide all features by yourselves or do incorporate user testing in the sprint? Any other solution?

答:
The customer is your audience. Now obviously that poses a problem, and to solve that you need to let yourselves represent the customer.

The difficulty here is being able to stand back from your work and make sure that you know what the audience really wants.

To help with this you can get user feedback, perhaps recruit some people from your audience to try out your work before you release it.

Most importantly you need data. Make sure that the changes you make are really working towards the happiness of your customers, this means statistics. Watch your numbers carefully whenever you make changes, and use that to inform how you progress.

OwnerDisplayName: jordi

OwnerDisplayName: thomasfedb


答: Yes, in that situation someone needs to proxy the user's requirements.  You can use tools to collect user feedback like Getsatisfaction.com but someone will need to decide the requirements.  You may want to involve individual users for testing and validation but understand their requirements will vary.</p>

Title: How can a team apply the Scrum methodology without a clear customer?

Body:
Our team is trying to understand and adapt Scrum and other agile practices, but we can not figure out how to deal with customer feedback when there is no customer. Every document about the subject emphasizes how important is having the customer involved in every sprint and how having early feedback helps correcting problems fast and maximizes satisfaction to both sides. I understand clearly this point.

In our case, we have no single customer. We develop a website and a smartphone app for an already established and growing audience. I am sure this is a fairly common case so I would like to know some real world experience about how to apply and manage Scrum in this case. Do you just decide all features by yourselves or do incorporate user testing in the sprint? Any other solution?

OwnerDisplayName: Colin Smillie


问:
What tools do you use to manage requests from users?
I'm drowning in user emails and I'd like to implement a better way to manage all these requests I get and put them in a queue where those people on a team, as well as users, have access to them and can make common notes. I'm thinking about some sort of task management tool that would allow multiple tasks to be created under a project where emails, comments, ideas, etc. could be dropped/entered and easily accessible.

I need something that all parties can be involved in - users, managers, team leaders, developers. I'm looking for a tool that can allow:

Users to just drag/drop an email to submit a request for maintenance or enhancement.

Developers to just see their queue and the weighted priority of each task/project.

A team of developers to see what everyone is working on in real-time.

Management to keep a a log of time spent on each task.

I I am starting to look in more of a Agile/Scrum direction for solving this problem. I found list of scrum agile sofware project management open source tools. Since I am limited on time, has anyone used these? Which one should I test to see if it will meet my needs? TeamPulse is a good direction, but think it is a little too bloated. I need something simple for all parties.

答:
Pivotal Tracker

I've used it with many clients, many organization types.

It's 'made for agile/scrum'.  It focuses on user stories, particularly features that deliver value.

It is free/very cheap.

It has drag and drop for doing ordering.

Makes sense and easy to use for non-technical end users.

Provides URL links for any given story.

Provides feedback on how much is really getting done during sprints to enable project management and time estimates that are based on the facts of past history.


答:
Considering you are new to the team you should be extremely confident in your changes first.

Standards help in situations like this.  Talk with others on the team and find out what is typical in the group.  Share your quality or efficiency suggestions openly with the team.

If your team has a general agreement that segments of code are "owned" by a particular developer then ask them to review code changes.  It's a good practice to have someone review code anyway and this is a great way for newer team members to gain trust.

Title: Value of maintaining debug outputs


答:
Source control is for sources.  Sources are what you're unable to build from other things.  Some files that qualify as sources happen to be binaries.

My VCS has lots of binaries checked into it, but each one is the unit of release from some product I didn't write and don't maintain.  This might be something like GNU ccRTP, which is released as a compressed tarball.  That tarball is my source, and it's checked in along with whatever infrastructure I need to turn it into a finished product (a Makefile and an RPM spec in my case) in a single, automated step.  When there's a new version of ccRTP, I treat the new tarball as changed source:  it goes into a checked-out copy, gets built, tested and committed back to the VCS.  I've done the same with commercial products that don't ship with source (compilers, libraries, etc.) and it works the same way.  Instead of unpack-configure-compile-package, it's just unpack-package.  The software that does the nightly builds doesn't know or care as long as it can run make and get finished products.

Most VCSes have features that make human-readable source easier to deal with and more efficient to store, but to say that they aren't suited to binaries isn't really true if binaries put in come back out unmolested.  How a VCS deals with binaries internally depends entirely on whether or not its authors thought attempting to only store differences was worth the effort.  Personally, I think storing full copies of a the ccRTP distribution at 600K a pop is more than made up for by the ability to tag a version of it along with all of my other sources.

Title: Binaries in source control


答: We have an internal person represent the customers.  This person talks to tech support to see what customers are requesting or having problems with.  She also deals with our high-profile, mission critical customers directly.  She talks to sales as well to see what potential customers are looking for.  Based on all this feedback, she is the 'product owner' and puts forth the priorities from the backlog.</p>


答:
Other answers have indicated the need for data, and for a customer proxy.

To facilitate both these, you are likely to have two potential resources available. Firstly any feedback you have received from your existing customer base - whether directly or via your  platform provider. Error logs, faqs, feature requests, and the like. I appreciate that for a smartphone app these may not be accessible to you.

The second resource is the team member who is a professional pessimist - most teams have one of these. The guy who is always full of good logical reasons why what is being proposed won't work; why what is already available is all wrong; etc. Ask them what is wrong with the app, and then winnow the answers to identify improvements you can make, that can be incorporated. Your only problem may be getting the pessimist to turn off the list of flaws.


答:
The Product Owner hopefully understands the domain, users, application and can use different techniques to gather information from your current and future users.

This isn't that different from working with a large organization/enterprise. Just because there is only one entity paying the bill doesn't mean you won't be dealing with multiple managers, users and conflicting requirements. This can be worse because everyone thinks their requirements are absolute must have deal-killers.


答:
Threads are the only option in two cases:

to use multiple cores without memory separation.

to cope with external code that blocks.

The second one is why most people think that threads are unavoidable for doing IO or network programming, but this is usually because they don't know their OS has a more advanced API (or don't want to fight with using it).

As for ease to use and readability, there are always event loops (like libev or EventMachine) which make programming a state machine almost as simple as doing it with threads, yet giving enough control to forget about sync problems.

Title: State machines vs threads


答:
Look at what other web companies do to collect iterative feedback.  This site uses a voting method to move good answers up.  Google uses the concept of "Labs" to try out new ideas.

Establish "incentives" for repeat web users to meet with you.  It can be as simple as inviting some users to talk with the lead developers.  Humanize your site with a blog from the developers.  The point here is that if you can't move the customers closer to the developers, then move the developers closer to the customer.

Having a knowledgeable product owner that meets with customers regularly is also valuable.


答:
I think the biggest problem (other than having an insane customer) is that the arguments you make are weak:

Hundreds of hours of work on a dual-screen PC will require a large
  amount of disk space for the recorded videos. If I don't care about
  space, I do care about this customer wasting my bandwidth downloading
  those videos.

Disk space and bandwidth really shouldn't be a concern. You'll bill both of those at a significant markup in addition to the hourly rate you already negotiated.

Recording a video can affect the overall performance and decrease my
  productivity (which is not actually true, since the machine is
  powerful enough to record this video without performance loss, but,
  well, it still looks like a valid argument).

It's not a valid argument because, as you admit, it's simply not true. It may be a plausible argument, but you're trying to build trust with this client rather than undermine it, right?

I can't always remember to turn the video recording on before
  starting the work, and off at the end.

Counterargument: How are you keeping track of the time that you bill? You should be marking time when you start and stop, not trying to figure out how many hours you worked after the fact. Just make the video part of your process.

It may be a privacy concern. What if I switch to my mails when
  recording the video? What if, to open the directory with the files
  about this customers project, I first open the parent directory
  containing the list of all of my customers?

You should be able to handle that. Don't switch to your personal e-mail when you're supposed to be working on the project. Use an alias to get to the project.

Such video cannot be a reliable source to track the cost of a
  project (I'm payed by hour), since some work is done with just a
  pencil and a paper (which is actually true, since I do lots of draft
  work without using the PC).

Your billing process should be a separate matter. If there's a requirement for video of all billed time, that should absolutely have been part of the original contract. So you're right on this point: the video is not the source of billing.

The best argument, IMO, is simply that recording every second will make you feel like you have someone watching over your shoulder all the time, and that's not something you're comfortable with. If your client doesn't trust you to work and bill in good faith, he or she should pay for what you've done and find a new contractor to finish the work (with the understanding that very few professionals would work under the required conditions).

Title: My customer wants me to record a video of how I develop his software product

Body:
Working as a freelancer, I often see strange requests from my customers, some of which can negatively affect my daily work¹, and others trying to set some sort of control. I usually encounter those things during preliminary negotiations, so it's easy enough at this stage to explain to the customer that I do care about my work and productivity and expect my customers to trust my work.

Things were much harder² on a project I just accepted, since it's only after the end of the negotiations (the contract has already been signed and did not mention anything about video tracking) and after I started to work on the project that my customer requested that I record a video of all I do on my machine when working on his project, that is, a video which will show that I move the cursor, type a character, open a file, move a window, etc.

I work in my own company, using my own PCs.

I answered to this customer that such request cannot be accepted, since:

Hundreds of hours of work on a dual-screen PC will require a large amount of disk space for the recorded videos. If I don't care about space, I do care about this customer wasting my bandwidth downloading those videos.

Recording a video can affect the overall performance and decrease my productivity (which is not actually true, since the machine is powerful enough to record this video without performance loss, but, well, it still looks like a valid argument).

I can't always remember to turn the video recording on before starting the work, and off at the end.

It may be a privacy concern. What if I switch to my mails when recording the video? What if, to open the directory with the files about this customers project, I first open the parent directory containing the list of all of my customers?

Such video cannot be a reliable source to track the cost of a project (I'm paid by the hour), since some work is done with just a pencil and a paper (which is actually true, since I do lots of draft work without using the PC).

Despite those points, the customer considers that if I don't want to record the video, it's because I have something to hide and want to lie about the real time spent on his project³.

How to explain to him that it is not usual practice for freelancers to record videos of their daily work, and that such extravagant requests must be reserved for exceptional circumstances⁴?

¹ The most frequent example is to be requested to work through Remote Desktop on a more-than-slow server which uses a more-than-slow Internet connection, or to be forced to use outdated software such as Windows Me without serious justification such as legacy support.

² In fact, I already did a lot of management and system design related work, which is essential, but usually misunderstood by customers and perceived as a waste of time and money. Observing the concerned customer, I'm pretty sure that he will refuse to pay a large amount of money for what was already done, since there is actually zero lines of code. Even if legally I can easily prove that there was a lot of work undertaken on the design level, I don't want to end my relation with this customer in a court.

³ Which is not as risky as it could be, since I gave this customer the expected and the maximum cost of the project, so the customer is sure to never be asked to pay more than the maximum amount, specified in the contract, even if the real work costs more.

⁴ One case when I effectively record on my own initiative the video of actions is when I have to do some manipulations directly on a production server of a customer, especially when it comes to security issues. Recording those steps may be a good idea to know precisely what was done, and also ensure that there were no errors in my work, or see what those errors were.

First update

Since the question attracted much more attention and had many more answers than I expected, I imagine that it can be relevant to other people, so here is an update. First, to summarize the answers and the comments, it was suggested to (ordered randomly):

Suggest other ways of tracking, as shown in Twitter Code Swarm video, or deliver a "short milestone with a simple, clear deliverable, followed by more complex milestones", etc.

Explain that video is not a reliable source and can be faked, and that it would be difficult to implement, especially for support.

Explain that video is not a reliable source since it shows only a small part of the work: a large amount of work is done without using a computer, not counting the extra hours spent thinking about a solution to a problem.

Stick with the contract; if the customer wants to change it, he must expect new negotiations and a higher price.

Do the video, "but require that the customer put [the] entire fee into an escrow account", require a lawyer to video tape all billable time, etc., in other words, "operate in an environment void of trust", requiring the customer to support the additional cost.

Search for the laws which forbid this. Several people asked in what country I live. I'm in France. Such laws exist to protect the employees of a company (there is a strict regulation about security cameras etc., but I'm pretty sure nothing forbids a freelancer to sign consciously a contract which forces him to record the screen while he works on a project.

Just do it and send the videos: the customer will "watch a few ten second snippets of activity he won't understand", then throw those videos away.

Say no. After all, it's my business, and I'm the only one to decide how to conduct it. Also, the contract is already signed, and has nothing about video tracking.

Say no. The processes and practices I employ in my company can be considered as trade secrets and are or can be classified.

Quit. If the relation starts like this, chances are it will end badly sooner or later. Also, "if he's treating you like a thief - and that is what he's suggesting - then it's just going to get worse later when XYZ feature doesn't work exactly the way he envisioned".

While all those suggestions are equally valuable, I've personally chosen to say to my customer that I accept to do the videos, but in this case, we must renegotiate the contract, keeping in mind that there will be a considerable cost, including the additional fee for copyright release. The new overall cost would be on average three times the actual cost of the project. Knowing this customer, I'm completely sure that he would never accept to pay so much, so the problem is solved.

Second update

The customer effectively declined the proposal to renegotiate the original contract, taking into account the considerable additional cost. He agreed to continue the project without video recording.

The project continued without video recording. Eventually, the customer seemed satisfied by the final result and cost, so the video recording was not mentioned again.


答:
I think the only thing really wrong here is the extra parameters which are used only for debugging -- you really shouldn't change the semantics of the codebase to debug things. Having lots of debug output is generally a good thing beyond that.

In terms of operational effects, lots of Debug.Write() statements don't hurt a fly; they get passed over by the compiler if you are not passing the DEBUG flag into it. And, unlike your breakpoints, they survive with the codebase so if you have a regression you don't need to remember where you set the breakpoint and what you were watching. Whereas with the debug output you will always have your instrumentation.

Title: Value of maintaining debug outputs


答:
Do it but require that the customer put your entire fee into an escrow account; otherwise, how will you know he will pay you?

The escrow account should be created by a lawyer who will video tape all billable time spent on the contract.

The client must record all time spent approving the software. Preferably one video file per requirement.

If you're going to operate in an environment void of trust, you may as well go all the way.

Maybe you can just have a Nanny-Cam taped to the top of your head?


问:
What is a clean Agile (Scrum) Sprint Presentation?
Suppose someone of your development team is presenting a sprint to the customer but he is having web connection problems such that a complete story cannot be presented. For the sake of the cleanness of the presentation, do you help your colleague suggesting possible solutions and try to fix it in the moment? Or is it kind of messy?

May be the customer (who is "part" of the team) will understand? Why?

答:
If you and the customer(your teacher) are at the Sprint review meeting and you are demonstrating the working product but the product cannot be shown to work then it's not done.

Having said that, if the product owner (your teacher?) and developers have been working as "part of team" then they probably already know that it's working and may even have tried the functionality themselves.  In that situation, the product owner could decide that the story is done.

So, I would say that if everyone "really" is working together, skip the demo (your presentation).  If the demonstration is what determines done or not then you need to balance the cost of keeping the team longer at the meeting or moving the story to another sprint.

OwnerDisplayName: negarnil


问:
Do you write titles in code comments?
I was browsing some old code that I wrote (first year in the university) and noticed that I used to write comment titles preceeding various parts of the code. Stuff like (this is from a Monopoly game): </p>

```<code>/*Board initialization*/
...code...

/*Player initialization*/
...code...

/*Game logic starts here*/
/*Displaying current situation*/
...code...

/*Executing move*/
...code...

/*Handle special event*/
...code...

/*Commit changes, switch to next player*/
...code...
</code>```

<p>This might be redundant, and arguably unnecessary if the code is really super clear, but as I scanned through the file it surprised me how strongly I felt like I know what's going on even though I hardly looked at the actual code. I can definitely see this as being fitting in certain circumstances, so I wonder- do you do this? Do you think it's a good idea? Or is it too much? </p>

答: I find it interesting how many people dislike the practice without really being able to articulate why.  The reason comments like that are frowned on is they are a sign you have violated the single responsibility principle.  That specific name is usually only used in an OO context, but the general concept is also called cohesion and applies to other paradigms.  Schools don't usually teach those sorts of design principles until toward the end of a degree program, if at all. In fact, some teachers mandate its violation in order to make things easier to grade by cramming everything into one file.  Therefore, your freshman ignorance is excusable, and the fact you noticed "something" wrong and tried to clarify with comments is even laudable under the circumstances, but in general it's better to fix an unclear design rather than try to paper over it with comments.</p>

Title: Do you write titles in code comments?


问:
How to effectively (but minimally) *simulate* a distributed computing environment?
I am doing some personal research on Byzantine Faults. I am trying out algorithms from various research papers which present algorithms for consensus in distributed systems like this one. For this i need a small scale simulation environment of a distributed system. How do i approach this problem ? </p>

答:
I just skipped through the paper that you mention, but here I go. We often use a virtualised environment to create experimental setups that involve multiple computers. Using Hyper-V on Windows Server (or similar software) you can easily create a private, isolated network of machines that you can configure on the fly and reuse as needed.

You seem to be working on fault detection and the associated consensus reaching, so I wouldn't think that the low latency, high bandwidth that a virtualised environment would yield would be a problem. In any case, if it is a problem, you can always use a WAN simulator such as WAN Connection Emulator to simulate an arbitrarily high-latency, low-bandwidth connection between your nodes.


答: Short of virtual machines -- which are probably the way to go -- most client server software lets the same machine behave as client and server. So you might need a distributed pardagim on a single PC.</p>

Title: How to effectively (but minimally) *simulate* a distributed computing environment?

Body: I am doing some personal research on Byzantine Faults. I am trying out algorithms from various research papers which present algorithms for consensus in distributed systems like this one. For this i need a small scale simulation environment of a distributed system. How do i approach this problem ? </p>


答:
Virtual machines may be the way to go, the problem is that if you setup 5 VM's on one server the response time between them will be effectively 0, which may not be true in your real environment where there could be a delay between servers. </p>

<p>If that is an issue (or could be) I would suggest setting up some servers on AWS or the like to test. Chances are that this could be done for less than $10 or $20. </p>

Body:
Virtual machines may be the way to go, the problem is that if you setup 5 VM's on one server the response time between them will be effectively 0, which may not be true in your real environment where there could be a delay between servers.

If that is an issue (or could be) I would suggest setting up some servers on AWS or the like to test. Chances are that this could be done for less than $10 or $20.


答:
We use this: http://lxc.sourceforge.net/

Linux Containers are extremely light weight virtual machines (basically zero overhead). We are using only 250 machines per physical machine, but there shouldn't be any issue going for thousands per machine.

We successfully used both LVM partitions and overlay filesystems as the system root.


答:
Is there any room for a compromise?

Maybe you could provide the client with repository logs or a local file history (as provided by Eclipse, I guess there are also stand-alone tools for similar tasks out there). This might satisfy them while not affecting your actual workflow too much...


答:
In principle, I appreciate the "check everything you need to build into source control" camp, but dependency management has evolved quite a bit in the last few years, with tools like Maven, Ivy and NuGet.

Also, in practice, I find checking in binaries to create a number of unpleasant side effects. Git/Mercurial aren't really tuned for it, for example, and Subversion and Perforce can drive you nuts when merging branches that contain binaries.

With a dependency management solution, you specify in a source-controlled file in your project which package names and which versions your project depends on. Almost all dependency management tools allow you to create a private repository of your dependencies, following some sort of versioning and naming convention; when you do a build, the dependency management tool will resolve all of your open source and proprietary dependencies from a list of approved sources, then stuff them into your local cache. Next time you build with the same version dependencies, everything's already there and it goes much faster.

Your private repository can then be backed up with conventional filesystem backup tools.

This avoids the slowdowns I've experienced when a ton of binaries are being pulled from the source tree, and prevents your repository from having lots of hard-to-diff files. There's only one location for any given dependency, by name and version number, so there's no merge conflicts to deal with, and the local filesystem caching means that you don't have to deal with the cost of evaluating whether your local copy has changed when you pull updates.

Title: Binaries in source control


答:
You need to keep everything you will need to rebuild specific versions of the product at some point in the future.

However you don't have to keep everything in Source Control.

One company kept a frozen server rack (because the OS only ran on that specific hardware, and the toolchain only ran on that OS, and the source was dependent on that toolchain).  Can't check that into Source Control.

If you do need to split up the requirements for a build, then you have the accounting problem of keeping two version control systems sync'd.  e.g. the hardware box in this closet, or the VM or binaries in this preserved backup volume, go with this SVN Source Code revision, etc.  This is messier that using a single source control system, but solvable.

Title: Binaries in source control


答:
You need to be very clear about the difference of a Product Company, and a IT department of a company. The former is your case. We often see Scrum practices applied on the context on the second one; when you have the customer inside the company. But the first one is a totally different beast.

I have been reading about your concern and find two mayor sources having their own method but in essentially they teach the same principle: put the customer first.

Steve Blank: Customer Development, see his book The Four Steps to the Epiphany

The Silicon Valley Product Group (SVPG): and their book Inspired: How to Create Products Customers Love

I believe you will find all your answers on their work.


问:
Is there a general rule for when you should use 'make clean' instead of just 'make'?
I am writing a multiple-filed program right now, and apparently running only 'make' (as one would intuitively think needs to be done in most situations) for some reason causes my program to fail. I guess I can provide more detail of the problem, but the important thing is that it does run when using 'make clean'. So I was wondering if anyone knew the general rule of thumb for running 'make clean' instead of just 'make'</p>

答: I would run "make clean" before a nightly build. In that case the additional time it takes to do a full build probably won't matter much, but the additional safety you will get from making sure everything is in the right version is probably worth it.</p>


答:
Well, I agree with @cczona on both her answers. Also, I'm here to suggest an alternative, besides the video thing:

What if you suggest him that you can keep track of what you've been doing?

I.e. you make a log in (when you start working every day) and a log out (when you stop it, i.e. you could just take note of the hours you spent working that day). Besides, you write a little abstract containing your work-day, your accomplishments and so on, the topics you moved inside the code. Exactly what you did for that day, point approximately how much time you spent in each step. That's a little reasonable and wouldn't cost you so much disk space, nor privacy, nor the negative points listed by @cczona, since you receive your payment by the worked hours.

As a professor, I work with a system where it's mandatory to note the beginning and the ending of the classes, as well as an abstract of them...

If you're up this alternative, and he accepts it, then it's ok. Otherwise, just say farewell.

Good luck!


问:
git / other VCS - how often to commit?
I've been a programmer now for over 11 years, and am just starting to get into version control for real. The places I've worked at have never really used version control (one committed at the end of each day, the others simply haven't bothered).

I am not happy with the way that I've been taught to version control (programme.js, programme.js.bak, programme.js.bak.20110901 etc) and so have been teaching myself to use git.

I currently use it along with github to keep my .vimrc file current across 4 machines, but I'm never sure when I should consider a change a commit, and when it's just a change which should be included along with another commit. I have started to use it for javascript development too and find it awesomely useful :)

My question is: At what point do changes become a commit? As I said, the only company I've worked for who used version control did it at the end of the day - this doesn't seem sensible to me. I feel that they should be more atomic. But my question is how atomic?

Is a bug fix for a function enough for a commit? Should I fix three (unrelated) functions and commit them all at once? Should I commit after changing the condition in an if statement?

On personal projects, I commit after any change. I personally find that useful, but I don't know if it's bad practice or annoying.

How do you do it, how does the industry do it, and what are best practices?

(I'm a web developer so work on short projects - perhaps a month long)

答:
When it comes to git, I believe one should commit as often as possible - some people commit every successful compilation. Don't confuse commits with pushes - a local commit does not have to be pushed (and with git, you should use many branches as they are cheap).

This should be the rule all around, but some SCMs are too slow for such a rule.

Personally, when using SVN, I try to commit several times a day and only when I am certain the code is in good condition (ie compiling and passing all its tests).

Title: git / other VCS - how often to commit?


答: You commit when you can write a commit message (you write those right... :) that clearly describes the single new feature/function/bugfix/improvement included in the commit.</p>

Title: git / other VCS - how often to commit?

Body:
I've been a programmer now for over 11 years, and am just starting to get into version control for real. The places I've worked at have never really used version control (one committed at the end of each day, the others simply haven't bothered).

I am not happy with the way that I've been taught to version control (programme.js, programme.js.bak, programme.js.bak.20110901 etc) and so have been teaching myself to use git.

I currently use it along with github to keep my .vimrc file current across 4 machines, but I'm never sure when I should consider a change a commit, and when it's just a change which should be included along with another commit. I have started to use it for javascript development too and find it awesomely useful :)

My question is: At what point do changes become a commit? As I said, the only company I've worked for who used version control did it at the end of the day - this doesn't seem sensible to me. I feel that they should be more atomic. But my question is how atomic?

Is a bug fix for a function enough for a commit? Should I fix three (unrelated) functions and commit them all at once? Should I commit after changing the condition in an if statement?

On personal projects, I commit after any change. I personally find that useful, but I don't know if it's bad practice or annoying.

How do you do it, how does the industry do it, and what are best practices?

(I'm a web developer so work on short projects - perhaps a month long)


问:
Should code from an incomplete story be removed from the build?
During the sprint review the product owner may say that a particular story is incomplete or the team itself may not have completed some committed tasks.

In what situations do you leave the code in the build?  If the code is left in the build, is this a conscious decision made during the review?  In other words, do you discuss this issue during the review?

Are there specific instances where code should be removed?

答:
The code for that feature never should have gone in to the release-ready codebase in the first place.  This used to be pretty tough with server-based version control (e.g. SVN) if you weren't using feature branching.  Nowadays with distributed version control (e.g. Mercurial, git) it's an easy thing to do.

In addition to tools, you may need to make process changes.  For example, requiring that code be reviewed before it's merged, ensuring that the review with the product manager happens early enough in the iteration so that incomplete things can be course corrected and tested.

Bottom line is that you can't earn value on a partially completed story. Plus if it's not finished, the customer may change course with the next iteration in which case you have now caused bloat with a half finished feature.


问:
Big-O for nested loop
I am reading this post on Big-O

It says that the following code is O(n^2):

```<code>bool ContainsDuplicates(String[] strings)
{
    for(int i = 0; i < strings.Length; i++)
    {
        for(int j = 0; j < strings.Length; j++)
        {
            if(i == j) // Don't compare with self
            {
                continue;
            }

            if(strings[i] == strings[j])
            {
                return true;
            }
        }
    }
    return false;
}
</code>```

But I can not understand why.

The inner loop does something constant.

So it is summation of 1....N of a constant. i.e. constant number O(1).

The outer loop is summation over the O(1).

So I would imagine it is n*O(1).

I think I am misunderstanding something here.

I do not think that all nested loops mean O(n^2), right?

答:
If the length of the string is n, the test if i == j will execute n^2 times. The order of an algorithm is the order of whatever part of it has the highest order. Since 'i' is compared to 'j' n^2 times, the order of the algorithm cannot possibly be less than O(n^2).

For a very large 'n', doubling 'n' will quadruple the run time.

Title: Big-O for nested loop


答:
Your mistake is with the inner loop.  It does something constant n times, so it is O(n). The outer loop does the inner loop n times, so it is O(n × n), or O(n2 ).

In general, if the number of iterations a loop makes is dependant on the size of the input, it is O(n).  And if k such loops are nested, it is O(nk ).

Title: Big-O for nested loop

Body:
I am reading this post on Big-O

It says that the following code is O(n^2):

```<code>bool ContainsDuplicates(String[] strings)
{
    for(int i = 0; i < strings.Length; i++)
    {
        for(int j = 0; j < strings.Length; j++)
        {
            if(i == j) // Don't compare with self
            {
                continue;
            }

            if(strings[i] == strings[j])
            {
                return true;
            }
        }
    }
    return false;
}
</code>```

But I can not understand why.

The inner loop does something constant.

So it is summation of 1....N of a constant. i.e. constant number O(1).

The outer loop is summation over the O(1).

So I would imagine it is n*O(1).

I think I am misunderstanding something here.

I do not think that all nested loops mean O(n^2), right?


答: If you are fixing independent bugs, they should be seperate commits.  The reason being, if you later find a problem with you fix for bug A, and want to reverse it, it is much easier if it is not combined with bugs B and C.  Especially if there have been additional code committed before you found the problem.  The same logic applies to features as well.   Basically, the smallest unit of working code that someone else can checkout and use.  Even if that someone is you on another machine.</p>

Title: git / other VCS - how often to commit?


问:
Great Programmer Productivity - Accounting for 10,000 fold difference?

A great lathe operator commands several times the wage of an average lathe operator, but a great writer of software code is worth 10,000 times the price of an average software writer. - Bill Gates

Say there's a "great" software engineer and an "average" software engineer on the same team. How can you account for one engineer being 10,000 times more productive? I can't quite fathom this, given they're both taking on their share of features, bugs and investigations, and consistently deliver with quality. Would my description possibly justify them to be above "average"? "great"?

答:
The point of the quote isn't that one is 10K times more productive, it's that one is 10K times the worth of the other. Software has the unique condition where a defective design or implementation can lay dormant for years (a part that is machined wrong will usually just "not work" and not make it into the field), well into the life-cycle of the product until one day it rears its head in an intractable situation.

Everyone should be familiar with the exponential cost of fixing a defect as it moves from design, to implementation to testing to production to maintenance.

When you account for possible liability as well as corporate reputation, it is easy to conclude that the developer who knew enough to avoid the problem is worth 10,000 times the one who ignorantly or naively implemented a poor solution.

Edit (Spring 2014): "Heartbleed"

OwnerDisplayName: TheImpact


答:
I'll try to tackle this in terms of the differences:

A great engineer will do the following better than an average one:

Design - produce designs that will need less modifications and be more flexible. This translates to savings throughout the lifetime of the software.

Features - these will be implemented fasted and be cleaner implementations.

Bugs - will be found faster, be fixed well and not introduce less future bugs.

Investigations - will be concluded faster with better resolutions and results.

Taken together, these would save the company lots of money in development time and make the company lots of money in extra opportunities.

Title: Great Programmer Productivity - Accounting for 10,000 fold difference?

Body:
A great lathe operator commands several times the wage of an average lathe operator, but a great writer of software code is worth 10,000 times the price of an average software writer. - Bill Gates

Say there's a "great" software engineer and an "average" software engineer on the same team. How can you account for one engineer being 10,000 times more productive? I can't quite fathom this, given they're both taking on their share of features, bugs and investigations, and consistently deliver with quality. Would my description possibly justify them to be above "average"? "great"?


答:
Many people have come up with valid arguments (including yourself) to try to dissuade the client from requesting this video. But you needn't concern yourself with such things.

Businesses all operate differently. They have different processes and practices they employ to gain an edge, or just generally generate an income. All these practices fall under what is commonly known as "trade secrets" or "classified information" depending on your region.

These secrets are protected by law (check your region for more details) since a business' competitive edge, and thus livelihood, rest on them.

Let's take an example: Apple Inc. They have the most stringent security of any company in existence. They take the protection of their trade secrets with the utmost seriousness. One way they protect their secrets is to issue NDA (non-discolure agreements) to many that do business with them. Even iOS and OS X developers sign these agreements. This ensures that whatever bit of information that is not made publicly available will remain classified. Now imagine asking them to produce video of how they make their products. You'd be laughed out of their offices.

Recording the process by which you write code and design programs most definitely falls under classified information.

You needn't explain yourself to the client—they obviously don't have a good understanding on how business works. Simply inform them that you will not reveal your trade secrets (for obvious reasons) under any circumstances. They can then choose to end the contract or carry on with the work. But what's important here is not that they'll smear your good name or label you "shady" (I'm sure any intelligent person would balk at such an lunatic demand), but that you protect your business.

In closing, the protection of trade secrets are implicitly protected by law. They do not need to be included in your contract or reaffirmed in writing.


答:
Nested loops run O(i1 * i2 * ... * in), where n is the number of nested loops and ix is the number of iterations in loop x.  (Or, to put that another way, it's the product of the number of iterations in each of the loops.)

Your pair of loops iterates over the same array twice, which by coincidence is O(n * n) or O(n2).

What happens inside the innermost loop is treated as constant because it's going to happen every time.  Big-O notation isn't really about measuring the performance of linear code, it's more about making relative comparisons of how iterative algorithms behave when given n items of input to deal with.  Certain operations that don't actually do any iterating (such as a push or pop on a stack) get dinged as O(1) because they do handle one element of the data.

Title: Big-O for nested loop


答:
It's very simple. The answer is no. The negotiations are done.

If he is concerned that you are going to rip him off, then you can find another way to satisfy his concern. With milestones, payment schedule, delivery of source code for him to inspect, etc.

If you can't find a way to satisfy him in a way that makes sense for you, then don't do the job. This world is filled with millions of clients which are less trouble and more sane. Kick him to the curb now before he causes trouble later.

One of the main benefits of freelancing is that you choose who you work with. You don't work with every person who says that they will pay you. You work with who you want to work with. If you don't like them then tell them no.


答:
Each individual change should be one commit. A few things to consider:

Having stuff committed means that you can roll back. Assume you have a bigger task to be done. You're 50% done, that part looks good so far. Then you continue and break something massively by some mistake. Having the commit in between means you can go back there and didn't loose all of the work.

Version control is not a place to dump data and forget. Version control provides a history. Lateron you can use the history, including my favorite annotate feature, to figure out why a change was made (and who is responsible) this often helps. But to work properly the change should be small and self contained.

When working in teams it's great to have people reviewing it (actually even when working alone this would be great ;-) ), for a review it's good to have small parts which can be reviewed without being mixed in between unrelated changes.

Looking at git specifically, it allows local commits which are not visible to other people, so you can even commit broken code locally and fix it with a later commit before pushing. git commit is very fast so committing locally doesn't really interrupt the development process. Git also allows rewriting commits, so many commits can be rewritten into one before being pushed, which makes it easier to review - while rewrites are dangerous and should be done with care (don't rewrite after push etc.)

Title: git / other VCS - how often to commit?


问:
Why such popularity with Python?
Other than being annoyed at whitespace as syntax, I'm not a hater, I just don't get the fascination with Python.

I appreciate the poetry of Perl, and have programmed beautiful web services in bash & korn, and shebang gnuplot.  I write documents in troff and don't mind REXX.  Didn't find tcl any more useful years ago, but what's the big stink about Python?  I see job listings and many candidates with this as a prize & trophy on their resumes.

I guess in reality, I'm trying to personally become sold on this, I just can't find a reason.

答:
Reapproaching the question now that I'm a little less tired:

Python is a language I've found particularly well suited for scientific programming tasks, which is one of the places where its popularity is growing pretty strongly. A few reasons why:

Fairly strong community support means there's some strong libraries in place, and Python works as a decent replacement for MATLAB and some of the other popular languages in that field.

It plays well with C when you do need speed, but often speed isn't really that necessary, so Python's interpreted nature isn't all that big of a deal.

I've found it to be a fairly approachable language without a huge number of what, to outsiders, feel like weirdly arbitrary syntax rules. It's pretty swift to translate between pseudo-code and Python.

"Take it or leave it OOP". A lot of scientific programming projects don't benefit all that heavily from extensive OOP. Some do. It's nice to have a language that can hop between the two easily.

Strong cross-platform support. Especially as what I work with rarely involves GUIs, I can pretty much rely on being able to send off a Python program to someone else without worrying about what OS they're running.

It's not the end-all, be-all of programming languages, but its a decent "Yeah, I probably have a tool to solve whatever problem comes up" language, which is probably why it's enjoying popularity at the moment.

Title: Why such popularity with Python?


答:
Say there's a "great" software engineer and an "average" software engineer on the same team. How can you account for one engineer being 10,000 times more productive? I can't quite fathom this, given they're both taking on their share of features, bugs and investigations, and consistently deliver with quality. Would my description possibly justify them to be above "average"? "great"?

That is a lot of "givens" for an "average" software engineer.  In reality, the great software engineer solves problems in hours that the average engineer will never solve correctly.  The great software engineer solves ordinary problems in one-third the time with one-fifth as much code and one-tenth as many bugs.  The great software engineer's code runs in O(n) while the average software engineer's code runs in O(n^3) time.  The great software engineer can adapt his solution while you wait, while the average software engineer complains about late changes to the spec and says it will take weeks to meet new requirements now.  These are all real differences I have seen when a great engineer redoes the work of the average engineer.


问:
How do freelancer web developers manage web hosting for customers?
I have built a number of websites for friends, family, etc. and I have put them all on a single shared web hosting account. Now that they are built, I want to get out of business of supporting them and paying for them (my friends are reimbursing me but I am paying for the actual bill) so I was thinking of having them create their own hosting accounts and slowly migrating the sites over.

It got me thinking how does any freelancer do this? Do they force their clients to setup their own hosting up front and let the programmer log into the customer account during development. What if there is a bug in the future and they need to go back in?

I was curious to see what model most people use who build websites for others as it seems like a tricky situation.

答:
There are two ways to handle this:

Move them to their own account that you make them sign up for.  Personally, I think this is bad for a host (pun intended) of reasons.  First, they are most assuredly non-technical and have no idea if they need a 25GB or 50GB of bandwidth or storage space.   Next, the definitately won't know what to do in the event the host has a problem.  That's what they hired you for.  Third, if they ever want anything they will call you and at some point you'll need all of the passwords etc...  Essentially, you are going to be managing it anyway so it may as well be under your account.

Keep your own account, and bill them monthly or annually.  I like this one a lot.  You can handle the problems as they come up (and they will) AND you can pick up a few extra dollars each month for it.  Again, you're the expert.  If you can get them on a plan that costs $20/month.  Then charge them $30, and pocket the difference for your time / trouble.

Finally, the second option adds a bit of "stickiness" to the relationship.  They will always go to you for things.  This is generally a good thing.  Of course, don't hassle them if they want to switch (that's a bad thing), but do provide good service and bill appropriately.


问:
What causes bad performance in consumer apps?
My Comcast DVR takes at least three seconds to respond to every remote control keypress, making the simple task of watching television into a frustrating button-mashing experience. My iPhone takes at least fifteen seconds to display text messages and crashes ¼ of the times I try to bring up the iPod app; simply receiving and reading an email often takes well over a minute. Even the navcom in my car has mushy and unresponsive controls, often swallowing successive inputs if I make them less than a few seconds apart.

These are all fixed-hardware end-consumer appliances for which usability should be paramount, and yet they all fail at basic responsiveness and latency. Their software is just too slow.

What's behind this? Is it a technical problem, or a social one? Who or what is responsible?

Is it because these were all written in managed, garbage-collected languages rather than native code?  Is it the individual programmers who wrote the software for these devices? In all of these cases the app developers knew exactly what hardware platform they were targeting and what its capabilities were; did they not take it into account? Is it the guy who goes around repeating "optimization is the root of all evil," did he lead them astray? Was it a mentality of "oh it's just an additional 100ms" each time until all those milliseconds add up to minutes?  Is it my fault, for having bought these products in the first place?

This is a subjective question, with no single answer, but I'm often frustrated to see so many answers here saying "oh, don't worry about code speed, performance doesn't matter" when clearly at some point it does matter for the end-user who gets stuck with a slow, unresponsive, awful experience.

So, at what point did things go wrong for these products? What can we as programmers do to avoid inflicting this pain on our own customers?

答: I think the reason is that most consumer directed apps are controlled and marketed by people who don't know anything about software, and hire developers based on their resumes or the recommendations of some no-nothing manager, as opposed to their actual skills and knowledge.</p>


答:
A great programmer very often doesn't just "take on their share of features, bugs and investigations" to earn a wage.  They sometimes quit and start their own company, or join a startup, or start a new skunkworks project, or, in the olden days maybe, joined a nationally renowned blue-sky R&D lab, and innovate some product that no one thinks they even needed, or thought was possible to do with software, before that great programmer's insight, skill, and sweat.

A lot of this programmer "worth" is about proportionate reward for risk.  The programmer might have even gotten fired for thinking about such crazy software products, rather than getting paid 2X or so more.

What happens with an occasional software startup: going public for million/billions, or getting acquired by Google or Facebook, et.al. for similar amounts, rarely happens to lathe operators (although at least one successful Silicon Valley tech company founder had a lathe in his workshop).


问:
Why would it ever be possible for Java to be faster than C++?
Sometimes Java outperforms C++ in benchmarks.  Of course, sometimes C++ outperforms.

See the following links:

http://keithlea.com/javabench/

http://blog.dhananjaynene.com/2008/07/performance-comparison-c-java-python-ruby-jython-jruby-groovy/

http://blog.cfelde.com/2010/06/c-vs-java-performance/

But how is this even possible?  It boggles my mind that interpreted bytecode could ever be faster than a compiled language.

Can someone please explain?  Thanks!

答: The Java runtime isnt interpreting bytecode.  Rather, it uses whats called Just In Time Compilation.  Basically, as the program is run, it takes bytecode and converts it into native code optimized for the particular CPU.


答:
All things being equal, you could say: no, Java should never be faster.  You could always implement Java in C++ from scratch and thereby get at least as good performance.  In practice, however:

JIT compiles the code on the end-user's machine, allowing it to optimise for the exact CPU that they are running.  While there's an overhead here for the compilation, it may well pay off for intensive apps.  Often real life programs are not compiled for the CPU you are using.

The Java compiler may well be better at automatically optimising things than a C++ compiler.   Or it may not, but in the real world, things aren't always perfect.

Performance behaviour can vary due to other factors, such as garbage collection.  In C++, you typically call the destructor immediately when done with an object.  In Java, you simply release the reference, delaying the actual destruction.  This is another example of a difference which is neither here nor there, in terms of performance.  Of course, you can argue that you could implement GC in C++ and be done with it, but the reality is that few people do / want to / can.

As an aside, this reminds me of the debate regarding C in the 80s / 90s.  Everyone was wondering "can C ever be as fast as assembly?".  Basically, the answer was: no on paper, but in reality the C compiler created more efficient code than 90% of the assembly programmers (well, once it matured a bit).

Title: Why would it ever be possible for Java to be faster than C++?

Body:
Sometimes Java outperforms C++ in benchmarks.  Of course, sometimes C++ outperforms.

See the following links:

http://keithlea.com/javabench/

http://blog.dhananjaynene.com/2008/07/performance-comparison-c-java-python-ruby-jython-jruby-groovy/

http://blog.cfelde.com/2010/06/c-vs-java-performance/

But how is this even possible?  It boggles my mind that interpreted bytecode could ever be faster than a compiled language.

Can someone please explain?  Thanks!