问:
Purpose oriented user accounts on a single desktop?

Starting point:

I currently do development for Dynamics Ax, Android and an occasional dabble with Wordpress and Python.

Soon, I'll start a project involving setting up WP on Google Apps Engine.

Everything is, and should continue to, run from the same PC (running Linux Mint).

Issue:

I'm afraid of botching/bogging down my setup due to tinkering/installing multiple runtimes/IDE's/SDK's/Services, so I was thinking of using multiple users, each purposed to handle the task at hand (web, Android etc) and making each user as inert as possible to one another.

What I need to know is the following:

Is this a good/feasible practice? The second closest thing to this using remote desktops connections, either to computers or to VM's, which I'd rather avoid.

What about switching users? Can it be made seamless?

Anything else I should know?

Update and clarification regarding VM's and whatnot:

The reason I wish to avoid resorting to VM's is that I dislike the performance impact and sluggishness associated with it.

I also suspect it might add a layer of complexity I wish to avoid.

This answer by Wyatt is interesting but I think it's only partly suited for requirements (web development for example).
Also, in reference to the point made about system wide installs, there is a level compromise I should accept as experessed by this for example.

This option suggested by 9000 is also enticing (more than VM's actually) and by no means do I intend to "Juggle" JVMs and whatnot, partly due to the reason mentioned before.

Regarding complexity, I agree and would consider what was said, only from my experience I tend to pollute my work environment with SDKs and runtimes I tried and discarded, which would occasionally leave leftovers which cause issues throught the session.

What I really want is a set of well defined, non virtualized sessions from which I can choose at my leisure and be mostly (to a reasonable extent) safe from affecting each session from the other. And what I'm really asking is if and how can this be done using user accounts.

答:
The challenge is many of these things are more machine-level installs rather than user level installs. Except for stuff that already has some sort of virtual environment ability such as python which eliminates the needs for another account entirely.

What you might want to look into is Vagrant, a tool for easily spinning up and managing virtual machines. That will let you handle complex scenarios without risky software installs. Yes it does install VMs but it avoids most of the downsides, such as the "magic vm" trap many folks run into as it forces you to that the configuration as code.


问:
What would be the best approach to make revisions of user content?
I have searched and could not find any information about it. What is the best approach to storing revisions?

I have a website where the user can write a document which can be fairly long (200-300 lines). How do you determine when to make a revision?

Is it not a scalable solution to make a new one whenever the save, because that would be useless to the user when the want to look back, and it would require quite a lot of space.

You could use time and say for every 15 minute they are working on it there would be a revision, but that would sometimes be nothing or the whole document have completely changed.

I could make a diff from the previous revision, and compare by line and look at how many percent of the lines have been changed.

What are other doing revisions?

答:
When the user saves check if he or she actually changed something before storing a revision.

Additionally you could possibly merge saves that are really close together, depending on your datamodel. Any saves that are more then for instance 10 minutes apart would get a revision, anything smaller would get merged with the previous revision.

Sometimes you see users getting an option to indicate if a save is major or minor. You could use this as input for revising also.

ContentLicense: CC BY-SA 3.0


问:
How do you get users to rank their software enhancement needs?
I've inherited a legacy software system, and have been tasked with performing usability and system upgrades. While there's nothing bad with the system, from discussions with the users, there are "small" usabilty issues that need to be addressed.

At this stage I'm the lone developer on this system, and apart from testing I don't use the system at all, so its difficult for me to know what issues may exist or are percieved to exist. I'm going to have some time to speak with them all and discuss what they percieve to be good/bad or indifferent about the system.

Since its essentially just me for the time being my time is limit. So I was considering asking them to imagine that I'd only be able to do one change, have them all write privately what they'd want that one change to be, and then helping them rank those, but I'm hoping for other tips as well.

What techniques exist for getting users to explain their wants, needs, and requirements, while also having them rank them by importance or desirability?

答:
The programmer imagines the users taking the approach that: There is a long list of features that I want and our lone programmer has a finite amount of time, so I need to make sure I maximize the development time by pain-stakingly order my requirements to make sure the most important are completed first.

If this is the case, they'll come out and tell you. You are concerned that you'll randomly choose one feature over another and someone will come back and complain about it. It could happen, so what. Just be open about taking their input and prioritizing things as they see fit. They just need to let you know.

More than likely, they'll put things in groups: high, medium and low/no priority. Give everyone a list of requirements before the meeting and see if you can get them to indicate what is important INDIVIDUALY! You can aggregate the results and share with them at the meeting. Dont let the meeting turn into a G8 summit. Someone will keep going on and on about a text box label.

Remember, the priority may change, so don't spend too much time on it in a meeting. And since you're not a typical user of the app, get someone to use it as early as possible and observe.


问:
Naming: objectAction or actionObject?
The question, Stored procedure Naming conventions?, and Joel's excellent Making Wrong Code Look Wrong article come closest to addressing my question, but I'm looking for a more general set of criteria to use in deciding how to name modules containing code (classes, objects, methods, functions, widgets, or whatever).

English (my only human language) is structured as action-object (i.e closeFile, openFile, saveFile) and since almost all computer languages are based on English, this is the most common convention.

However, in trying to keep related code close together and still be able to find things, I've found object-action (i.e. fileClose, fileOpen, fileSave) to be very attractive. Quite a number of non-English human languages follow this structure as well.

I doubt that one form is universally superior, but when should each be used in the pursuit of helping to make sure bad code looks bad?

答:
You should consider the importance of the entities involved in the function you're describing, and apply a naming convention based on that - probably by naming the most-important-first. I'll try to clarify with some examples.

The object-oriented paradigm considers "objects" to be the most important entities you work with, and you'll find that objects just about always come first when defining behaviors. If you are calling an instance method of an object, then the instance is named before the method is named (File f; ... f.close(); - f precedes close();). If you are calling a class method, then the class is named before the method (File::open(fileName) - File precedes open(fileName)).

On the other hand, in a more algebraic paradigm, you might consider operations to be more important than the objects against which they operate. If I want to add two integers (ignoring the possible existance of a + operator), I'd prefer to name the operation addIntegers, rather than integersAdd(), because it's more important to me that I'm performing an addition than that the numbers involved happen to be integers.

To get back to your example - which part of openFile would you consider more important? The open, describing the operation, or the File, defining the domain in which the operation applies? (bearing in mind NimChimpsky's point that packages already solve the issue of grouping related code together) I'd think that open is more conceptually important than that you're dealing with files (for example, the calling code might decide to open a socket instead of a file, which may have no noticeable effect on the rest of the calling code), so it should probably come first in the function name.

Title: Naming: objectAction or actionObject?


问:
Would learning any natural language in particular further your programming career?
It seems apparent that English is the dominant international language for programming based on previous P.SE questions (though a highly upvoted comment correctly points out that asking a question like that on a predominantly English site will skew the results).

However, is there benefit in learning a foreign language for software development? For example, do the Chinese have completely different software tools, languages, technologies, etc? How about Japanese, Russian, and other non-latin based languages? Is there an entire world of software development languages, tools and so on that only exist in these other languages?

Or do people that know these languages use the tools and languages we know and love?

答:
English is the language of problem solving.

Watch this short video.

"Your native language is your life, but with english you become part
  of a wider conversation, a global conversation about global problems,
  like climate change or poverty... mathematics is the
  language of science, music is the language of emotions and now english
  is becoming the language of problem solving."

```<code>-- Jay Walker, american inventor and entrepreneur
</code>```

I guess if the Roman Empire had not collapsed, we would be writing in latin right now.

Definitively english is the language to go. My native tongue is spanish and though spanish is one of the most widely spoken languages, the amount of technical material, documentation, tutorials, blogs, Q&A sites, etc. in spanish doesn't even come near the vast a amount of resources in english.

Also english has a concise quality to it that makes it unambiguous in many contexts.

Other reason: iTunes U.

Body:
English is the language of problem solving.

Watch this short video.

"Your native language is your life, but with english you become part
  of a wider conversation, a global conversation about global problems,
  like climate change or poverty... mathematics is the
  language of science, music is the language of emotions and now english
  is becoming the language of problem solving."

-- Jay Walker, american inventor and entrepreneur

I guess if the Roman Empire had not collapsed, we would be writing in latin right now.

Definitively english is the language to go. My native tongue is spanish and though spanish is one of the most widely spoken languages, the amount of technical material, documentation, tutorials, blogs, Q&A sites, etc. in spanish doesn't even come near the vast a amount of resources in english.

Also english has a concise quality to it that makes it unambiguous in many contexts.

Other reason: iTunes U.


问:
Using Sql Server Change Data Capture with a frequently changing schema
We are looking into enabling Sql Server Change Data Capture for a new subsystem we are building.

It's not really because we need it, but we are being pushed for having a complete history traceability, and CDC would nicely solve this requirement with minimum effort on our parts.

We are following an agile development process, which in this case means that we frequently make changes to the database schema, e.g. adding new columns, moving data to other columns, etc.

We did a small test where we created a table, enabled CDC for that table, and then added a new column to the table. Changes to the new column is not registered in the CDC table.

Is there a mechanism to update the CDC table to the new schema, and are there any best practices to how you deal with captured data when migrating the database schema?

答:
You are able to track addition of columns with DDL triggers.

```<code>CREATE TRIGGER trigger_name
ON { ALL SERVER | DATABASE }
[ WITH <ddl_trigger_option> [ ,...n ] ]
{ FOR | AFTER } { event_type | event_group } [ ,...n ]
AS { sql_statement [ ; ] [ ,...n ] |
EXTERNAL NAME < method specifier > [ ; ] }
</code>```

You can use the event group DDL_TABLE_EVENTS to fire for the CREATE, DROP, or ALTER of a table.

However, you might want to take a look at SQL Server Audit, if you are using enterprise >2008, as it can "combines all the auditing capabilities into an audit specification". This msdn link has a detailed article about it: http://msdn.microsoft.com/en-us/library/dd392015(v=sql.100).aspx.

```<code>CREATE SERVER AUDIT audit_name
TO { [ FILE (<file_options> [, ...n]) ] |
APPLICATION_LOG | SECURITY_LOG }
[ WITH ( <audit_options> [, ...n] ) ] }[ ; ]

<file_options>::=
{FILEPATH = 'os_file_path'
[, MAXSIZE = { max_size { MB | GB | TB } | UNLIMITED } ]
[, MAX_ROLLOVER_FILES = integer ]
[, RESERVE_DISK_SPACE = { ON | OFF } ] }

<audit_options>::=
{ [ QUEUE_DELAY = integer ]
[, ON_FAILURE = { CONTINUE | SHUTDOWN } ]
[, AUDIT_GUID = uniqueidentifier ]}
</code>```

Then you create Server or Database Specifications.

Body:
You are able to track addition of columns with DDL triggers.

CREATE TRIGGER trigger_name
ON { ALL SERVER | DATABASE }
[ WITH <ddl_trigger_option> [ ,...n ] ]
{ FOR | AFTER } { event_type | event_group } [ ,...n ]
AS { sql_statement [ ; ] [ ,...n ] |
EXTERNAL NAME < method specifier > [ ; ] }

You can use the event group DDL_TABLE_EVENTS to fire for the CREATE, DROP, or ALTER of a table.

However, you might want to take a look at SQL Server Audit, if you are using enterprise >2008, as it can "combines all the auditing capabilities into an audit specification". This msdn link has a detailed article about it: http://msdn.microsoft.com/en-us/library/dd392015(v=sql.100).aspx.

CREATE SERVER AUDIT audit_name
TO { [ FILE (<file_options> [, ...n]) ] |
APPLICATION_LOG | SECURITY_LOG }
[ WITH ( <audit_options> [, ...n] ) ] }[ ; ]

<file_options>::=
{FILEPATH = 'os_file_path'
[, MAXSIZE = { max_size { MB | GB | TB } | UNLIMITED } ]
[, MAX_ROLLOVER_FILES = integer ]
[, RESERVE_DISK_SPACE = { ON | OFF } ] }

<audit_options>::=
{ [ QUEUE_DELAY = integer ]
[, ON_FAILURE = { CONTINUE | SHUTDOWN } ]
[, AUDIT_GUID = uniqueidentifier ]}

Then you create Server or Database Specifications.


问:
Mono is frequently used to say "Yes, .NET is cross-platform". How valid is that claim?
In What would you choose for your project between .NET and Java at this point in time? I say that I would consider the "Will you always deploy to Windows?" the single most important technical decision to make up front in a new web project, and if the answer is "no", I would recommend Java instead of .NET.

A very common counter-argument is that "If we ever want to run on Linux/OS X/Whatever, we'll just run Mono"1, which is a very compelling argument on the surface, but I don't agree for several reasons.

OpenJDK and all the vendor supplied JVM's have passed the official Sun TCK ensuring things work correctly.  I am not aware of Mono passing a Microsoft TCK.

Mono trails the .NET releases.  What .NET-level is currently fully supported?

Does all GUI elements (WinForms?) work correctly in Mono?

Businesses may not want to depend on Open Source frameworks as the official plan B.

I am aware that with the new governance of Java by Oracle, the future is unsafe, but e.g. IBM provides JDK's for many platforms, including Linux.  They are just not open sourced.

So, under which circumstances is Mono a valid business strategy for .NET-applications?

1Mark H summarized it as: "If the claim is that "I have a windows application written in .NET, it should run on mono", then not, it's not a valid claim - but Mono has made efforts to make porting such applications simpler."

答:
It varies is the honest answer.  I have seen small web server stuff moved from IIS to Apache, running under mono with almost no difficulty.  I have run unchanged Windows .Net applications using Win Forms on Linux successfully.

However, whilst it can work, if you are using an API call that's not implemented on mono then it won't work, and the only solutions are to either rewrite your application, stick with windows or write the extra stuff in mono.

ContentLicense: CC BY-SA 2.5


问:
Avoiding the Anaemic Domain - How to decide what single responsibility a class has
Even after reading a bunch I'm still falling into the same trap. I have a class, usually an enity. I need to implement more than one, similar operations on this type. It feels wrong to (seemingly arbitrarily) choose one of these operations to belong inside the entity and push the others out to a separate class; I end up pushing all operations to service classes and am left with an anaemic domain.

As a crude example, imagine the typical Employee class with numeric properties to hold how many paid days the employee is entitled to for both sickness and holiday and a collection of days taken for each.

```<code>public class Employee
{
    public int PaidHolidayAllowance { get; set; }

    public int PaidSicknessAllowance { get; set; }

    public IEnumerable<Holiday> Holidays { get; set; }

    public IEnumerable<SickDays> SickDays { get; set; }
}
</code>```

I want two operations, one to calculate remaining holiday, another for remaining paid sick days. It seems strange to include say, CalculateRemaingHoliday() in the Employee class and bump CalculateRemainingPaidSick() to some PaidSicknessCalculator class. I would end up with a PaidSicknessCalculator and a RemainingHolidayCalculator and the anaemic Employee entity as seen above. The other alternative would be to put both operations in the Employee class and kick Single Responsibility to the curb. That doesn't make for particularly maintainable code.

I suppose the Employee class should have some initialisation/validation logic (not accepting negative alowances etc.) So maybe I just stick to basic initialisation and validation in the entities themselves and be happy with my separate calculator classes. Or maybe I should be asking myself if Anaemic Domain is actually causing me some tangible problems with my code.

答:
Since we're talking about SRP, I think it's a good idea to dissect exactly what a responsibility can mean in the context of an entity. To me their responsibilities come in 2 kinds :

Primary responsibilities of an Entity

Identifying itself

Composing itself with objects given to it (adding sub-entities/value objects etc.)

If you're into DDD : for an Aggregate Root, enforcing aggregate invariants

Secondary responsibilities of an Entity

Any other behavior defined in the domain language that naturally seems to belong in the entity

In your example, CalculateRemainingHoliday() and CalculateRemainingPaidSick() clearly fall in the second category.

Even if primary responsibilities taken together can be considered as one responsibility (that of "being an Entity"), I think we can all agree that most rich domain entities still tend to not adhere to SRP strictly speaking, because of secondary responsibilities - these are a growing crowd by nature, and each time you add or remove one of them, the entity effectively changes for a different reason. However, you can design your entities so that they comply with a lesser kind of SRP : changing something inside one secondary responsibility shouldn't change the entity class itself.

In other words, you should design your entities so that secondary responsibilities are delegated to other objects. These can be sub-entities, value objects, or objects that were injected into the entity. For instance, Employee could have a HolidayCalculationStrategy and a SickDaysCalculationStrategy that take care of these concerns. Although they are closely related to an Employee and in fact manipulate Employee data, these objects will be the only ones modified when said strategies need to change, the entity itself remaining untouched.

In summary, rich domain entities can't respect SRP to the letter, but it's necessary evil to ensure cohesion and avoid anemicness. They can still be SRP-ish enough that you can tweak non-quintessential domain behaviors exposed by an entity without touching the code of the entity itself.

Interesting links about SRP vs Rich Domain Model :

https://stackoverflow.com/questions/10454593/can-a-rich-domain-model-violate-the-single-responsibility-principle

http://blog.pluralsight.com/2012/03/02/whats-the-single-responsibility-of-an-entity-in-domain-driven-design/


答:
Think about containers: lxc, docker.io. These look like VMs but are lighter weight than VMs, and provide enough isolation.

With Python, you have virtualenv and friends. I only use these, one (or more) per project, and never install development stuff into my system Python.

With some sleight of hand, you can install multiple Java runtimes / JDKs, but this is usually not really necessary. It is highly improbable that an Android IDE would conflict with any other locally installed (as opposed to system-installed) Java software, since they all carry their jars with them.

WRT having multiple users: I'd avoid that. You'll have to duplicate much of the setup for each user (in which .bashrc have you made that convenient change?). OTOH you can try and see; just take two toy projects, like editing two separate text files, one per user. Work for a hour on one, then switch to another.

I usually didn't have problems working with a wild mix of projects you describe, even without containers or VMs. Do not complicate things unless you see that conflicts really crop up: usually they don't.

Title: Purpose oriented user accounts on a single desktop?

Body:
Starting point:

I currently do development for Dynamics Ax, Android and an occasional dabble with Wordpress and Python.

Soon, I'll start a project involving setting up WP on Google Apps Engine.

Everything is, and should continue to, run from the same PC (running Linux Mint).

Issue:

I'm afraid of botching/bogging down my setup due to tinkering/installing multiple runtimes/IDE's/SDK's/Services, so I was thinking of using multiple users, each purposed to handle the task at hand (web, Android etc) and making each user as inert as possible to one another.

What I need to know is the following:

Is this a good/feasible practice? The second closest thing to this using remote desktops connections, either to computers or to VM's, which I'd rather avoid.

What about switching users? Can it be made seamless?

Anything else I should know?

Update and clarification regarding VM's and whatnot:

The reason I wish to avoid resorting to VM's is that I dislike the performance impact and sluggishness associated with it.

I also suspect it might add a layer of complexity I wish to avoid.

This answer by Wyatt is interesting but I think it's only partly suited for requirements (web development for example).
Also, in reference to the point made about system wide installs, there is a level compromise I should accept as experessed by this for example.

This option suggested by 9000 is also enticing (more than VM's actually) and by no means do I intend to "Juggle" JVMs and whatnot, partly due to the reason mentioned before.

Regarding complexity, I agree and would consider what was said, only from my experience I tend to pollute my work environment with SDKs and runtimes I tried and discarded, which would occasionally leave leftovers which cause issues throught the session.

What I really want is a set of well defined, non virtualized sessions from which I can choose at my leisure and be mostly (to a reasonable extent) safe from affecting each session from the other. And what I'm really asking is if and how can this be done using user accounts.


问:
How to organise OO code
If you have a method that doesn't need access to any non public fields, properties or methods where should you put the method ?

should it just be a normal method in the class, a static method that takes an instance as a parameter, an extension method or something else ?

答:
If it uses private fields, properties or methods just keep it non static. Passing in an instance variable just adds noise.

I do tend to make methods static if I can (without passing instances in), it signals opportunity to cheaply move the method elsewhere if needed.

When in doubt leave the static out.

Title: How to organise OO code


问:
A better approach to refactor code when doing A/B Testing
I'm asked to refactor my component code to support A/B Testing.

What is the better approach:

1) Pass a boolean value to the methods and check for that flag inside the method body?

```<code>method(flag abTest):
    if A_VERSION_ENABLED:
       // Do 'A' logic
    else
       // Do 'B' logic
</code>```

2) Create dedicated methods for each version?

```<code>codeForATest()
codeForBTest()
</code>```

答: You should look into the Strategy Pattern. It allows you to swap out the behavior of a function or object on the fly by using interfaces. You specify how a method will be called, then have two or more versions that implement that interface. Then, you don't care about which one you're using in the code except upon initialization.</p>


答:
Is this method still logically part of the class interface? If so, you'll want to put it in proximity to the class itself somehow. That could be as a member, as a static method of a related utility class (including extension methods if your language has such a thing, e.g. C#), or a free function in the same package/namespace as the class, if your language supports that (e.g. C++).

But if it isn't really that inherently bound to the class, maybe somewhere else is a better place.

In general, I wouldn't give a class a static method that takes a single instance parameter. In most languages, that method isn't any more restricted in what it can access (usually can access private members), so it's just a syntactic burden on the caller.

Title: How to organise OO code

Body:
If you have a method that doesn't need access to any non public fields, properties or methods where should you put the method ?

should it just be a normal method in the class, a static method that takes an instance as a parameter, an extension method or something else ?


问:
How to save during real-time collaboration
I want multiple users to edit same document. Problem I'm facing is when a new user joins, he might see an outdated document. How do I make sure that new users get most recent changes?

Some solutions I thought of:

Save on every change. I don't like this solution because it will slow things down on UI and put load on db.

When new user joins, trigger save on all other clients. After other clients saved, load document.   With this there can be inconsistency still.

Any other suggestions would be helpful.

UPDATE: After looking into suggested solution, Google Realtime API, I found out that:

Users of your app must have Google Drive and give you access to their drive. This could at best present awkward UI flow or prevent users who don't have Google Drive from using realtime feature.

All the sharing settings that are done on your side, have to be replicated for Google document.

UPDATE 2: To acoomplish the goal, I went with Google's Firebase

答:
Google Drive

If you're trying to make your own version of google docs, I suggest you take a look at the Google Realtime API. Google recently released this with the intent of allowing other developers to use the same tools they did to allow for realtime collaboration. This would allow you to save time on your development and get a working product sooner.

You could easily take the data that is in the document and push it into your database at regular intervals, or have the database itself be a 'participant' of the exchange, simply listening to and logging all the changes. It also allows for a user to define their own data structures which are then usable in the realtime API, so you are free to extend it as you see fit.

Non-Google Drive

So according to your research, Google Drive isn't an option. That's fine, but it's going to be tougher and possibly not work as well, depending on how much you put into it.

Here's a general strategy I would use to accomplish this problem:

Have the server be the communication multiplexer. Each person talks to the server, and the server sends out that information to everyone else. This way the server always has the most up to date view of the document.

Find a third party algorithm/module for conflict resolution. Conflict resolution is tough, and is something that still isn't perfect. Doing this alone could easily increase the scope of the project to be far too large. If you can't use a third party algorithm, I would suggest that you only allow one user to edit an area of a time, so that the user must obtain a lock before editing an area, or you risk destroying another users work, which will get very old, very fast.

When a new user joins, give them the most recent document and automatically start streaming the commands to them. The server has the most recent view and thus can dish it out automatically.

Backup to the database at certain intervals. Decide how often you want to back up (every 5 minutes or maybe every 50 changes.) This allows you to maintain the backup you desire.

Problems: This isn't a perfect solution, so here are some issues you might face.

Throughput of the server could bottleneck performance

Too many people reading/writing could overload the server

People may become out of sync if a message is lost, so you may want to make sure you synchronize at regular points. This means sending out the whole message again, which can be costly, but otherwise people might not have the same document and not know it.


问:
Should we persist with an employee still writing bad code after many years?
I am putting this question to C++ programmers because:
a) Only a C++ programmer can judge the technical merits of the examples;
b) Only a programmer will have a feel for the temperament of another programmer who writes code like this.

HR and the directors are aware there is a problem simply because they see evidence in the field. It's my call whether we give the programmer in question more time. Many of the errors are at a very basic level - my question (to programmers) is whether someone who professes to be a senior C++ developer should be given a benefit of a doubt based on samples of their current code. Non-programmers - even people outside C++ programming - can't make any judgement on this.

For background, I've been assigned the task of managing developers for a well-established company. They have a single developer who specialises in all their C++ coding (since forever), but the quality of the work is abysmal. Code reviews and testing have revealed many problems, one of the worst being memory leaks. The developer has never tested his code for leaks, and I discovered that the applications could leak many MBs with only a minute of use. User's were reporting huge slowdowns, and his take was, "it's nothing to do with me - if they quit and restart, it's all good again."

I've given him tools to detect and trace the leaks, and sat down with him for many hours to demonstrate how the tools are used, where the problems occur, and what to do to fix them. We're 6 months down the track, and I assigned him to write a new module. I reviewed it before it was integrated into our larger code base, and was dismayed to discover the same bad coding as before. The part that I find incomprehensible is that some of the coding is worse than amateurish. For example, he wanted a class (Foo) that could populate an object of another class (Bar). He decided that Foo would hold a reference to Bar, e.g.:

```<code>class Foo {
public:
    Foo(Bar& bar) : m_bar(bar) {}
private:
    Bar& m_bar;
};
</code>```

But (for other reasons) he also needed a default constructor for Foo and, rather than question his initial design, he wrote this gem:

```<code>Foo::Foo() : m_bar(*(new Bar)) {}
</code>```

So every time the default constructor is called, a Bar is leaked. To make matters worse, Foo allocates memory from the heap for 2 other objects, but he didn't write a destructor or copy constructor. So every allocation of Foo actually leaks 3 different objects, and you can imagine what happened when a Foo was copied. And - it only gets better - he repeated the same pattern on three other classes, so it isn't a one-off slip. The whole concept is wrong on so many levels.

I would feel more understanding if this came from a total novice. But this guy has been doing this for many years and has had very focussed training and advice over the past few months. I realise he has been working without mentoring or peer reviews most of that time, but I'm beginning to feel he can't change. So my question is, would you persist with someone who is writing such obviously bad code?

答:
My advice would be to confront him about this particular example and see what he says.  If he denies there being anything bad with the code, then I'm afraid there is little you can do.  If he accepts that he made a mistake (even if he's defensive about it), then at least there is room for improvement.  If you accept the time and effort on improving him, then you or a senior programmer will need to sit him down and code together until all these tendencies are flattened out (be prepared to dedicate this person for at least 1 months time).

A bad programmer, I can usually work with, but a programmer who can't improve, I cannot.


问:
Working for free?
I came across this article Work for Free that got me thinking.

The goal of every employer is to gain
  more value from workers than the firm
  pays out in wages; otherwise, there is
  no growth, no advance, and no
  advantage for the employer.
  Conversely, the goal of every employee
  should be to contribute more to the
  firm than he or she receives in wages,
  and thereby provide a solid rationale
  for receiving raises and advancement
  in the firm.

I don't need to tell you that the
  refusenik didn't last long in this
  job.

In contrast, here is a story from last
  week. My phone rang. It was the
  employment division of a major
  university. The man on the phone was
  inquiring about the performance of a
  person who did some site work on
  Mises.org last year. I was able to
  tell him about a remarkable young man
  who swung into action during a crisis,
  and how he worked three 19-hour days,
  three days in a row, how he learned
  new software with diligence, how he
  kept his cool, how he navigated his
  way with grace and expertise amidst
  some 80 different third-party plug-ins
  and databases, how he saw his way
  around the inevitable problems, how he
  assumed responsibility for the
  results, and much more.

What I didn't tell the interviewer was
  that this person did all this without
  asking for any payment. Did that fact
  influence my report on his
  performance? I'm not entirely sure,
  but the interviewer probably sensed in
  my voice my sense of awe toward what
  this person had done for the Mises
  Institute. The interviewer told me
  that he had written down 15 different
  questions to ask me but that I had
  answered them all already in the
  course of my monologue, and that he
  was thrilled to hear all these
  specifics.

The person was offered the job. He had
  done a very wise thing; he had earned
  a devotee for life.

The harder the economic times, the
  more employers need to know what they
  are getting when they hire someone.
  The job applications pour in by the
  buckets, all padded with degrees and
  made to look as impressive as
  possible. It's all just paper. What
  matters today is what a person can do
  for a firm. The resume becomes pro
  forma but not decisive under these
  conditions. But for a former boss or
  manager to rave about you to a
  potential employer? That's worth
  everything.

What do you think? Has anyone here worked for free? If so, has it benefited you in any way? Why should(nt) you work for free (presuming you have the money from other means to keep you going)? Can you share your experience?

Me, I am taking a year out of college and haven't gotten a degree yet so that's probably why most of my job applications are getting ignored. So im thinking about working for free for the experience?

答:
Sort of.

I'm finishing a government contract that a friend botched even though there is no budget left - and I'm doing it for free. There was money in it earlier, and I made some money from the project, but for the past year I've been doing it part-time for free to get the damned thing finished.

A friend I have known for 6 years was over his head with this project, and since it had some interesting things that I thought would help my current job, I helped him on the side. Helping him with his projects is something I had also been doing off and on for about 3 years. Sometimes it is interesting, sometimes same old boring stuff. Sometimes there is money, sometimes, all I get is dinner. Shortly after that I got brought on to the job officially. When the folks at the government agency saw that I was getting the work done, while my friend was screwing around and billing 40 hours for no work (and working 2 other jobs remotely and billing each of them 40 hr/week), they fired him and kept me on. The contracting company then got into trouble elsewhere and decided to foist the contract off onto his longtime friend (but only after all the money in the budget was gone). I had this stupid idea that I could somehow redeem my friend's reputation, and when all the money ran out the government agency was making threats to blacklist the new contracting company. This "new" contracting company only does government contracting, and if I walked away, about 40 people would lose their jobs.

This was a simple conversion of a coldfusion site (which can no longer meet government security standards) to a .NET site. Making a website FIPS and PCI-DSS compliant is a skill needed for my main job anyway. It brings in $250,000,000 in tax revenue per year. There is no dev nor QA environment, so all code changes have to go live immediately. The site has been live for several months, so I'm just fixing bugs at this time. When they admit the site is working to spec, I will hand in my laptop and tell them "don't call me ever again."

I had an idea that maybe as some sort of payoff, since the network admins and DBAs will be retiring over the next 2 years, that I could swing some sort of pay-off from getting hired to replace one of them. As a government agency, I've since found out that cannot happen as all permanent hiring has to go through OPM. And with veteran's preferences (of which I am not one), I don't stand a chance of making it through the initial selection process to get to the interviewing stage.

Also, my initial idea that "hey I made $20k already, that's plenty" was also stupidly naive. Basically, I am married to these people at this agency, and it has been hard pushing back on the boundaries so that they don't call and email me at my day-job which could get me fired.

Working for free is a bad idea.

The customer won't recognize that boundaries exist, the value of what time you sacrificed for them and you'll never be finished. If you've been suckered into fixing computers for family and friends, you've come across this mentality. You touched it once, and now you're stuck with it forever. Likewise, if you own a pick up truck, you're everybody's greatest friend when they need to move something.

I leave this as a cautionary tale to others. If I knew then what I know now, I never would have taken this gig. While my friend (who burned through about $110k of the contract) and the first contracting company (who burned through about $60k of the contract) would have been sued into bankruptcy, perhaps they deserved that to happen. My friend got into a lot of financial trouble (mortgage resetting and going up 100%) and he made a lot of bad ethical and moral decisions to try to save his house. He has basically burned his reputation here in Denver and can't get work around here, so he's moved to the Baltimore/DC area where older contractors are common enough for him to fit in.

Title: Working for free?


答:
So my question is, would you persist with someone who is writing such obviously bad code?

No. I would fire any professional C++ developer that lacked the basic understanding of memory management.

If it's someone coming from Java or C# or something I'd give them some lattitude, but this is pure incompetence.

Title: Should we persist with an employee still writing bad code after many years?

Body:
I am putting this question to C++ programmers because:
a) Only a C++ programmer can judge the technical merits of the examples;
b) Only a programmer will have a feel for the temperament of another programmer who writes code like this.

HR and the directors are aware there is a problem simply because they see evidence in the field. It's my call whether we give the programmer in question more time. Many of the errors are at a very basic level - my question (to programmers) is whether someone who professes to be a senior C++ developer should be given a benefit of a doubt based on samples of their current code. Non-programmers - even people outside C++ programming - can't make any judgement on this.

For background, I've been assigned the task of managing developers for a well-established company. They have a single developer who specialises in all their C++ coding (since forever), but the quality of the work is abysmal. Code reviews and testing have revealed many problems, one of the worst being memory leaks. The developer has never tested his code for leaks, and I discovered that the applications could leak many MBs with only a minute of use. User's were reporting huge slowdowns, and his take was, "it's nothing to do with me - if they quit and restart, it's all good again."

I've given him tools to detect and trace the leaks, and sat down with him for many hours to demonstrate how the tools are used, where the problems occur, and what to do to fix them. We're 6 months down the track, and I assigned him to write a new module. I reviewed it before it was integrated into our larger code base, and was dismayed to discover the same bad coding as before. The part that I find incomprehensible is that some of the coding is worse than amateurish. For example, he wanted a class (Foo) that could populate an object of another class (Bar). He decided that Foo would hold a reference to Bar, e.g.:

```<code>class Foo {
public:
    Foo(Bar& bar) : m_bar(bar) {}
private:
    Bar& m_bar;
};
</code>```

But (for other reasons) he also needed a default constructor for Foo and, rather than question his initial design, he wrote this gem:

```<code>Foo::Foo() : m_bar(*(new Bar)) {}
</code>```

So every time the default constructor is called, a Bar is leaked. To make matters worse, Foo allocates memory from the heap for 2 other objects, but he didn't write a destructor or copy constructor. So every allocation of Foo actually leaks 3 different objects, and you can imagine what happened when a Foo was copied. And - it only gets better - he repeated the same pattern on three other classes, so it isn't a one-off slip. The whole concept is wrong on so many levels.

I would feel more understanding if this came from a total novice. But this guy has been doing this for many years and has had very focussed training and advice over the past few months. I realise he has been working without mentoring or peer reviews most of that time, but I'm beginning to feel he can't change. So my question is, would you persist with someone who is writing such obviously bad code?


答: Of course you should not. Remember, this is not a charity, you are exchanging money for work. If he isn't holding up his side of the deal then like any transaction I'd stop paying.</p>


答:
We can't answer the broader part of your question.  Namely, should you retain or fire that employee.  Firing an employee is difficult, but that's a decision outside the purview of a community like this.

You updated your question to restrict answers to C++ programmers.  For my background / qualifications: I cut my teeth in C, and I can code in C++, C#, and Java.  And I like to chase race conditions between threads because I think it's fun.  Yes, I "get" bit twiddling.

Your answer and decision wraps around this:  Whether or not someone can change depends upon the individual and if they want to change.

But let's start with some questions of you:

Have you asked him about the code and the example you mentioned?  What was his impression of the review?

Did you give him specifics during those 6 months about understanding memory manipulation and making sure his code didn't have memory leaks?

Were you providing reasonably frequent feedback during those 6 months to indicate whether he was making progress or not.

Did you explicitly call out that his old way of coding was no longer acceptable in new code?

You need to make sure you can say yes to all of those questions.  If not, there's still a burden of proof upon your part for communicating with him.

His response to your recent review is going to be the most telling part.

If he's been trying, and shows some signs of progress then maybe you need to review your mentoring process.  If anything, maybe you need to consider pairing him with a more experienced programmer so he can get some immediate feedback while he's making design decisions.  I'm not a fan of pair programming, but it can be very useful in a case like this.  Continually sending him off to make more and more revisions to old code isn't always a practical route for learning.

If he hasn't been trying, then you need to understand his motivation better.  Did he not understand that he needs to try harder?  Does he just not care?  Are there other areas on the team where his skills would be a better fit and he's more interested in that? If he didn't care to try, then you need to understand why.

From there, you'll know whether he wants to change and whether he can change.  No desire to change is equivalent to not being able to change.  If there's desire and a degree of progress, then strongly consider changing how you are trying to rehabilitate him.


答:
If splitting off a responsibility seems nonsensical to you, chances are you are already following the SRP fairly well, even if you haven't consciously applied it.

To me, it's very difficult to determine if I'm following the SRP by simply asking what the responsibility is, for the reason you've already discovered:  you can define a responsibility to be either very large or very small, when the ideal is somewhere in between.

The easiest way to spot an SRP violation is by noticing that you are tending to group methods within a class.  Some people even put section comments, like this:

```<code>/******** Time off calculations ********/
</code>```

If you catch yourself doing that, or being tempted to do that, that's a sign you're most likely violating the single responsibility principle.

Title: Avoiding the Anaemic Domain - How to decide what single responsibility a class has

Body:
Even after reading a bunch I'm still falling into the same trap. I have a class, usually an enity. I need to implement more than one, similar operations on this type. It feels wrong to (seemingly arbitrarily) choose one of these operations to belong inside the entity and push the others out to a separate class; I end up pushing all operations to service classes and am left with an anaemic domain.

As a crude example, imagine the typical Employee class with numeric properties to hold how many paid days the employee is entitled to for both sickness and holiday and a collection of days taken for each.

```<code>public class Employee
{
    public int PaidHolidayAllowance { get; set; }

    public int PaidSicknessAllowance { get; set; }

    public IEnumerable<Holiday> Holidays { get; set; }

    public IEnumerable<SickDays> SickDays { get; set; }
}
</code>```

I want two operations, one to calculate remaining holiday, another for remaining paid sick days. It seems strange to include say, CalculateRemaingHoliday() in the Employee class and bump CalculateRemainingPaidSick() to some PaidSicknessCalculator class. I would end up with a PaidSicknessCalculator and a RemainingHolidayCalculator and the anaemic Employee entity as seen above. The other alternative would be to put both operations in the Employee class and kick Single Responsibility to the curb. That doesn't make for particularly maintainable code.

I suppose the Employee class should have some initialisation/validation logic (not accepting negative alowances etc.) So maybe I just stick to basic initialisation and validation in the entities themselves and be happy with my separate calculator classes. Or maybe I should be asking myself if Anaemic Domain is actually causing me some tangible problems with my code.

Body:
If splitting off a responsibility seems nonsensical to you, chances are you are already following the SRP fairly well, even if you haven't consciously applied it.

To me, it's very difficult to determine if I'm following the SRP by simply asking what the responsibility is, for the reason you've already discovered:  you can define a responsibility to be either very large or very small, when the ideal is somewhere in between.

The easiest way to spot an SRP violation is by noticing that you are tending to group methods within a class.  Some people even put section comments, like this:

/******** Time off calculations ********/

If you catch yourself doing that, or being tempted to do that, that's a sign you're most likely violating the single responsibility principle.


答: I am fluent in Chinese, and on occasion have peeked into the world of Chinese programmers.  Most of their learning material is translated English stuff, so you are not missing anything on that front.  However, It is interesting to see cultural differences in programming technology choices.  For example, Go seems to be more popular in China than in any other country.  You can check doing a google trends search for 'golang': http://www.google.com/trends/explore?q=golang#q=golang&cmpt=q</p>

Title: Would learning any natural language in particular further your programming career?

Body:
It seems apparent that English is the dominant international language for programming based on previous P.SE questions (though a highly upvoted comment correctly points out that asking a question like that on a predominantly English site will skew the results).

However, is there benefit in learning a foreign language for software development? For example, do the Chinese have completely different software tools, languages, technologies, etc? How about Japanese, Russian, and other non-latin based languages? Is there an entire world of software development languages, tools and so on that only exist in these other languages?

Or do people that know these languages use the tools and languages we know and love?


问:
What did network programs use to communicate before sockets was invented (around 1983?)
Sockets were invented in Berkeley around 1983, but how did networked computer programs work before this? These days, pretty much everything uses sockets, so it's hard for me to imagine how else programs could communicate and Google turned up nothing.</p>

答:
Berkeley socket was just an API that was invented then. The technology that sockets abstracts away was there before; ARPANET and TCP/IP stack was invented in the 70's and there were computer networks even before that.

Technically you can connect two computers with a serial cable an make them communicate over it.


答:
I'm afraid his bad code is not the only problem in your team.

Who reviews his code? Why did he slip away without a warning for accepting code with memory leak vulnerability?

Why didn't stress tests find this problem? Do you use them? If yes, then why aren't they working?

He was left unattended for a long period of time. Why?

He's not using the tools you gave him. How did you motivate him to start using proper tools?

You say he's been in the company for the extended period of time. Firing such a person is rarely a good idea (unless he's a Wally-type of employee). Their knowledge of client needs, products you own, etc. is often much more valuable than the code they write.

Solutions:

move him to QA to let him learn what to avoid

pair programming with someone who can point out his errors

extended QA effort on his code

make him write stress tests, if he sees his dev machine crashed after creating and destroying 10k of objects maybe he'll learn

a few/all of them above :)


答:
It might make sense when you want to specialize in a specific technology which was developed in a non-english country.

SAP, for example, is a German company. SAP ERP, the behemoth of a software usually referred to as "SAP", has most of its user software modules written in SAPs own programming language ABAP. As a developer you can (and often have to) look at the ABAP code.

A decade ago most of the ABAP development happened in Germany and there was no policy that comments and identifiers need to be in English, so you find a lot of German in legacy ABAP code.

As an ABAP developer I frequently need to debug legacy code written by SAP. I am a native German speaker so it's just a mild annoyance for me to mentally switch between German and English all the time, but I really pity everyone who doesn't speak German and suddenly finds himself in sourcecode commented in German.

You also find some German in older APIs. For example, the current time is found in the global variable SY-UZEIT. "Uzeit" is short for "Uhrzeit", which is German for "Time of the day".  A customerID is a KUNNR ("Kundennummer"), an amount of money in house currency is a BETRH ("Betrag - Hauswährung") etc.

I've heard anecdotes of poor non-German ABAP programmers who have a German dictionary right next to their ABAP reference book.


问:
How can I quickly weed out "copy & paste" coders?
I need a way to filter out resumes of folks who just copy-and-paste code then hope it works, and check it in if it does.  All this happens without having an understanding (or care) to understand the rest of the code in the system.

Sure I know that copying and pasting code is part of learning a new object, control, etc... but how can one tell if that accounts for 70% (or more) of their development career?

I've come across some senior level guys perhaps whose skills are so outdated or irrelevant for the project, that all they do is google, copy-then-paste some code without thinking about the solution as a whole.  As a result we have a mismash of JSON, AJAX, callbacks, ASMX, WCF and postbacks in the same project.  It is clear there is no consistency or logic behind where each technology is being used.

In the worst case, this type of developer creates security issues and vectors for attack.

Question

How would you recommend I filter out people who have a poor programming background?  Can I do it at the resume level?  If not, how do I do this during the interview.

答:
I have spent the last few years interviewing people and finding that 90% of candidates simply cannot program.  My interview technique for determining programming is to give the candidate an overly simple brief and let the candidate solve it using a marker and a whiteboard.

Failure modes include:

coming up with a design and then implementing something different. These candidates are rejected because they are dangerous on a team. not follow specs, write bugs etc...

Not being able to invent a design. A surprising number of "experienced" candidates need a spec to include implementation design.

not knowing the programming language, despite CV claiming experience.

Not asking additional questions to extract fuller specifications.

Not being able to explain design decisions.  This one is major.  If someone cannot explain why, then each time they will do it differently, and consistency is lost.

The end result was I spent a lot of time interviewing, and not recruiting very often. however, the development team was very good, and had the complete respect of the entire company and it delivered!


答:
English is the dominating language in the field, not only in EU/US.

As a native speaker of Chinese, I know people there are using the same set of OSs, programming languages and tools. Some of them are translated into Chinese, the rest are not as difficult as English novels. There are a few "Chinese programming languages" that has Chinese keywords, they are not widely used or even considered serious stuff.

Currently I am living in Japan and I see similar things here. So at least I don't think knowing Chinese or Japanese or other mysterious natural language can grant access to irreplaceable resources.

On the other way, I did benefit from (non language-specified) theory of semantics. In both natural language and programming language, it helped me to distinguish and refine expressions in a way similar to code review.


答:
While English is the de facto software developers' language, a few times I've been able to find hints & solutions on community sites in other languages. Automated translation makes mush out of such pages, so it's nice to be able to read it as is.

Of course, if you're working with people who are more proficient with another language it can be very good, in both a professional and a personal sense, to be able to communicate in their native tongue. Depending on their level and yours, it may be easier to learn a couple technical words in their language and have them express themselves in the most comfortable way than to shoe-horn their understanding into a language where they are more likely to make semantic mistakes.


答:
Making a decision to fire anyone is a hard decision for anyone to make. Your situation though is compounded by several factors:

It appears that this developer has been in the company for several
years

The developer writes all of the companies C++ code

It appears
        that before you no one ever discussed the level of poor code with
        the developer

As a new manager you have no idea of who/what the
    developer knows in/about the company and what the political
    ramifications of firing the developer are

That said you have spent the last 6 months showing the developer the error of his ways and his new code has not yet improved.

At this stage you really need to start some proactive management so that within 3 months you have

A decent C++ programmer who knows what he is doing

or

Terminated the developer.

In order to do this though you need to sit down with the developer, explain what is wrong in writing/email, explain how the developer can improve and very very clearly state that if there expected improvement does not materialise then he will be terminated in 3 months.

You also need to be very clear that the improvement is expected from this point on for the rest of his employment with the company and not just for the 3 moth period!

You should also inform your own manager and the HR Department (if any).

During this process you will have to actively manage the developer and review tasks/code every 1-2 days and ensure they are up to scratch, detailing those that are not and explain what can be done to improve them.


答: I'm going to answer your title question. The answer is yes, but not for the reasons you're after. Being multilingual in spoken languages, IMO, can help you separate ideas from the things used to express them. For similar reasons I recommend learning at least one non-c-based syntax language if you started with one.</p>


答: If you want to give him a chance, develop a standardised test that gathers metrics on memory leaking. Monitor his progress on a weekly basis, insisting on seeing the code that he changed, and look for improvement. If he can't manage at that point, sack the useless invective.


答:
Static if it's not relevant to the instance. That you would want to pass an instance means it is instance relevant so no.

Private if at best it does nothing more than confuse people trying to re-use your class when exposed to them. The whole point is to bury how it works and just give people easy to understand, well-labeled buttons to press.

Think first about what you want to expose to somebody else using your class. And pay attention to public APIs on stuff that you like working with best for some ideas of what works well.

The only reason to typically use an extended method is if you have a variety of classes that you want to all have the same standard set of methods. There are people out there extending and implementing for all kinds of reasons and complex patterns d'jour but it's bad OOP and in most cases they should probably stop.

Keep everything as simple and clean as it needs to be. It's always easier to make your classes more complex moving forward than it is to maintain a code base chock full of stuff that didn't need to be there. The less there is to look at, the more clear your intentions are, and the easier it is to maintain/modify without everything blowing up in your face.

Title: How to organise OO code


答:
Either you haven't been clear about how seriously you take his poor workmanship (i.e. it's possible he sees what time you've spent with him as an option if he wants to improve rather than an absolute necessity), or he has an incredibly bad attitude that's unsustainable. If it's not already clear to this developer that you're considering his position over this issue, then it needs to be spelled out (assuming your leadership are ok with your authority to terminate). The shock will hopefully bring about change.

The employment decision has much wider implications than just this guy though, you need to consider the impact upon the team. If his attitude is allowed to prosper, it can provide either resentment from others or have others feel that this sort of thing is ok too. From the team's angle though, it has to be absolutely clear that if he did go, it was for the right reasons and he had ample opportunity to improve.

One gem I picked up on a course years back is the fact that people with technical knowledge that others don't have can lead management to give them slack. It's bad for the team. You may be fearful of losing the only c++ developer, but they can be replaced. Obviously there are inherent risks if he knows the released products well, but often I've seen people with seemingly irreplaceable product/technical knowledge replaced more easily than anticipated. Teams and organisations can often fill in gaps that initially appear tough to fill. Of course if he doesn't have c++ skills or organisation specific knowledge that you think will be tough to replace, there's much less of a problem!


答:
It depends what you understand as career.

If you have work as employee in your country, and you want it to stay so, there's usually no need for you to know any language except your native and English. An exception may be, when your company's main client is foreign company, and you should know the language of that company. For example, many companies from west Poland are cooperating mostly with German companies, and knowing German is a great advantage, or even requirement, for working as senior developers (while juniors don't have contact with customer, they are not required to speak German).

However, if you want be a freelancer, you need to be fluent in the language of your customer. You can of course target English-speaking countries only, but knowing for example German or France gives you more opportunities, and potential better payed contracts.

If you want to work abroad, it depends. Of course, going to USA or UK, the English is the correct choice. In small countries (in Europe) there are many English-speaking teams, so as a foreign contractor, you can hope for many English-speaking jobs for example in Denmark or Netherlands.

But in big countries such as Germany, English-speaking jobs are an exception, and without knowing German good you have little chances of finding something. To get best payed contracts, you need to speak German fluent, but you can then get really good payed jobs.


答: I don't know where this originated, but if a customer has multiple bugs/enhancement requests tell them they have a $100 (or equivalent currency). How do they want it spent? Everything towards one issue? Even divided between two? This helps to block the usual response that everything is high priority as well as gives weights to each issue.</p>

Title: How do you get users to rank their software enhancement needs?

Body:
I've inherited a legacy software system, and have been tasked with performing usability and system upgrades. While there's nothing bad with the system, from discussions with the users, there are "small" usabilty issues that need to be addressed.

At this stage I'm the lone developer on this system, and apart from testing I don't use the system at all, so its difficult for me to know what issues may exist or are percieved to exist. I'm going to have some time to speak with them all and discuss what they percieve to be good/bad or indifferent about the system.

Since its essentially just me for the time being my time is limit. So I was considering asking them to imagine that I'd only be able to do one change, have them all write privately what they'd want that one change to be, and then helping them rank those, but I'm hoping for other tips as well.

What techniques exist for getting users to explain their wants, needs, and requirements, while also having them rank them by importance or desirability?


答: No. If this young man was such a genius, he would made his ẃay anyway. Fact is: working for free is, for obvious reasons, not sustainable. You may get some references, you may get some experience, but it will be a gig of (say) 1-2 months, because sooner or later you will run out of money. Unfortunately, a 1-2 months gig doesn't look too well on your resume.</p>

Title: Working for free?

Body:
I came across this article Work for Free that got me thinking.

The goal of every employer is to gain
  more value from workers than the firm
  pays out in wages; otherwise, there is
  no growth, no advance, and no
  advantage for the employer.
  Conversely, the goal of every employee
  should be to contribute more to the
  firm than he or she receives in wages,
  and thereby provide a solid rationale
  for receiving raises and advancement
  in the firm.

I don't need to tell you that the
  refusenik didn't last long in this
  job.

In contrast, here is a story from last
  week. My phone rang. It was the
  employment division of a major
  university. The man on the phone was
  inquiring about the performance of a
  person who did some site work on
  Mises.org last year. I was able to
  tell him about a remarkable young man
  who swung into action during a crisis,
  and how he worked three 19-hour days,
  three days in a row, how he learned
  new software with diligence, how he
  kept his cool, how he navigated his
  way with grace and expertise amidst
  some 80 different third-party plug-ins
  and databases, how he saw his way
  around the inevitable problems, how he
  assumed responsibility for the
  results, and much more.

What I didn't tell the interviewer was
  that this person did all this without
  asking for any payment. Did that fact
  influence my report on his
  performance? I'm not entirely sure,
  but the interviewer probably sensed in
  my voice my sense of awe toward what
  this person had done for the Mises
  Institute. The interviewer told me
  that he had written down 15 different
  questions to ask me but that I had
  answered them all already in the
  course of my monologue, and that he
  was thrilled to hear all these
  specifics.

The person was offered the job. He had
  done a very wise thing; he had earned
  a devotee for life.

The harder the economic times, the
  more employers need to know what they
  are getting when they hire someone.
  The job applications pour in by the
  buckets, all padded with degrees and
  made to look as impressive as
  possible. It's all just paper. What
  matters today is what a person can do
  for a firm. The resume becomes pro
  forma but not decisive under these
  conditions. But for a former boss or
  manager to rave about you to a
  potential employer? That's worth
  everything.

What do you think? Has anyone here worked for free? If so, has it benefited you in any way? Why should(nt) you work for free (presuming you have the money from other means to keep you going)? Can you share your experience?

Me, I am taking a year out of college and haven't gotten a degree yet so that's probably why most of my job applications are getting ignored. So im thinking about working for free for the experience?


问:
Solutions for floating point rounding errors
In building an application that deals with a lot of mathematical calculations, I have encountered the problem that certain numbers cause rounding errors.

While I understand that floating point is not exact, the problem is how do I deal with exact numbers to make sure that when calculations are preformed on them floating point rounding doesn't cause any issues?

答:
If floating point values have rounding problems, and you don't want to have to run into rounding problems, it logically follows that the only course of action is to not use floating point values.

Now the question becomes, "how do I do math involving non-integer values without floating point variables?"  The answer is with arbitrary-precision data types.  Calculations are slower because they have to be implemented in software instead of in hardware, but they're accurate.  You didn't say what language you're using, so I can't recommend a package, but there are arbitrary precision libraries available for most popular programming languages.


答:
There are three fundamental approaches to creating alternative numeric types that are free of floating point rounding.  The common theme with these is that they use integer math instead in various ways.

Rationals

Represent the number as a whole part and rational number with a numerator and a denominator. The number 15.589 would be represented as w: 15; n: 589; d:1000.

When added to 0.25 (which is w: 0; n: 1; d: 4), this involves calculating the LCM, and then adding the two numbers.  This works well for many situations, though can result in very large numbers when you are working with many rational numbers that are relatively prime to each other.

Fixed point

You have the whole part, and the decimal part.  All numbers are rounded (there's that word - but you know where it is) to that precision.  For example, you could have fixed point with 3 decimal points.  15.589 + 0.250 becomes adding 589 + 250 % 1000 for the decimal part (and then any carry to the whole part).  This works very nicely with existing databases.  As mentioned, there is rounding but you know where it is and can specify it such that it is more precise than is needed (you are only measuring to 3 decimal points, so make it fixed 4).

Floating fixed point

Store a value and the precision.  15.589 is stored as 15589 for the value and 3 for the precision, while 0.25 is stored as 25 and 2.  This can handle arbitrary precision. I believe this is what the internals of Java's BigDecimal uses (haven't looked at it recently) uses. At some point, you will want to get it back out of this format and display it - and that may involve rounding (again, you control where it is).

Once you determine the choice for the representation, you can either find existing third party libraries that use this, or write your own.  When writing your own, be sure to unit test it and make sure you are doing the math correctly.

Title: Solutions for floating point rounding errors

Body:
In building an application that deals with a lot of mathematical calculations, I have encountered the problem that certain numbers cause rounding errors.

While I understand that floating point is not exact, the problem is how do I deal with exact numbers to make sure that when calculations are preformed on them floating point rounding doesn't cause any issues?


问:
Security Risks of Unsigned ClickOnce Manifests
Using signed manifests in ClickOnce deployments, it is not possible to modify files after the deployment package has been published - installation will fail as hash information in the manifest won't match up with the modified files. I recently stumbled upon a situation where this was problematic - customers need to be able to set things like connection strings in app.config before deploying the software to their users.

I got round the problem by un-checking the option to "Sign the ClickOnce manifests" in VS2010 and explicitly excluding the app.config file from the list of files to have hashes generated during the publish process.

From a related page on MSDN

"Unsigned manifests can simplify development and testing of your
  application. However, unsigned manifests introduce substantial
  security risks in a production environment. Only consider using
  unsigned manifests if your ClickOnce application runs on computers
  within an intranet that is completely isolated from the internet or
  other sources of malicious code."

In my situation, this isn't an immediate problem - the deployment won't be internet-facing. However, I'm curious to learn what the "substantial security risks" of what I've done would be if it was internet-facing (or if things changed and it needed to be in the future).

Thanks in advance!

Edit / follow-up:

Does not signing the ClickOnce manifest constitute an unsigned manifest (as per MSDN's definition)? The application manifest contains a hash of the files in the deployment package. Any changes to the files within it results in a validation failure during installation. Does this negate the above security risks, at all?

答:
I imagine the risks are the same as using any unsigned executable. The reason that it's okay to download the application over an intranet is that you trust the network hardware (and people who have access to that hardware) that serves you the file. When you ask, "Server foo.local, please send me bar.exe," you know that foo.local is a trustworthy machine, and all the routers and switches between you and foo.local are also trustworthy.

In an Internet distribution setup, the user asks foo.com to serve bar.exe. The user has no good way to be sure that:

foo.com hasn't tampered with the file

his DNS records haven't been tampered with to keep him from talking to the right host

that an attacker on his home network hasn't ARP poisoned his router to redirect and alter his traffic

The user gets the file from a fundamentally untrustworthy source. Digital signatures are a way to provide trust even when the distributing source is not trustworthy. The signature is a sealed guarantee to the end recipient that this file is exactly the one that was produced by the original signer.

Ultimately, the risk is not that the file will somehow be less trustworthy when it reaches the user; the problem is that the user may not ever receive your file, but will instead be unknowingly provided with a different file. Digital signatures allow you to mark your files as uniquely yours, in a way that can be verified by the end user. Any malicious agent who tries to provide a malicious lookalike will not be able to fake your signature. However, if you don't have a signature in the first place (or, more importantly, the user is not expecting a signature), then there's no way to verify he got the right file.


答:
If English is your native language, learning a foreign language will probably not help your programming career much directly. Personally, I think that knowing foreign languages is a very good general exercise that expands your horizons ("Wie viele Sprachen du sprichst, sooftmal bist du Mensch"), but if you are only looking into instant gains, it's probably not worth the fuss.

Self-realization aside, here are some situations in which I think you could benefit from knowing a foreign language for purely pragmatic reasons:

Cooperation with partners or customers from abroad. Even if you don't know the language well enough to communicate, knowing some basics may make you aware of issues which may arise in the communication or of problems which users of foreign languages may have with your product.

Working on any product that needs to be internationalized well. Without knowing the basics of some foreign language, you may be left wondering what all the complex i18n libraries are for (like why the message "%d new messages" may require several different translations to the same language depending on the value of %d).

It helps in understanding the complexities of proper Unicode handling.

However, as mentioned earlier on, in many situations the benefits won't be worth the effort if you only look at the immediate gains.


答:
This is a good question. I would argue that it is useful to learn another spoken language for the same reason it's useful to learn another programming language: it allows you to think about things in new ways.

For better or worse, English is the universal language of programmers. So you're not likely to miss out on much due to only speaking English.


答:
You might try the Agile / SCRUM approach: create a list of all known work (bugs, enhancements, new features, etc.) Then tell your stakeholders (users, bosses, or whomever) that you're always going to work on the top-most item on the list until it is done. Allow them to order it (and reorder it) as often as they like.

The method of getting them ordered is going to differ based on whether you've got a bunch of end-users vs. project management. If nothing else, issues could be "voted" upon in order to order them.

You will need to make dependencies clear though; i.e. issue A has to be done before we can do issue B, even though they want B and don't care about A.

There are a number of software solutions that can help you with this sort of thing, such as issue trackers (Trac, JIRA, Rally, etc.)


答:
Yes, learning another language will further your programming career. This is because in my opinion, learning another language will further any career.

This is for several reasons, some of which have already been touched on above:

Learning another language will expand your horizons; it will necessarily expose you to aspects of another culture and way of thinking and give you experience in mapping this to your own thoughts. Obviously, this has parallels with programming, but it is also a generally useful skill for inter-person communication.

Learning another language (especially your second) will help you understand how your own language works, because you are forced to analyse how the grammar of the new language works and how it maps to the grammar of your own language, rather than blindly accepting that "that's how it is". Even if you only use your native tongue in your career, better understanding it will help you communicate more effectively.

Having even a little knowledge of another language can make you look really good. All but the smallest companies will have to deal with foreign suppliers or customers. Even if you both conduct your business in English, being able to exchange small pleasantries (greetings, for instance) with people in their native tongue creates a good impression. Being available to create that good impression will increase your standing with your company.

Knowing another language will help you communicate more effectively with native speakers of that language, even if you are using your native language. This is because you can spot attempts to use constructs that are common in the foreign language and get the meaning from them, even if they are not so clear in your own. Similarly, it will help you spot and understand any false friends that may crop up.

Knowing a language well opens up the possibility of working in countries where that language is spoken. This widens the pool of potential jobs available to you, which in turn means you will have more opportunities to further your career.

So, to answer your questions directly: Will learning a foreign language open up an amazing new range of programming languages and learning resources? No. Will it make you a better software engineer? Probably not directly. But will it help make you a better, more-rounded, more-employable person and advance your career? Absolutely.


答:
I've never worked for free, but have worked almost for free, and can honestly tell you, the less somebody pays, the less they appreciate you.

Besides, you don't need an employer any more, the barrier to entry is so low, if you have a computer and an internet connection, you can start your own company.

If you are willing to work for free, I recommend (in order):

Build your own app (free or for profit) that people need and will use.

Find an existing startup and work for equity.

Start or become a serious contributor to an OSS project you are passionate about.

Participate in a charity you are passionate about.

Participate in an industry association, where you will make legitimate industry contacts.

Participate in a non-profit where nobody is benefiting financially (I have no examples, but suspect many of these are a little deceptive about anybody financially benefiting)

But what ever you do, make sure it's engaging and something you have a strong interest in, otherwise you're going to burn out on a project for which you get nothing.

I would absolutely NEVER recommend you work for free.

... oh yeah, and make sure you get the credit.  Your name is on it, and can never be removed by anyone other than you!

Title: Working for free?


答:
Its seems that all people here seem to agree that there is no immediate benefit of learning another language for programming directly (programming languages are mostly based on english, it is the language of computer science textbooks and journals, etc.).

Nevertheless knowing a foreign language is beneficial in a lot of ways. That is at least what my experience learning several foreign languages tells me. You will learn different ways of expressing things in other languages and it will open new ways for you to look at things.


答:
I tend to use the concepts of coupling and cohesion to decide what goes in any specific class/interface/module/etc. Low coupling and high cohesion are what you want.

Coupling is pretty easy to understand. But I find that many developers have trouble with cohesion. Basically, "cohesion" is like the old Sesame Street song, "One of these things is not like the others..." In a class with high cohesion, everything seems to belong together.

(Also, to be pedantic, I'd say this is more about how you "design" OO code rather than "organize" it -- where organization would be more about how you order methods, name packages, etc.)

Title: How to organise OO code


答:
I'm not talking about any language-specific OO words (static, private, etc.).

If you have a method that doesn't need access to any non public fields, properties or methods where should you put the method ?

If the code is not related with any class in your domain, then it can be a simple function, outside a class scope. A dumb example is factorial or even fibonacci, either just receives a value and computes a result, doesn't belonging to any class in special.
If the code is some kind of factory or has something else related with a certain class, then it can be a static or class method, or even another class.

It's important to note that if your language allows pure functions, not just classes and methods, then you can take advantage of it and make your design more simple (for me, it's one of the major drawbacks of the Java language, but it's just my personal opinion).

Title: How to organise OO code


答:
Real World - Go with Object-Action

I worked in a small shop that created and hosted 600+ websites. We amassed a huge code library and when you are looking for a comlpete code set that you can borrow from one site and plug into another site it doesn't take very long to determine that the Object-Action namining convention works best.

Who's got the PressRelease-XXXXXXX widget? (code and sql scripts)

Which PhotoGallery-XXXXXXX do I need?

This naming convention makes stuff easy to find, package, deploy and debug.

Title: Naming: objectAction or actionObject?

Body:
The question, Stored procedure Naming conventions?, and Joel's excellent Making Wrong Code Look Wrong article come closest to addressing my question, but I'm looking for a more general set of criteria to use in deciding how to name modules containing code (classes, objects, methods, functions, widgets, or whatever).

English (my only human language) is structured as action-object (i.e closeFile, openFile, saveFile) and since almost all computer languages are based on English, this is the most common convention.

However, in trying to keep related code close together and still be able to find things, I've found object-action (i.e. fileClose, fileOpen, fileSave) to be very attractive. Quite a number of non-English human languages follow this structure as well.

I doubt that one form is universally superior, but when should each be used in the pursuit of helping to make sure bad code looks bad?


问:
Should I force users to update an application?
I'm writing an application for a medium sized company that will be used by about 90% of our employees and our clients.

In planning for the future we decided to add functionality that will verify that the version of the program that is running is a version that we still support. Currently the application will forcequit if the version is not among our supported versions. Here is my concern.

Hypothetically, in version 2.0.0.1 method "A" crashes and burns in glorious fashion and method "B" works just fine. We release 2.0.0.2 to fix method A and deprecate version 0.1. Now if someone is running 0.1 to use method B they will be forced to update to fix something that isn't an issue for them right now.

My question is, will the time saved not troubleshooting old, unsupported versions outweigh the cost in usability?

答:
I would not force an update on a user.

First, it tends to happen that someone's "work flow" or "process" becomes dependent on certain behavior of your app.  If you change that, it will cause chaos and anarchy and whining to someone's boss that those mean IT people are stopping me from doing work and they need to fix it NOW.

Secondly, like you said, sometimes people don't need to or have time to upgrade right now.  Imagine a critical report is due very soon and you can't get your work done because the app is updating and you're stuck waiting for it.

I think the best solution is to have a written policy somewhere that states that you support versions 2.0.0.3 to 2.0.0.5. and that if you are outside that window you either have to upgrade to get support or you are on your own.


问:
Tester/Doer pattern: Assume the caller conforms to the pattern or be defensive and repeat the check?
Assume a simple class that implements the Tester/Doer pattern:

```<code>public class FooCommandHandler : ICommandHandler
{
    public bool CanHandle(object command)
    {
        return command is FooCommand;
    }

    public void Handle(object command)
    {
        var fooCommand = (FooCommand)command;
        // Do something with fooCommand
    }
}
</code>```

Now, if someone doesn't conform to the pattern and calls Handle without verifying the command via CanHandle, the code in Handle throws an exception.

However, depending on the actual implementation of Handle this can be a whole range of different exceptions.

The following implementation would check CanHandle again in Handle and throw a descriptive exception:

```<code>public void Handle(object command)
{
    if(!CanHandle(command))
        throw new TesterDoerPatternUsageViolationException("Please call CanHandle first");

    // actual implementation of handling the command.
}
</code>```

This has the advantage that the exception is very descriptive.

It has the disadvantage that CanHandle is called twice for "good" clients.

Is there a consensus on which variation should be used?

答:
If you can't guarantee that Handle is always given something it can handle, then you have no choice but to repeat the check by calling CanHandle from Handle.

That doesn't mean you always have to incur the double check penalty. If you put the call to CanHandle in an Assert statement, then suitable compiler options can ensure that it is only run in debug builds and removed from release builds.

That way developers get slapped on the wrist when getting it wrong, while production code doesn't have to worry about the overhead. One caveat: you need to have a strong (unit) test suite in place to ensure that all calls to Handle are checked by the assertion.

Actually, it may be better to avoid the dilemma altogether.

The problem with a class with one method that validates X, and another method then processes X is that you make that class hugely dependent on its clients and you need to take steps to ensure that people use your class the way it was intended to be used.

If you make Handle itself responsible for returning whether the work is acceptable and  will get done, then checking whether the work received is suitable becomes a natural part of how Handle should be implemented.

The contract of Handle now obviously includes refusing unsuitable work and any tests for implementers of the ICommandHandler interface would check that its Handle implementation would respond as desired both when handed suitable and when handed unsuitable work.

Using this approach you can do away with the CanHandle method from the interface entirely. CanHandle may still exist in a class implementing the ICommandHandler but if it does, it now is just an implementation detail of that class.

I have written up a slightly more extensive discussion of this here: Designing your way out of the CanHandle-Handle conundrum


答:
Forcing users to whatever is a Bad Thing (TM).  Forcing to download and install stuff is even more rude.   And your reasoning is not sound either.

If you don't want to support some versions, do that. You need not sabotage my ability to run the program to achieve that goal. Just start any support session with version request and stop if it's out of range.

I may be more interested in just running what I used to than "support". If there is a problem that is indicated as fixed, I can go out and upgrade. At my pace, voluntarily.

Title: Should I force users to update an application?

Body:
I'm writing an application for a medium sized company that will be used by about 90% of our employees and our clients.

In planning for the future we decided to add functionality that will verify that the version of the program that is running is a version that we still support. Currently the application will forcequit if the version is not among our supported versions. Here is my concern.

Hypothetically, in version 2.0.0.1 method "A" crashes and burns in glorious fashion and method "B" works just fine. We release 2.0.0.2 to fix method A and deprecate version 0.1. Now if someone is running 0.1 to use method B they will be forced to update to fix something that isn't an issue for them right now.

My question is, will the time saved not troubleshooting old, unsupported versions outweigh the cost in usability?


答:
I am of the opinion that there's no need for this specific pattern in C#, due to the features of the language.  Here's how I'd implement it:

```<code>public class CommandManager
{
    private List<ICommandHandler> handlers = new List<ICommandHandler>();

    public void RegisterHandler(ICommandHandler handler) { handlers.Add(handler); }
    public void Dispatch<T>(T command)where T : ICommand {
        foreach (var handler in handlers.OfType<ICommandHandler<T>>()) handler.Handle(command);
    }
}

public interface ICommand { }
public class FooCommand : ICommand { }
public class BarCommand : ICommand { }

public interface ICommandHandler { }
public interface ICommandHandler<T> : ICommandHandler where T : ICommand
{
    void Handle(T command);
}

public class FooCommandHandler : ICommandHandler<FooCommand>, ICommandHandler<BarCommand>
{
    public void Handle(FooCommand command)
    {
        Console.WriteLine("Called FooCommandHandler with FooCommand");
    }
        public void Handle(BarCommand command)
    {
        Console.WriteLine("Called FooCommandHandler with BarCommand");
    }
}

public class BarCommandHandler : ICommandHandler<BarCommand>
{

    public void Handle(BarCommand command)
    {
        Console.WriteLine("Called BarCommandHandler with BarCommand");
    }
}
</code>```

Executing it would be like this:

```<code>void Main()
{
    var myCommands = new CommandManager();
    myCommands.RegisterHandler(new FooCommandHandler());
    myCommands.RegisterHandler(new BarCommandHandler());

    myCommands.Dispatch(new FooCommand());
    /* Output:
         Called FooCommandHandler with FooCommand
    */
    myCommands.Dispatch(new BarCommand());
    /* Output:
        Called FooCommandHandler with BarCommand
        Called BarCommandHandler with BarCommand
    */
}
</code>```

OfType<>() handles your checking for you - it will automatically filter to only the types which can handle the specified command and cast to that type so you can call Handle().  You add only a single Handle overload for each specific command it can handle, so you don't have to worry about it being called with an invalid command.

Title: Tester/Doer pattern: Assume the caller conforms to the pattern or be defensive and repeat the check?

Body:
Assume a simple class that implements the Tester/Doer pattern:

```<code>public class FooCommandHandler : ICommandHandler
{
    public bool CanHandle(object command)
    {
        return command is FooCommand;
    }

    public void Handle(object command)
    {
        var fooCommand = (FooCommand)command;
        // Do something with fooCommand
    }
}
</code>```

Now, if someone doesn't conform to the pattern and calls Handle without verifying the command via CanHandle, the code in Handle throws an exception.

However, depending on the actual implementation of Handle this can be a whole range of different exceptions.

The following implementation would check CanHandle again in Handle and throw a descriptive exception:

```<code>public void Handle(object command)
{
    if(!CanHandle(command))
        throw new TesterDoerPatternUsageViolationException("Please call CanHandle first");

    // actual implementation of handling the command.
}
</code>```

This has the advantage that the exception is very descriptive.

It has the disadvantage that CanHandle is called twice for "good" clients.

Is there a consensus on which variation should be used?

Body:
I am of the opinion that there's no need for this specific pattern in C#, due to the features of the language.  Here's how I'd implement it:

public class CommandManager
{
    private List<ICommandHandler> handlers = new List<ICommandHandler>();

    public void RegisterHandler(ICommandHandler handler) { handlers.Add(handler); }
    public void Dispatch<T>(T command)where T : ICommand {
        foreach (var handler in handlers.OfType<ICommandHandler<T>>()) handler.Handle(command);
    }
}

public interface ICommand { }
public class FooCommand : ICommand { }
public class BarCommand : ICommand { }

public interface ICommandHandler { }
public interface ICommandHandler<T> : ICommandHandler where T : ICommand
{
    void Handle(T command);
}

public class FooCommandHandler : ICommandHandler<FooCommand>, ICommandHandler<BarCommand>
{
    public void Handle(FooCommand command)
    {
        Console.WriteLine("Called FooCommandHandler with FooCommand");
    }
        public void Handle(BarCommand command)
    {
        Console.WriteLine("Called FooCommandHandler with BarCommand");
    }
}

public class BarCommandHandler : ICommandHandler<BarCommand>
{

    public void Handle(BarCommand command)
    {
        Console.WriteLine("Called BarCommandHandler with BarCommand");
    }
}

Executing it would be like this:

void Main()
{
    var myCommands = new CommandManager();
    myCommands.RegisterHandler(new FooCommandHandler());
    myCommands.RegisterHandler(new BarCommandHandler());

    myCommands.Dispatch(new FooCommand());
    /* Output:
         Called FooCommandHandler with FooCommand
    */
    myCommands.Dispatch(new BarCommand());
    /* Output:
        Called FooCommandHandler with BarCommand
        Called BarCommandHandler with BarCommand
    */
}

OfType<>() handles your checking for you - it will automatically filter to only the types which can handle the specified command and cast to that type so you can call Handle().  You add only a single Handle overload for each specific command it can handle, so you don't have to worry about it being called with an invalid command.


问:
Vim key mappings / plugin XCode?
I'm a developer who mostly does web stuff in ruby and C#.

I'd like to start tinkering with iOS and Mac development.

Over the last few month i've been trying to get fluent in one set of key bindings (vi / vim because it just feels right).

I have the awesome ViEmu installed for visual studio on windows which gives me a ton of the vim awesomeness side by side with visual studio power toys.

Is there anything like this for xcode?

I know I could set up MacVim as the default editor, but I'm not too interested in this as it means losing all of xcode's cocoa awareness.

The other option of course would be to go for the lowest common denominator and switch to emacs (as the mac keybindings are based massively on emacs) but let's not think about that for too long. :P

答: ViEmu has become available for Xcode 4, I've tried it and it's far far better than all the other Vim emulators for Xcode.</p>

Title: Vim key mappings / plugin XCode?