问:
Is it unreasonable to write user documentation in the style of a technical book?
Tell me if this sounds familiar:

something something something... as seen in figure 1-1 on the next page...

It's in practically every book I've ever read about programming. So when I was writing a small instructional booklet on how to use some in-house software, which had images of the screen that the user will be on at this certain step I wrote something like "The screen that pops up looks like the one shown in figure 1-1 below."

But I'm thinking: I'm used to that style of writing, but if my target audience is the 'average person' are they going to be confused?

So, more generally, are there any common practices in technical books that should be avoided when writing documentation for average people?

答:
There are a lot of books describing styles and giving advices on technical writing, but when publishing a book, I think it is a publisher's decision, as to how many pictures it will have (images affect publishing costs), and that can also somewhat influence your style of writing (whether you will reference Figure 1-1 several times, or whether it will always appear below the text, as in a tutorial).

For example, books dealing with courses of CAD tools often choose, for clarity and ease of use the second approach (because user doesn't want to flip pages all the time, but to follow the process of generating a design, for example).

Programming books, from what I've seen more often follow the first example. Since images usually serve only as an aid to the text, the user will get most of its information from the text itself. Therefore, referencing a figure several times is acceptable.

Hope this makes some sense ...


问:
Is programming or computer science in general, all about algorithms?
As a grad student, I find it more and more common for prestigious companies (like Google, Facebook, Microsoft,...) to put algorithm questions in their test and interviews. A few startups I applied to also asked about algorithms. I wonder if algorithms fluency is the most important thing for software developer in those companies?

If the answer being yes, what are the best method or resources for one to learn & practice about algorithms effectively? I can't seem to get interested in solving seemingly too complicated problems found in most textbook or websites. Though easily understand basic algorithms (like quicksort, bubblesort,...), I find it immensely difficult to remember and reuse them later.

Thanks.

P/S: If you ask me what I like, it's building good softwares to solve users' problems innovatively. I suppose that does not necessarily mean the software has to be very complicated.

答:
The answer is entirely dependent on the work you are pursuing. Some fields are particularly more algorithm focused than others. Speaking to that note though I had the pleasure to interview with Amazon multiple times. Even though the position would have little to do with these complex algorithms I was grilled on how to make a task amortized constant time.

What proving a strong understanding of algorithms provides is proof to your potential employer that you are an apt problem solver. It isn't really a good indicator (IMO) of a good employee but some employers use this for screening. If you are applying for a position that requires a graduate degree you are going to be expected to have a more rigorous foundation in algorithms.

What (IMO) is immensely helpful in practice isn't to memorize specific algorithms but through understanding how some algorithms work there is this small nugget in the back of your mind where you will say "I have seen this before" or "I know I can do this better" which will spawn a bit of research on the solution to your problem.

ContentLicense: CC BY-SA 3.0


答:
In general, programming as a job is not about algorithms. You can spend years programming CRUD applications without requiring deep algorithmic skills.

Programming as a job is about:

Communication:

Your source code is a mean of communicating your ideas to your peers. If nobody can read/understand your code, it's worthless.

A lone developer who doesn't speak to any other developer would probably start doing mistakes in code and believe that his own approach is the only acceptable one.

You must know how to communicate with stakeholders, QA department, users, visual designers, DBAs, etc.

As an experienced developer, you must teach less experienced colleagues who wish improving their skills.

Knowledge of the right tools: version control, bug tracking system, IDEs, which language is better suited for a specific task and why, how to use code analysis, etc.

Broad knowledge and culture: what are functional languages? How computers interpret code? Why LOC is a meaningless measure? etc.

Deep knowledge of the language(s) you work with.

Algorithms.

Computer Science, on the other hand, is more oriented to algorithms. If you work as a scientist, this may have nothing to do with a job of a developer, and you'll work more on how to optimize an algorithm, how to transform a data representation into another, etc.

Title: Is programming or computer science in general, all about algorithms?

Body:
As a grad student, I find it more and more common for prestigious companies (like Google, Facebook, Microsoft,...) to put algorithm questions in their test and interviews. A few startups I applied to also asked about algorithms. I wonder if algorithms fluency is the most important thing for software developer in those companies?

If the answer being yes, what are the best method or resources for one to learn & practice about algorithms effectively? I can't seem to get interested in solving seemingly too complicated problems found in most textbook or websites. Though easily understand basic algorithms (like quicksort, bubblesort,...), I find it immensely difficult to remember and reuse them later.

Thanks.

P/S: If you ask me what I like, it's building good softwares to solve users' problems innovatively. I suppose that does not necessarily mean the software has to be very complicated.

ContentLicense: CC BY-SA 4.0


答:
I think that questions about algorithms in interviews are one of the main ways that companies try to judge candidate's grasp of the computer science fundamentals. While this is not the only important area of skill for a professional programmer, it is one of the core competencies of a good programmer.

I think the reason a lot of big companies emphasize CS fundamentals in their interview process, is that it is the core skill that is developed the least after having graduated and gone into the workforce. Practical programming ability, design skills, software engineering practices, and the like are all things that are primarily developed through experience, while your CS fundamentals are primarily developed in the course of your education.

As for how to practice algorithm design, Steve Yegge recommends Skiena's The Algorithm Design Manual in his excellent guide to interviewing as a programmer.


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

答:
If you're introducing a new concept (symbols) into a familiar syntax, why not introduce new notation along with it? For example, within the rules of your lexer you could use a single lead-in character for a simple symbol name:

```<code>$symbol
$this_could_also_be_a_symbol_name
</code>```

For arbitrarily named symbols, a symbol("$ymbol w1th 4rbitrary n4m3") compile-time construct could provide the needed flexibility. It might even be useful to have a function that constructs symbols at runtime, depending on the semantics of your language.

It occurs to me that Ruby does almost exactly this using ::

```<code>:symbol
:this_could_also_be_a_symbol_name
:'$ymbol w1th 4rbitrary n4m3'
</code>```

Title: Backquoted symbols, good or bad?

Body:
If you're introducing a new concept (symbols) into a familiar syntax, why not introduce new notation along with it? For example, within the rules of your lexer you could use a single lead-in character for a simple symbol name:

$symbol
$this_could_also_be_a_symbol_name

For arbitrarily named symbols, a symbol("$ymbol w1th 4rbitrary n4m3") compile-time construct could provide the needed flexibility. It might even be useful to have a function that constructs symbols at runtime, depending on the semantics of your language.

It occurs to me that Ruby does almost exactly this using ::

:symbol
:this_could_also_be_a_symbol_name
:'$ymbol w1th 4rbitrary n4m3'


答:
I always think programming is more data-driven than algorithms.. but then, what use is data if you don't do things to it... all those manipulations are algorithms. So actually, yes, programming is pretty much entirely algorithm based.

It may not look like maths, and a lot of algorithmic work you'd do day-to-day is very simply stuff like sending data between a GUI and a program, but that counts as an algorithm too. Inserting an element in a listbox is a standard insert algorithm that comes with its own issues like performance and list structure manipulations.


问:
Procedural Code vs OOP code
I've finished a project in PHP of 13000+ lines in Procedural Style [because I'm very familiar with that, though I know OOP], and the project is running perfectly.

But should I convert it to OOP?  [because the world is busy with OOP ]

My code doesn't need any of the feature of OOP [encapsulation, inheritance basically...]!

So what should I do?

And what kind of help I will get if I convert it to OOP ?

答:
If you think back to why OO was invented, you'll see that you don't need OOP at all, but sometimes it makes your life a lot easier.

Back in the days of C coding, a very large program could become quite messy and difficult to keep working with. So they invented ways of splitting it up into modular chunks. OOP takes this approach and makes it even more modular, putting data with those chunks of program logic so they are even more separated from the rest of the code.

This allows you to write bigger and bigger programs, safe that you've changed your huge elephant of a task into a hundred mice-sized tasks instead. The added bonus is that you can take some of these 'mice' and reuse them in other programs!

Of course, the real world is not quite like that, and object reuse never quite caught on in the way it was intended, but it doesn't mean it's a useless paradigm.

What is useless is an over-reliance on either style of coding. Anyone who does OO with a thousand tiny, insignificant classes is not really doing it right - they're making a maintenance nightmare for themselves (or someone else). Anyone writing a procedural application that is only 3 functions is also making life hard. The best way is the middlle ground, large-ish objects (sometimes called components which is where we looked to be going once upon a time) that can provide a fair amount of stand-alone code and data that is much more likely to be reused in isolation from the rest of your app.

My advice for next time: try writing your usual procedural code, but create a single object of your main data structure. See how you find that working with it is easier than passing data around from function to function.

Title: Procedural Code vs OOP code


问:
Is it a must for every programmer to learn regular expressions?
I am new to programming, and at an interview I got a question on regular expressions; needless to say I couldn't answer. So I was wondering whether I should learn regular expression? Is it a must for every programmer of all fields? Or it is a must for programming for some particular fields?

Related questions:

Why are regular expressions so morbidly attractive?

When you should NOT use Regular Expressions?

答:
Regular expressions can be thought of as a very useful, cross-language, cross-platform, processing tool. I can use regex in my code, I can use regex in my editor, I can use regex on the commandline!

It's not just that you need, or should learn them. It's more like

WOW! I LOVE REGEX!


答:
Regardless of the domain you are working in, regular expressions are a useful tool to know because most programming languages are written as plain text. Regex is therefore a great way to manipulate and refactor your source code and it is built into many text editors.  I have seen countless programmers making repeated changes to source files when a regular expression would make the changes much more quickly and accurately.

This is what Chapter 3 of the Pragmatic Programmer talks about with plain text being the "basic raw material of programming".

Title: Is it a must for every programmer to learn regular expressions?

Body:
I am new to programming, and at an interview I got a question on regular expressions; needless to say I couldn't answer. So I was wondering whether I should learn regular expression? Is it a must for every programmer of all fields? Or it is a must for programming for some particular fields?

Related questions:

Why are regular expressions so morbidly attractive?

When you should NOT use Regular Expressions?


问:
Should PHP view files be called something other than '.php'?
By default, any file that PHP touches is usually suffixed with .php. It's universally understood by Apache / Nginx as the default for PHP files and most setups expect PHP files to end in this extension. In short, .php is the standard for everything PHP.

However, I'm wondering if perhaps view files should have a different extension to help differentiate them from other PHP files.

First, when it comes to views I have found that almost all MVC frameworks using a matching view file named after the controller or method. In addition, you generally also have a matching model named the same thing. This causes a problem with most IDE's and editors.

For example, you might have a "user" controller, a "user" view, and a "user" model. The results in having three files open called "user.php" which makes it a bother when you are moving around and clicking on the wrong tabs.

Second, separating views as a fundamentally different kind of PHP file (the presentation type) is another argument for changing the extension of the view files to something other than .php. Something that immediately tells your brain what type of content belongs in it.

Third, some applications expose parts (or all) of the PHP files in the webroot and it's directories. Rather than adding something like <?php if(!defined(ABC)) die('not allowed'); it would be nice to have an easy way to forbid access to views while allowing other files like the customary index.php.

Are there any other good/bad reasons to think it's a good idea to change the file extension of view files?

答:
To differentiate views from models and controllers, I would rather use directories:

+ /root
+    /controllers
         DefaultController.php
+    /models
+    /views
+        /Default
             Home.php ← Home view of DefaultController.
             About.php ← Another view.
```

As for your second argument, do your views contain PHP code? If yes, then they are not fundamentally different kind. They are just... different. That's why they are in a separate directory.

A counter-argument could be that in an IDE, you don't see the full path. If I open side by side /models/Home.php and /views/Default/Home.php, how would I know that the first Home.php is a model and the second Home.php is a view?

But still, even in this case, I would avoid changing extensions, but rather use prefixes/suffixes: HomeModel.php and HomeView.php are clear enough in an IDE. In fact, if you change extensions just for the IDE, another developer would have to reconfigure her IDE to accept and understand those extensions as PHP source code files.

Body:
To differentiate views from models and controllers, I would rather use directories:

+ /root
+    /controllers
         DefaultController.php
+    /models
+    /views
+        /Default
             Home.php ← Home view of DefaultController.
             About.php ← Another view.

As for your second argument, do your views contain PHP code? If yes, then they are not fundamentally different kind. They are just... different. That's why they are in a separate directory.

A counter-argument could be that in an IDE, you don't see the full path. If I open side by side /models/Home.php and /views/Default/Home.php, how would I know that the first Home.php is a model and the second Home.php is a view?

But still, even in this case, I would avoid changing extensions, but rather use prefixes/suffixes: HomeModel.php and HomeView.php are clear enough in an IDE. In fact, if you change extensions just for the IDE, another developer would have to reconfigure her IDE to accept and understand those extensions as PHP source code files.


答:
MVC pattern already divides/segregates your project's code to a folder structure to reflect Model, View and Controller. In my opinion that should be enough to identify file types.

Your example with User controller may vary across frameworks. I mostly worked with CodeIgniter and it sure does not force file naming convention as you presented. You free to call your Views the name you want, put them in sub directories named after your controller etc. (like it's done in ASP.NET MVC)

Title: Should PHP view files be called something other than '.php'?

Body:
By default, any file that PHP touches is usually suffixed with .php. It's universally understood by Apache / Nginx as the default for PHP files and most setups expect PHP files to end in this extension. In short, .php is the standard for everything PHP.

However, I'm wondering if perhaps view files should have a different extension to help differentiate them from other PHP files.

First, when it comes to views I have found that almost all MVC frameworks using a matching view file named after the controller or method. In addition, you generally also have a matching model named the same thing. This causes a problem with most IDE's and editors.

For example, you might have a "user" controller, a "user" view, and a "user" model. The results in having three files open called "user.php" which makes it a bother when you are moving around and clicking on the wrong tabs.

Second, separating views as a fundamentally different kind of PHP file (the presentation type) is another argument for changing the extension of the view files to something other than .php. Something that immediately tells your brain what type of content belongs in it.

Third, some applications expose parts (or all) of the PHP files in the webroot and it's directories. Rather than adding something like <?php if(!defined(ABC)) die('not allowed'); it would be nice to have an easy way to forbid access to views while allowing other files like the customary index.php.

Are there any other good/bad reasons to think it's a good idea to change the file extension of view files?


问:
How should I plan and start a project?
Every time I start a project, I decide at crucial moments to completely change the core classes and get caught up in obscure errors. I try planning in advanced and usually start off on a good foot but then I go to it another day and decide I would like to do it 'another way'.

Is there a standard, of sorts, when starting a project such as mapping out classes and starting with unit tests? What is a good convention when planning and starting a medium project.

The last project and started was a projectile motion simulator - I know, predictable.

答: As you gain exp you will need to rewrite/scratch and start over, less often. Write down the problem you trying to solve. Write down vague class descriptions that you think you will need, write up how the will need to interact. Get an idea of how everything is going to work then code. Do not spend tons of times writing out every property, method of your classes. At this stage you're trying to get the 50K foot view of what your supposed to do. Once you start coding if you need to write down more detail go for it. If not just start coding.</p>

Title: How should I plan and start a project?


答:
Algorithms are clear

Here's the beautiful thing about algorithms: The problem space they deal with is well-defined, i.e. your requirements are not only actually known, but usually even formalized much like the metrics for the solution's quality.

So if I tell you to come up with an algorithm, there isn't much potential for communication problems, and measuring your performance is a trivial task. At the same time your performance is a fairly good indicator for your ability to think logically.

Algorithms are an efficient filter

The current problem of the industry (and the education) is the poor average quality of graduates. This has been illustrated with the FizzBuzz test, which is:

Write a program, that will go through the numbers from 1 to 100 and
  will print "fizz" if the number is divisible by 3, "buzz" if it is
  divisible by 5 and the number itself if it is divisible by neither.

Apparently, the majority of all Comp Sci graduates fail to solve this problem. Please note that this is an algorithmic question, although of course an embarrassingly simple one. Given this, getting someone who can solve the kind of problems given in Google Code Jam or Project Euler, you're already enjoying the crème-de-la-crème.

Algorithms are a tiny part of software development

The truth is, as soon as you work in the industry, you will not be using your algorithm skills more than 1% of the time.

Before you even start writing code, you must first gather and analyze requirements. Then you must synthesize your design based on them. Then you must implement the design. Then you must evaluate the implementation against the original requirements, then iterate the requirements, then iterate the design, then iterate the implementation and so on.

One of the requirements is sensible performance. If that requirement is not met, you must profile your implementation to track down the bottlenecks and then you can optimize it, which sometimes is a matter of straight forward micro-optimization (which is rather easy to do), but sometimes is a matter of using better algorithms (which is not always easily done afterwards). Therefore:

Algorithms are critical

The better your grasp of algorithms, the bigger is the chance that you get it right the first time. Otherwise, you're not only likely to run into a problem that can only be solved by implementing a better algorithm, but also you will be unable to actually solve it.

So while you almost never need this skill, it presents a single point of failure in your development methodology and if you don't have the skill, you can only hope that the necessity never arises, or that someone else jumps in to fix it for you.

What is really important is to get a feeling for computational complexity and how to keep it low, as I also explained in response to a similar question. Or to specialize in things where this simply isn't important, such as GUI development, but then again almost everybody hates it ... for a reason!


答:
You don't need to know all the little regex quirks by heart in order to be a great programmer, specially since they all tend to vary a bit around differnt implementations and programming languages. What you do need to know is

What are regular expressions and regexes.

What kind of things they do efficiently (parsing regular languages)

What kind of things are inneficient (parsing nested stuff, using tons of backreferences)

Where to get information on the syntax whenever you need to read or write one.

Anyway, you don't even have to worry to much about wether it will take too much effort to learn them in the first place. The simplest operators (., *, |, (), etc) are almost universally present and go a long way!


答:
As a successful software developer who is self taught and only took a few computer science courses in college, I will say that the largest problems facing business today are not the ability for all of their programmers to write a bubble sort algorithm in the most efficient manner possible.  The true problems that businesses face:

Developers who cannot quickly learn and adapt to new domains

Developers who cannot socially interact with clients or stakeholders in a meaningful way

Developers who cannot second guess and question incorrect or poorly thought out business requirements

Developers who do not understand how to thoroughly test their code and features

Developers who cannot provide meaningful estimates in a timely fashion

Developers who cannot create clear and concise documentation

Developers who cannot be self starting or take charge of a situation

Nine times out of ten I will wager that nearly all circumstances where a developer flounders in a company is because they hopelessly fail in one of the qualities above.  Forget Google and Facebook, they are exception cases and have legitimate need for people who deeply understand computer science.

Real businesses though don't struggle with the complexities of computer science, they struggle with the complexities of humanity.  The problem is that it is REALLY hard to test for the above mentioned qualities.  Most of the time you have to judge people on these qualities based on your gut reaction.  That is hard if you do not have good people skills and intuition, it is much easier to test for algorithm knowledge.


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

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

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

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

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

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

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

答:
Sharepoint

is good for tracking issues and tasks.

ContentLicense: CC BY-SA 2.5


问:
What do you optimize for?
Generally speaking, what type of optimizations do you typically slant yourself towards when designing software?

Are you the type that prefers to optimize your design for

Development time (i.e., quick to write and/or easier to maintain)?

Processing time

Storage (either RAM, DB, Disc, etc) space

Of course this is highly subjective to the type of problems being solved, and the deadlines involved, so I'd like to hear about the reasons that would make you choose one form of optimization over another.

答:
Expressiveness of my intent.

I want someone reading my code to be able to easily see what operations I was trying to invoke on the domain.  Similarly I try to minimize non-semantic junk (braces, 'function' keywords in js, etc) to make scanning easier.

Of course you gotta balance that by maintainability. I love writing functions that return functions and all sorts of advanced techniques and they DO further my goal, but if the benefit is slight I will err on the side of sticking to techniques that solid jr programmers would be familiar with.

Title: What do you optimize for?


问:
When using Java Persistence API (JPA), which layer owns the entities?
When working with annotations on entities in JPA, do these entities belong to the model layer or the persistence layer?

Does there have to be some kind of clone of the entities (simple JavaBeans) in the model layer so it could be decoupled entirely from JPA?

What is the best practice here?

答:
The correct answer on "best practice" questions is always - it depends on the context.

I would start simple by putting JPA entities into Model layer and using them in Persistence layer. This will serve you well for small, medium and even most large projects. If the time comes when you need to have separate entities/value objects/transfer objects for each layer (don't forget UI!), the refactoring is not going to be insurmountable. One way to buy affordable insurance now is to use DAO pattern for all persistence concerns. Looks like you're already doing it because you mentioned Persistence layer.


答:
Yes, programming is mostly about algorithms.

But maybe not in the sense that you're thinking.

I get the impression we're all using different definitions of algorithm.  To be honest, this question is hard to answer because algorithm is a vague term.  I'll use Wikipedia's definition to answer this question:

A set of rules that precisely defines a sequence of operations.

This is the heart and soul of programming.  When you write any code, you are just implementing an algorithm.  If you're writing some CRUD applications, you're implementing a simple algorithm.  Being able to come up with an algorithm to solve a problem is what programming is.  The rest are just details.

I disagree with the previous poster that said having a deep understanding of a language is more important than understanding algorithms.  Any good programmer should be able to deeply learn a language, but without algorithms, you can't come up with any code on your own.


问:
Lua-type Java integration with C++
So I'm curious:

I've implemented Lua within C++ a few times before, and while it was relatively simple, it still didn't harness the power that I would have liked.

I love how eclipse works, including javadoc locations, etc. and I was wondering if there was a way to integrate Java into a native application (that is cross-platform, of course) to do what Lua does, but with Java.

This means I'd be able to build my own base classes and stuff, etc.

Just an interesting thought! Any insight?

EDIT: Also, what about MonoDevelop? Is it relatively easy to integrate? Is it compiled? Is it cross-platform-able?

答:
As someone mentioned in the comments, hosting Java within a C++ app would be difficult. You'd have to provide an environment for it to run in. It's not outside the realm of posibilities though. For example, the mono project has IKVM with is a .NET implementation of the Java Virtual Machine. This allows Java and .NET code to run together. Look at the sources of IKVM to get a grasp of the magnitude of making such an effort with C++.

There is a similar project called Junc++ion but I don't have any experience using it. One of the features they highlight is a shared JVM which forgoes the necessity to have a separate JRE installed on the machine. From the looks of things though, it only supports invoking Java code from C++ not the other way around.

Title: Lua-type Java integration with C++


问:
Why is SQL known as a relation-based / functional language?
We're learning that most languages are classified as either of the two, "relation based" or "high level". I've never used SQL before, but from reading its syntax it seems more like the imperative/high-level syntax than functional/relation-based (Lisp, Haskell)??

Or it could just be that my interpretation of my professor's lecture notes is wrong... but it definitely lists SQL as one of the relation-based languages (as opposed to high level), and it equates relation-based with functional... or perhaps it's that I don't understand why the fact that SQL deals with relational databases makes a functional language the way it should be implemented? (and why 'relation-based' equates with 'functional' when categorizing programming languages?)

Thanks :)

答:
We're learning that most languages are classified as either of the two, "relation based" or "high level".

Those concepts are orthogonal. "Relation-based" means that the language's semantics are based on the concept of a relation, that is, a many-to-many association between two sets (relations are the mathematical foundation behind SQL tables). "High-level" means that the language contains a lot of abstractions that hide much of the underlying technical details (such as memory locations, CPU registers, disk access, bitwise operations, etc.). SQL is certainly relation based, as its main purpose is to describe relational data and operations upon it. SQL is also fairly high level; it does not provide any means to access bytes on disk directly, and it doesn't tell you any details about how it stores its data (at least standard SQL doesn't; most vendors provide extensions to the standard that can give you quite some information, but that's beside the point).

In fact, there are many more axes along which programming (and data) languages can be classified; a particularly interesting one is declarative vs. imperative. Declarative languages describe what something is; imperative languages describe how to do something. The DDL part of SQL is mostly declarative, despite the imperative-looking keywords ("CREATE TABLE", "DROP DATABASE", etc.), and even the data manipulation part (SELECT, UPDATE, INSERT, DELETE) is still pretty declarative. A very interesting property of SQL is that it is not Turing complete: you cannot write an unbounded loop in plain standard ANSI SQL.

Functional programming centers around a few core ideas:

functions are first-class citizens (that is, they can be used as values, as inputs to other functions, and as output from other functions)

higher-order functions (functions that operate on functions, or functions that return functions)

purity (a pure function is one that has no side effects; a pure function cannot do any I/O, it cannot read nor modify any global state, and it cannot take non-const reference arguments. Pure functions are especially interesting because they will always produce the same output given the same inputs)

SQL certainly doesn't revolve around functions as the main tool for modeling things, but it does somewhat embrace the purity idea - the same query run on the same database will yield the same result, every time (except for ordering). Calling SQL a 'functional' language is a bit of a stretch though IMO.


答:
http://nathanmarz.com/blog/suffering-oriented-programming.html

This address your problem. He started by simply making sure that the software was possible, prototyping and creating it. Then, he begins taking the code and breaking it up. Then, he optimizes it.

Title: How should I plan and start a project?

Body:
Every time I start a project, I decide at crucial moments to completely change the core classes and get caught up in obscure errors. I try planning in advanced and usually start off on a good foot but then I go to it another day and decide I would like to do it 'another way'.

Is there a standard, of sorts, when starting a project such as mapping out classes and starting with unit tests? What is a good convention when planning and starting a medium project.

The last project and started was a projectile motion simulator - I know, predictable.


答: Regular expressions are very useful tool, and there are a lot of situations, when programmer should use them. You shouldn't learn them all by heart to use. Just use reference and do your task. After 10-20-50-100(depending on the programmer) tasks where you have used regular expressions, you will know them all by heart. They are being learned by themselves, you shouldn't learn them specially.</p>


答:
I work in an embedded code base that does not have a regular expression library available.  A certain task required 275 lines of code, and took around two weeks to debug all the corner cases, back and forth between tester and developer.  I later wrote a function to do the same thing as part of a javascript utility.  The exact same task using regular expressions used 10 lines of code and worked perfectly in around 15 minutes.

Do you need regular expressions?  Technically not, but it's foolish to intentionally remain ignorant of a tool that efficient.


答:
When you plan, don't plan every possible thing about the application in advance. Plan in baby steps. What is the absolute minimum functionality you need to start using the application? Start there.

When you start your project, only code out the absolute minimum functionality. When you do code it out, make sure you are writing good, clean code with smart encapsulation. This will minimize errors that come from making changes later.

Iterate on that minimum functionality until you are happy with it. Then start adding in new functionality and enhancements, one at a time. Again focus on writing good, clean code with smart encapsulation.

If you plan in baby steps and write clean code it will minimize the number of changes you actually need to make. By the time you've finished writing that first feature, you should have adopted the patterns your application's foundation will sit on. If there are problems with that foundation, your next features should quickly reveal the problem. It will be easier to see how piece integrate together. The changes you do make should, at this point, cause minimal disruptions.

Title: How should I plan and start a project?


答:
When you're talking about convention, there are a few bajillion different ways to do it. Ways I've seen:

```<code>index.tpl.php
index.phtml
templates/index.php
views/index.php
</code>```

You can combine these methods to get some really amazing conventions!

```<code>views/templates/index.tpl.phtml
</code>```

But if you ever do that you should feel bad about yourself.

The long and short of it - if you're using a framework, use their template convention. If you're doing it your own way, just be consistent, and, most importantly, if your template files are in web root and not named *.php make sure your webserver does not serve them as text!!!!!

Body:
When you're talking about convention, there are a few bajillion different ways to do it. Ways I've seen:

index.tpl.php
index.phtml
templates/index.php
views/index.php

You can combine these methods to get some really amazing conventions!

views/templates/index.tpl.phtml

But if you ever do that you should feel bad about yourself.

The long and short of it - if you're using a framework, use their template convention. If you're doing it your own way, just be consistent, and, most importantly, if your template files are in web root and not named *.php make sure your webserver does not serve them as text!!!!!


问:
What sources of sample work should be used in a job interview?
One of my friends has been laid off. When I talked to him, he said they didn't let him take a copy of anything he worked on. When he asked how to show what he worked on to another employer in an interview, he was told that he will have some explaining to do.

Should we, as programmers, be allowed to take samples of our previous work former employers? What sources of code should we be expected to show off in an interview? When almost every employer asks for sample work, how are we to justify what can be sent? Is it our responsibility to maintain after-work projects for our entire life so we have code we can legally show to our next employer?

答:
I am not sure about the Legal part but what I think of it, you should never be allowed to take your work with you. You were paid for the work. That is not your property but your company property.

It is common people take their work with them for reference or other reasons, without informing the company. That is the only way you can do it. You are still responsible for it, in case it leaks.

I had a similar situation where I could show my old work and that probably would have boosted my profile but I choose not too and I do not regret it. That was my old company asset and it should be that way. If your communication skills are not good enough to explain what you did, you should not be blaming your previous employer.

Note: I am not sure what type of work is being referenced here. That might matter to some extent.


答:
It's the company's property (unless otherwise noted in his contract if he has one). They can do whatever they want with it including not allowing him to access, show, or copy it. They paid him to produce something, it's theirs.

```<code>From what I know of my other co-workers, people easily get the stuff they worked on
(without informing the company), and either make a video or take some screenshots of it
without any problem.
</code>```

This could be seen as stealing and very well could be illegal.

I am not a lawyer.

Title: What sources of sample work should be used in a job interview?

Body:
One of my friends has been laid off. When I talked to him, he said they didn't let him take a copy of anything he worked on. When he asked how to show what he worked on to another employer in an interview, he was told that he will have some explaining to do.

Should we, as programmers, be allowed to take samples of our previous work former employers? What sources of code should we be expected to show off in an interview? When almost every employer asks for sample work, how are we to justify what can be sent? Is it our responsibility to maintain after-work projects for our entire life so we have code we can legally show to our next employer?

Body:
It's the company's property (unless otherwise noted in his contract if he has one). They can do whatever they want with it including not allowing him to access, show, or copy it. They paid him to produce something, it's theirs.

From what I know of my other co-workers, people easily get the stuff they worked on
(without informing the company), and either make a video or take some screenshots of it
without any problem.

This could be seen as stealing and very well could be illegal.

I am not a lawyer.


答:
Everything I say applies to normal, at-will employees. If you are a contractor, then the rules may be different, though I'd bet not much with respect to these points.

If you are a regular employee, then everything you did is the property of your employer. That means you can't take it with you, without permission. It's theirs - that's why they paid you to do the work! And they don't necessarily want it shown all over the industry.

They are perfectly within their rights to not let you keep a copy.


答:
If someone came to an interview and showed me something that was clearly confidential property of a previous employer (including source code for a public website), I would have serious reservations about hiring that person regardless of his or her other skills and abilities.

Which is to say, I suspect that this is perfectly legal and acceptable, and any subsequent employer worth working for would understand the situation.


答:
In contrast to the majority of the answers here I don't think knowledge of reg exs is a required skill to be a productive programmer. When I interview candidates for a position I would dig deeper if they felt compelled to bring their skills of reg ex up them self. Why? they are often used in places because they like the right hammer but often what you needed was a screw driver. Search SO for HTML and regex and you'll see quite a few questions and quite a few reasons why regex is a misfit.

The ability to do proper OOD is required before I will advocate for hiring an interviewee the knowledge of regular expressions is certainly not. And I don't actually think any one believes you can be are more productive programmer knowing regexs but lacking in areas such as analysis, design and knowledge of the framework used

Sure sometimes they are handy but in my more than 20 years as a professional developer I think I've used them less than 20 times in code (and I've even code a few perl scripts) I do use them regularly to do search and replace though.


答:
Well, you need to understand that it is not your code.  You have no right to show it to anybody, and your former employer certainly has a right to protect their as sets by not letting you leave with a copy.

Code that you would typically show in an interview would consist of hobby projects, and/or utilities you churned out in your spare time.  If you don't have any of these to show and you're looking for a job, then start working on one.  A public git-hub repository is a great thing to show off in an interview.

Furthermore, I think showing off a previous employers code in an interview is in poor taste, and will likely cost you the interview.  Any and every bit of code COULD be riddled with bugs that may expose a vulnerability.


答:
No one really knows what the best design will be until they've coded a certain amount of it.  Therefore, the secret to good design is to recognize that your first draft is inevitably suboptimal, and plan to rewrite smaller portions earlier and more frequently.  Instead of scrapping an almost complete program, rewrite lines or functions or classes as soon as you recognize their deficiencies.

Good experienced programmers don't usually get it right on the first draft either.  What comes with experience is the ability to recognize a bad design sooner, and the ability to rewrite more quickly.

Title: How should I plan and start a project?


答:
As already mentioned Regex is a tool, a very useful tool IMHO.

Consider this example:

```<code>//fomat number using string.replace and regex in javascript
function numberWithCommas(x) {
    return x.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, ",");
}
</code>```

Just one line to convert for example a number like this 1000000.00 into "1,000,000.00"

Using any other method will be far more complex

Body:
As already mentioned Regex is a tool, a very useful tool IMHO.

Consider this example:

//fomat number using string.replace and regex in javascript
function numberWithCommas(x) {
    return x.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, ",");
}

Just one line to convert for example a number like this 1000000.00 into "1,000,000.00"

Using any other method will be far more complex


答:
I would really advise you to learn regexps. At work, when we are hiring programmers, the candidates who don't know regexp are generally quickly disposed of. Not because they absolutely need to know regular expressions, but because it is a very good indicator of their level of understanding of programming and level of programming addiction.

A real programmer knows their regular expressions

This is a little biased, however, as I'm mostly involved in web programming, where regular expressions are something you are bound to come across a lot, both on the server side and on the client side. If you were an assembly programmer for a built in system in a dishwasher, you would probably not come across regular expressions at all. But it would still possibly come in handy, as you are in most cases more able to wield your development environment when you do know regular expressions (search and replace, search for a file, search in multiple files, etc...).

Also, you will find it easier to be acknowledged by fellow programmers if you do know it.


答:
There are two aspects to designing an application. The first is deciding just what your application can do. The second is designing how to do it. Changes to what it does are pretty significant and depending on the maturity of the application (and the shift in direction of the application) are best approached as a rewrite rather than re-work.

The second aspect is the how. Using unit testing and agile development practices, you can minimize the impact of changing how a specific function is accomplished through refactoring. Part of learning how to leverage those techniques is practice practice practice.

I'll give the advice I've given time and time again. Pick a pet project. Write it to the best of your abilities. Learn something new, and apply what you've learned to improve how you approach developing that project.

For example, start with a Todo list. Make it simple...don't even worry about database storage at first. Just get it working. Now start building on that foundation. Maybe you want to learn MVVM and WPF...you already know how to implement the in memory todo list, so you have one less problem to solve. Now you want to make it where multiple users can load their todo lists from a database. You've solved in memory and separated presentation, so you can focus on learning data access. From there you can expand the application to have a more complex domain model (for instance changing from a Todo list to a project management solution), a web interface, or even make it run on a mobile device. The key to making this work is to pick something that is accomplishable by you that you can mark progress against and that you can grow over time.

Title: How should I plan and start a project?


答:
In my experience, employers are more interested in the results of your past work, or hearing you describe the architecture of it. They're not interested in going through pages and pages of actual code. If they actually want to see your coding style, they'll usually ask you to do some trivial task.

Personally, I ask my employers if I can take screenshots of my work to add to my portfolio. I'll do some image editing to remove company-specific data, or populate the app with dummy data, so they're usually fine with it. I can then use these screenshots to describe the application to potential employers, and they can see the results of what I've done in the past.

Just remember to ask your employer first. I would not take anything, even screenshots that had company-specific data removed, unless they were OK with it.


答: It does not matter what extension you assign to your files. But, most probably, you would like to distinct view files from other files you have in the application. Some kinds of distinction may be more suitable for you, just choose one and stick to it.


问:
How might a Windows 8 Metro app handle back end database access?
While researching Metro and WinRT I haven't been able to find anything regarding enterprise apps and database access. All I hear about is the front end development.

Does anyone have any idea of how a Metro app will access a database server? Will this still be done through ASP.Net and ADO.Net? If not, then does anyone have any idea or guess as to how?

答: It looks like Metro apps will be able acccess enterprise data via web/WCF (Windows Communication Foundation) services (at a minimum.).   It looks like you can also use local databases like sqllite, as discussed in the stackexchange thread:  https://stackoverflow.com/questions/7746044/using-sqlite-with-winrt</p>


答:
A key part of a developers job is communication.  If you can communicate you past work history and knowledge well then there is no need to give previous code.

Also the company that you work for would in the vast majority of cases hold the intellectual property of the code that you write, so why should they or indeed would they just hand it over?


问:
Workflow Foundation to separate data from business logic on a mid-sized App?
We are currently developing a .net app in WPF, that will be a desktop app with a good bit of data-access to local (and some remote) servers. The business logic here is very complex, and currently it is built into the code along with the data access and whatnot (being WPF the UI is separated pretty nicely).

Now, I have been tasked with reorganizing this system to make it more maintainable in the long run as certain logic changes. I know that workflows are supposed to separate the logic out pretty nicely and allow you to visualize it a bit. Is workflow a good choice for an app that does not need to be run over long periods? (since workflows can wait in idle for months) What has been your experience with the platform? Is it slow for dealing with a mid-sized company; around 150 simultaneous users? If you liked it, do you know of any good online tutorials (preferably not MSDN) that can give me a taste for the platform and do some testing before I commit to implementing it on a huge app?

答:
I have a small amount of experience with WF - creating custom TFS workflows and activities. I found it generally painful and slow to work with - opening a workflow takes a long time (on a WEI 5.9 machine), it often hangs VS.NET, is missing some core features and is marginally buggy.

If you have anything more than a simple workflow you soon run out of screen real estate. I have a 24" in portrait orientation (1200x1920) and often found myself wanting more vertical room.

Overall I found it pretty frustrating and wouldn't recommend it. It didn't seem to allow me to do anything that I couldn't have done more easily in code.


答:
Not sure where you draw the line on looking at copies of code or a question about how you solved a particular problem. How much detail can you go into without revealing something important about the code?

If you bring me a printout, how do I know you wrote it? Of course you'll be asked to explain what it does and why you did it that way. It could be just as easy to have you look at someone else's code and explain what it does and how you would improve it.

Eventually, you'll just need to prove you can write code and I hope the way you do that is by actually writing code.

It can save some trouble if you work on an open source project and get a recommendation from a trusted source who can verify your contributions. I doubt your current employer will lay claim to it, but I don't know the law where you live.


答:
I think the potential confusion is a serious problem.  If you already find yourself confusing backquote and single-quote, think how many future code writers and readers will make the same mistake.

Many languages that use backquotes as special syntax seem to reserve them for comparatively rare usage.  I could speculate why, but if you expect symbols to get heavy usage, you could take this as a cue to use some other syntax.

So, for the multiple choice bonus question, I would prefer #3 or #4 over #1 or #2, for anti-confusion reasons.  You can keep backquotes in reserve for when you need an extra-special quotelike operator...

Title: Backquoted symbols, good or bad?

Body:
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.


答:
One of .Nets not so hidden gems is WCF Data Services, which in a nutshell allows you to query a Data Model over HTTP, in a very seemless LINQ type way using a protocol called odata. Data services are usually create with Entity Framework, but I believe there are other providers too.

http://msdn.microsoft.com/en-us/library/cc668792.aspx

Title: How might a Windows 8 Metro app handle back end database access?

Body:
While researching Metro and WinRT I haven't been able to find anything regarding enterprise apps and database access. All I hear about is the front end development.

Does anyone have any idea of how a Metro app will access a database server? Will this still be done through ASP.Net and ADO.Net? If not, then does anyone have any idea or guess as to how?


答: You may not have been able to take your work with you that you did for your employer, but what programmer doesn't have pet projects that he could show?</p>


问:
Architecting Challenge: How would you write an opensource script installer to run in a browser?
I currently have an installer that works, but I have to repackage the open source apps and hack things together to get the installer to install them. I want to be able to use the apps installation method without having to hack and repackage. So I am thinking about rewriting it.

It will allow a user with little to no tech experience install open source apps (ie. WordPress, Joomla, Drupal, et.al.). There are a few requirements I want to meet:

The installation should run the scripts install process to make sure
the database is setup correctly and the passwords use the apps
default password encryption processes.

Ability to track the progress and report back any errors.

Ability to run upgrades for future releases.

Ability to remove the application if someone decides they do not want
it any longer.

The only access I will for sure have to the users remote server is
via FTP.

I have thought about using Selenium. However, if you were challenged to hand spin the code in PHP, how would you do it?

UPDATE FOR CLARIFICATION:

The installer will collect the scripts settings from a form in the browser filled out by the end user. The installation process (that runs in the background and connects over FTP to the users server) will then process the installation. (i.e. SimpleScripts, Installatron, Softaculous, Fantastico, WebPub, etc.) I am trying to figure out how you would design the cleanest simplest install process possible. It needs to create databases, install the application using the scripts install method (as if the user was running it manually), etc. I hope that clarifies the challenge.

答:
You're not going to have the ability to execute scripts via FTP, obviously.

But, you can upload a .PHP file into the user's web directory, and then remotely execute that PHP file (or whatever language you pick).  Thats why we dont give world writable rights to directories where scripts are stored! :-)

So, an approach one might take could be:

Gather application parameters (what programs, where to store them, database information)

Generate a big .PHP file that scripts the installation of the applications.
Upload that via FTP into the domain's root directory.

Execute it remotely (and ensure the php file cant be executed more than once).

Practical problems:

The user the web server is operating as may not have the necessary rights to create directories where you need them.  Presumably the user does, so these might be creatable via FTP.

The db user that the user provides may not have the rights to create a new database, so they may have to create that via whatever tool their ISP provides.

The amount of information required ahead of time might be very large, and require a certain level of familiarity with the server's directory structures... and if the user has that, then the utility of the service is deminished since most apps have their own similar installers.

If there are missing libraries or PHP extensions, for example a PHP app that requires cUrl and its missing, you're out of luck.


问:
To use, or not to use, commons-io in a Java applet
I am building a Java applet for a client. Yes, we have gone over all the options, and for the client's requirements and environment, this is the Right Choice.

I am a big believer in using Apache Commons whenever possible to simplify my code and avoid reinventing the wheel. One part of the functionality I need for this applet is implemented in the Commons IO library, which is 160kb in size.

Or I could create a custom build of Commons IO with just the classes I want. Less easily maintained, but minimizes the overhead of the applet.

I could also write the needed functions; they would be far smaller than 160kb.

I've probably spent more time pondering the Right Thing To Do than it would take me to write the code by hand.

As an additional consideration, I will be doing a code review with the client, and would like to take any opportunities I have to teach them best practices like using Apache Commons.

Any strong opinions, and justifications, for which option I should choose?

答: If you already found a library that will do the job, just use it as is. If its footprint is too large, consider another library that could be used in its place to deliver the same functionality and use it as is. Don't write your own library unless you absolutely have to. Using a third-party library has the benefit of being developed and tested by someone other than you, so it's very hard to go wrong with using it in your own applications, especially when it comes from the Apache Software Foundation.</p>


问:
Is there a difference between the quotes in `help',``help", 'help' and "help"?
Sometimes I find in the source code files comments have quotation marks like these ,notice the ` :

```<code>`help'
``help"
</code>```

For example, these are comments from GNU cat source code file, cat.c:

```<code>  /* Plain cat.  Copies the file behind `input_desc' to STDOUT_FILENO.  */
</code>```

>

```<code>  /* Select which version of `cat' to use. If any options (more than -u,
     --version, or --help) were specified, use `cat', otherwise use
     `simple_cat'.  */
</code>```

>

```<code>/* Suppress `used before initialized' warning.  */
</code>```

While in other parts, "" is used :

```<code>  /* Determines how many consecutive newlines there have been in the
     input.  0 newlines makes NEWLINES -1, 1 newline makes NEWLINES 1,
     etc.  Initially 0 to indicate that we are at the beginning of a
     new line.  The "state" of the procedure is determined by
     NEWLINES.  */
</code>```

What does ` mean? and what is it used for?

答:
In general, there is no standard meaning for quotes in comments.  Some standard meaning may be defined within an organization, or for a particular project, but I've never seen that done.

In your examples, the quotes are sometimes used to indicate that the enclosed word is the name of something, like a variable ('input_desc'), or a program ('cat').  There may be conventions defined for GNU source code, but it's not clear from the examples that there are.

In the last example, it is not clear to me why "state" was quoted.


答: If you only need a small part of the library, I would cut it down to just the part you need, especially if this is for a Java applet. The issue with rewriting the functionality yourself is that you may run into subtle bugs that a more stable library has already solved. But the decision there depends on the complexity of the functionality involved.</p>

Title: To use, or not to use, commons-io in a Java applet

Body:
I am building a Java applet for a client. Yes, we have gone over all the options, and for the client's requirements and environment, this is the Right Choice.

I am a big believer in using Apache Commons whenever possible to simplify my code and avoid reinventing the wheel. One part of the functionality I need for this applet is implemented in the Commons IO library, which is 160kb in size.

Or I could create a custom build of Commons IO with just the classes I want. Less easily maintained, but minimizes the overhead of the applet.

I could also write the needed functions; they would be far smaller than 160kb.

I've probably spent more time pondering the Right Thing To Do than it would take me to write the code by hand.

As an additional consideration, I will be doing a code review with the client, and would like to take any opportunities I have to teach them best practices like using Apache Commons.

Any strong opinions, and justifications, for which option I should choose?


答:
Jeff Atwood wrote a great blog about regular expressions, in it there is this amazing quote:

```<code>Some people, when confronted with a problem, think "I know, I'll use regular
expressions." Now they have two problems. [Jamie Zawinski]
</code>```

There is also a great answer to a good question a stack overflow you might want to check out.

You should definitively know a little about it. Regular expressions are easy to learn but difficult to master. You don't need to learn everything about it to start using it. Just be sensible about it.

tl;dr

You need to know about the technology so that you can make a good decision on when to use it.

Body:
Jeff Atwood wrote a great blog about regular expressions, in it there is this amazing quote:

Some people, when confronted with a problem, think "I know, I'll use regular
expressions." Now they have two problems. [Jamie Zawinski]

There is also a great answer to a good question a stack overflow you might want to check out.

You should definitively know a little about it. Regular expressions are easy to learn but difficult to master. You don't need to learn everything about it to start using it. Just be sensible about it.

tl;dr

You need to know about the technology so that you can make a good decision on when to use it.


答:
Title 17 § 107 of the U.S. code outlines the circumstances in which a copyrighted work can be copied for fair use, whether the work has been published or not.  As copyright law is what usually protects source code, it's relevant to your question.

I'm not a lawyer, and I'm not aware of any case law establishing this either way, but in my opinion copying short examples of your work would fall under fair use, provided it is a small enough sample as to not be a complete working program or module, and that it doesn't reveal any trade secrets.  One of ten files from your implementation of a driver for a chip with a publicly available datasheet is not going to hurt your former employers in any way.  Your implementation of the company's top-secret algorithm you helped design is going to get you into trouble.


问:
libavcodec/libavformat question
I've seen this code referenced in two different places, yet I haven't seen anybody bring this up, but it seems that on line 00339 there is an empty if block and I just copied the code to compile try it out but it won't even compile cause of that.

```<code>if (frame_count >= STREAM_NB_FRAMES) {
 /* no more frame to compress. The codec has a latency of a few
    frames if using B frames, so we get the last frames by
    passing the same picture again */
} else {
</code>```

Any idea or explanation why it is like that. Is it a mistake on the author's part when copying it? What is supposed to be going on in that if block anyways?

答:
There is no mistake. The if part of that block is indeed empty.

It is often easier to express the logic by making the if part empty and doing the work in the else part. In, this case, the if part has a comment specifically explaining why it is empty and why there is nothing to do.

The code is legal C and will compile fine.

Title: libavcodec/libavformat question


答:
It's the result (habit) of someone using LaTeX - it doesn't mean anything.

E.g., in LaTeX, ``hello there'' would result in "hello there".

If, however, you see as part of a shell script, the command within the backticks () is performed. E.g.,

```<code>$ echo `whoami`
awesome-linux-accountname
</code>```

Title: Is there a difference between the quotes in `help',``help", 'help' and "help"?

Body:
Sometimes I find in the source code files comments have quotation marks like these ,notice the ` :

```<code>`help'
``help"
</code>```

For example, these are comments from GNU cat source code file, cat.c:

```<code>  /* Plain cat.  Copies the file behind `input_desc' to STDOUT_FILENO.  */
</code>```

>

```<code>  /* Select which version of `cat' to use. If any options (more than -u,
     --version, or --help) were specified, use `cat', otherwise use
     `simple_cat'.  */
</code>```

>

```<code>/* Suppress `used before initialized' warning.  */
</code>```

While in other parts, "" is used :

```<code>  /* Determines how many consecutive newlines there have been in the
     input.  0 newlines makes NEWLINES -1, 1 newline makes NEWLINES 1,
     etc.  Initially 0 to indicate that we are at the beginning of a
     new line.  The "state" of the procedure is determined by
     NEWLINES.  */
</code>```

What does ` mean? and what is it used for?

Body:
It's the result (habit) of someone using LaTeX - it doesn't mean anything.

E.g., in LaTeX, ``hello there'' would result in "hello there".

If, however, you see as part of a shell script, the command within the backticks () is performed. E.g.,

$ echo `whoami`
awesome-linux-accountname


答:
After you have been laid off / let go it is too late, IMO. (Well, it's not too late but now you have work to do in your new "free time").

You should be doing OTHER PROGRAMMING PROJECTS in your spare time. Shareware, smart phone or tablet apps. Work on open source projects. PICK ONE, and then do it.

SO - when the prospective employer asks for samples, you have lots to show from your 'free time'.

I agree - stuff you did as a paid employee for your previous employers should never be taken and certainly not shown.


问:
In Windows 8 will it be possible to use WCF in conjunction with HTML5/JS?
Correct me if I'm wrong but I've heard that communicating with a database in Windows 8 will more than likely be done with WCF when working with C#/XAML.

If this is true then will this also be the case when working with HTML5/JS?

答:
On December 14th, 2011, Microsoft MVP Morten Nielsen said:

You can use HttpClient to download pretty much anything from the web.
  Why don't you configure your WCF service to return data as JSON, and
  use the DataContractJsonSerializer to deserialize the results?

In an HTML5/JS application, the DataContractJsonSerializer class obviously won't be available, but the balance of his advice still applies.

TL;DR

Configure your WCF service to return data as JSON.

And use a Javascript library such as datajs or jQuery on the client-side to communicate with your WCF service.

Emphasis: Microsoft may provide helper Javascript libraries to communicate with WCF services, but don't hold your breath. [Heck, they've already ruffled a few feathers by dropping the System.Data namespace for XAML apps.]

Until you hear otherwise, use a popular Javascript library to make it happen on the client-side.


答:
Older versions of Apache & PHP supported additional file extensions, based on the installed PHP version:

```<code>customers.php3
sales.php3
products.php4
purchases.php4
</code>```

I think, still can be done, in the Apache or PHP configuration,
but, it think, that will be complicated, and bring more problems,
that advantages.

But, sometimes, its good to differentiate among several related source-code files.

One trick its using hyphens ("minus") or dots inside the filename, not the file extension, or file suffix.

Example 1:

```<code>customers-model.php
customers-view.php
customers-controller.php
</code>```

Example 2:

```<code>customers.model.php
customers.view.php
customers.controller.php
</code>```

Example 3 (Prefixes or suffixes):

```<code>CustomersModel.php
CustomersView.php
CustomersController.php
</code>```

This way, you still support the file extension, and implement a "subextension", for your source code.

Body:
Older versions of Apache & PHP supported additional file extensions, based on the installed PHP version:

customers.php3
sales.php3
products.php4
purchases.php4

I think, still can be done, in the Apache or PHP configuration,
but, it think, that will be complicated, and bring more problems,
that advantages.

But, sometimes, its good to differentiate among several related source-code files.

One trick its using hyphens ("minus") or dots inside the filename, not the file extension, or file suffix.

Example 1:

customers-model.php
customers-view.php
customers-controller.php

Example 2:

customers.model.php
customers.view.php
customers.controller.php

Example 3 (Prefixes or suffixes):

CustomersModel.php
CustomersView.php
CustomersController.php

This way, you still support the file extension, and implement a "subextension", for your source code.


答:
Any half decent compiler is going to remove that block anyway, and leave just the else block (unless it is also empty).

The point is to explain what happens when a certain important condition is met.

Title: libavcodec/libavformat question

Body:
I've seen this code referenced in two different places, yet I haven't seen anybody bring this up, but it seems that on line 00339 there is an empty if block and I just copied the code to compile try it out but it won't even compile cause of that.

```<code>if (frame_count >= STREAM_NB_FRAMES) {
 /* no more frame to compress. The codec has a latency of a few
    frames if using B frames, so we get the last frames by
    passing the same picture again */
} else {
</code>```

Any idea or explanation why it is like that. Is it a mistake on the author's part when copying it? What is supposed to be going on in that if block anyways?


答:
On December 14th, 2011, Microsoft MVP Morten Nielsen said:

You can use HttpClient to download pretty much anything from the web.
  Why don't you configure your WCF service to return data as JSON, and
  use the DataContractJsonSerializer to deserialize the results?

And on September 14th, 2011, Microsoft employee Tim Heuer said:

...You cannot directly have a SQL db embedded in your app or use
  something like ADO.NET.  This is more of an async/services
  infrastructure.  So if your data was exposed via services...

Oh and forget about the System.Data namespace. It's not supported in WinRT.

On November 01, 2011, Microsoft employee Immo Landwerth wrote:

When I wrote that .NET for Metro style apps does not include database
  APIs I bascically meant System.Data. This also includes
  SqlConnection and SqlCommand, which you would probably need to
  communicate with the remote SQL Server.

TL;DR

You can use HttpClient to download pretty much anything from the web. Configure your WCF service to return data as JSON.

If you're developing a XAML application, use the DataContractJsonSerializer class to deserialize the results.

If you're developing an HTML5/JS application, use a Javascript library.


问:
Anyone know of any parallelizing compilers following the approach of the Dragon Book?
In Compilers: Principles, Techniques, & Tools, Aho et al describe an approach for optimizing for parallelism (chapter 11 in the second edition). Is anyone aware of any existing compilers which follow that approach?

答:
I can't answer directly that question, regarding parallelism or concurrency, but, the Dragon Book was written some decades ago, with some updates, maybe, and Compiler Techniques have change a lot.

I have read some compilers docs, on the internet, and some of them use different ideas.

Besides, there are other books & (online) publications about compilers, that try to "kill the dragon", each one in a different way.


问:
How does one request / handle personal or financial information?
I would like to create a budget app for Android. Obviously, to be competitive, I would need to allow users to get data from their bank. For [huge] security reasons, this stuff is not just freely given to any would be developer, but I know it can be done. There are budget apps that connected to users banks.

My question is, what do I need to do to poll users bank data? Do I need to contact every bank that I wish my app to deal with? Do I need to write the app and present it the the bank(s)? Or am I just too ignorant to take on a challenge of this magnitude?

I ask because I obviously don't know the standards that are needed here and would like to learn about them, even if it ends up that I cannot write the bank interface section of my app.

答:
You need to check out OFX.  This is how programs all get their data.  Banks have gone to (a version) of it and pretty much moved away from the QIF format formerly used by Quicken.

Unforturately, Banks mostly use QFX, the intuit extension/variant of OFX.  Banks have to pay Intuit to use it so don't expect to get free and easy access to it unless (big banks never miss an opportunity to charge you)


问:
Best way to maintain data between local and remote sql databases
So I have, what would seem like a common question that I can't seem to find an answer to. I'm trying to find what is the "best practice" for how to architect a database that maintains data locally, then syncs that data to a remote database that is shared between many clients. To make things more clear, this remote database would have many clients that use it.

For example, if I had a desktop application that stored to-do lists (in SQL) that had individual items. Then I want to be able to send that data to a web-service that had a "master" copy of all the different clients information. I'm not worried about syncing problems as much as I am just trying to think through actual architecture of the client's tables and the web-services tables

Here's an example of how I was thinking about it:

Client Database

```<code>list
--list_client_id (primary key, auto-increment)
--list_name

list_item
--list_item_client_id (primary key, auto-increment)
--list_id
--list_item_text
</code>```

Web Based Master Database (Shared between many clients)

```<code>list
--list_master_id
--list_client_id (primary key, auto-increment)
--list_name
--user_id

list_item
--list_item_master_id (primary key, auto-increment)
--list_item_remote_id
--list_id
--list_item_text
--user_id
</code>```

The idea would be that the client can create todo lists with items, and sync this with the web service at any given time (i.e. if they lose data connectivity, and aren't able to send the information until later, nothing will get out of order). The web service would record the records with the clients id's as just extra fields.
That way, the client can say "update list number 4 with a new name" and the server takes this to mean "update user 12's list number 4 with a new name".

答:
We had a similar case. The solution was kind of unusual, each database, wheter main server or local client, had a copy of the same database structure or schema. (Same tables with same fields and same field types).

We add a client table catalog:

```<code>create table client
{
   client_key int primary key,
   client_title varchar(200)
}
</code>```

The primary key of each table was integer, but, managed, as it was string / char of a fixed type, with integers up to 9999 9999 9999 9999

Its length was big enough to support a large qty. of records.

The numbers where stored in reverse, in order to support padding with zeroes.
If we want to store a "4", it should be like this: "4000 0000 0000 0000".

The first 3 digits store the key of the table, padded with 0. The rest of the 12 digits stored the incremental value of the key padded with zeroes.

So, the following data:

```<code>Client Sequential Number <other fields>
1      1                 ...
2      1                 ...
3      1                 ...
1      2                 ...
2      2                 ...
3      2                 ...
1      3                 ...
2      3                 ...
3      3                 ...
</code>```

Was stored in the primary key, of each table, as this:

```<code>Table_Key        <other fields>
1000000000001000 ...
1000000000002000 ...
1000000000003000 ...
2000000000001000 ...
2000000000002000 ...
2000000000003000 ...
3000000000001000 ...
3000000000002000 ...
3000000000003000 ...
</code>```

In order to avoid primary key collisions.

Body:
We had a similar case. The solution was kind of unusual, each database, wheter main server or local client, had a copy of the same database structure or schema. (Same tables with same fields and same field types).

We add a client table catalog:

create table client
{
   client_key int primary key,
   client_title varchar(200)
}

The primary key of each table was integer, but, managed, as it was string / char of a fixed type, with integers up to 9999 9999 9999 9999

Its length was big enough to support a large qty. of records.

The numbers where stored in reverse, in order to support padding with zeroes.
If we want to store a "4", it should be like this: "4000 0000 0000 0000".

The first 3 digits store the key of the table, padded with 0. The rest of the 12 digits stored the incremental value of the key padded with zeroes.

So, the following data:

Client Sequential Number <other fields>
1      1                 ...
2      1                 ...
3      1                 ...
1      2                 ...
2      2                 ...
3      2                 ...
1      3                 ...
2      3                 ...
3      3                 ...

Was stored in the primary key, of each table, as this:

Table_Key        <other fields>
1000000000001000 ...
1000000000002000 ...
1000000000003000 ...
2000000000001000 ...
2000000000002000 ...
2000000000003000 ...
3000000000001000 ...
3000000000002000 ...
3000000000003000 ...

In order to avoid primary key collisions.


问:
Should PHP view files be called something other than '.php'?
By default, any file that PHP touches is usually suffixed with .php. It's universally understood by Apache / Nginx as the default for PHP files and most setups expect PHP files to end in this extension. In short, .php is the standard for everything PHP.

However, I'm wondering if perhaps view files should have a different extension to help differentiate them from other PHP files.

First, when it comes to views I have found that almost all MVC frameworks using a matching view file named after the controller or method. In addition, you generally also have a matching model named the same thing. This causes a problem with most IDE's and editors.

For example, you might have a "user" controller, a "user" view, and a "user" model. The results in having three files open called "user.php" which makes it a bother when you are moving around and clicking on the wrong tabs.

Second, separating views as a fundamentally different kind of PHP file (the presentation type) is another argument for changing the extension of the view files to something other than .php. Something that immediately tells your brain what type of content belongs in it.

Third, some applications expose parts (or all) of the PHP files in the webroot and it's directories. Rather than adding something like <?php if(!defined(ABC)) die('not allowed'); it would be nice to have an easy way to forbid access to views while allowing other files like the customary index.php.

Are there any other good/bad reasons to think it's a good idea to change the file extension of view files?

答:
The naming convention should help, not hinder, clarity. The setup you describe clearly hinders clarity and therefore is not helpful.

The file extension should always represent what is in the file. If it's php, it should be ".php". That said, I like the Zend MVC standard of using ".phtml" for the view files. Which, in essence, says to me, this is primarily an html file that you can also expect to contain some php.

Going back to Zend, the controller is UserController.php, the model is User.php (or Application_User.php, depending on how you roll), and the view for the index action is index.phtml, in the scripts/user directory.

If the framework leaves you so confused you want to change standards, I'd look for another framework.


答:
In the olden days, the glyphs displayed for ` and '  produced nicely-symmetric "smart quotes" rather than the Unicode-correct unbalanced mess we see today.

Code and habits from that time use them as single smart quotes, and repeat them as a simulacrum of double smart quotes:

```<code>``help''
</code>```

but this is no longer recommended for the GNU code that it arguably originated in.

There is futher reading and background in Markus Kuhn's treatise here.

Body:
In the olden days, the glyphs displayed for ` and '  produced nicely-symmetric "smart quotes" rather than the Unicode-correct unbalanced mess we see today.

Code and habits from that time use them as single smart quotes, and repeat them as a simulacrum of double smart quotes:

``help''

but this is no longer recommended for the GNU code that it arguably originated in.

There is futher reading and background in Markus Kuhn's treatise here.


问:
Assembly instructions execution time
Where can I find the x86 instructions execution time? How to find out which instruction is faster or smaller?</p>

答:
http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html - you want the optimization manual for the CPU you are interested in; AMD publishes an optimization manual for their CPUs.

Keep in mind that there is no "time" for each instruction, these days.  You have out of order execution, memory and register stalls, and instruction level parallelism to take into account.

Different instructions do still have different latencies and throughputs, and number of uops or m-ops they decode to, and the execution ports those uops can run on.  The best source for these numbers are Agner Fog's instruction tables, and his microarchitecture pdf with the details of how these numbers matter.  See also the optimization section in Stack Overflow's x86 tag wiki.

Title: Assembly instructions execution time


问:
Is programming or computer science in general, all about algorithms?
As a grad student, I find it more and more common for prestigious companies (like Google, Facebook, Microsoft,...) to put algorithm questions in their test and interviews. A few startups I applied to also asked about algorithms. I wonder if algorithms fluency is the most important thing for software developer in those companies?

If the answer being yes, what are the best method or resources for one to learn & practice about algorithms effectively? I can't seem to get interested in solving seemingly too complicated problems found in most textbook or websites. Though easily understand basic algorithms (like quicksort, bubblesort,...), I find it immensely difficult to remember and reuse them later.

Thanks.

P/S: If you ask me what I like, it's building good softwares to solve users' problems innovatively. I suppose that does not necessarily mean the software has to be very complicated.

答:
You've asked two questions in the question header, so I'll answer both of them.

Yes, Computer Science is all about algorithms. Well... actually that's a little misleading because there are many aspects to computer science, so I'll rephrase.  Computer science as it is applied in the working world is predominantly about algorithms. Companies like Google, Facebook, and all those crazy places in Wall Street hiring Physicists and Developers want highly complex problems reduced to a simple form, which in itself requires a deep understanding of mathematics, and algorithm design.

No, Programming is not all about algorithms.  Programming is about taking specifications and converting them into code which can be compiled for execution.

The extra part of the answer:  Software Development is not programming, and yet many seem to confuse the terms and use them interchangeably. Programming is merely a function or a technique perhaps of the larger process of Software Development. Software Development is certainly not all about algorithms, it's about solving problems with software, and applying sound business compatible processes to allow problems to be solved efficiently. While software development processes - and even programming itself - might be algorithmic processes in their nature, this is not the same as being about algorithms.


答: If you are concerned about preventing access to view files in your webroot, then the solution is to use .htaccess to redirect requests to those files over to your application.  I prefer a bootstrap index file that handles all requests.</p>


问:
Why don't public web applications use ini files for configuration
Almost every public CMS out there uses a .php configuration file for the database settings and so on. For example WordPress automatically creates a .php config file when you install it.

Why don't they just use a .ini file? PHP already has parse_ini_file() and I'm sure other languages have similar functions.

答:
With PHP in particular; the difference between an .ini file and a .conf.php file is negligible.

Using PHP directly for configuration has the distinct advantage of only needing to relate to one well-defined, portable syntax for configuration, and the fact that the configuration file is properly code is occasionally useful.

Compared to that; an ini file has little to nothing to offer; and include, require and require_once are all well-known and (mostly) well understood.


答:
Generally speaking I prefer .ini or XML configuration files. In larger systems, often someone other than the developer will need to change a configuration value, possibly a DBA or a sysadmin. Most DBAs and sysadmins I know wouldn't have any problem navigating through a simple PHP script, but I would prefer if they didn't. One small mistake in there can harm the whole application in quite a few ways.

But in smaller systems, it's extremely convenient to use PHP scripts for configuration. I was playing around with the AWS SDK today, which also uses a PHP script for configuration:

```<code>CFCredentials::set(array(
    'development' => array(
        'key' => 'xxx',
        'secret' => 'xxxx',
        'default_cache_config' => sys_get_temp_dir(),
        'certificate_authority' => true
    ),
    '@default' => 'development'
));
</code>```

Instead of hardcoding a default_cache_config, I'm passing the system temp, and that would work in every system I deploy the script. This script is a small proof of concept that will be passed around 10 developers, and I want them to run it as is, withouth having much to think about. If the prototype evolves, I'll hardwire it with my XML configuration class (and obviously won't rely on filesystem cache).

Title: Why don't public web applications use ini files for configuration

Body:
Almost every public CMS out there uses a .php configuration file for the database settings and so on. For example WordPress automatically creates a .php config file when you install it.

Why don't they just use a .ini file? PHP already has parse_ini_file() and I'm sure other languages have similar functions.

Body:
Generally speaking I prefer .ini or XML configuration files. In larger systems, often someone other than the developer will need to change a configuration value, possibly a DBA or a sysadmin. Most DBAs and sysadmins I know wouldn't have any problem navigating through a simple PHP script, but I would prefer if they didn't. One small mistake in there can harm the whole application in quite a few ways.

But in smaller systems, it's extremely convenient to use PHP scripts for configuration. I was playing around with the AWS SDK today, which also uses a PHP script for configuration:

CFCredentials::set(array(
    'development' => array(
        'key' => 'xxx',
        'secret' => 'xxxx',
        'default_cache_config' => sys_get_temp_dir(),
        'certificate_authority' => true
    ),
    '@default' => 'development'
));

Instead of hardcoding a default_cache_config, I'm passing the system temp, and that would work in every system I deploy the script. This script is a small proof of concept that will be passed around 10 developers, and I want them to run it as is, withouth having much to think about. If the prototype evolves, I'll hardwire it with my XML configuration class (and obviously won't rely on filesystem cache).


答:
I would never take and show the code that I wrote for a previous employer.  I also wouldn't trust someone that I interviewed who brought code from their last employer (are they going to steal code from us next?  Did you actually write it?).

A solution for this would be to work on an open source project or a personal side project if you need to demonstrate your code.  While I have done this, and have offered to show the code that I have written, most employers don't want to see previous work (it's no proof you actually wrote it).  When I have interviewed people in the past I have asked them to write snippets or answer programming related questions.  You can't BS that.


问:
Why should I prefer composition over inheritance?
I always read that composition is to be preferred over inheritance. A blog post on unlike kinds, for example, advocates using composition over inheritance, but I can't see how polymorphism is achieved.

But I have a feeling that when people say prefer composition, they really mean prefer a combination of composition and interface implementation. How are you going to get polymorphism without inheritance?

Here is a concrete example where I use inheritance. How would this be changed to use composition, and what would I gain?

Class Shape
{
    string name;
  public:
    void getName();
    virtual void draw()=0;
}

Class Circle: public Shape
{
    void draw(/*draw circle*/);
}
```

答:
The example you've given is one where inheritance is the natural choice. I don't think anyone would claim that composition is always a better choice than inheritance -- it's just a guideline that means that it's often better to assemble several relatively simple objects than to create lots of highly specialized objects.

Delegation is one example of a way to use composition instead of inheritance. Delegation lets you modify the behavior of a class without subclassing. Consider a class that provides a network connection, NetStream. It might be natural to subclass NetStream to implement a common network protocol, so you might come up with FTPStream and HTTPStream. But instead of creating a very specific HTTPStream subclass for a single purpose, say, UpdateMyWebServiceHTTPStream, it's often better to use a plain old instance of HTTPStream along with a delegate that knows what to do with the data it receives from that object. One reason it's better is that it avoids a proliferation of classes that have to be maintained but which you'll never be able to reuse. Another reason is that the object that serves as the delegate can also be responsible for other things, such as managing the data received from the web service.


答:
Polymorphism does not necessarily imply inheritance.  Often inheritance is used as an easy means to implement Polymorphic behaviour, because it is convenient to classify similar behaving objects as having entirely common root structure and behaviour.  Think of all those car and dog code examples you've seen over the years.

But what about objects that aren't the same.  Modelling a car and a planet would be very different, and yet both might want to implement Move() behaviour.

Actually, you basically answered your own question when you said "But I have a feeling that when people say prefer composition, they really mean prefer a combination of composition and interface implementation.".  Common behaviour can be provided through interfaces and a behavioural composite.

As to which is better, the answer is somewhat subjective, and really comes down to how you want your system to work, what makes sense both contextually and architecturally, and how easy it will be to test and maintain.

Title: Why should I prefer composition over inheritance?

Body:
I always read that composition is to be preferred over inheritance. A blog post on unlike kinds, for example, advocates using composition over inheritance, but I can't see how polymorphism is achieved.

But I have a feeling that when people say prefer composition, they really mean prefer a combination of composition and interface implementation. How are you going to get polymorphism without inheritance?

Here is a concrete example where I use inheritance. How would this be changed to use composition, and what would I gain?

Class Shape
{
    string name;
  public:
    void getName();
    virtual void draw()=0;
}

Class Circle: public Shape
{
    void draw(/*draw circle*/);
}
```


问:
Github-like "pull requests" without Github
I work as an analyst for a financial institution, which, due to data sensitivity, will not store any data in the cloud. However, I'm having some success getting my team to use Git for code management. I was wondering whether there was any way to implement Github-like pull requests in our own server. The specific feature I'm interested in is the ability to submit a changeset for comments, without actually having it merged into a given branch. I like the workflow of (1) submit changes, (2) have changes reviewed and commented on, and (3) either accept the commit or reject it. Can this be implemented (even better, can this be easily implemented) on our own servers?

答:
You can self host GitHub for a price, personally I think it is very expensive but it is available as an alternative if you just love GitHub.

Personally I went with Gitorious and had great success with it. Self hosting it and integrating the project/repository features with a typical Git Merge Request system, it works great for distributed and non-distributed teams.


答: The answer is simple: a conf.php has basically zero work required for it to operate. It's just another source file.</p>