答:
Adding to nibot's excellent explanation, just a couple of more points.

Numerical computing environments such as MATLAB, Octave or SciPy/NumPy will save you a lot of effort compared to doing it all by yourself in a  generic programming language such as C++. Juggling with double arrays and loops just doesn't compare with having data types such as complex numbers and operations such as integrals at your fingertips. (It's doable for sure, and good C++ code can be an order of magnitude faster, with good library abstractions and templates it can even be reasonably clean and clear, but it's definitely easier to begin with e.g. MATLAB.)

MATLAB also has "toolkits" for e.g. Image Processing and Digital Signal Processing, which may help a lot, depending on what you do.

Mitra's Digital Signal Processing is a good book to learn (in MATLAB!) the basics of discrete time, filters, transforms, etc. which is pretty much mandatory knowledge to do any decent  technical algorithms.

Title: Implementing technical paper algorithms in C++ or MATLAB

Body:
I am an Electrical Engineering undergrad. I've reading many technical papers about Signal and Image processing algorithms (reconstruction, segmentation, filtering, etc). Most of the algorithms shown in these papers are defined over continuous time and continuous frequency, and often give the solutions in terms of complicated equations. How would you implement a technical paper from scratch in C++ or MATLAB in order to replicate the results obtained in said paper?

More specifically, I was looking at the paper "A general cone-beam reconstruction algorithm" by Wang et al (IEEE Trans Med Imaging. 1993;12(3):486-96), and I was wondering, how do I even start implementing their algorithm?
Equation 10 gives you the formula of the reconstructed image at . How would you code that up? Would you have a for-loop going through each voxel and computing the corresponding formula? How would you code functions of functions in that formula? How would you evaluate functions at arbitrary points?

I've read the book "Digital Image Processing" by Gonzalez and Woods but I'm still at a loss. I have also read about the Numerical Recipes book series. Would that be the correct way?

What are your experiences programming algorithms from research papers? Any tips or suggestions?


问:
Is it possible for a one-man start-up to follow agile methods like Scrum?
For a small start-up with only one or two programmers, is it possible to implement agile methods like Scrum? If NO, what is the minimum team size required?

I guess Scrum needs few programmers to be onsite as well?

 Edited **
I think the Agile methods are meant for team collaboration and improve workflow so a single man may not benefit much.

答:
Even if you are working alone, there is no excuse for not being agile.

I'm a freelance, working alone from home, and I use a combination of agile methods with great success. Scrum in itself is good for a single person, but need to be adapted. For example, a standup meeting or a planning poker alone is not funny.

The most useful practice, in my opinion, is splitting project into fixed time iterations. Work two weeks. Deliver partial product. Get paid. Start again. You don't need to have a big team to work with iterations, right?

Always getting feedback is also very important: make sure that your client is always as happy as possible.

Use stories to feed your backlog, and have your client sort it out by priority: priceless.

Other methods can be added for more efficiency: TDD, pomodoro, etc.

Sometimes, I happen to work with a friend when I get too much work. If you already use a Scrum canvas, adding another person in a team is quite easy.

ContentLicense: CC BY-SA 3.0


问:
If TDD is about design why do I need it?
TDD gurus more and more tell us that TDD is not about tests, it is about design. So I know some developers who create really great design without TDD. Should they practice TDD then?</p>

答:
I can talk only from my experience. For me TDD brought several things I didn't have before in my development style habits toolbox. Although, it is worth to say again that TDD is not solution to everything. I always try to separate exploration and production ready implementation. TDD in exploration phase is absolutely not needed and even is slowing down. On the other side for production ready code it brings several benefits which on short and long run are very valuable for the mental health of developers and karma of the project.

TDD makes me think before I implement, which is usually very good practice which prevents lot of shoot and forget solutions

It makes me think in small portions of problem, forcing me to break apart solution to small pieces that fit together.

It makes me write very decoupled code because whenever I have to stub/mock/fake something which doesn't fit into the problem I naturally throw one "WTF, why should I do this if I don't have to be coupled with it". And it makes me realize connections between things better.

It gives me set of easily executable checks for my code, so I don't have to go through painful "var_dump", "p", "pp", "echo" style of debugging of code. It just reports what is wrong, when is wrong. And if I don't have a check for it yet, it is just matter of adding simple test to check it over and over again.

It makes me certain that my code works if all tests pass before we deploy. Then instead of eating my nails I go eating a cake and drinking coffe and enjoying my afternoons.

High level tests are very nice in the cases you have to refactor something. If my module has to provide some functionality to outside world and I have developed functional/integration/cucumber tests to prove it's working correctly I will be very brave to refactor the hell out of that code. Several times I was faced with the code that didn't have tests and need to refactor it. In that case there were two ways to go in practice. 1) drop the code 2) skip the changes and leave it as it is.

There is one thing that TDD doesn't fix. If you don't know how to build the thing you are building, then TDD will not produce solution for you. You need to have rough "design" or overview of the problem and solution. TDD will make you just implement it in more elegant and maintainable way with the code of higher quality.

At last, I prefer thinking in BDD terms which lean on TDD practices. BDD makes me to implement solution using vocabulary of the domain and to make software fit the problem better.


问:
Tabs versus spaces—what is the proper indentation character for everything, in every situation, ever?
The coding standards for the code hosted in drupal.org suggest to use two spaces to indent the code; other sites suggest to use tabs to indent the code.

What is the proper indentation character for everything, and in every situation? Please explain the answer you give.

答:
The answer is that there can be no single proper indentation character for every situation. Formatting using characters is inflexible and can cause conflict when different styles are used within a team.

The only method to format code flawlessly and flexibly with different formatting styles is to do it virtually, that is, without any indentation characters. The only code editor I know that supports this though is the one used in the sample below:

To demonstrate virtual formatting, the screenshot below is from an XSLT editor* that uses this indentation method (there's also a short video here). Every character in the XSLT has been highlighted in yellow, for illustrative purposes, to allow the only tab or space characters in the content to be seen clearly. The code indentation is handled by the editor's rendering system adjusting the left margin (which has a white background).

The only leading space characters precede the Books lines, because this is literal text content, not code, these space characters must be preserved.

With virtual formatting you choose the indentation width to suit the environment and indentation style without affecting any characters in the source file. You can even set the indentation width to 0, if you need a flattened view of the code as shown below:

To contrast this with space character formatting, the same XSLT opened in an editor without virtual formatting is transformed by that editor's auto-formatter to this:

The larger blank yellow blocks in the screenshot above clearly show the space characters added by the formatter of the conventional editor. Unfortunately, these now can't be distinguished from real content so the XSLT would have to be modified to correct this issue.

Summary

XSLT is possibly an extreme case, but this principle holds true for many programming languages: Characters should be used for content and an alternative method sought when it comes to formatting.

**Disclosure: The XSLT Editor with virtual formatting was developed by my own company*


问:
How do I avoid "Developer's Bad Optimization Intuition"?
I saw on a article that put forth this statement:

Developers love to optimize code and with good reason. It is so
  satisfying and fun. But knowing when to optimize is far more
  important. Unfortunately, developers generally have horrible intuition
  about where the performance problems in an application will actually
  be.

How can a developer avoid this bad intuition? Are there good tools to find which parts of your code really need optimization (for Java)? Do you know of some articles, tips, or good reads on this subject?

答:
my remedy is to start by getting clear answers to two questions:

how to measure performance (eg. measure data load time)

what is the target value (eg. data loads in 3 sec or less with 95% confidence)

Learned above trick from tiger team guys who were once invited to save a broken release of our product. That release was broken for performance reasons, it could make company loose strategic customer which justified tiger guys involvement (pretty expensive btw). I was assigned to assist them in clarifying project details; also used this as an opportunity to learn a bit or two about performance.

ContentLicense: CC BY-SA 4.0


问:
How do you help your fellow programmers to grow?
As a team lead, how can you help your programmers to grow?

The reason I ask this is because there are a few programmers working with me, and I really want to "turn them on the loose", to realize their maximum potential, and to keep them happy.

But I don't quite know how to do this, do I have to

Interact with them frequently, or give them quiet time, leave them undisturbed?

Ask them to follow coding guidelines, such as enforcing unit tests, coding styles, or let them do whatever they see fit?

Be lenient with them. Such as don't really care whether they really come into office for 8 hours or 4 hours, or need to enforce some "disciplines" in the work place?

Guess what, each positions have their own points, and different people would argue for different things. Such confusions make managing people indefinitely harder.

What do you think?

答:
Interact with them frequently, or give them quiet time, leave them
  undisturbed?

Interact with them frequently. Obviously not the point of bugging them but as their manager you should be having regular conversations with them about how things are going and more genral chit chat. Roughly once every few hours sounds the right frequency but play it by ear.

Ask them to follow coding guidelines, such as enforcing unit tests,
  coding styles, or let them do whatever they see fit?

You should expect them to be working to exactly the same standards you do. If you do unit tests and follow guidlines then they should. They need to learn how to code well and its your responsibility to teach them that.

Be lenient with them. Such as don't really care whether they really
  come into office for 8 hours or 4 hours, or need to enforce some
  "disciplines" in the work place?

I would be more diciplined at first but ease up when they prove they can be trusted. Giving people the trust to work a 4h day right from the off is asking for trouble however letting a valued employee who regularly works late have some slack between projects is fine.


答:
Yes, managing people is indefinitely harder than managing computers or software, precisely because every person is different, and we may change even day by day. So there is no universal answer. I believe you just need to communicate a lot with your developers to get to know them and understand their individual strengths/weaknesses, their attitude to work and to learning, etc. You can thus learn about each of them, whether (s)he prefers lots of communication and workshops, or learning on his/her own in a quiet corner.

IMHO developers under normal circumstances have a natural urge to learn (unless they have been burnt out or jaded by a previous bad job experience). So all you need to do is understand what and how they would like to learn, and provide them the tools and time to do it (within reasonable limits of course).

E.g. in our team, we can freely define learning tasks for ourselves, as long as these are somehow (directly or indirectly) related to the project. These tasks are typically a few hours to one day per sprint (not in every sprint though). (A recent example: I got a task to learn and experiment with Scala accepted, on the basis that this - and a functional approach in general - might help simplifying a complex part of our Java code.) These then get prioritised and scheduled into a Sprint, just like regular tasks. It is also encouraged and expected to perform demos / lectures about what we learnt, to transfer knowledge to other team members (and potentially even to developers in different teams).

Ask them to follow coding guidelines, such as enforcing unit tests, coding styles, or let them do whatever they see fit?

When working in a team, following the same development process is a must. Of course, that process should be the simplest thing which could possibly work, not something described in a 600-page manual. And the process should be defined and continuously adapted to the situation by the team themselves. So if the team has agreed to a coding standard, and TDD, they are to follow it.

Be lenient with them. Such as don't really care whether they really come into office for 8 hours or 4 hours, or need to enforce some "disciplines" in the work place?

If you don't know a developer, it is normal to follow more closely what (s)he is doing, her deliveries, her work rhythm etc. It is also OK to review her code (either yourself, or an experienced and trusted team member). Once she has earned trust, she can gradually get more freedom. But that trust must be earned first. About working hours, in my experience flexible hours is great up to a limit, i.e. it is good to have a common agreed minimum, like daily between 11AM and 2PM, when developers are (usually) to be found in their workplace, so that they can be approached with questions, or invited to meetings. But other than that, there is no point being strict.

Title: How do you help your fellow programmers to grow?

Body:
As a team lead, how can you help your programmers to grow?

The reason I ask this is because there are a few programmers working with me, and I really want to "turn them on the loose", to realize their maximum potential, and to keep them happy.

But I don't quite know how to do this, do I have to

Interact with them frequently, or give them quiet time, leave them undisturbed?

Ask them to follow coding guidelines, such as enforcing unit tests, coding styles, or let them do whatever they see fit?

Be lenient with them. Such as don't really care whether they really come into office for 8 hours or 4 hours, or need to enforce some "disciplines" in the work place?

Guess what, each positions have their own points, and different people would argue for different things. Such confusions make managing people indefinitely harder.

What do you think?


答:
It's a very fine line you have to walk.

In the end, any technical decisions you make are decisions that you won't have to live with. So make as few of them as possible, let the people who do have to live with them make their own choices. But do guide them if you think they're going down a bad road.

On the other hand, process choices are yours. In those decisions, let the team guide you but ultimately you need to make them. At least at first.

Have a read of Roy Osherove's Three Maturity Stages of a Software Team and see if you can figure out what stage your team is currently at. This should affect the way you act. The more chaotic, the more you have to put controls in place. eg. In an extremely chaotic team, you need to start by reviewing all code committed. But while you're doing that, take the time to teach them to review each others' code.

And if you manage to pull a team from Chaos to Midlife, change your behaviour at that point, otherwise they won't move any further (this last from personal experience).


问:
Why do most programming languages not nest block comments?
A few do, but not any of the popular ones as far as I know. Is there something bad about nesting comments?

I plan to have block comments nest in the (small) language I'm working on, but I would like to know if this is a bad idea.

答:
A good point of nesting block  comments is that you can comment out large portions of code easily (well, almost, unless you have the block comment end sequence in a string constant).

An alternative method is to prepend a bunch of line with the line comment start sequence if you have an editor that supports it.

Haskell has nested block comments, but most people dont seem to notice or to complain about it. I guess this is because people that do not expect nested comments tend to avoid them as this would be a lexical error in other languages.

OwnerDisplayName: Vuntic


答:
Not mentioned until now: There are languages (Python, Haskell) where indentation matters. But 1 character counts as 1 character, be it a space or a tab so the indentation seen by the compiler may not be the same one you see on the screen if you use tabs.

Therefore, in languages like Haskell, spaces are a must.
In Makefiles, TABS are a must.
In all others, it's a matter of personal taste and nowadays not a great deal - every decent editor has a "(leading) tabs to spaces" and "(leading) spaces to tabs" command.

Title: Tabs versus spaces—what is the proper indentation character for everything, in every situation, ever?

Body:
The coding standards for the code hosted in drupal.org suggest to use two spaces to indent the code; other sites suggest to use tabs to indent the code.

What is the proper indentation character for everything, and in every situation? Please explain the answer you give.


答:
Related to your three points:

Interact with them frequently, or give them quiet time, leave them undisturbed?

I'll say that it really depends on the type of person you work with. Some prefer discussing at fixed coffee time (around 10am say) and otherwise working alone, undisturbed. With them (OK, I'll admit, I am exactly like that), I generally send emails (even when they are near me, like 2-3 meters away) so that you may leave them the choice on when they read your information. And by the way, don't ask them if they "got your memo" :-) And of course, some "need" more guidance, more interaction.

Ask them to follow coding guidelines, such as enforcing unit tests, coding styles, or let them do whatever they see fit?

As for following guidelines, it is pretty clear to me. If you set guidelines related to the coding style, always-provide-test-case rule, etc then you have to enforce them if you are the lead developer. For the project you are managing, every developer should follow your guidelines, no exception, even for "superstars".

Be lenient with them. Such as don't really care whether they really come into office for 8 hours or 4 hours, or need to enforce some "disciplines" in the work place?

If you already know how people work and are confident than they will not break your confidence you can relax the discipline. But I think that for this point the rule (or no-rule) you define should apply to everybody. The important thing is that there should be no exception. I'm currently very happy to work for a project manager that simply says "as long as you do your 40 works per week and the job is done, it's ok". That way you may come late one morning, work only 6 hours and the next two days work for 9 hours. It does not matter "as long as the job is done". I like that rule.


问:
How can you tell good programmers from the average one?

Possible Duplicates:

  How do managers know if a person is a good or a bad programmer?

  How to recognize a good programmer?

For your record, I am a programmer myself, and I still do coding. We are not doing your-just-another-CRUD-app, instead we are working on CAD apps.

The nature of software development makes it really hard to gauge a programmer's worth. How can you tell whether a programmer is good or not-so-good?

All programmers who are working with me work on different parts of the applications, and how difficult it is to get those parts working is only known to the person who spend most time in it, in this case it's the programmers themselves; me as an outsider would not be able to fully appreciate the amount of sweat, ingenuity, effort they put in into solving those problems precisely because I don't have a chance to do the same job. This gives me a hard time when I evaluate them. How do I know programmer A is really great at solving the problem at hand and therefore I can throw him a bigger, harder task? And how do I know programmer B is just working hard, but not working smart?

How can I evaluate and compensate programmers fairly?

答: Regular code reviews. Also measure how long it takes to do projects how many bugs those projects have and how much help they need along the way. That should then give you a rough feel for their worth. Also check job sites for what the market rate for their skill level is.</p>


答:
There's no simple answer for this one, every programmer has strengths and weaknesses. That really big task they've excelled at might have been perfect for them, but that other one might be totally off-track for what they're good at and they'll seem like a worse developer.

Evaluating how good they are is something that you'd need to do over months rather than tasks, get a feel for how they approach a problem, how they devise their solution and how successful the implementation is. Try them on multiple different tasks, if they're succeeding more than they're sucking then keep trying to see where their limit is. If they just suck then it's pretty easy to tell if they're good or bad.

Title: How can you tell good programmers from the average one?

Body:
Possible Duplicates:

  How do managers know if a person is a good or a bad programmer?

  How to recognize a good programmer?

For your record, I am a programmer myself, and I still do coding. We are not doing your-just-another-CRUD-app, instead we are working on CAD apps.

The nature of software development makes it really hard to gauge a programmer's worth. How can you tell whether a programmer is good or not-so-good?

All programmers who are working with me work on different parts of the applications, and how difficult it is to get those parts working is only known to the person who spend most time in it, in this case it's the programmers themselves; me as an outsider would not be able to fully appreciate the amount of sweat, ingenuity, effort they put in into solving those problems precisely because I don't have a chance to do the same job. This gives me a hard time when I evaluate them. How do I know programmer A is really great at solving the problem at hand and therefore I can throw him a bigger, harder task? And how do I know programmer B is just working hard, but not working smart?

How can I evaluate and compensate programmers fairly?


问:
Books on custom iPhone interface development?
I have been looking around for a book on designing and developing custom interfaces for iOS but I don't seem to be able to find any books on this topic and I was wondering if anyone here knew of any books on the design and development of custom iOS interfaces and applications.

Also, I am not aware of any other questions asked on this site, so if there is, please do let me know and I'll vote to delete :)

Thanks in advance!

答: I'm not sure of any books off the top of my head, but the custom interface designs are mostly done using Core Graphics, so that should give you a good starting point. There is of course an O'Reilly .</p>


问:
Which tool to use for creating application releases?
I'm wondering what others use as a tool for creating the final package to hand over to the customer. For now, these are the tasks it should perform for our company:

build a set of VS projects (C#,C++); which set depends on configuration on commandline of preferrably in a file

copy some of the outputs (dll,exe) and header files; should again be configurable: not all customers get the same functionality)

make a zip file for each configuration

Additional features that are not yet needed now, but might be in the future:

upload it to a website of some kind (we're still not sure what we're going to use.. might be ftp or vesrionsing system). Well, actually, it would be awesome if the tool could create an entry on a Confluence page.

instead of zip files we might switch to installers, though that shouldn't change too much I guess

Right now I have the first steps covered in a batch file that takes some arguments, and a master batch file that calls it for each configuration. It works, but I can't get used to the batch syntax and I'm now building by invoking devenv.exe which seems slow and is error-prone as it takes the .suo file into account.

I was thinking about doing everything again in msbuild, but first I'd like to hear more opinions on this. I'd also want to know what kind of tools big companies use for large products.

答:
Why not use MS Build? It's totally integrated and it has been created for such tasks.

I also recommend you the following reading:

and


问:
Password insanity! Recommended approaches to password management on multiple client systems?
A software development company I work with has a web based product they are successfully selling to clients. All of these clients have a support agreement with us that generally requires us to access their servers, databases and application data. As the number of clients grows, (and the number of different people supporting those clients grows), we are seeing a need to better manage in particular passwords, but more generally all the information one would need to fully support client systems ie. URLs, application login details, IP addresses, any client-specific weird stuff etc etc. This data is changing on an increasingly rapid basis, as systems get moved around to different machines, IP addresses. The worst problem is superuser passwords for the applications. These are constantly changing and occasionally we find ourselves in a situation where nobody seems to know who made the most recent change.

This is clearly an unsatisfactory situation. There are procedures in place which say that password changes etc need to be documented in a central secure place. But of course, people being humans, sometimes forget to document these things. The danger is that when people get so fed up of password chaos, that you can end up with a situation where everyone's password is "password123" as they can't be bothered any more.

Apart from enforcing the procedures, what other approaches could we take? One suggestion I heard was to have a "hidden" application superuser whose password is easily remembered/derived, which only support personnel would know about it. Personally I think that solution is a scary security hole, especially when you have multiple clients using your software.

So how would you handle this situation if you were supporting multiple clients? More strict procedure enforcement, or a technical approach to make life easier for everyone?

答: If all your websites have a centralized authentication system, then it would not be too difficult to do the "superuser" thing in a secure way. That is, coupled with a role-based security system, you could create a "superuser" role that all your support personnel would be added to, and each website you develop explicitly allows "administrator" access to anybody in the superuser role.


答:
What do you mean by "custom interface"?

Do you mean interfaces that don't look being built using Cocoa Touch native widgets? If yes then don't estimate the power of Cocoa Touch and graphics.

UITableView for example is a versatile widget, you can't believe how much you achieve with it.

With Quartz 2D, Core Animation and graphics you can achieve extremely lovely interfaces.

iOS Recipes contains a lot of tricks and tips that will help you customizing your interfaces. Check the book's TOC.

Title: Books on custom iPhone interface development?

Body:
I have been looking around for a book on designing and developing custom interfaces for iOS but I don't seem to be able to find any books on this topic and I was wondering if anyone here knew of any books on the design and development of custom iOS interfaces and applications.

Also, I am not aware of any other questions asked on this site, so if there is, please do let me know and I'll vote to delete :)

Thanks in advance!


答:
I would like to propose that the term 'good' is conditional. Some programmers are good in one area and not the other. Also, some programmers are good in development of new apps, but can't solve problems in existing apps.

A programmer is good, in my opinion, in a specific project if:

he/she follows standards set

does work on-time

produce good quality work

can understand requirements without too much effort

is a team player to the extent that he/she does not make problems

produces documentation as per project requirements

has good command of his area of expertise without reading books, or expermenting all the
time to get the job done

can draw a balance between time/effort/value/complexity

provides more answers than questions

focused on the objectives

willing to accept other opinions and willing to learn new tech.

other personal attitudes (positive attitude, helps other, etc.)


答:
Give your team challenging work and the tools to solve them. Even if you see your work as mundane because you're just supporting a legacy system, push everyone to make it better.

Your team should develop coding standards. Your job is to help them enforce and adapt the standards.

Work with your team to develop an estimating system. Your job is to help coordinate this effort with the team and provide enforcement. Outside forces expect quality code in a timely fashion and they don't always have reasonable or provide any logic for their requests. You can't escape this, but you have to manage both sides. Once your team has built a reputation for getting things done, everyone will be more accepting of your time estimates. They need to know you will support them if they are making the effort.

When I say your job is to enforce, I don't mean to take on some sort of Draconian leadership style. When a group of capable individuals have input on how they are going to behave, they also must agree to consequences for not following the rules. Someone is ultimately in charge and since you're that team leader, that's you.


问:
Surviving MATLAB and R as a Hardcore Programmer
I love programming in languages that seem geared towards hardcore programmers.  (My favorites are Python and D.)  MATLAB is geared towards engineers and R is geared towards statisticians, and it seems like these languages were designed for people who aren't hardcore programmers and don't think like hardcore programmers.  I always find them somewhat awkward to use, and to some extent I can't put my finger on why.  Here are some issues I have managed to identify:

(Both):  The extreme emphasis on vectors and matrices to the extent that there are no true primitives.

(Both):  The difficulty of basic string manipulation.

(Both):  Lack of or awkwardness in support for basic data structures like hash tables and "real", i.e. type-parametric and nestable, arrays.

(Both):  They're really, really slow even by interpreted language standards, unless you bend over backwards to vectorize your code.

(Both):  They seem to not be designed to interact with the outside world.  For example, both are fairly bulky programs that take a while to launch and seem to not be designed to make simple text filter programs easy to write.  Furthermore, the lack of good string processing makes file I/O in anything but very standard forms near impossible.

(Both):  Object orientation seems to have a very bolted-on feel.  Yes, you can do it, but it doesn't feel much more idiomatic than OO in C.

(Both):  No obvious, simple way to get a reference type.  No pointers or class references.  For example, I have no idea how you roll your own linked list in either of these languages.

(MATLAB):  You can't put multiple top level functions in a single file, encouraging very long functions and cut-and-paste coding.

(MATLAB):  Integers apparently don't exist as a first class type.

(R): The basic builtin data structures seem way too high level and poorly documented, and never seem to do quite what I expect given my experience with similar but lower level data structures.

(R): The documentation is spread all over the place and virtually impossible to browse or search.  Even D, which is often knocked for bad documentation and is still fairly alpha-ish, is substantially better as far as I can tell.

(R):  At least as far as I'm aware, there's no good IDE for it.  Again, even D, a fairly alpha-ish language with a small community, does better.

In general, I also feel like MATLAB and R could be easily replaced by plain old libraries in more general-purpose languages, if sufficiently comprehensive libraries existed.  This is especially true in newer general purpose languages that include lots of features for library writers.

Why do R and MATLAB seem so weird to me?  Are there any other major issues that you've noticed that may make these languages come off as strange to hardcore programmers?  When their use is necessary, what are some good survival tips?

Edit:  I'm seeing one issue from some of the answers I've gotten.  I have a strong personal preference, when I analyze data, to have one script that incorporates the whole pipeline.  This implies that a general purpose language needs to be used.  I hate having to write a script to "clean up" the data and spit it out, then another to read it back in a completely different environment, etc.  I find the friction of using MATLAB/R for some of my work and a completely different language with a completely different address space and way of thinking for the rest to be a huge source of friction.  Furthermore, I know there are glue layers that exist, but they always seem to be horribly complicated and a source of friction.

答:
The extreme emphasis on vectors and matrices to the extent that there
  are no true primitives.

It depends what you call a true primitive.  In R, a vector is a true primitive; that is, all variables are vectors.  Likewise, in MATLAB all variables are matrices.

The difficulty of basic string manipulation.

In MATLAB, string manipulation is powerful but I agree that the code is often ugly and unintuitive (at least for now).  For R, there is the stringr package, which is as nice to use as tools in any other language.

Lack of or awkwardness in support for basic data structures like hash
  tables and "real", i.e. type-parametric and nestable, arrays.

In R, vectors have names which works like a hash.  There are also the hash and filehash packages.  Not sure about MATLAB implementations, but you can call JAVA or .NET versions easily if you want.

They're really, really slow even by interpreted language standards,
  unless you bend over backwards to vectorize your code.

Once you get the hang of vectorisation (I'm sure you will, if you're really hardcore) you'll curse having to use loops when you return to other languages.  Speed of execution is a tradeoff for speed of programming.

They seem to not be designed to interact with the outside world. For
  example, both are fairly bulky programs that take a while to launch
  and seem to not be designed to make simple text filter programs easy
  to write. Furthermore, the lack of good string processing makes file
  I/O in anything but very standard forms near impossible.

They both can read and write data in pretty much any format.  They can both be called from most other programming languages.  Or from a command prompt.  You can create GUIs with them.  How is that not interacting with the outside world?  If you're struggling with your text filter program, ask on stackoverflow.

Object orientation seems to have a very bolted-on feel. Yes, you can
  do it, but it doesn't feel much more idiomatic than OO in C.

Agreed; they're primarily procedural languages.

No obvious, simple way to get a reference type. No pointers or class
  references. For example, I have no idea how you roll your own linked
  list in either of these languages.

Agreed in R.  In MATLAB, references are called handles.

You can't put multiple top level functions in a single file,
  encouraging very long functions and cut-and-paste coding.

Nonsense.  Just create multiple files.

Integers apparently don't exist as a first class type.

They do.  See int8, int16, int32 and int64.

The basic builtin data structures seem way too high level and poorly
  documented, and never seem to do quite what I expect given my
  experience with similar but lower level data structures.

They are suited to doing data analysis.  Please give specific examples of unexpected behaviour.

The documentation is spread all over the place and virtually
  impossible to browse or search. Even D, which is often knocked for bad
  documentation and is still fairly alpha-ish, is substantially better
  as far as I can tell.

There are many kinds of documentation.  Start with ?some_function, RSiteSearch('some concept'), rseek.org, and the sos package.  Not to mention the manuals that come with the install. Or a good book.

At least as far as I'm aware, there's no good IDE for it. Again, even
  D, a fairly alpha-ish language with a small community, does better.

Try Architect or RStudio or the Revolution Analytics IDE.  See "IDEs and editors for R" section of the Stack Overflow info page for links and more options.


问:
Why is DRY important?
Quite simple, why would I want to write code that works for all cases and scalable data when all I need to do is repeat the same process a few times with a few minor tweaks?

I'm unlikely to need to edit this again any time soon.

It looks like a lot of less work to just go...

```<code>function doStuff1(){/*.a.*/}
function doStuff2(){/*.b.*/}
function doStuff3(){/*.c.*/}
</code>```

And if I ever need to add something...

```<code>function doStuff4(){/*.d.*/}
</code>```

And if I need to remove it, I remove it.

It's harder to figure out how to make all of those into one straight-forward pattern that I can just feed data into and deal with all the cases, and make a bunch of changes I don't feel like I'm ever going to have to do.

Why be DRY when it looks like a quick cut+paste is going to be so much less work?

答:
As I stated in the answer to another question, my approach is the following:

The first time I solve a certain problem, I just get it done.

The second time (i.e. when I solve a similar problem) I think: hm, maybe I am repeating myself, but I will go for a quick copy-and-paste for now.

The third time I think: hm, I AM repeating myself -> make it
general!

I.e. up to 2, another principle (YAGNI) wins over DRY. But starting from 3 (or 4 if I am really lazy!) it seems I AM gonna need it and so I follow DRY.

Update

Some further ideas from my recent experience. I had to adapt / integrate two components A and B developed by another team into our product. First: the two components A andb B are very similar to each other, so I was already disturbed by the fact that they had a somewhat different architecture. Second: I had to adapt them so I would have been glad to use subclasses and only override what I really needed.

So I started refactoring these two components (each of which consists of about 8 C++ classes): I wanted to have a common architecture for both A and B, and then add the features we need by defining subclasses. In this way, our two new components A' and B' would have been derived from the existing ones.

After two weeks trying to get a common and well-defined structure out of the existing code and having to explain during our daily meetings that I was making little progress because the original code was too messy, I spoke to my boss. We observed that we were not going to need anything more than these two new components A' and B' (there were not going to be four or six of them, just those two).

Ok, so be it: I did a massive copy and rename of classes from A and B and started to adapt the copy of the code. I got it to work in two more weeks (still doing some bug-fixing now).

Advantages: We have the functionality almost finished now and when we have fixed all the bugs we are finished. We have saved all the refactoring and testing of A and B.

Disadvantages: Two weeks ago the other team changed another component C, which is used by A and B. They adapted A and B but A' and B' were also broken and we had to change them ourselves. This introduced a new bug that we had to fix. This extra work would probably have been unnecessary if A' and B' had shared most of their code with A and B.

So: code duplication is always dangerous. I think it is always a matter of finding trade-offs and often it is not easy.

Title: Why is DRY important?


问:
iOS version/device statistics - where can I find?
Since I am developing iOS apps I'm trying to find stats on how many iOS devices there are out there. Preferably broken down into versions: Iphone 3G, Iphone 3Gs, Iphone 4 etc.

Also I'd like to know the stats on different iOS versions.

After an hour of googling I found out that it is not the easiest thing to find. Anyone got some nice bookmarked links to share?

答:
This is what you're looking for. A quick summary:

4.0 and above = 98.2%

less than 4.0 = 1.8 %

52.23% have 4.3.3

14.37% have 4.3.4

13.57% have 4.2.1

Now this article is from August 3rd of 2011, so it's a bit old, but the data is new enough to be relevant.

Also, 30 seconds of Googling got this :P


答:
It's specific to his app (Instapaper) but Marco Arment publishes a fairly complete breakdown of device and version stats for his users:

http://www.marco.org/2011/08/13/instapaper-ios-device-and-version-stats-update

Title: iOS version/device statistics - where can I find?

Body:
Since I am developing iOS apps I'm trying to find stats on how many iOS devices there are out there. Preferably broken down into versions: Iphone 3G, Iphone 3Gs, Iphone 4 etc.

Also I'd like to know the stats on different iOS versions.

After an hour of googling I found out that it is not the easiest thing to find. Anyone got some nice bookmarked links to share?


问:
Effectiveness of "what is your greatest strength/weakness" interview questions
As someone who is now finding himself on the other end of the interview table, I'm wondering how useful these questions are from an employer's perspective. Some of my coworkers think they're good because you can see "how they respond," but I'm not convinced it tells you anything useful, for several reasons:

It's not a very comfortable question and can lead people to twist their answers, even if not on purpose

People may not fully know their greatest strengths or weaknesses (i.e. judge them by their peers)

Explaining what a strength is isn't as good as showing it

I still don't know any more about the candidate afterwards

The rationale of my coworkers is that it can help weed out people that give ridiculous responses, like one guy that said his greatest strength was "his intellect" or people that try to turn the weakness question into a strength like "I work too hard." But I think there's more effective ways to determine such things. If you want to see if someone's smart, ask them technical questions. If you want to see if someone is productive, look at their work history. If you want to see how someone reacts under stress or change, ask them how they've dealt with it and ask for concrete examples.

What are people's thoughts on these questions, from the perspective of an interviewer? What do they really tell you about a candidate, and what are better alternatives? How do I convince my colleagues of this?

答:
I once had a job interview where the hiring person was a dev, and he asked me to cut some code in the language they needed, right then and there on the whiteboard.  I did what he asked, he looked at it, nodded, and asked "Can you start tomorrow?"

Asking BS questions like "name your biggest strengths and weaknesses" is the most egregious waste of time ever invented by pseudo-intellectual MBA Human Resource specialists.

ContentLicense: CC BY-SA 2.5


答: I'd say that the amount of experience (not just programming, but also in business environments) your developers have is a key element in how much time you spend with them.  I'm currently working with some developers who are just out of school, and I'm finding that they need more guidance in how to work with others, not just in documenting/testing/standards ways, but also in interpersonal ways (when to call on the phone or meet in person, instead of just sending emails).  Knowledge of our business is also a key thing to learn about, as many of the same words are used very differently in our business context than in a software development context.  And this is before we get to the acronyms...</p>


问:
Balance between workload and helping new-hires
I've been at my first job for about 2 months and I've started to notice that there is a delicate balance between workload and helping new-hires. Since there is a lot of pressure from management to fix bugs and resolve as many customer issues as possible everyone on the team seems to be very focused on their backlog of work instead of helping the new-hires get up to speed. The new-hires can ask questions and occasionally we'll get a developer to sit down and help us but often we'll get an obscure answer that only a veteran of the product would understand because they are too busy with their task.

I understand the the new-hire must also maintain a balance. Sometimes it will take a new-hire 3 days to investigate and fix something where a veteran could have done it in 20 minutes. New-hires need to show effort toward learning the product and the codebase.

With out simply reducing the workload of the veterans, how can you balance between helping new-hires and continuing to work on your backlog at a reasonable rate?

答: At our company we assign for every new-hire someone to take care of him for the first few months. With this formal assignment we ensure the newbie only will consume one person and the person who is "coaching" the new hire has the responsability over his development, so it isn't a burden, just a temporary responsability. For the new guy is good because he learns faster and for the guy who is already there is an investment: in less time he will get someone to help him.</p>


答:
I'm assuming you're asking this from the "New Hire" point of view. I've been in this situation many times. Sometimes you feel bad asking so many questions, but there's really no way you could come to the solution sometimes with such a lack of domain knowledge, etc.

The most important thing to remember is this. Don't go asking questions when you "assume" you won't be able to find the answer yourself. Give things a shot, poke around first, examine the code, try changing some things and see what happens - see if you can get something to work first. If you really can't, ask your question. However, when you ask your question, go to them with examples of what you've already tried. None of them want to feel like you are asking them to do your work for you.

Say, "Hey, I'm trying to do this, and I've tried this, this, and this already, do you have any ideas?" That will help them spend less time on you, and they will be more inclined to do it.

Title: Balance between workload and helping new-hires

Body:
I've been at my first job for about 2 months and I've started to notice that there is a delicate balance between workload and helping new-hires. Since there is a lot of pressure from management to fix bugs and resolve as many customer issues as possible everyone on the team seems to be very focused on their backlog of work instead of helping the new-hires get up to speed. The new-hires can ask questions and occasionally we'll get a developer to sit down and help us but often we'll get an obscure answer that only a veteran of the product would understand because they are too busy with their task.

I understand the the new-hire must also maintain a balance. Sometimes it will take a new-hire 3 days to investigate and fix something where a veteran could have done it in 20 minutes. New-hires need to show effort toward learning the product and the codebase.

With out simply reducing the workload of the veterans, how can you balance between helping new-hires and continuing to work on your backlog at a reasonable rate?


问:
Data Mining Books
I'm passionate about data mining, I have read some books like Programming Collective Intelligence, and I would like to know more good books, specially practical ones, about data mining in conjunction with AI. Any tips will be appreciated as well. Thanks.

答: I've looked at several of the suggested books and have found Introduction to Machine Learning by Pan, Steinbach and Kumar to be the best. One thing it has that most of the others don't is a whole chapter at the beginning on data preparation and how to represent data to the algorithms. I've not found a better treatment of that very important piece of data mining.</p>

Title: Data Mining Books


答:
Some of the more experienced coders actually enjoy mentoring younger developers, and make it a priority to do so.  I do, whenever I have the opportunity.  Perhaps you can find someone like that at your company by asking a different colleague each time you need help, then gauging their enthusiasm in answering you.

There are two ways you might need help: if it's a problem with the language or your tools, you can often find the answers either online or by purchasing technical books and reading them on your own time.  While you would be reasonable in feeling that it's the company's responsibility to train you, very few company's invest much in training anymore.  If you want to grow as a developer you need to invest time and money in training yourself when you're not on the job.

If your question is about your company's product, like how something works in the source code, it is more likely that you will just have to ask one of your colleagues for help.  Alternatively, create a branch of your product's code in your revision control system, name the branch something like "learning_new_code" and just experiment with it.

Finally, project managers and departmental managers are there to help with problems like yours.  If you feel you have no recourse but to get time from your more experienced colleagues, but they are unable to give it to you, it may be because they have deadlines to meet.  Perhaps your manager will extend their deadlines in order to allow them more time to bringing you up to speed.


问:
Can I use MIT licence plugins in my commercial web site?
If yes, what precautions should I take?</p>

答:
The full text of the MIT License can be found here.

I'm not a lawyer, but it seems like you can

deal in the Software without restriction

even so far as

distribute, sublicense, and/or sell copies of the Software

provided that

The above copyright notice and this permission notice shall be
  included in all copies or substantial portions of the Software.

Again, I'm not a lawyer, but you might fulfill that condition via comments in all pages or scripts that use the MIT licensed plugin or an Acknowledgments page.


答:
With an MIT/X11-licensed product:

you CAN:

re-use the code freely for your own use,

re-use the code freely for non-commercial AND commercial re-distribution, whether in source or binary form.

you CANNOT:

claim authorship of the software,

thus you cannot attack the original author for using or publishing his original version.

So, yes, you CAN use MIT/X11-licensed plug-ins in your commercial application.

MIT/X11 is basically a simple contract that says:

Person or company X created Y.

Y belongs to X, but X is granting you the right to use it and do whatever you want with it.

X cannot be held accountable for anything that goes downhill with what you do with Y.

Title: Can I use MIT licence plugins in my commercial web site?

Body: If yes, what precautions should I take?</p>


答:
The best advice I can give you is to make an appointment.  Everyone has some downtime during the day, but if you just drop in randomly you're very unlikely to hit it.  Say something like, "I have some questions about X, can I set up some time today to go over it with you?"  They might decide to give you time right then, or later in the day, or maybe refer you to someone who might be able to answer your question better or faster.  Either way, you're going to get more focused attention.  If they give you an appointment later in the day, use the intervening time to try to figure the answer out on your own, or at least to refine the question.  Even if I postpone someone's question for only 15 minutes, more often than not they figure it out on their own.

Just be aware that for most of us, your questions are important to us, they just usually aren't urgent.  Try not to take offense at the difference.


问:
Is Silverlight only for eye-candy, or does it have a use in business?
Granted that Silverlight may make eye-popping websites of great beauty, is there any justification for using it to make practical web applications that have serious business purposes?  I'd like to use it (to learn it) for a new assignment I have, which is to build a web-based application that keeps track of the data interfaces used in our organization, but I'm not sure how to justify it, even to myself.

Any thoughts on this?  If I can't justify it then I will have to build the app using the same old tired straight ASP.NET approach I've used (it seems) a hundred times already.

答: Well, Microsoft recently released a Web version of Office, and there's not a trace of Silverlight to be seen anywhere.  Feel free to draw your own conclusions from this.</p>


答:
Often this is more an issue of focus than of time. Schedule 30-45 minute meetings with your team lead or mentor (before or after lunch is always my preference - my flow is already breaking then) a couple of times a week and save up your questions for then.

Most developers (or, at least, the ones most likely to be helpful in the meeting) will be fine with this.

If there's a very specific detail that's blocking your progress, use email.


答:
OK as a lead it is your job to get the projects out the door. So you have to be the one who enforces standards, code reviews, asks for progress reports and all those things when the developers would rather you left them alone. These things are just requirements of management and except for the code reviews don't really grow the employees' skills.

However, you want to help them grow which is a great attribute in a leader.

Code reviews are certainly a first step, they will help you see who has less than stellar skils and needs improvement to even have satsifactory performance. They willl help the developers see other ways to do things and to understand different parts of the code base than the ones they personally worked on. In my opinion, code reviews are best done in person in a conference room with the developer and the reviewer (who should be another developer when possible not always the lead, reviewing other's code is also a skill that needs to be developed) and you as a moderator. You should keep notes on what needed to be changed to identify trends. What you really are looking for isn't mistakes or changes (everyone's code can be improved), but consistent failure to learn from mistakes. Do not tell upper management you are keeping these notes or you will find yourself forced to use them as measurements in the performance review process which frankly defeats the purpose.  If several developers are making the same mistakes, a training session or a wiki entry on how to do X may be in order.

Now on to growing vice getting to the minimal level. First, you need to know what skill sets the developers have and what skill sets it would be useful that they had and what they might be interested in getting knowldge in.  You need to talk to them and review their resumes and understand what they liek and don't like to do.

Don't give all the interesting assignments only to the most skilled. That doesn't help the others get up to speed on new problems and technologies. You can't move from being the most junior guy getting only the smallest and least important tasks to the senior guy unless someone takes a chance and assigns more difficult work to you. That said, the less experienced may need to be assigned first to pair program with a senior to get more advanced skills. Including the juniors in code reviews will also expose them to more advanced techniques.

First give them a chance to figure out the issue themselves. But sometimes people are stuck and don't know where to start (a skill that you also needs developing especially in new programmers) or what to do to solve a problem.

If you give them a couple of days to research something and they still don't have a direction for how they are going to do something, then you may need to intervene with some suggestions. If you are technical yourself, you may give them some ideas for how to solve the problem. If not, a meeting with several people where you brainstorm ideas can help if the person is stuck. Or asking a more experienced person to give some suggestions. What you don't want to do is take the problem away from them and solve it yourself. But you have to balance getting the project done with the programmer's ego and at times you need to send them in a specific direction. If he has a bad solution and it needs to be fixed, the worst thing you can do is give it to someone else unless you intend to fire the programmer. Making people fix their own mistakes is how they learn not to make them.

I've seen bad programmers coddled, where someone else has to fix almost everything they do. The other programmers resent this and just want the person out of their lives. Coddling a bad programmer leads to the good programmers leaving. You have to find the line between coddling and devloping skills. If you give someone several chances and he or she never gets better, then cut him or her loose.

For the seniors who are already competent in their current skill sets, things are easier. Usually you just need to give them the opportunity to do something new and they jump in and learn it. Just make sure the interesting opportunities get spread around and don't all go to Joe the Wonder Programmer who can fix anything. You want to end up with ten Joes not just one.

Another way to develop skills is to have a weekly 1-hour training session. Make each devloper responsible for a particular topic. This will help them get better at communicating, will make them research something in depth and will give everyone the benefit of their research. Some topics should be assigned to people who are not familair with the topic to force them to grow some knowledge in that are and some should be assigned to people you know are the local experts on that topic. Topics should be a combination fo things you need people to be good at inthe near furture or right now and some coverage of new upcoming technologies that you don't use right now but peoplea re intersted in learning about to see if they could be useful. But everyone including the most junior must be assigned a topic. Doing the training is as much a growth opportunity as listening to the training.

Depending on how your developers' time is billed (this is harder in a customer billing situation), it is usually worth it for developers to have 4-8 hours a week to work on personal projects. They will be excited to do this. The best people will want to work there and they will learn alot that will become useful for the future. It's hard for the bean counters to understand the need for this, but this time will be paid back many times over in employee satisfaction, new features or software that nobody required (or which will help automate some of the drudgery) and faster development due to new techniques learned. Some developers will use this time strictly for personal projects not related to what you do (and that's good, they will still be gaining skills and happy for the opportunity), but many others will use it to solve persistent problmes that, due to the nature of how projects are managed, ndbody had time to fix beforehand. So you may get refactorings that benefit everyone; some people might write tests to improve test coverage to make it easier to refactor; some others might explore some new features that might make your software more useful to it's customers. In general, if you can persuade the bean counters, there is no way to lose by allowing them this freedom.

You have to learn how to balance letting people have some stretch for their skills and keeping the project on track. The less experienced the developer is, the more someone needs to check on progress especially in the early stages when changing direction is easier.  The inexperienced may struggle and be afraid to speak up. These people tend to leave just before launch and you find their part of the project isn't anywhere close to being done. Be especially careful to check progress on anyone you have who has changed jobs frequently (unless they were a contractor as that is the nature of contracting).

The more experienced can generally be trusted to tell you when they are having trouble finding the solution and need some assistance from someone with more knowledge in the area or they will go seek out that person and get the knowledge transfer. So they don't need to be monitored as closely in the intial phases of learning a new skill set for a project. They will find a way to deliver the project. Those who have a track record of delivering can usually be left alone except for minimal progress reports (you usually have to report to your management too and thus need some information).


问:
Why does the Git community seem to ignore side-by-side diffs
I used to use Windows, SVN, Tortoise SVN, and Beyond Compare.  It was a great combination for doing code reviews.

Now I use OSX and Git.  I've managed to kludge together a bash script along with Gitx and DiffMerge to come up with a barely acceptable solution.

I've muddled along with this setup, and similar ones, for over a year.  I've also tried using the Github diff viewer and the Gitx diff viewer, so it's not like I've not given them a chance.

There are so many smart people doing great stuff with Git. Why not the side-by-side diff with the option of seeing the entire file?  With people who have used both, I've never heard of anyone that likes the single +/- view better, at least for more than a quick check.

答:
I can't speak for Linus on this, but the way git handles difftools is very unixish, philosophically speaking. git does what it does very well, and uses external tools for everything else, including more sophisticated diffing and merging.

I use DiffMerge with git on OS X too, and I haven't had to resort to any bash shells. It was tricky, but I configured git's difftool and mergetool settings to call DiffMerge directly, and I can now view diffs and resolve merge conflicts in an excellent, visual third party tool.

Here's my config:

```<code>[mergetool "diffmerge"]
        cmd = "diffmerge --merge --result=\"$MERGED\" \"$LOCAL\" \"$(if test -f \"$BASE\"; then echo \"$BASE\"; else echo \"$LOCAL\"; fi)\" \"$REMOTE\""
        trustExitCode = false
[difftool "diffmerge"]
        cmd = diffmerge \"$LOCAL\" \"$REMOTE\"
[merge]
        tool = diffmerge
[diff]
        tool = diffmerge
</code>```

Body:
I can't speak for Linus on this, but the way git handles difftools is very unixish, philosophically speaking. git does what it does very well, and uses external tools for everything else, including more sophisticated diffing and merging.

I use DiffMerge with git on OS X too, and I haven't had to resort to any bash shells. It was tricky, but I configured git's difftool and mergetool settings to call DiffMerge directly, and I can now view diffs and resolve merge conflicts in an excellent, visual third party tool.

Here's my config:

[mergetool "diffmerge"]
        cmd = "diffmerge --merge --result=\"$MERGED\" \"$LOCAL\" \"$(if test -f \"$BASE\"; then echo \"$BASE\"; else echo \"$LOCAL\"; fi)\" \"$REMOTE\""
        trustExitCode = false
[difftool "diffmerge"]
        cmd = diffmerge \"$LOCAL\" \"$REMOTE\"
[merge]
        tool = diffmerge
[diff]
        tool = diffmerge


答:
You'll notice that SVN itself doesn't offer a side-by-side solution, either. What you've listed are third-party tools. As with most things in git, this is extraordinarily configurable, and it has great tool support out of the box. Do you have a mergetool set up? If not, you should. If you do, try git difftool. Then have a look at the man page for config options.

I use KDiff3 as my mergetool since it's a nice, cross-platform tool, and with no further configuration, git difftool does exactly what you're asking.

Title: Why does the Git community seem to ignore side-by-side diffs

Body:
I used to use Windows, SVN, Tortoise SVN, and Beyond Compare.  It was a great combination for doing code reviews.

Now I use OSX and Git.  I've managed to kludge together a bash script along with Gitx and DiffMerge to come up with a barely acceptable solution.

I've muddled along with this setup, and similar ones, for over a year.  I've also tried using the Github diff viewer and the Gitx diff viewer, so it's not like I've not given them a chance.

There are so many smart people doing great stuff with Git. Why not the side-by-side diff with the option of seeing the entire file?  With people who have used both, I've never heard of anyone that likes the single +/- view better, at least for more than a quick check.


答:
But I don't quite know how to do this, do I have to

Interact with them frequently, or give them quiet time, leave them
  undisturbed?

Ask them to follow coding guidelines, such as enforcing unit tests,
  coding styles, or let them do whatever they see fit?

Be lenient with them. Such as don't really care whether they really
  come into office for 8 hours or 4 hours, or need to enforce some
  "disciplines" in the work place?

My suggestion is to have some conversations about what style works best for that individual and fine tune over time.  Some people may want to meet once a day to review how things are going while others may find once a quarter to be excessive.  Some people may want a formal written out performance review every month and others may just want a chat about performance.  The key is getting the relationship to the stage where you can get honest about what works and doesn't work for someone.

The flip side to this would be to study personal development philosophies though this can be a tricky road if someone gets analyzed incorrectly.  If you want a few examples of such philosophies you could look at Myers-Briggs, Enneagram, and Strengths Finder 2.0 for a few examples.


答:
It's the *nix philosophy. A lot of the people who use these tools spend a lot of time in the terminal. The terminal doesn't require us to move our hands from the keyboard to the mouse. I know that I prefer the +/- style to the visual diff/merge tools, mostly because I only care about the differences. I care about the 3-4 lines around the change and the change itself. Anything more is extra information that really doesn't help me.

Diff's are commonly used to get a quick look at what has been changed. Not to read the code.

I have never found the visual diff tools very useful compared to the default diff on GNU systems. All they ever make me do is start messing with the mouse and forcing me to scroll through the file, figure out their user interface, and then struggle on getting back into the command line where I can do something about a problem I see in the diff.


问:
How to best annotate MVC custom action filters?
As I get deeper into the area of ASP.NET MVC 3, I feel like I'm finding a lot of very nice technical nuggets as well as new ways of doing things versus classic ASP.NET.  One of those "nuggets" is custom action filters.  You can simply decorate your controller classes or methods with attributes that, by convention, point to a "custom action filter" class that can perfom some operations given some point of execution (e.g. On Exception, On Method Execution, etc).  They are VERY handy if you have some sort of operation that needs to be performed at a regular point in the execution of your code.

The question is this:  How does this best fit in with object oriented design?  What do you think is the best way of annotating that on a UML diagram or when you are trying to draw them up on a white board and explaining the design?

I'm very visual, so I like explaining my designs on the white board, but I'm at a loss of how to best convey custom action filters in an Object Oriented basis.  They are not really an interface that needs to be implemented.  They do take advantage of inheritance, but not in the context of where they are executed.  They seem to fit best under the realm of "Aspect oriented" programming, where you have actions that take place under the covers for different scenarios (e.g. Logging, Exceptions).

Any thoughts are appreciated.

答:
Yes, "Aspect-oriented" would be the best way to describe them.  Their use via attributes suggests implementation of cross-cutting concerns.

Using UML for Modelling Cross-Cutting Concerns in Aspect Oriented
Software Engineering

http://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=4530349


答:
Silverlight has not been designed to build websites.

It has been designed to build web applications that run in a browser.

Title: Is Silverlight only for eye-candy, or does it have a use in business?

Body:
Granted that Silverlight may make eye-popping websites of great beauty, is there any justification for using it to make practical web applications that have serious business purposes?  I'd like to use it (to learn it) for a new assignment I have, which is to build a web-based application that keeps track of the data interfaces used in our organization, but I'm not sure how to justify it, even to myself.

Any thoughts on this?  If I can't justify it then I will have to build the app using the same old tired straight ASP.NET approach I've used (it seems) a hundred times already.


问:
Should I understand SVN before I jump to GIT?
I work in a department where no one has ever used source control before, including myself.

I am trying to push the concept. I have spent a little while researching SVN. I some basics learned. I can Create/update/checkout/commit with command line and from Tortoise. I am starting to learn how to tag and branch but still confused a lot about conflicts between branches and trunk etc. I am still learning, but I do not have a physical person who can show me anything. Its all from books/tutorials and trial and error.

From what I have read online it seems like git is the better thing to know, but its also more complicated. I don't want to overwhelm myself. Should I continue to master svn before moving to git or would I be wiser to just jump to git now?

Are there pros and cons to both approaches?

答: Nope. Download Git, create a github account, and mess around for a couple of days forking repos, etc.  Git is pretty trivial to get up to speed with.  Learn 5 or 6 bash commands and you can do all of the essential tasks.  I generally prefer the "idiot-proofness" of a GUI, but the Git Bash is about as easy as it gets. Also, the Git Gui is pretty decent if you prefer that route. I do not really see the benefit you would see from learning SVN. I went through a period a while back where I was evaluating a few different Version Control systems for a new open source project. I tried out SVN, Bazaar, Git, and a couple others and learned the basics of each. YMMV, but Git was by far the easiest. There is nothing wrong with learning SVN as well, but it really will not help you to learn Git.


答:
I am fortunate that I currently work somewhere this isn't an issue.  I've gotten a healthy dose of mentoring here, and I'm very pleased with it.

Every day one developer at my company is the "util" developer, on a rotating basis.  The Util developer is the first line of contact when support needs to escalate something.  Frequently, Util is just passing a problem off to someone else.  But it is one specific developer and support knows to go to this person.  I did some "ride-alongs" at first (they didn't put me in the schedule for a little while) to see how some problems were dealt with.  This got me exposed to portions of code.  When they started scheduling my regular util days there was someone "on call" at first to add additional assistance.

We pair.  You need to schedule pair time, pretty much, but everyone here is willing to do it.  Further more, everyone knows what the schedule is and thanks to the next point has an idea of how progress is going for each individual.  So if there's a problem, it gets proper attention.

Every day we do a standup meeting at 11:45.  This is 15-20 minutes.  Every developer/QA person speaks.  It's basically a way to say "this is what I am doing and this is where I am stuck", and if you are stuck you generally get pointed in some alternate direction (if it's a known issue/ an issue with code someone is very familiar with) or pair time is set up.  Occasionally an additional meeting is scheduled.

I've had to dive into completely alien code numerous times here (as with any job).  Someone has always been sure to make themselves available to answer questions, if not right away.

I'll echo others: schedule meeting time to ask questions where possible.  Id that still isn't helpful. . . well I don't want to get extreme here.  But I don't consider that an ideal workplace.  Is it possible people are still warming up to you/getting a handle on your abilities/etc?

I suspect the extra time spent when I came on board was easily justified because once people felt I was up to speed that obviously meant less work for them.  More time spent short term saved a lot of time long term, and everyone understood that where I work.  I'm very fortunate in my current position.


问:
How do you help your fellow programmers to grow?
As a team lead, how can you help your programmers to grow?

The reason I ask this is because there are a few programmers working with me, and I really want to "turn them on the loose", to realize their maximum potential, and to keep them happy.

But I don't quite know how to do this, do I have to

Interact with them frequently, or give them quiet time, leave them undisturbed?

Ask them to follow coding guidelines, such as enforcing unit tests, coding styles, or let them do whatever they see fit?

Be lenient with them. Such as don't really care whether they really come into office for 8 hours or 4 hours, or need to enforce some "disciplines" in the work place?

Guess what, each positions have their own points, and different people would argue for different things. Such confusions make managing people indefinitely harder.

What do you think?

答:
You ask them how they would prefer to work.

What they'd like to change and so on.

Not all at once. Just... as things show up.

Stay natural. (or they'll smell fear)

And then... you may even learn stuff from them. If you don't think that would ever be the case, (too much distance in education and experience) don't really bother trying to make them grow up, it would only confuse them.

(In that special case, give it up and rule with an iron fist, it's more honest than faking interest you don't have in them)

Establish a democratic process, vote things up, discuss issues.

Like every president out there, you keep the final word: the veto.

The rest is up to the group.


问:
How to deal with potential enterpreneur developer in a IT startup
In a software startup, how can we deal with the main developers/programmers of the company who are good at design and communication, and also have entrepreneurial skills?

How do we get them work for us and avoid any kind of competition from them to our business?

How can we convince the lead programmer that our startup is the place for him?

答:
I'm not a fan of them, but non-compete clauses are one way to do this.

A better way is to find incentives that keep your people happy. Those incentives are not always money; autonomy and the ability to make your own decisions about your work details is the most important one to me.  Treat your people well, and they will treat you well.

Everyone wants the benefits of owning their own business, but few want the responsibility.


答:
I'm going though a personnal evaluation at the moment, and i'm in the middle of this very exercise. Only there's a twist; i have to ask colleagues and friends what my strengths/weaknesses are, and not look at the result before having compiled my own list

This is very interesting because it makes some discrespancies between what you think you are and what other perceives about you obvious.

"I think i'm a hard worker, and i'm very serious and ..."

"He's an obsessive control freak who programs so defensively his code is
unreadable and ..."

In interviews, i think this may be a kind of low level sanity check. "Do you know the basics, did you prepare?" they seem to say. Or perhaps it's just that this question used to trip people, to shake them up.

But now the question is so widely known it's become useless; interviewers keep asking it out of habit because that's what they've learned. Interviewees keep trying to game it out of self-preservation...

Perhaps it could be updated; instead of "what's your weakness", ask "hey, if you could go back in time one year, what is the thing you'd like to change the most?"

Chances are, the interviewee will have a chance to talk about a moment when he didn't manage to reach his standards, but in a positive way: "well this didn't work out, so i'd... to have it succeed". The interviewer has an idea of what the interviewee didn't like, and the interviewee shows he did learn from a mistake.

The same could be done with the strengths: "if you had to showcase one thing you did during last year, what would it be?"

what do you think? Does it keep the goal of the original question but in better clothes?

Title: Effectiveness of "what is your greatest strength/weakness" interview questions

Body:
As someone who is now finding himself on the other end of the interview table, I'm wondering how useful these questions are from an employer's perspective. Some of my coworkers think they're good because you can see "how they respond," but I'm not convinced it tells you anything useful, for several reasons:

It's not a very comfortable question and can lead people to twist their answers, even if not on purpose

People may not fully know their greatest strengths or weaknesses (i.e. judge them by their peers)

Explaining what a strength is isn't as good as showing it

I still don't know any more about the candidate afterwards

The rationale of my coworkers is that it can help weed out people that give ridiculous responses, like one guy that said his greatest strength was "his intellect" or people that try to turn the weakness question into a strength like "I work too hard." But I think there's more effective ways to determine such things. If you want to see if someone's smart, ask them technical questions. If you want to see if someone is productive, look at their work history. If you want to see how someone reacts under stress or change, ask them how they've dealt with it and ask for concrete examples.

What are people's thoughts on these questions, from the perspective of an interviewer? What do they really tell you about a candidate, and what are better alternatives? How do I convince my colleagues of this?


答: I would adopt the strategy of taking the best programmers, the entrepreneurial, super-effective stars and giving them an entrepreneurial-level stake in the business. That engineer is much more likely to put all his or her energy into making your business a huge success if it means that they, too, will be huge successes. That's going to dramatically cut back on the likelihood of that person defecting from your company.</p>

Title: How to deal with potential enterpreneur developer in a IT startup

Body:
In a software startup, how can we deal with the main developers/programmers of the company who are good at design and communication, and also have entrepreneurial skills?

How do we get them work for us and avoid any kind of competition from them to our business?

How can we convince the lead programmer that our startup is the place for him?


问:
How to handle "can you add just a few more fields" type of requests from customers?
Very commonly we have feature requests for fields that only one customer wants. This, at best, clutters the application's code. Often when we look in their database a few months after adding the fields, we can see that they are not actually even using the extra fields. Also, it's quite an old application so adding a single field requires multiple code changes, changing reports, and making sure that it doesn't affect other customers who do not need to see the field.

How can we make sure that a customer actually needs these feature requests?

How do we politely say "you don't really need that"?

Currently we are beginning to charge for certain feature requests. (Previously, feature requests were free usually) Is there anything else we can do?

答:
Build a standard negotiation system for requests. Maybe something based off of a bug-reporting or feature request system, like fogbugz. Allow your customers to place a request, and prioritize it based on:

the technical feasibility/cost of the feature

is the feature request a "for pay" one? If it's in a contract, and/or they've paid for it, then put it in

does the feature "make sense"? This is a bit of an art, but, generally, if enough customers ask for a feature, then implement it for free. It's an opportunity to make your product better, and make the sale to the next customer an easier one

do you have unused, paid cycles available? If you include a set of monthly hours for maintenance/support as part of your contracts (I highly recommend you do, even if the number is very low), and they're not getting used, start throwing them at making these kinds of changes


问:
How should I document a Python script?
I have a couple of Python modules that are meant to be run as scripts. How should I write the docstrings at the module and function level to make it clear how to run and use the module?</p>

答:
I'd mimick a man(1) page

```<code>NAME
      this command does things
SYNOPSIS
      command do-things nice
DESCRIPTION
      things are nice when this command does them
</code>```

Title: How should I document a Python script?

Body:
I'd mimick a man(1) page

NAME
      this command does things
SYNOPSIS
      command do-things nice
DESCRIPTION
      things are nice when this command does them


问:
I'm writing about language syntax. Is there a language out there in which parameters are placed inside method name?
in JavaScript:

function getTopCustomersOfTheYear(howManyCustomers, whichYear) {
   // Some code here.
}
getTopCustomersOfTheYear(50, 2010);
```

<p>in C#:</p>

<pre class="lang-cs prettyprint-override"><code>public List<Customer> GetTopCustomersOfTheYear(int howManyCustomers,
 int whichYear)
{
   // Some code here
}
List<Customer> customers = GetTopCustomersOfTheYear(50, 2010);
</code>```

in PHP:

public function getTopCustomersOfTheYear($howManyCustomers, $whichYear)
{
   // Some code here
}
$customers = getTopCustomersOfTheYear(50, 2010);
```

<p>Is there any language out there which support this syntax:</p>

<pre class="lang-c prettyprint-override"><code>function GetTop(x)CustomersOfTheYear(y)
{
    // Some code here
}
returnValue = GetTop(50)CustomersOfTheYear(2010);
</code>```

Isn't it more semantic, more readable form of writing a function?

Update: The reason I'm asking this question is that, I'm writing an article about a new syntax for a new language. However, I thought that having such syntax for declaring methods could be nicer and more friendly to developers and would decrease learning-curve of the language, because of being more closer to natural language. I just wanted to know if this feature has already been contemplated upon or not.

答:
In JavaScript or any other language that supports closures, you can curry a function like this:

function getTopCustomersFunc(count) {
    return function(year) {
       // run some query, return count customers from year
    }
}
var top20Func = getTopCustomersFunc(20);
var top20Customers2005 = top20Func(2005);
var top20Customers2008 = top20Func(2008);
```


问:
Offline demo of website - tools to handle "saved" external links
I am designing a test (demo to users) of a web site from my local machine without Internet access. The site will be hosted locally, but I would also like users to be able to follow  links to certain external sites. Are there tools that can make the user think they are browsing a site online when they are actually browsing a local copy of the relevant external pages?

The kind of tool I'm imagining would allow you to specify a proxy in the browser that would intercept certain URLs and hand them to the offline copy of a page. There would also be an easy way to save and manage these offline pages.

The offline access requirement is a developing world thing - smart people don't rely on Internet access in places where there is little by way of infrastructure and they only have one chance to get something right.

答:
Fiddler is exactly what you need here. You can set up "autoresponders" to known external URLs to return local content. With a little more effort you can actually use Fiddler to record a session to a real site and then get it to "Play back" the responses, you do have to be very careful to make all your requests in exactly the same way though.

There's even a short video on his site showing you exactly how to do this - item 2 on this page: http://www.fiddler2.com/Fiddler/help/video/default.asp


答:
In addition to ZJR's suggestion of mimicking a man page, you can also provide a usage statement, return codes, and in-code documentation.

I would consider providing a usage statement that explains how to invoke the application in a clear, concise manner. This would simply provide a list of the arguments, what the arguments represent, if a given argument is optional, and any other relevant information. This would be convenient to users who invoke your scripts from the command-line.

For automated applications that call your scripts, I would consider using various return codes to document errors or other non-standard execution considerations. These can be easily parsed and would shift handling of exceptional cases (especially those that you simply can't handle in your script) as well as logging of the event into the calling application.

Using docstrings might be overkill, depending on the complexity of the script, but some form of in-code documentation is needed for future developers (including youself in the future). I would include a high-level overview of what the script does as the very first thing in the file. Self-documenting code would always help, as well, so make sure you've got good variable names. If there's any complex logic, make sure it's clear what's going on and why you made the design decisions that you did with comments.

Title: How should I document a Python script?

Body: I have a couple of Python modules that are meant to be run as scripts. How should I write the docstrings at the module and function level to make it clear how to run and use the module?</p>


答:
Every opensource licence to date (MIT too, a BSD-spirited licence) allows you to use the software on a commercial web site (and that's part of the reasons for the extreme OSS propagation in latter years) with some notable exception. Those exceptions are:

Creative Commons' CC-BY-NC and CC-BY-NC-SA (NC = Non Commercial)

Affero/GNU Affero/AGPL (many names, same licence)


答:
Personally I use the docstrings for other programmers/installers, there I document the purpose and any setup details that you need to look at rarely.  For user documentation, I use the argparse module so users can run: program --help

```<code>import argparse

# other stuff

parser = argparse.ArgumentParser(
    description='Path building utility.',
    epilog="""Default operation is to read a list of directory
           names from stdin and print a semi-colon delimited
           path list to stdout.  To terminate --add, --append,
           --prepend or --remove list, use -- as in: {}
           --remove *foo* *bar* -- input.file
           """.format(os.path.basename(sys.argv[0])))
parser.add_argument('--add', '--prepend',
    help='add specified directories to the front of the path',
    dest='front', type=str, nargs='+', metavar='DIR', action='append')

# etc.
</code>```

Title: How should I document a Python script?

Body:
Personally I use the docstrings for other programmers/installers, there I document the purpose and any setup details that you need to look at rarely.  For user documentation, I use the argparse module so users can run: program --help

import argparse

# other stuff

parser = argparse.ArgumentParser(
    description='Path building utility.',
    epilog="""Default operation is to read a list of directory
           names from stdin and print a semi-colon delimited
           path list to stdout.  To terminate --add, --append,
           --prepend or --remove list, use -- as in: {}
           --remove *foo* *bar* -- input.file
           """.format(os.path.basename(sys.argv[0])))
parser.add_argument('--add', '--prepend',
    help='add specified directories to the front of the path',
    dest='front', type=str, nargs='+', metavar='DIR', action='append')

# etc.


问:
How do I handle refactoring that takes longer than one sprint?
I work with a code base that is over 500K lines of code. It is in serious need of refactoring. There have been refactoring efforts identified that will take longer than the normal two week sprint. These can't be broken up into smaller tasks as I have seen suggested in other answers on this site. The product needs to work at the end of the iteration, and partial refactoring will leave the system in an unusable state as the dependency between items is horrible. So what would be the best way to approach this hurdle? Again I mention, breaking it down into smaller pieces is is not an option, that has already been done.

Update:
People seem to need an explanation of why this can't be fit into a 2 week sprint. There is more involved in a sprint than just writing code. We have a policy of no code without tests. That policy did not always exist and a large portion of the codebase does not have them. Also some of our integration tests are still manual tests. The issue is not that the refactoring itself is so large. It is with the fact that small changes have an effect on many parts of the system, and we need to ensure that those parts still operate correctly.

We can't put off or extend a sprint because we have monthly hotfixes. So this change extending past a sprint cannot stop the other work being added to the hotfix.

Refactoring vs Redesign:
Just because our development process is not efficent enough to handle this refactoring in a two week cycle does not warrant renaming it to a redesign. I would like to believe that in the future we could accomplish the exact same task within a two week cycle as our process improves. The code in question here has not had to change in a very long time, and is quite stable. Now, as the direction of the company is becoming more adaptable to change, we want this portion of the code base to be as adaptable as the rest. Which requires refactoring it. Based on the answers here, it is becoming apparent that there is missing scaffolding necessary to make this refactoring work in the time frame of normal sprints.

Answer:

I am going to do the branch and merge approach that Corbin March suggested the first time so we can learn more about these problem areas and how to identify the missing tests. I think moving forward, we should take the approach that Buhb suggested of identifying the areas that are missing tests and implement those first, then do the refactoring. It will allow us to keep to our normal two week sprint cycle, just like many here have been saying should always be the case for refactoring.

答:
I recommend that when certain tasks will take longer than the 2 week sprint cycle, the task be slated for another time. Your team has identified the need for refactoring and that is important. Sometimes, there is no other option ...and, yes, that does suck.

When the time comes to begin the refactoring, you will simply suspend the normal sprints. You don't have a choice. Use smart version control - branch, refactor, test, merge. There is always a point in time where refactoring some large projects take priority over features. If possible, I would also attempt to separate the concerns for better flexibility.


答:
My suggestion:

Create a branch

Merge daily from trunk to your branch and resolve conflicts.

Work until it's done. Your branch may be outside core development for several sprints.

Merge back to trunk.

There's no getting around the fact that it will probably get ugly. I don't envy you. In my experience, when you drastically change a project, it's easier to merge ongoing development into the new paradigm versus somehow merging the new paradigm into a now-changed trunk after everything is finished. Still, it's going to hurt.

Title: How do I handle refactoring that takes longer than one sprint?

Body:
I work with a code base that is over 500K lines of code. It is in serious need of refactoring. There have been refactoring efforts identified that will take longer than the normal two week sprint. These can't be broken up into smaller tasks as I have seen suggested in other answers on this site. The product needs to work at the end of the iteration, and partial refactoring will leave the system in an unusable state as the dependency between items is horrible. So what would be the best way to approach this hurdle? Again I mention, breaking it down into smaller pieces is is not an option, that has already been done.

Update:
People seem to need an explanation of why this can't be fit into a 2 week sprint. There is more involved in a sprint than just writing code. We have a policy of no code without tests. That policy did not always exist and a large portion of the codebase does not have them. Also some of our integration tests are still manual tests. The issue is not that the refactoring itself is so large. It is with the fact that small changes have an effect on many parts of the system, and we need to ensure that those parts still operate correctly.

We can't put off or extend a sprint because we have monthly hotfixes. So this change extending past a sprint cannot stop the other work being added to the hotfix.

Refactoring vs Redesign:
Just because our development process is not efficent enough to handle this refactoring in a two week cycle does not warrant renaming it to a redesign. I would like to believe that in the future we could accomplish the exact same task within a two week cycle as our process improves. The code in question here has not had to change in a very long time, and is quite stable. Now, as the direction of the company is becoming more adaptable to change, we want this portion of the code base to be as adaptable as the rest. Which requires refactoring it. Based on the answers here, it is becoming apparent that there is missing scaffolding necessary to make this refactoring work in the time frame of normal sprints.

Answer:

I am going to do the branch and merge approach that Corbin March suggested the first time so we can learn more about these problem areas and how to identify the missing tests. I think moving forward, we should take the approach that Buhb suggested of identifying the areas that are missing tests and implement those first, then do the refactoring. It will allow us to keep to our normal two week sprint cycle, just like many here have been saying should always be the case for refactoring.


答: If the guy is the lead developer, why not make him a partner?  I mean he is doing most of the work.  Failing that offer incentives to keep the guy there rather than make him think he's wasting his time/talent when he could "beat you at your own game" instead.  If you offer him tangible benefits he won't think that.