问:
Backquoted symbols, good or bad?
I'm designing a programming language which has three kinds of quoted entities: strings and characters as in C, and symbols (interned strings intended for use as lookup keys and such) which I consider one of the most endearing features of Lisp. Currently I have the following syntax for these:

```<code>"*" // String
'*' // Character
`*` // Symbol
</code>```

which I quite like, but has a couple of potential problems:

I'm told that on some keyboard layouts, backquote is a nuisance to type.

Backquote and ' are not the most visually distinct of characters, and I have a few times found myself typing ' when I meant backquote. On my setup this is not a problem because I have UltraEdit syntax highlighting set up to show backquoted symbols in green so the mistake is instantly apparent, but of course I can't provide syntax highlighting for most of the editors people use, so at least in the early days most users won't have the benefit of that kind of special coloring.

So, given these potential problems, I'd like to get some feedback on which option people consider preferable:

Keep the syntax the way I have it now.

Swap backquote and ', so that ' is used for symbols and backquote is used for character constants.

Use ' for symbols, @"*" for character constants (in e.g. the Linux kernel code, character constants are something like thirty times rarer than string constants, so it's arguably okay to give them slightly more verbose syntax) and backquote for something else, perhaps raw (most escape codes not interpreted) strings.

Use ' for symbols, @"*" for character constants and forswear the use of backquote entirely.

答:
Smalltalk also has a distinction between the three things, and uses this syntax:

```<code>'strings are in single quotes'
"comments are in double quotes. Yes, comments!"
$a "is the character a, dollar-sign prefixes characters"
#symbol "is a symbol, prefixed by a hash"
</code>```

Aside from the potential difficulty of getting at some symbols (sorry Euro-folks!) it does have the unconventional but pleasant syntax of using single-quotes for strings, since it doesn't (on an American keyboard) require a shift-key press to get at and you type a lot more strings than characters (comments using the double-quote is a bit odd, but arguably people put up with longer key strokes for comments since they are typed in a different mindset than code.)

There are really several ways you can handle it, but keep in mind the rarity and use cases for each type.  Strings will get used a lot, and should have the easiest syntax.  Characters are rarer to use.  Symbol-usage will depend on how much meta-programming your language allows or requires.

You can also do some trickery at compile-time, depending on how much type-checking you've got you might be able to convert a single-character string to a char or a char to a single-character string as needed with implicit casting.  In most high-level languages, the needs to directly utilize an actual char type are fairly uncommon.

Another option is to use tagged strings. C#, for example, has "regular strings" and @"non-escaping strings that ignore things like \n".  The D language uses r"this is a string" for the same purpose.  Those are very good for symbol heavy strings like regexps or directory names.  You could use c"A" for characters and s"symbol" for symbols.  Letters as operators is tricky business, but it makes for a very easy mnemonic for the programmer, and shouldn't be hard to lex since a string literal would never directly follow a symbol without whitespaces in most languages.

Title: Backquoted symbols, good or bad?

Body:
Smalltalk also has a distinction between the three things, and uses this syntax:

'strings are in single quotes'
"comments are in double quotes. Yes, comments!"
$a "is the character a, dollar-sign prefixes characters"
#symbol "is a symbol, prefixed by a hash"

Aside from the potential difficulty of getting at some symbols (sorry Euro-folks!) it does have the unconventional but pleasant syntax of using single-quotes for strings, since it doesn't (on an American keyboard) require a shift-key press to get at and you type a lot more strings than characters (comments using the double-quote is a bit odd, but arguably people put up with longer key strokes for comments since they are typed in a different mindset than code.)

There are really several ways you can handle it, but keep in mind the rarity and use cases for each type.  Strings will get used a lot, and should have the easiest syntax.  Characters are rarer to use.  Symbol-usage will depend on how much meta-programming your language allows or requires.

You can also do some trickery at compile-time, depending on how much type-checking you've got you might be able to convert a single-character string to a char or a char to a single-character string as needed with implicit casting.  In most high-level languages, the needs to directly utilize an actual char type are fairly uncommon.

Another option is to use tagged strings. C#, for example, has "regular strings" and @"non-escaping strings that ignore things like \n".  The D language uses r"this is a string" for the same purpose.  Those are very good for symbol heavy strings like regexps or directory names.  You could use c"A" for characters and s"symbol" for symbols.  Letters as operators is tricky business, but it makes for a very easy mnemonic for the programmer, and shouldn't be hard to lex since a string literal would never directly follow a symbol without whitespaces in most languages.


问:
Code ownership: What should I do when a dev leaves or team splits?
There are multiple ways of tracking code ownership (i.e., collective, team or individual).

In case of team or individual ownership, how do you:

track ownership?

deal with situations when dev leaves or team splits/re-organizes for new projects?

答:
You may use the version control system to keep tracking of code ownership. I'm not sure if you can do this with all VCSes or not, but for the git/Gerrit pair, you can put the name and contact details of the code owner in the description field. For other systems you can consider creating a text file (let's call it OWNER.txt) within the module that provides the same information; so that, if the developer can checkout the code, she already has the contact details of the module owner. If you create a template, you can also script it, so that you get an up to date list available whenever you need it (even create a web page that displays the code owners).

Developers leaving the project happens all the time and I don't see a direct link to this problem, but with my proposed solution, you can simply change the module description (or the OWNER.txt file for that matter).

ContentLicense: CC BY-SA 3.0


问:
Is unit testing or test-driven development worthwhile?
My team at work is moving to Scrum and other teams are starting to do test-driven development using unit tests and user acceptance tests. I like the UATs, but I'm not sold on unit testing for test-driven development or test-driven development in general.

It seems like writing tests is extra work, gives people a crutch when they write the real code, and might not be effective very often.

I understand how unit tests work and how to write them, but can anyone make the case that it's really a good idea and worth the effort and time?

Also, is there anything that makes TDD especially good for Scrum?

答:
Let me approach this from the other side. What happens when you develop a non-trivial application without unit tests? If you have a good QA department, one of the first things that will happen is that you will find that you have a large number of reported issues. Why because you didn't test what you did and assumed it would work and because you didn't pay that much attention to the requirements and your application doesn't meet them. Oops back to the drawing board to rewrite and fix. Now you've made the fixes and find a whole new set of issues because you had no way to verify that your fixes didn't affect anything else before you pushed to QA. Oops deadline has now come and gone and management is upset.

Situation is worse if you don't have a good QA department because then the users will find the bugs and not only will that make your boss unhappy, it may bring the production environment to its knees and 100s or even thousands of people will be at a standstill while you fix the bugs that unit testing would have prevented. This is NOT a good career choice.

Now suppose this cowboy approach goes on for years? Now every change, even trivial ones, seems to bubble up a new unsuspected problems. Not only that, but many of the things you would like to do to make the application work better, you can't do because they are too risky or too expensive or both. So you put patches on the patches making the system more and more convoluted and buggier and harder to use.

Users start questioning your time estimates because they keep getting larger and larger and it's hard to explain to them that the system has become such a complicated mess, it is hard to find where to even make the changes and harder still to make sure they don't break something else.

I worked in a place like this where after ten year of development, virtually nothing we wanted to do to fix the real problems could be done because we couldn't tell which of hundreds of customized client applications would break. The initial developers were very much the "unit tests, we don't need no stinking units tests" kind of developers. Everyone who followed them suffered thanks to their short-sightedness.

Without unit tests, software is buggier and takes longer both to initially develop and to maintain. Why on earth wouldn't you want to do unit tests? The time you spend writing the test will be far less than the time you would spend fixing issues you should have found earlier (the earlier the bug is found the less time it takes to fix) and issues you would have avoided altogether by writing the tests first which gives a better understanding of the requirements before you start coding.


问:
Web application to a multiplatform phone app
I'm really lost here so I hope some can help me.

I have to develop a phone application on every platform so i tough of using phonegap. Seems pretty nice.

I have a web application coded in classic Asp and it's this webApplication that i need to strip down to be a phone app.

At first at thought it will be simple, my classic Asp render some html so phonegap is able to put it as an app.

But it's not that simple, because in my asp I have some code that is rendered server side, I've talked to some who tell me that some html could call the asp pages and this html could be used in phonegap. Don't think it's possible ...

Well if someone could help me here, maybe i've said wrong thing in my little text dont hesitate to correct me :)

My solution (i think) : code some webServices in asp.net that will use the same database as my asp classic web application. And some html and jquery will call the webservices and those html and jquery will go trough phoneGap

Well thanks for the help and saying what you think about it ! :)

Simple question : What is the best way to transfer an asp classic web app to a multiplatform phone app ?

答: The simplest way: re-think it and re-write it. Developing for phones is different from developing for desktops.</p>


问:
How to camel-case where consecutive words have numbers?
Just wondering if anybody has a good convention to follow in this corner-corner-corner case.  I really use Java but figured the C# folks might have some good insight too.

Say I am trying to name a class where two consecutive words in the class name are numeric (note that the same question could asked about identifier names).  Can't get a great example, but think of something like "IEEE 802 16 bit value".

Combining consecutive acronyms is doable if you accept classnames such as HttpUrlConnection.  But it seriously makes me throw up a little to think of naming the class IEEE80216BitValue.  If I had to pick, I'd say that's even worse than IEEE802_16BitValue which looks like a bad mistake.  For small numbers, I'd consider IEEE802SixteenBitValue but that doesn't scale that well.

Anyone out there have a convention?  Seems like Microsoft's naming guidelines are the only ones that describe acronym naming in enough detail to get the job done, but nobody has addressed numbers in classnames.

答:
I'd figure out a new variable name instead of trying to figure out what naming convention to use for a double-number variable

That said, if I absolutely HAD to use a double-number in my variable name, and I couldn't rearrange the words/numbers to come up with something reasonable, and absolutely no other name would make sense, I would use an _ between the numbers

...

Actually I take it back, I would just figure out a new variable name :)

OwnerDisplayName: Rob I


问:
Going further with C for iOS development
I am an experienced iOS developer amongst other things. I have a good mastery of Objective-C and Apple's frameworks in the language.

But when it comes to the C-based frameworks I often hit a ceiling with my knowledge, and often have to look up idioms and syntax. I learnt C from K&R but it's been a while. I did try learning from it again and it was a blast; but by Chapter 6, I got a feeling that its C is a bit archaic, at least idiom-wise. Also, I want to learn C mostly for the sake of iOS development and so a Mac/iOS focused learning process would be ideal.

What will be a good way to go about doing this?

答: I suggest just doing; just code all kinds of sample projects on Mac using C and C-based frameworks. That's the real way of dealing with coding C under Mac. Then you can ask more specific questions to help you going forward.


问:
What does it mean to say an algorithm is Sound and Complete?
I heard different interpretations of sound and complete. I understand that completeness means finding a solution if there is one. What does it mean to say an algorithm is sound.

What does it mean to say an algorithm is Sound and Complete?

答:
These are very specific terms as related to logic.

Here are some starting points:

http://en.wikipedia.org/wiki/Soundness

http://en.wikipedia.org/wiki/Completeness_(logic)

Basically, soundness (of an algorithm) means that the algorithm doesn't yield any results that are untrue.  If, for instance, I have a sorting algorithm that sometimes does not return a sorted list, the algorithm is not sound.

Completeness, on the other hand, means that the algorithm addresses all possible inputs and doesn't miss any.  So, if my sorting algorithm never returned an unsorted list, but simply refused to work on lists that contained the number 7, it would not be complete.

It is complete and sound if it works on all inputs (semantically valid in the world of the program) and always gets the answer right.


问:
Learning embedded systems development without supervision
I have graduated this year and got my first job involved with C programming, Linux administration and embedded systems development. I feel quite content with my job, but I'm afraid I won't become a successful programmer in this field. I'm a lone developer on my job now, with my teammates being hardware experts, there is no one to guide me or teach me in the ways of embedded programming, I have to study all on my own.

So here are my questions. Is it possible to become a good embedded systems developer starting from an entry level position without any supervision by senior programmers? How could I become one (perhaps with the help of forums, IRC channels, good textbooks)? How long would it take?

UPDATE: So far, I have received a handful of helpful answers, but I realized that I need some specific pointers on the subject.

So, here are my particular questions:

What are some good textbooks one can use to learn embedded development?

What specialized online communities can be helpful for an aspiring embedded developer (not counting general stuff like Stack Overflow, Reddit and so on)?

What are the most interesting blogs dedicated to embedded development?

答:
You are right that being in your case will make things little bit harder. However there are many solutions to solve your issue.

First try to participate to communities like this one, but maybe more specialized in your field. By participating, you will increase your knowledge, and more importantly, meet other people.

Try to participate to code camps, or any initiative where you meet other developers like you in real. It's easier to share knowledge when you have the person in front of you.

Ask your boss to book you at least 10 days of training a year. No need to explain the advantages here, if he refuses, he is stupid.

Try to go to 1 to 2 conference or trade show related to your business.

Try to read a technical book every two months. If you can read more, don't hesitate.

Get a mentor. It's not the easiest thing to achieve of course.

Reserve some time in the week to experiment and do research & development, by trying new technologies of things you read in your books, community, trade shows, trainings, etc... Taking the time to practice what you have learn is VERY important.

Today you are the only developer, but thanks to your hard work, the company you are in will grow, and will probably need to hire more people of your kind.

ContentLicense: CC BY-SA 2.5


答:
It's really two different problems, and you can't really "port" the application as-is. Your ASP application is running in a server environment, whereas phonegap runs locally stored HTML/Javascript/CSS within the phone's environment.

Going the route of writing some webservices that will be consumed by jQuery is going to be your best bet if you are trying to write a "native" application that can be downloaded from an App Marketplace.

If you just want to display your website on a mobile phone, find a device detection library, and use that to either redirect or change your layout (and CSS) so that it's formatted for a smaller screen

Title: Web application to a multiplatform phone app

Body:
I'm really lost here so I hope some can help me.

I have to develop a phone application on every platform so i tough of using phonegap. Seems pretty nice.

I have a web application coded in classic Asp and it's this webApplication that i need to strip down to be a phone app.

At first at thought it will be simple, my classic Asp render some html so phonegap is able to put it as an app.

But it's not that simple, because in my asp I have some code that is rendered server side, I've talked to some who tell me that some html could call the asp pages and this html could be used in phonegap. Don't think it's possible ...

Well if someone could help me here, maybe i've said wrong thing in my little text dont hesitate to correct me :)

My solution (i think) : code some webServices in asp.net that will use the same database as my asp classic web application. And some html and jquery will call the webservices and those html and jquery will go trough phoneGap

Well thanks for the help and saying what you think about it ! :)

Simple question : What is the best way to transfer an asp classic web app to a multiplatform phone app ?


问:
Understanding Data Binding for Windows Phone 7
I want to develop a simple app for the Windows Phone 7 platform. It's basically a vocabulary based game that involves the user moving word tiles from one area to another to score points.

I want to know what is the best way of tying the UI to the game's backend? I saw the Windows Phone 7 jumpstart videos, there they touch up on Data Binding but don't really go into any depth.

I'm a newbie and don't have any experience with designing the architecture for a phone app,
It'd be great if someone could explain what steps I should be taking or guide me to a resource from where I could learn more.

答:
This month's issue of MSDN magazine has a good article: http://msdn.microsoft.com/en-us/magazine/hh852595.aspx.

However, when you used the phrase "tying the UI to the game's backend" and the word "architecture", I'm thinking that you need more information beyond simply binding from a XAML view to an object behind it. I'm thinking you should start reading about MVVM, as well as general WP7 architecture guidance.

There's stuff all over the web but the problem is that the overall guidance is not fully prescriptive in all cases - MS has advice for you, but no silver bullet. This makes it hard to pull any useful information out of all the noise on message boards and places like StackOverflow (not implying that there aren't good answers out there, but you will find many that are conflicting, overly confusing or tailored to specific scenarios.)

In my opinion, the best way to get started is with the publications from MS Patterns and Practices. Hit that link and Ctrl-F for "phone" and get to reading. Even the "retired" Windows Phone 7 Developer Guide there is great, but I'd start at the top with the Phone/MVVM one. Check out the Resources in that one, including Karl's "MVVM In the Box". And make sure you actually download and study the code as well as reading the article.


问:
What techniques help retain programming knowledge?
How do you remember programming related stuff? Have you had the feeling that you've encountered the error you have before you right now, a few years ago and you could swear you knew the cause then but now you've forgotten it?

Did you work with the xsl's string parsing some time ago but now you can't remember exactly which are the string functions altogether from xsl and you have to start from scratch? Or perhaps you forget about some feature from Apache Commons like "filtering a collection by some predicate" that you surely used in the past.

So how do you do it? I tried having a blog but when I develop apps, I never find the time to update the blog or write about my experiences. Also, using a wiki is a nice thing but then I found it difficult to keep a clean separation between them since many times I needed to change a blog post to add new information about that topic. This made me think that I actually should have put this topic in the wiki instead of the blog.

Do you have any systems that help you remember about your programming experience? What's your setup?

答:
I use OneNote. I have a lot of different programming languages I work with so I have different sections for each language and different tabs for different types of notes.

Now, I am starting to use Stack Exchange also.


答:
It mostly depends on yourself. If you are willing to learn and know how gather enough information on the subject you can teach yourself anything. But not all people are equally succesfull in doing that:

I started in a similar environment, and if I see where I am now as opposed to 5 years ago (graduated as electronics engineer, practically no programming background), I find it amazing what the human brain is capable of. When I started I had never heard of design patterns, TDD, ... and had never seen the code of a real program. Now I know these things pretty well, and know how to use them. The only thing I do is searching the net, reading code from others and some books (which again, I found on the net), and most important, write tons of code, debug, learn from my mistakes. Learning from a mistake is imo a much much better way to learn something as opposed to just reading a sample and replicating behaviour. It's very strange, but I have only talked in real life to what I'd call a good programmer a couple of times.

The only other programmer here is what you'd call a senior (because he's been on the job for 15+ years). He works in a completely different way than I do. And he's still writing a crippled form of C with classes, never uses STL, has no idea what a design pattern is etc etc (I'm probably going to start a question on this matter soon, I'm having a hard time trying to get him to adopt at least some of my methods..)

Title: Learning embedded systems development without supervision

Body:
I have graduated this year and got my first job involved with C programming, Linux administration and embedded systems development. I feel quite content with my job, but I'm afraid I won't become a successful programmer in this field. I'm a lone developer on my job now, with my teammates being hardware experts, there is no one to guide me or teach me in the ways of embedded programming, I have to study all on my own.

So here are my questions. Is it possible to become a good embedded systems developer starting from an entry level position without any supervision by senior programmers? How could I become one (perhaps with the help of forums, IRC channels, good textbooks)? How long would it take?

UPDATE: So far, I have received a handful of helpful answers, but I realized that I need some specific pointers on the subject.

So, here are my particular questions:

What are some good textbooks one can use to learn embedded development?

What specialized online communities can be helpful for an aspiring embedded developer (not counting general stuff like Stack Overflow, Reddit and so on)?

What are the most interesting blogs dedicated to embedded development?


问:
How can I refactor a code base while others rapidly commit to it?
I'm on a private project that eventually will become open source. We have a few team members, talented enough with the technologies to build apps, but not dedicated developers who can write clean/beautiful and most importantly long-term maintainable code.

I've set out to refactor the code base, but it's a bit unwieldy as someone in the team out in another country I'm not in regular contact with could be updating this totally separate thing.

I know one solution is to communicate rapidly or adopt better PM practices, but we're just not that big yet. I just want to clean up the code and merge nicely into what he has updated. Would using a branch be a suitable plan? A best-effort-merge? Something else?

答:
tl;dr - Sounds like it's time to step up to the big leagues. Putting lipstick on a pig doesn't make it any prettier, unless you're into that sort of thing...

The people problem

The first issue is commit synchronization. IF you have multiple people working on the same code at the same time you only need one rule to prevent problems:

```<code>Rule 1: Always pull before you merge/rebase
</code>```

When it comes to DVCS, it's hard to make changes to a remote branch (ie the main repository) and very easy to make changes to the local. Every person is responsible for making their own code additions fit into the greater whole without issues. Unless 2 people commit at the exact same time, you shouldn't experience. Commit access to the origin/remote master should be limited to only a few developers and they should pull changes from the other developers via remote tracking branches.

The code problem

How do you know that the changes you make don't break code?

Simple answer... Write tests to prove they don't. If you ignore the TDD (Test Driven Design) school of thought, the whole point of tests is to add a level of verification that enables you to change code without breaking it.

```<code>Rule 2: Don't make assumptions, write proofs (ie tests).
</code>```

In addition to this, the full gamut of tests should be run before you push to the origin/remote master.

Keep your commits as small and concise as possible. That way, if you need to back out a change that broke something later on, you'll save from having to re-implement the parts that didn't break the code.

You may need some organizational re-structuring first

If the above solutions can't easily be applied, there are probably some issues with the development structure that need to be addressed first.

The owner of the project should be the gatekeeper. If there are commit syncing issues, there are probably too many people with commit access. Even on massive projects like the Linux kernel, only a handful of developers have commit access to the origin/remote master repository. There are actually multiple levels of repositories to manage commits. Instead of a single layer commit model where everybody is pushing their changes to the origin, the hierarchical model has gatekeepers that pull changes and verify their quality before inclusion into the project. The hierarchical commit model can scale a lot bigger and more effective than the single layer model without sacrificing quality.

For the devs that don't get commit access, they should learn to create their own remote tracking branches (git and gitorious are good for this) so the devs who do have commit access can easily pull/integrate branches into the origin. If the changes are small, patches will work just as well.

The ability to pull changes before doing a merge/rebase assumes that you're not developing on your local master branch. The easy way to handle this is to make an initial pull before you start to code, then do all your work on that branch. The hard way is to branch it just before merging and roll back the master.

Define the coding style for the project overall and make the devs follow it. Contributing devs should be writing code that conforms to the project's standards/norms to minimize cleanup. Coding style can be a big ego barrier in an open project. If no standard is set, everybody will code in their own preferred style and the codebase will get very ugly very fast.

The myth of "The Mythical Man Month"

Believe it or not, the larger/more successful open source projects aren't run like a democracy. They're run as a hierarchy. Stating that a project can't effectively grow beyond 8-10 developers is naive. If that were true then mega-projects like the Linux Kernel wouldn't exist. The deeper issue is that giving everybody commit access just makes effecive communication too hard to handle.

The problem of the mythical man month can actually be overcome. You just need to run your project like the military. There are many levels within the hierarchy because it's common knowledge that individual people are really only effective at managing communications with a handful of people. As long as no single individual is responsible for managing the work of more than 5-7 people, the system can scale indefinitely.

It may limit the best/experienced developers to doing more integration and higher-level design/planning but that's not a bad thing. Part of scaling up is making the move to decide that the project needs a long-term plan. The people at the highest levels who have the greatest investment (time is also a resource) in the projects future should be charged with making the big decisions.

It's nice to hear about an open source project going through growing pains. Congrats and good luck.

Body:
tl;dr - Sounds like it's time to step up to the big leagues. Putting lipstick on a pig doesn't make it any prettier, unless you're into that sort of thing...

The people problem

The first issue is commit synchronization. IF you have multiple people working on the same code at the same time you only need one rule to prevent problems:

Rule 1: Always pull before you merge/rebase

When it comes to DVCS, it's hard to make changes to a remote branch (ie the main repository) and very easy to make changes to the local. Every person is responsible for making their own code additions fit into the greater whole without issues. Unless 2 people commit at the exact same time, you shouldn't experience. Commit access to the origin/remote master should be limited to only a few developers and they should pull changes from the other developers via remote tracking branches.

The code problem

How do you know that the changes you make don't break code?

Simple answer... Write tests to prove they don't. If you ignore the TDD (Test Driven Design) school of thought, the whole point of tests is to add a level of verification that enables you to change code without breaking it.

Rule 2: Don't make assumptions, write proofs (ie tests).

In addition to this, the full gamut of tests should be run before you push to the origin/remote master.

Keep your commits as small and concise as possible. That way, if you need to back out a change that broke something later on, you'll save from having to re-implement the parts that didn't break the code.

You may need some organizational re-structuring first

If the above solutions can't easily be applied, there are probably some issues with the development structure that need to be addressed first.

The owner of the project should be the gatekeeper. If there are commit syncing issues, there are probably too many people with commit access. Even on massive projects like the Linux kernel, only a handful of developers have commit access to the origin/remote master repository. There are actually multiple levels of repositories to manage commits. Instead of a single layer commit model where everybody is pushing their changes to the origin, the hierarchical model has gatekeepers that pull changes and verify their quality before inclusion into the project. The hierarchical commit model can scale a lot bigger and more effective than the single layer model without sacrificing quality.

For the devs that don't get commit access, they should learn to create their own remote tracking branches (git and gitorious are good for this) so the devs who do have commit access can easily pull/integrate branches into the origin. If the changes are small, patches will work just as well.

The ability to pull changes before doing a merge/rebase assumes that you're not developing on your local master branch. The easy way to handle this is to make an initial pull before you start to code, then do all your work on that branch. The hard way is to branch it just before merging and roll back the master.

Define the coding style for the project overall and make the devs follow it. Contributing devs should be writing code that conforms to the project's standards/norms to minimize cleanup. Coding style can be a big ego barrier in an open project. If no standard is set, everybody will code in their own preferred style and the codebase will get very ugly very fast.

The myth of "The Mythical Man Month"

Believe it or not, the larger/more successful open source projects aren't run like a democracy. They're run as a hierarchy. Stating that a project can't effectively grow beyond 8-10 developers is naive. If that were true then mega-projects like the Linux Kernel wouldn't exist. The deeper issue is that giving everybody commit access just makes effecive communication too hard to handle.

The problem of the mythical man month can actually be overcome. You just need to run your project like the military. There are many levels within the hierarchy because it's common knowledge that individual people are really only effective at managing communications with a handful of people. As long as no single individual is responsible for managing the work of more than 5-7 people, the system can scale indefinitely.

It may limit the best/experienced developers to doing more integration and higher-level design/planning but that's not a bad thing. Part of scaling up is making the move to decide that the project needs a long-term plan. The people at the highest levels who have the greatest investment (time is also a resource) in the projects future should be charged with making the big decisions.

It's nice to hear about an open source project going through growing pains. Congrats and good luck.


问:
Are there any concrete examples of where a paralellizing compiler would provide a value-adding benefit?
Paul Graham argues that:

It would be great if a startup could give us something of the old
  Moore's Law back, by writing software that could make a large number
  of CPUs look to the developer like one very fast CPU. ...
  The most ambitious is to try to do it automatically: to write a
  compiler that will parallelize our code for us. There's a name for
  this compiler, the sufficiently smart compiler, and it is a byword for
  impossibility. But is it really impossible?

Can someone provide a concrete example where a paralellizing compiler would solve a pain point? Web-apps don't appear to be a problem: just run a bunch of Node processes. Real-time raytracing isn't a problem: the programmers are writing multi-threaded, SIMD assembly language quite happily (indeed, some might complain if we make it easier!). The holy grail is to be able to accelerate any program, be it MySQL, Garage Band, or Quicken. I'm looking for a middle ground:
 is there a real-world problem that you have experienced where a "smart-enough" compiler would have provided a real benefit, i.e that someone would pay for?

A good answer is one where there is a process where the computer runs at 100% CPU on a single core for a painful period of time. That time might be 10 seconds, if the task is meant to be quick. It might be 500ms if the task is meant to be interactive. It might be 10 hours. Please describe such a problem.

Really, that's all I'm looking for: candidate areas for further investigation. (Hence, raytracing is off the list because all the low-hanging fruit have been feasted upon.)

I am not interested in why it cannot be done. There are a million people willing to point to the sound reasons why it cannot be done. Such answers are not useful.

答: Scientific computing has many fields where programs can be parallelized, but not easily. One particular example is linear algebra, another fluid dynamics. Parallelizing compilers in these areas are the subject of active research.</p>


问:
Customer relations in agile development
My management just asked an unprecedented question in my (admittedly brief) history with the organization: "What can we do to help you?"

Simultaneously, we're working several big projects for a fairly new client whose ability to push requirements around mid-project is legend. Developing for these guys is like tap dancing on quicksand.

Seems like a prime opportunity to propose a shift to a more agile approach. The thing I know I'm going to get asked, and that I don't have any idea about, is how to quote/bid/bill for that sort of project. Do you go hourly? Do you bid a range of prices? Do you charge by the sprint?

More generally, the aspect of the Agile Manifesto that reads "We value customer collaboration over contract negotiation" is GOING to scare my management. How do you value that in the real world of customers who want a lot for a little?

答:
A customer wants to pay little for a lot isn't going to pay more just because you write up a large set of requirments and get them to sign a contract. They will always come back and want it changed without paying. They'll claim they misunderstood the spec or better yet, you misinterpreted. They will demand changes knowing you won't push back. This is a bad relationship that you don't want to keep going.

If you break up a large project, and get them to pay as you go, it is easier to see that this amount of development costs this amount of money. The next componenent is going to cost the same amount and take the same amount of time to build. When it is all together in a large project, they'll want to get some sort of "bulk" discount.

I've hired someone to do work on my home. Started with a small project. Maybe I could have negotiated a better price by bundling a bunch of jobs together, but what do I do when he's in the middle of 3 projects, doing a poor job and taking longer than expected? I saw the quaility and timeliness of his work. And felt very comfortable having him to other jobs and I didn't have to monitor him. You could have a much better relationship with your clients. They may ask for more because they may feel you're taking advantage of them.

Title: Customer relations in agile development


答:
Actually I did ray tracing for many years. Writing SIMD code is not the same as utilizing multiple cores. Compilers can now "vectorize" a lot of code that previously was done by hand and use the SIMD instructions. For my own efforts I went with OpenMP which allowed the outer loops to be run in parallel on many cores (doing ray per pixel stuff). This could be done automatically by a compiler if it did a LOT of analysis. It turns out that the parallel threads all access the data structures but do not modify them (no side effects), so with much analysis a compiler might decide that the loops could be run concurrently. That is not usually the case and when it is people will probably know it anyway.

Since people have a hard time making parallel programs, I suspect a general algorithm will be hard to find. The trivial cases already have simple tools to help.

From what I understand functional languages should be more parallelizable since they allegedly have no side effects and no state. That sounds like lots of things that could be run in parallel.

Title: Are there any concrete examples of where a paralellizing compiler would provide a value-adding benefit?

Body:
Paul Graham argues that:

It would be great if a startup could give us something of the old
  Moore's Law back, by writing software that could make a large number
  of CPUs look to the developer like one very fast CPU. ...
  The most ambitious is to try to do it automatically: to write a
  compiler that will parallelize our code for us. There's a name for
  this compiler, the sufficiently smart compiler, and it is a byword for
  impossibility. But is it really impossible?

Can someone provide a concrete example where a paralellizing compiler would solve a pain point? Web-apps don't appear to be a problem: just run a bunch of Node processes. Real-time raytracing isn't a problem: the programmers are writing multi-threaded, SIMD assembly language quite happily (indeed, some might complain if we make it easier!). The holy grail is to be able to accelerate any program, be it MySQL, Garage Band, or Quicken. I'm looking for a middle ground:
 is there a real-world problem that you have experienced where a "smart-enough" compiler would have provided a real benefit, i.e that someone would pay for?

A good answer is one where there is a process where the computer runs at 100% CPU on a single core for a painful period of time. That time might be 10 seconds, if the task is meant to be quick. It might be 500ms if the task is meant to be interactive. It might be 10 hours. Please describe such a problem.

Really, that's all I'm looking for: candidate areas for further investigation. (Hence, raytracing is off the list because all the low-hanging fruit have been feasted upon.)

I am not interested in why it cannot be done. There are a million people willing to point to the sound reasons why it cannot be done. Such answers are not useful.


答: I have used some letter to delimit consecutive numbers. For me it would be Ieee802x16bit (not IEEE802x16bit). I think it is less distracting then a lone underbar in the middle of a jungle of letters and digits.

Title: How to camel-case where consecutive words have numbers?

Body:
Just wondering if anybody has a good convention to follow in this corner-corner-corner case.  I really use Java but figured the C# folks might have some good insight too.

Say I am trying to name a class where two consecutive words in the class name are numeric (note that the same question could asked about identifier names).  Can't get a great example, but think of something like "IEEE 802 16 bit value".

Combining consecutive acronyms is doable if you accept classnames such as HttpUrlConnection.  But it seriously makes me throw up a little to think of naming the class IEEE80216BitValue.  If I had to pick, I'd say that's even worse than IEEE802_16BitValue which looks like a bad mistake.  For small numbers, I'd consider IEEE802SixteenBitValue but that doesn't scale that well.

Anyone out there have a convention?  Seems like Microsoft's naming guidelines are the only ones that describe acronym naming in enough detail to get the job done, but nobody has addressed numbers in classnames.


答:
clean/beautiful and most importantly long-term maintainable code.

In my experience clean/beautiful is the enemy of maintainable.  Beautiful code often:

Has a layer on the framework that introduces a higher level of abstraction

Optmizes for code reuse, resulting in a lot of dependencies

Tries to solve the generic problem instead of the specific one

On the other hand, maintainable code:

Is written directly on the framework, so all developers can read it

Optimizes for a low number of dependencies, so a change in one area doesn't impact another

Does not try to solve more problems than it has to

Title: How can I refactor a code base while others rapidly commit to it?

Body:
I'm on a private project that eventually will become open source. We have a few team members, talented enough with the technologies to build apps, but not dedicated developers who can write clean/beautiful and most importantly long-term maintainable code.

I've set out to refactor the code base, but it's a bit unwieldy as someone in the team out in another country I'm not in regular contact with could be updating this totally separate thing.

I know one solution is to communicate rapidly or adopt better PM practices, but we're just not that big yet. I just want to clean up the code and merge nicely into what he has updated. Would using a branch be a suitable plan? A best-effort-merge? Something else?


问:
Any language where every class instance is a class too?
Taking inspiration from Javascript prototypes, I had the idea of a language where every instance can be used as a class.

Before I potentially reinvent the wheel, I would like to ask if there is a language already using this concept:

```<code>//To declare a Class, extend the base class (in this case, Type)
Type(Weapon,{price:0});

//Same syntax to inherit; simply extend the parent:
Weapon(Sword,{price:3});
Weapon(Axe,{price:4});

Sword(Katana,{price:7});
Sword(Dagger,{price:3});

//And the same to create an instance:
Katana(myKatana,{nickname:"Leon"});
myKatana.price; // 7
myKatana.nickname; // Leon

// An operator to return children of a class;
Sword_; // [Katana, Dagger]

// An operator to return array of descendants;
Sword__; // [Katana, Dagger, myKatana]

// An operator to return array of parents;
Sword^; // Weapon

// Arrays can be used as elements
Sword__.price += 1; //increases price of Sword's descendants by 1
mySword.price; //8

// And to access specific element (using its name instead of index)
var name = "mySword"
Katana_[name]; // [mySword]
Katana_[name].nickname; // Leon
</code>```

Has this kind of approach been already studied/implemented?

答: Well I haven't seen a language exactly like yours, but prototype inheritance exists in JavaScript, for example.  Which seems to me to satisfy your "every class instance is a class too".  Unless your requirements are more specific than that.</p>


问:
Promoting ecology and/or sustainability as a programmer
A seemingly odd question, but here it goes. Say that a potential client asks that a certain level of ecology and sustainability is to be respected before they will consider your company for a web site project. How would you go about meeting this requirement?</p>

答: You probably want some equivalent of the Portland, OR based Sustainability at Work program to help you understand the parameters.  You may have a more locally suitable program, but the general framework will be similar enough to answer your general question.</p>


答:
The trouble is in the more mundane fields of computing for which the majority of programs are written:

calculating interest

adding sales tax to a bill

routing an e-mail

liking a picture of a puppy etc.

don't lend themselves to the type of parallel processing used for simulating a hydrogen bomb explosion, or, predicting the path of a hurricane.

For these types of tasks you need to run the logic sequentially to get the correct result. You can however run several individual tasks in parallel, to maximize hardware utilization. This has been common practice even before SMP machines were conceived, and, there is a vast amount of software out there dedicated to running several tasks in parallel from the ancient and venerable CICS, to java EE, and specialized servers like Apache and ASP for web serving.

There are several languages which have features/architectures to aid multi-threading and parallel execution going back to PL/1 recent notable examples are Erlang, Scala and Go.


答:
JavaScript can already do this without the syntax sugar.

Live Example

Note the syntax is significantly uglier. It should be possible to write a DSL on top of JavaScript that uses your syntax

```<code>//To declare a Class, extend the base class (in this case, Type)
var Weapon = create(Object.prototype, {
    price: 0,
    name: "Weapon"
})

//Same syntax to inherit; simply extend the parent:
var Sword = create(Weapon, {
    price: 3,
    name: "Sword"
})
var Axe = create(Weapon, {
    price: 4,
    name: "Axe"
})

var Katana = create(Sword, {
    price: 7,
    name: "Katana"
})
var Dagger = create(Sword, {
    price: 3,
    name: "Dagger"
})

//And the same to create an instance:
var myKatana = create(Katana, {
    nickname: "Leon",
    name: "myKatana"
})
console.log(myKatana.price) // 7
console.log(myKatana.nickname) // Leon

// An operator to return children of a class;
console.log(children(Sword)) // [Katana, Dagger]

// An operator to return array of descendants;
console.log(descendants(Sword)) // [Katana, Dagger, myKatana]

// An operator to return array of parents;
console.log(Object.getPrototypeOf(Sword)); // Weapon

// Arrays can be used as elements
descendants(Sword).forEach(function (proto) {
    if (proto.hasOwnProperty("price")) proto.price += 1
})
console.log(myKatana.price) //8

// And to access specific element (using its name instead of index)
var name = "myKatana"
console.log(children(Katana)[name]) // [mySword]
console.log(children(Katana)[name].nickname) // Leon

function create(proto, props) {
    Object.keys(props).forEach(function (key) {
        props[key] = {
            value: props[key],
            writable: true,
            configurable: true,
            enumerable: true
        }
    })
    var instance = Object.create(proto, props)
    if (!proto.hasOwnProperty("__children__")) {
        proto.__children__ = []
    }
    proto.__children__.push(instance)
    proto.__children__[props.name.value] = instance
    return instance
}

function children(proto) {
    return proto.__children__
}

function descendants(proto) {
    return proto.__children__.reduce(function (memo, value) {
        memo.push(value)
        if (value.hasOwnProperty("__children__")) {
            memo = memo.concat(descendants(value))
        }
        return memo
    }, [])
}
</code>```

Title: Any language where every class instance is a class too?

Body:
Taking inspiration from Javascript prototypes, I had the idea of a language where every instance can be used as a class.

Before I potentially reinvent the wheel, I would like to ask if there is a language already using this concept:

```<code>//To declare a Class, extend the base class (in this case, Type)
Type(Weapon,{price:0});

//Same syntax to inherit; simply extend the parent:
Weapon(Sword,{price:3});
Weapon(Axe,{price:4});

Sword(Katana,{price:7});
Sword(Dagger,{price:3});

//And the same to create an instance:
Katana(myKatana,{nickname:"Leon"});
myKatana.price; // 7
myKatana.nickname; // Leon

// An operator to return children of a class;
Sword_; // [Katana, Dagger]

// An operator to return array of descendants;
Sword__; // [Katana, Dagger, myKatana]

// An operator to return array of parents;
Sword^; // Weapon

// Arrays can be used as elements
Sword__.price += 1; //increases price of Sword's descendants by 1
mySword.price; //8

// And to access specific element (using its name instead of index)
var name = "mySword"
Katana_[name]; // [mySword]
Katana_[name].nickname; // Leon
</code>```

Has this kind of approach been already studied/implemented?

Body:
JavaScript can already do this without the syntax sugar.

Live Example

Note the syntax is significantly uglier. It should be possible to write a DSL on top of JavaScript that uses your syntax

//To declare a Class, extend the base class (in this case, Type)
var Weapon = create(Object.prototype, {
    price: 0,
    name: "Weapon"
})

//Same syntax to inherit; simply extend the parent:
var Sword = create(Weapon, {
    price: 3,
    name: "Sword"
})
var Axe = create(Weapon, {
    price: 4,
    name: "Axe"
})

var Katana = create(Sword, {
    price: 7,
    name: "Katana"
})
var Dagger = create(Sword, {
    price: 3,
    name: "Dagger"
})

//And the same to create an instance:
var myKatana = create(Katana, {
    nickname: "Leon",
    name: "myKatana"
})
console.log(myKatana.price) // 7
console.log(myKatana.nickname) // Leon

// An operator to return children of a class;
console.log(children(Sword)) // [Katana, Dagger]

// An operator to return array of descendants;
console.log(descendants(Sword)) // [Katana, Dagger, myKatana]

// An operator to return array of parents;
console.log(Object.getPrototypeOf(Sword)); // Weapon

// Arrays can be used as elements
descendants(Sword).forEach(function (proto) {
    if (proto.hasOwnProperty("price")) proto.price += 1
})
console.log(myKatana.price) //8

// And to access specific element (using its name instead of index)
var name = "myKatana"
console.log(children(Katana)[name]) // [mySword]
console.log(children(Katana)[name].nickname) // Leon

function create(proto, props) {
    Object.keys(props).forEach(function (key) {
        props[key] = {
            value: props[key],
            writable: true,
            configurable: true,
            enumerable: true
        }
    })
    var instance = Object.create(proto, props)
    if (!proto.hasOwnProperty("__children__")) {
        proto.__children__ = []
    }
    proto.__children__.push(instance)
    proto.__children__[props.name.value] = instance
    return instance
}

function children(proto) {
    return proto.__children__
}

function descendants(proto) {
    return proto.__children__.reduce(function (memo, value) {
        memo.push(value)
        if (value.hasOwnProperty("__children__")) {
            memo = memo.concat(descendants(value))
        }
        return memo
    }, [])
}


问:
Closest to “Mathematica Graphics[]" drawing environment for Python
Being only familiar with Mathematica and its Graphics, I have now to learn to draw Graphics using Python for a server.

Mostly conditional combination of simple shape.

What would be a package for Python that make drawing Graphics as close as possible as the Mathematica Graphics environment ?

For Example, I would need to do such thing as in :

https://mathematica.stackexchange.com/questions/1010/2d-gaussian-distribution-of-squares-coordinates#comment2475_1010

答:
Matplotlib is what you want.

The special sauce is a rendering technology known as agg which i believe stands for anti-grain geometry. The results is that this library produces publication-quality graphics across a staggering range of plot families.

My plot isn't all that much like the one in linked to in your Question, but that's only because the colors are different.

That sort of plot is trivial in Matplotlib. Here's the code i used to create it.

```<code>import numpy as NP
from matplotlib import pyplot as MPL
import matplotlib.cm as CM

M = NP.random.randint(0, 25, 100**2).reshape(100, 100)
M = NP.where(M < 20, 0, M)

fig = MPL.figure(frameon='False')
ax1 = fig.add_subplot(111)
ax1.imshow(M, cmap=CM.Accent, interpolation='nearest')
ax1.set_xticks([])
ax1.set_yticks([])
MPL.show()
</code>```

Body:
Matplotlib is what you want.

The special sauce is a rendering technology known as agg which i believe stands for anti-grain geometry. The results is that this library produces publication-quality graphics across a staggering range of plot families.

My plot isn't all that much like the one in linked to in your Question, but that's only because the colors are different.

That sort of plot is trivial in Matplotlib. Here's the code i used to create it.

import numpy as NP
from matplotlib import pyplot as MPL
import matplotlib.cm as CM

M = NP.random.randint(0, 25, 100**2).reshape(100, 100)
M = NP.where(M < 20, 0, M)

fig = MPL.figure(frameon='False')
ax1 = fig.add_subplot(111)
ax1.imshow(M, cmap=CM.Accent, interpolation='nearest')
ax1.set_xticks([])
ax1.set_yticks([])
MPL.show()


答:
Aren't you, maybe, overthinking this concern a little?

Anyway: in the past I saw people advocating black, dark, and grey web designs, with the rationale that it consumes less energy. This could have had made a very little sense with CRT monitors, (though the save was pretty negligible and all) with LCD displays it is now complete nonsense. (backlight: always on)

Promoting the usage of less videos on the web, in general, might make sense. Adobe flash kinda hogs GPUs, (not to the point of warming the planet, but it certainly roasted my thigh) and server infrastructures for serving videos are pretty hefty and power consuming.

The only serious, meaningful discussion I ever saw on environmental consciousness / energy saving in web computing, to date, came from Facebook: the Open Compute Project, with whom they really tried to distance themselves from those loud-screaming turbines most vendors roll out and sell as rack servers.

Here's the video they used to introduce the OCP.

And some of the ideas they implemented (in Prineville, Oregon) and shared:

bigger centralized fans moving slower, conveying air efficiently.

bare bones and almost fanless servers (they cool the environment, and the cabinets, not the single servers) that are greener to produce (e.g. no paint)

a clever cooling system that uses water-cooled air flowing from the floor to the roof instead of conventional air conditioning.

They are also saying they chose Sweden for their next data center, deliberately because of the cold weather, and they intend to exploit it for cooling.

Anyway Dell, HP, Rackspace, Skype, and Zynga are now known to have joined the OCP. And yes many of them seem more part of the problem than of the solution, but at least now they are asking themselves some good questions. And yes, Greenpeace approves of all of this.

A really, really, really, environmentally conscious client, then, could choose to look for an OCP data center to host his apps on, but given the not-so-established state of the art, and the price increase such a choice would imply right now, I suppose most of those would just postpone their "getting green" to a future, unestablished, date.

Title: Promoting ecology and/or sustainability as a programmer

Body: A seemingly odd question, but here it goes. Say that a potential client asks that a certain level of ecology and sustainability is to be respected before they will consider your company for a web site project. How would you go about meeting this requirement?</p>


问:
How do I handle priority and propagation in an event system?
Let's say I have a simple event system with the following syntax:

```<code>object = new Object();
object.bind("my_trigger", function()  { print "hello"; });
object.bind("my_trigger", function()  { print "hello2"; });
object.trigger("my_trigger");
</code>```

How could I make sure hello2 is printed out first? (I do not want my code to depend on which order the events were bind).

On top of that, how would I prevent my events from propagating? (e.g. I want to stop every other event from being executed)

答:
I'm thinking a chain-like design would be sufficient.

Here is a quick example of what I'm trying to describe, in Scala.

```<code>object Main extends App {

  // Event 1 - Prints Hello and doesn't break the chain
  val event1 = new Event {
    override def trigger = { println("Hello"); continue }
  }

  // Event 2 - Prints Hello2 but breaks the chain
  val event2 = new Event {
    override def trigger = { println("Hello2"); stop }
  }

  // Create new EventChain
  val eventChain = new EventChain

  // Add event1, then event2 at the beginning
  eventChain.addFirst(event1).addFirst(event2)

  // Bind the event chain to the identifier
  EventManager.bind("my_trigger", eventChain)

  // Trigger a new event
  EventManager.trigger("my_trigger")
}

object EventManager {

  // Keeps track of trigger bindings
  var events = Map[String, EventChain]()

  // Binds a trigger
  def bind(id: String, chain: EventChain) {
    events += ((id, chain))
  }

  // Triggers an EventChain
  def trigger(id: String) {
    events.find(e => e._1 == id) match {
      case Some(event) => event._2.trigger
      case None =>
    }
  }
}

// An event
abstract class Event {
  // Your response here
  def trigger: Boolean;

  // To continue
  def continue = true

  // To break the chain
  def stop = false
}

class EventChain {
  // List of Events
  private var events = List[Event]()

  // Adds an event to the beginning
  def addFirst(event: Event) = {
    events ::= event
    this
  }

  // Triggers the EventChain
  def trigger {

    var continue = true
    val itr = events.iterator

    // While it isn't broken and has another event
    while (continue && itr.hasNext) {
      // Assign the return value to continue
      continue = itr.next.trigger
    }
  }
}
</code>```

Body:
I'm thinking a chain-like design would be sufficient.

Here is a quick example of what I'm trying to describe, in Scala.

object Main extends App {

  // Event 1 - Prints Hello and doesn't break the chain
  val event1 = new Event {
    override def trigger = { println("Hello"); continue }
  }

  // Event 2 - Prints Hello2 but breaks the chain
  val event2 = new Event {
    override def trigger = { println("Hello2"); stop }
  }

  // Create new EventChain
  val eventChain = new EventChain

  // Add event1, then event2 at the beginning
  eventChain.addFirst(event1).addFirst(event2)

  // Bind the event chain to the identifier
  EventManager.bind("my_trigger", eventChain)

  // Trigger a new event
  EventManager.trigger("my_trigger")
}

object EventManager {

  // Keeps track of trigger bindings
  var events = Map[String, EventChain]()

  // Binds a trigger
  def bind(id: String, chain: EventChain) {
    events += ((id, chain))
  }

  // Triggers an EventChain
  def trigger(id: String) {
    events.find(e => e._1 == id) match {
      case Some(event) => event._2.trigger
      case None =>
    }
  }
}

// An event
abstract class Event {
  // Your response here
  def trigger: Boolean;

  // To continue
  def continue = true

  // To break the chain
  def stop = false
}

class EventChain {
  // List of Events
  private var events = List[Event]()

  // Adds an event to the beginning
  def addFirst(event: Event) = {
    events ::= event
    this
  }

  // Triggers the EventChain
  def trigger {

    var continue = true
    val itr = events.iterator

    // While it isn't broken and has another event
    while (continue && itr.hasNext) {
      // Assign the return value to continue
      continue = itr.next.trigger
    }
  }
}


问:
Where should you store variables for a search program in java?
I'm wondering which is a more effective storage method in java. Would be better to save constants  in a class or a resource? The constants will be searched later by my Search program which will go through the list of constants so as to recognize possible options. Also if there is a more efficient method of storing them please say so or if i doesn't matter where i store them.

1). A java class called Search is going to be inputted with two or more constants they will then either access a java class that will redirect them as needed.

2). Search will receive the same information but will look to a external resource to see what possible files match it then corresponding what info was give will open a pathway to the java class it correlated.

Which version should be better or will it not matter?

the values the constants contain are going to be ints but each int will have their own unique meaning.

To clarify why i need these arrays each number  is going to have a meaning and the arraylists will hold the numbers like 1 may mean work 2 may mean private and so a private work document would have name PDocument has [1,2] so on and so on
hope that clarifies

So which option is more effecient #1 or #2

答:
It sounds like you are talking about variables that will hold constant values. These variables should be declared in the your class that handles the searching.

EX:

```<code>private static final int SearchType1 = 0;
</code>```

You could also create an enum type that will hold your search constants

EX:

```<code>public enum SearchTypes {
    SearchType1,
    SearchType2
}
</code>```

where SearchType1 will be 0, and SearchType2 will be 1

Body:
It sounds like you are talking about variables that will hold constant values. These variables should be declared in the your class that handles the searching.

EX:

private static final int SearchType1 = 0;

You could also create an enum type that will hold your search constants

EX:

public enum SearchTypes {
    SearchType1,
    SearchType2
}

where SearchType1 will be 0, and SearchType2 will be 1


问:
x86 segmentation and threading
Is some connection between using x86 segmentation and a possible implementation a thread package? I've been told that usually x86 segmentation is implemented in operating systems these days with an identity function (0 offset, unlimited limit), but can segmentation somehow be useful when dealing with multithreading?</p>

答:
So I found out that one interesting use of segmentation in thread packages (not saying this is actually done anywhere, but it's at least a potential use) is to manipulate the stack segment so that threads within a single process can share an address space, but not collide on the same stack. Each thread has its own stack, but the code running in the thread doesn't have to know where its stack is--if it doesn't try to manipulate its own stack segment register, the register will be set when it starts to point to an entry in the LDT, which leads it to some stack designated specifically for it in the process's address space.

This is similar to how I imagine kernels work when they run on a system with multiple cores. When an interrupt or exception occurs on one core, stuff gets pushed the kernel stack by the hardware--but this could mess up the stack if the kernel is also running on other cores at the moment that the exception/interrupt occurs. Instead, each core's kernel could have a separate stack, designated by entries in the IDT and GDT.

Title: x86 segmentation and threading


问:
MySQL with mutiple threads and processes
I'm developing a telecom messaging platform in C, and I'm going to need multiple processes to be working with MySQL DB.

How can I make two processes read/write to/from a Mysql DB and, if/when one of them goes down, get the other to seamlessly take over the work until the dead process gets back to work? I was thinking/googling some options and am stuck in place where I don't know which one to choose.

What I think so far is that table lock is not the best option to go for, as it will stall the other process until the table is unlocked. The other option is to use row-level locks or manual locks, but I can't find the best way to do it.

答:
You can have a look to these resources:

MySQL: Transactions across multiple threads

How we enabled threading in MySQL

MySQL Reference Manual – Server System Variables: thread_concurrency


问:
Why should we use low level languages if a high level one like python can do almost everything?
I know python is not suitable for things like microcontrolers, make drivers etc, but besides that, you can do everything using python, companys get stuck with speed optimizations for real hard time system but does forget other factors which one you can just upgrade your hardware for speed proposes in order to get your python program fit in it, if you think how much cust can the company have to maintain  a system written in C, the comparison is like that:
for example: 10 programmers to mantain a system written in c
and just one programmer to mantain a system written in python,
with python you can buy some better hardware to fit your python program, I think that low level languages tend to get more cost, since programmers aren't so cheaply than a hardware upgrade,
then, this is my point, why should a system be written in c instead of python?

答:
Some observations:

The huge trend in computing is mobile, which from several aspects is not far from microcontroller and embedded system development. Python is not yet the dedicated language for iOS, Android or Windows Phone 7.

In desktop computing, getting faster hardware is more and more difficult: CPU speed is stuck aroud 3GHz and getting all the power of multiple cores is far from easy. Low level languages have an advantage over Python here.

About maintainability, the 10:1 ratio may be true with just-graduated people who have never been exposed to C but know Python and Ruby and all other new languages. For the majority of senior developers, the ratio doesn't favour Python.

Some years ago, everything could be made in Java and be portable at the same time. Some years before, it was Perl. Clearly the actual winners these days are C, C++, C# and Objective-C.


答:
I'm not 100% sure it's an exact match for your description, but based on your examples this seems fairly close to the io language.

More specifically, since you always create new "subclasses" in io by cloning an existing object, you're always able to treat any "subclass" as a distinct type upon which to base instances.

For some additional, hopefully clarifying, information, this section of the docs is probably the most relevant:

http://www.iolanguage.com/scm/io/docs/IoGuide.html#Objects-Inheritance


问:
How can a PHP programmer best prepare for a C++ course?
I have never programmed in C++, but am going to be taking a class that involves programming in C++ in January. I want to be able to excel in the class, and looking for advice, as I come from a PHP background. How can I best prepare myself for success?</p>

答:
I took a series of Java programming classes a few years ago after working mostly with PHP for five years. In my case, I attended a community college.

The best advice I have is to stick with it. The first few weeks will undoubtedly be a little boring, but if you are inattentive, you may miss important key concepts. Don't be afraid to ask you instructor if you don't understand something and be careful not to rely too much on prior knowledge if you are unclear on what is being taught. That being said you are likely to find instruction on basic syntax redundant.

If you want to excel, read a chapter or two ahead before going to lecture and come to class armed with a question or two. A good attitude will help you learn. Also, speak with the instructor about your PHP knowledge before the class starts or after the first lecture. If enough people in your class are already programmers, your instructor may pace the class differently than if everyone is new to coding.


问:
Organizing MVC entities communication
I have the following situation. Imagine you have a MainWindow object who is layouting two different widgets, ListWidget and DisplayWidget. ListWidget is populated with data from the disk. DisplayWidget shows the details of the selection the user performs in the ListWidget.

I am planning to do the following: in MainWindow I have the following objects:

ListWidget

ListView

ListModel

ListController

ListView is initialized passing the ListWidget. ListViewController is initialized passing the View and the Model.

Same happens for the DisplayWidget:

DisplayWidget

DisplayView

DisplayModel

DisplayController

I initialize the DisplayView with the widget, and initialize the Model with the ListController. I do this because the DisplayModel wraps the ListController to get the information about the current selection, and the data to be displayed in the DisplayView.

I am very rusty with MVC, being out of UI programming since a while. Is this the expected interaction layout for having different MVC triplets communicate ? In other words, MVC focus on the interaction of three objects. How do you put this interaction as a whole into a larger context of communication with other similar entities, MVC or not ?

答: HMVC might be what you are looking for. It's specially good when it comes to widgetry since it encourages decomposition on the client's side (i.e. view).

Title: Organizing MVC entities communication


答:
Pointers, sir

Binky will help you.

OOP

Hoping that you are a good PHP developer and you have used classes (i.e. object oriented programming) you'll be pretty much conceptually ready to take on other concepts such as inheritance and polymorphism.

Title: How can a PHP programmer best prepare for a C++ course?

Body: I have never programmed in C++, but am going to be taking a class that involves programming in C++ in January. I want to be able to excel in the class, and looking for advice, as I come from a PHP background. How can I best prepare myself for success?</p>


答:
Would be better to save variables that will not change in a class or a resource?

By definition, a variable is something which will change over time. If it will not change, it is a constant.

Your description sounds, as if there is a index of keywords or topics for documents:

To clarify why i need these arrays each number is going to have a meaning and the arraylists will hold the numbers like 1 may mean work 2 may mean private and so a private work document would have name PDocument has [1,2] so on and so on hope that clarifies

Such keywords or topics may change over time, and then you can't modify them without recompiling the code, if you use enums in your class. Even if the today requirement says, they will not change: In the long run most requirements change. And you might try to solve a different problem, where the list of keywords/topics grows over time.

A map which can be extended, and is read from a file is more flexible.

Title: Where should you store variables for a search program in java?

Body:
I'm wondering which is a more effective storage method in java. Would be better to save constants  in a class or a resource? The constants will be searched later by my Search program which will go through the list of constants so as to recognize possible options. Also if there is a more efficient method of storing them please say so or if i doesn't matter where i store them.

1). A java class called Search is going to be inputted with two or more constants they will then either access a java class that will redirect them as needed.

2). Search will receive the same information but will look to a external resource to see what possible files match it then corresponding what info was give will open a pathway to the java class it correlated.

Which version should be better or will it not matter?

the values the constants contain are going to be ints but each int will have their own unique meaning.

To clarify why i need these arrays each number  is going to have a meaning and the arraylists will hold the numbers like 1 may mean work 2 may mean private and so a private work document would have name PDocument has [1,2] so on and so on
hope that clarifies

So which option is more effecient #1 or #2


问:
How to camel-case where consecutive words have numbers?
Just wondering if anybody has a good convention to follow in this corner-corner-corner case.  I really use Java but figured the C# folks might have some good insight too.

Say I am trying to name a class where two consecutive words in the class name are numeric (note that the same question could asked about identifier names).  Can't get a great example, but think of something like "IEEE 802 16 bit value".

Combining consecutive acronyms is doable if you accept classnames such as HttpUrlConnection.  But it seriously makes me throw up a little to think of naming the class IEEE80216BitValue.  If I had to pick, I'd say that's even worse than IEEE802_16BitValue which looks like a bad mistake.  For small numbers, I'd consider IEEE802SixteenBitValue but that doesn't scale that well.

Anyone out there have a convention?  Seems like Microsoft's naming guidelines are the only ones that describe acronym naming in enough detail to get the job done, but nobody has addressed numbers in classnames.

答: I'd personally go for the underscore route e.g. IEEE_802_16_BitValue.  Currently dealing with modelling some CPU architectures, this Q was good timing :-)


问:
Does MVC apply only to web
It is almost and instantaneous whenever I talk to developers about Model View Controller (MVC) they say you make a request to a url the server builds a entity (MODEL) and provides you with visual representation of that model.

So does this mean MVC is only for the web or have I been meeting people who are just developers who employ MVC for writing web applications?

Are there usages for MVC on desktop style applications?

I for one am new to paradigm and would like to know of any super-set to MVC

答: No, development for OS X and iOS uses Model View Controller pattern.</p>

Title: Does MVC apply only to web


答:
MVC is a pattern. Patterns apply across all programming. MVC just happens to work very well in a web context.

As gnat points out just have a look at the mvc tag and you will see multiple examples of it being implemented.

Title: Does MVC apply only to web

Body:
It is almost and instantaneous whenever I talk to developers about Model View Controller (MVC) they say you make a request to a url the server builds a entity (MODEL) and provides you with visual representation of that model.

So does this mean MVC is only for the web or have I been meeting people who are just developers who employ MVC for writing web applications?

Are there usages for MVC on desktop style applications?

I for one am new to paradigm and would like to know of any super-set to MVC


问:
Why is the Select before the From in an SQL query?
This is something that bothered me a lot at school.

Five years ago, when I learned SQL, I always wondered why we first specify the fields we want and then where we want them from.

According to my idea, we should write:

```<code>From Employee e
Select e.Name
</code>```

So why does the norm say the following?

```<code>Select e.Name -- Eeeeek, what does e mean?
From Employee e -- Ok, now I know what e is
</code>```

It took me weeks to understand SQL, and I know that a lot of that time was consumed by the wrong order of elements.

It is like writing in C#:

```<code>string name = employee.Name;
var employee = this.GetEmployee();
</code>```

So, I assume that it has a historical reason. Why?

答:
SQL statements begin with verbs. That was the choice of the language designers, and many programming languages work that way. Semantically, it is not uncommon to see programming languages that work like this:

```<code>verb(noun, noun, noun);
</code>```

Also, in the case of SELECT statement that you give as an example, your proposed syntax would put the object first in the statement. Instead of a VSO (verb, subject, object) sentence order, you would have OVS, which would be a very strange when compared to natural languages. SVO (e.g. English), VSO (e.g. Arabic), and SOV (e.g. Latin) are more reasonable approximations of human speech.

Body:
SQL statements begin with verbs. That was the choice of the language designers, and many programming languages work that way. Semantically, it is not uncommon to see programming languages that work like this:

verb(noun, noun, noun);

Also, in the case of SELECT statement that you give as an example, your proposed syntax would put the object first in the statement. Instead of a VSO (verb, subject, object) sentence order, you would have OVS, which would be a very strange when compared to natural languages. SVO (e.g. English), VSO (e.g. Arabic), and SOV (e.g. Latin) are more reasonable approximations of human speech.


答: Considering that MVC is from 1977, and the web was only invented in 1991, it should be pretty obvious that MVC is not only for the web.

Title: Does MVC apply only to web


答:
I work for a helicopter company we do lots of work for major utility companies in the UK. They require us to have an envionmental protection system very similar to a health and safety system.

ISO 14000 may be rather overblown for your company, but it may well point you in the right direction
http://www.iso.org/iso/iso_14000_essentials

From my experience, they are looking for companies that take a systematic aproach to environmental protection rather than specific requirements.


答: I'd create a pub/sub type class, that will aggregate all the subscriptions, along with a priority, and then publish each event by priority, so rather than subscribing to the object itself, you'd subscribe to the manager class</p>

Title: How do I handle priority and propagation in an event system?

Body:
Let's say I have a simple event system with the following syntax:

```<code>object = new Object();
object.bind("my_trigger", function()  { print "hello"; });
object.bind("my_trigger", function()  { print "hello2"; });
object.trigger("my_trigger");
</code>```

How could I make sure hello2 is printed out first? (I do not want my code to depend on which order the events were bind).

On top of that, how would I prevent my events from propagating? (e.g. I want to stop every other event from being executed)


答:
Ask the question in a Microsoft environment and many people will assume you mean Asp.Net MVC which is an MVC implementation specifically for the web.

Unfortunately there are many people who do not realise that this is an implementation of the MVC pattern and think they are interchangeable terms, which leads to an assumption of "web only".

Title: Does MVC apply only to web


问:
Do ORMs enable the creation of rich domain models?
After using Hibernate on most of my projects for about 8 years, I've landed on a company that discourages its use and wants applications to only interact with the DB through stored procedures.

After doing this for a couple of weeks, I haven't been able to create a rich domain model of the application I'm starting to build, and the application just looks like a (horrible) transactional script.

Some of the issues I've found are:

Cannot navigate object graph as the stored procedures just load the minimum amount of data, which means that sometimes we have similar objects with different fields. One example is: we have a stored procedure to retrieve all the data  from a customer, and another to retrieve account information plus a few fields from the customer.

Lots of the logic ends up in helper classes, so the code becomes more structured (with entities used as old C structs).

More boring scaffolding code, as there's no framework that extracts result sets from a stored procedure and puts it in an entity.

My questions are:

has anyone been in a similar situation and didn't agree with the store procedure approach? what did you do?

Is there an actual benefit of using stored procedures? apart from the silly point of "no one can issue a drop table".

Is there a way to create a rich domain using stored procedures? I know that there's the possibility of using AOP to inject DAOs/Repositories into entities to be able to navigate the object graph. I don't like this option as it's very close to voodoo.

Conclusion

First, thank you all for your answers. The conclusion that I've arrived is that ORMs don't enable the creation of Rich Domain models (as some people mentioned), but it does simplify the the amount of (often repetitive) work. The following is a more detailed explanation of the conclusion, but is not based on any hard data.

Most applications request and send information to other systems. To do this, we create an abstraction in the model terms (e.g. a business event) and the domain model sends or receives the event. The event usually needs a small subset of information from the model, but not the whole model. For example in a online shop, a payment gateway requests some user information and the total to charge a user, but doesn't require the purchase history, available products, and all the customer base. So the event has a small and specific set of data.

If we take the database of an application as an external system, then we need to create an abstraction that allows us to map the Domain Model entities to the database (as NimChimpsky mentioned, using a data-mapper). The obvious difference, is that now we need to handcraft a mapping for each model entity to the database (either a legacy schema or stored procedures), with the extra pain that, since the two are not in sync, one domain entity might map partially to a database entity (e.g a UserCredentials class that only contains username and password is mapped to a Users table that has other columns), or one domain model entity might map to more than one database entity (for example if there's a one-to-one mapping on the table, but we want all the data in just one class).

In an application with a few entities, the amount of extra work might be small if there's no need to transverse the entities, but it increases when there's a conditional need to transverse the entities (and thus we might want to implement some kind of 'lazy loading'). As an application grows to have more entities, this work just increases (and I have the feeling that it increases non-linearly). My assumption here, is that we don't try to reinvent an ORM.

One benefit of treating the DB as an external system, is that we can code around situations in which we want 2 different versions of an application running, in which each application has a different mapping. This becomes more interesting in the scenario of continuous deliveries to production... but I think this is also possible with ORMs to a lesser extent.

I'm going to dismiss the security aspect, on the basis that a developer, even if he doesn't have access to the database, can obtain most if not all the information stored in a system, just by injecting malicious code (eg. I can't believe I forgot to remove the line that logs the credit card details of the customers, dear lord!).

Small update (6/6/2012)

Stored procedures (at least in Oracle) prevent doing anything like continuous delivery with Zero downtime, as any change to the structure of the tables will invalidate the procedures and triggers. So during the time that the DB is being updated, the application will be down too.
Oracle provides a solution for this called Edition-Based Redefinition, but the few DBAs I've asked about this feature mentioned that it was poorly implmented and they wouldn't put it in a production DB.

答: Your domain objects can be populated however you please, its not neccesary to use Hibernate. I think the proper term is data-mapper. Its very possible that your persisted data will be completely different structure to your domain objects.</p>


答:
Stored procedures are very much more efficient than and client-side SQL code. They pre-compile SQL in the DB which also allows it to perform some optimisations.

Architecturally, a SP will return the minimum data required for a task, which is good as it means less data is being transferred. If you've got such an architecture, you need to think of the DB as a service (think of it as a web service and each SP is a method to call). It shouldn't be a problem to work with it like this, whereas an ORM guides you into working with remote data as if it was local, thus tricking you into introducing performance issues if you're not careful.

I've been in situations where we used SPs completely, the DB provided a data API and we used it. That particular app was very large scale and performed amazingly well. I won't have anything bad said about SPs after that!

There's another advantage - the DBAs will write all your SQL queries for you, and will happily handle all the relational hierarchy in the DB, so you don't have to.

Title: Do ORMs enable the creation of rich domain models?

Body:
After using Hibernate on most of my projects for about 8 years, I've landed on a company that discourages its use and wants applications to only interact with the DB through stored procedures.

After doing this for a couple of weeks, I haven't been able to create a rich domain model of the application I'm starting to build, and the application just looks like a (horrible) transactional script.

Some of the issues I've found are:

Cannot navigate object graph as the stored procedures just load the minimum amount of data, which means that sometimes we have similar objects with different fields. One example is: we have a stored procedure to retrieve all the data  from a customer, and another to retrieve account information plus a few fields from the customer.

Lots of the logic ends up in helper classes, so the code becomes more structured (with entities used as old C structs).

More boring scaffolding code, as there's no framework that extracts result sets from a stored procedure and puts it in an entity.

My questions are:

has anyone been in a similar situation and didn't agree with the store procedure approach? what did you do?

Is there an actual benefit of using stored procedures? apart from the silly point of "no one can issue a drop table".

Is there a way to create a rich domain using stored procedures? I know that there's the possibility of using AOP to inject DAOs/Repositories into entities to be able to navigate the object graph. I don't like this option as it's very close to voodoo.

Conclusion

First, thank you all for your answers. The conclusion that I've arrived is that ORMs don't enable the creation of Rich Domain models (as some people mentioned), but it does simplify the the amount of (often repetitive) work. The following is a more detailed explanation of the conclusion, but is not based on any hard data.

Most applications request and send information to other systems. To do this, we create an abstraction in the model terms (e.g. a business event) and the domain model sends or receives the event. The event usually needs a small subset of information from the model, but not the whole model. For example in a online shop, a payment gateway requests some user information and the total to charge a user, but doesn't require the purchase history, available products, and all the customer base. So the event has a small and specific set of data.

If we take the database of an application as an external system, then we need to create an abstraction that allows us to map the Domain Model entities to the database (as NimChimpsky mentioned, using a data-mapper). The obvious difference, is that now we need to handcraft a mapping for each model entity to the database (either a legacy schema or stored procedures), with the extra pain that, since the two are not in sync, one domain entity might map partially to a database entity (e.g a UserCredentials class that only contains username and password is mapped to a Users table that has other columns), or one domain model entity might map to more than one database entity (for example if there's a one-to-one mapping on the table, but we want all the data in just one class).

In an application with a few entities, the amount of extra work might be small if there's no need to transverse the entities, but it increases when there's a conditional need to transverse the entities (and thus we might want to implement some kind of 'lazy loading'). As an application grows to have more entities, this work just increases (and I have the feeling that it increases non-linearly). My assumption here, is that we don't try to reinvent an ORM.

One benefit of treating the DB as an external system, is that we can code around situations in which we want 2 different versions of an application running, in which each application has a different mapping. This becomes more interesting in the scenario of continuous deliveries to production... but I think this is also possible with ORMs to a lesser extent.

I'm going to dismiss the security aspect, on the basis that a developer, even if he doesn't have access to the database, can obtain most if not all the information stored in a system, just by injecting malicious code (eg. I can't believe I forgot to remove the line that logs the credit card details of the customers, dear lord!).

Small update (6/6/2012)

Stored procedures (at least in Oracle) prevent doing anything like continuous delivery with Zero downtime, as any change to the structure of the tables will invalidate the procedures and triggers. So during the time that the DB is being updated, the application will be down too.
Oracle provides a solution for this called Edition-Based Redefinition, but the few DBAs I've asked about this feature mentioned that it was poorly implmented and they wouldn't put it in a production DB.


答:
What often happens is that developers incorrectly use their ORM objects as their domain models.

This is incorrect, and ties your domain directly to your DB schema.

What should really have is seperate domain models as rich as you like and use the ORM layer seperately.

This means you will need mapping between each set of objects.


答: Your application should still be modelled from domain driven design principles.  Whether you use an ORM, straight JDBC, calling SPs (or whatever) should not matter. Hopefully a thin layer abstracting your model from the SPs should do the trick in this case. As another poster stated, you should view the SPs and their results as a service and map the results to your domain model.


问:
Copyrights concerning code snippets and larger amounts of code
I am designing a public code repository. Users will be allowed to post and edit whatever amount of code they want, from code snippets to entire multi-file projects. I have a few major legal concerns about this:

Not getting sued/shut down - I feel the site would be a much easier target than tracking down an individual user to sue. I have looked around a bit and see links to legal info in the footer of each page is common. What specific things should I do--and what does does a site such as YouTube (which I see copyrighted material on all the time) do--for protection?

Citing sources and editing sourced code - If a user wants to post code that isn't theirs, what concerns/safeguards should I have? Will a link suffice, and what do I need further to allow the code to be edited (to improve it for example)? What can happen if a user posts copyrighted code without citing it?

Large chunks of code - What legal differences should I look out for as the amount grows?

Not having a mess of licenses for the site - I would like to have a single license (like RosettaCode) that keeps things simple for interaction on the site. I want the code to be postable and editable. I have looked into StackOverflow's CreativeCommons license a little and it says that

If you alter, transform, or build upon this work, you may distribute
  the resulting work only under the same or similar license to this one.

And on RosettaCode:

All software found on Rosetta Code should be considered potentially
  hazardous. Use at your own risk. Be aware that all code on Rosetta
  Code is under the GNU Free Documentation License, as are any edits
  made by contributors. See Rosetta Code:Copyrights for details.

What other licenses are like this?

Commercializing the site - In what ways can I and can't I make money off of a site that contains code like this? All code will be publicly visible. Initial thoughts are having ads or making money by charging for advanced features.

答:
You are right to be concerned.  In many situations when somebody writes a block of code they are automatically given a copyright to it.  So you have to make sure the people posting said code to your website, agree they have the right to do so, otherwise you will be the next pastebin when the script kidies strike again.

and what does does a site such as YouTube (which I see copyrighted
  material on all the time) do--for protection?

Basically...They remove any content that is reported as being copyrighted.  You will have come up with a review process and remove any code that you believe should not be made public.

Large chunks of code - What legal differences should I look out for
  as the amount grows?

Your concerns remain the same, how you deal with violations might change, 10 lines of code owned by Microsoft will get you sued just as the entire source code for Windows would get you used by Microsoft.

Commercializing the site - In what ways can I and can't I make money
  off of a site that contains code like this? All code will be publicly
  visible. Initial thoughts are having ads or making money by charging
  for advanced features.

There are tons of questions like this, that is entirely up to you, there isn't a correct answer.

Not having a mess of licenses for the site - I would like to have a
  single license (like RosettaCode) that keeps things simple for
  interaction on the site. I want the code to be postable and editable.

So use a license that keeps the code postable and editable.  Since your website will not own the content ( unless you want to claim ownership ) just keep the license simple.