问:
The present and future of programming in local languages
Can programming become language-independent? Will we always program in English? Will we ever be able to program in our local languages? Is there any research that addresses the matter? Are there any such developments?</p>

答:
It certainly could, but it would require a change in the way we write programs.  Currently, we are wedded to a "write text file, give text file to computer" model of software development.  Every programming system works like this, and this makes it very difficult to make it language independent.  I don't think it is the only way, though.

Long ago, on small machines, it didn't always work this way.  On very low memory computers (think 16K Commodore PET) it wasn't reasonable to store the entire text in memory of a program.  Even a trivial BASIC program would have exhausted memory if "GOTO" took 4 bytes.  So these systems tokenized input as you typed.  You typed "GOTO" and that was immediately translated into a token.  When you listed your program and tokens were converted back to human readable keywords.

In such a system, creating an alternate language would be trivial.  English speakers would see "GOTO" and Japanese speakers would see "行く" and since the conversion happened at the code creation/display time, English and Japanese speakers could share source.  The source itself would be tokenized.  I see no reason why you couldn't do this with modern languages.

What it would require would be to break the "text file as source code" model.  The language would have to be completely integrated into the editing process.  In this imaginary world, when you fire up your editor and load, say, Python source, all of the language independent tokens in the file are translated to your locale language setting keywords.  When you type keywords they are automatically translated to tokens.  In other words, you aren't directly editing the text but rather creating the tokenized file.  The interpreter would then be written to operate on tokens rather than text.  It would probably even make interpretation/compilation a little faster as everything would be tokenized at the editing stage.

This is all possible and would have some advantages.  What you'd lose is the ability to read source using arbitrary text editors.  It would require language aware editors.  When I was in college, I wanted to build a system like this, but real life intruded.

Of course, this doesn't solve everything, which is probably why it has never been done.  Keywords might be language independent, but identifiers and constants wouldn't be.  It might not help much if the code looked like this:

```<code>for(unsigned int 人=人リスト.begin();人!=.end();人++)
</code>```

This probably doesn't just effect user written code but also libraries.  In the above, begin and end aren't language keywords, but library methods.  To solve that, you'd need machine translation, and we're not there yet.  As an English speaker who has on occasion read C++ code written in Japan, I can say the fact that the language keywords are in English only helps marginally.

Body:
It certainly could, but it would require a change in the way we write programs.  Currently, we are wedded to a "write text file, give text file to computer" model of software development.  Every programming system works like this, and this makes it very difficult to make it language independent.  I don't think it is the only way, though.

Long ago, on small machines, it didn't always work this way.  On very low memory computers (think 16K Commodore PET) it wasn't reasonable to store the entire text in memory of a program.  Even a trivial BASIC program would have exhausted memory if "GOTO" took 4 bytes.  So these systems tokenized input as you typed.  You typed "GOTO" and that was immediately translated into a token.  When you listed your program and tokens were converted back to human readable keywords.

In such a system, creating an alternate language would be trivial.  English speakers would see "GOTO" and Japanese speakers would see "行く" and since the conversion happened at the code creation/display time, English and Japanese speakers could share source.  The source itself would be tokenized.  I see no reason why you couldn't do this with modern languages.

What it would require would be to break the "text file as source code" model.  The language would have to be completely integrated into the editing process.  In this imaginary world, when you fire up your editor and load, say, Python source, all of the language independent tokens in the file are translated to your locale language setting keywords.  When you type keywords they are automatically translated to tokens.  In other words, you aren't directly editing the text but rather creating the tokenized file.  The interpreter would then be written to operate on tokens rather than text.  It would probably even make interpretation/compilation a little faster as everything would be tokenized at the editing stage.

This is all possible and would have some advantages.  What you'd lose is the ability to read source using arbitrary text editors.  It would require language aware editors.  When I was in college, I wanted to build a system like this, but real life intruded.

Of course, this doesn't solve everything, which is probably why it has never been done.  Keywords might be language independent, but identifiers and constants wouldn't be.  It might not help much if the code looked like this:

for(unsigned int 人=人リスト.begin();人!=.end();人++)

This probably doesn't just effect user written code but also libraries.  In the above, begin and end aren't language keywords, but library methods.  To solve that, you'd need machine translation, and we're not there yet.  As an English speaker who has on occasion read C++ code written in Japan, I can say the fact that the language keywords are in English only helps marginally.


问:
Application / Code reviews for lone programmers?
Are there any services that 'for a reasonable price' will give and provide good and technical advice on applications. On a lot of projects, I'm usually the only developer, and sometimes, I think some of my work needs to be improved for efficiency, better MVC interactions, etc. It would be great if there was a professional service that actually can and will do such reviews</p>

答: There are a lot of software consulting companies out there which will do this kind of service for you. They're not free of course (and often not cheap) but I am working with one now and I find what I learn from them is worth the price.</p>

ContentLicense: CC BY-SA 2.5


问:
Should I return iterators or more sophisticated objects?
Say I have a function that creates a list of objects. If I want to return an iterator, I'll have to return iter(a_list). Should I do this, or just return the list as it is? My motivation for returning an iterator is that this would keep the interface smaller -- what kind of container I create to collect the objects is essentially an implementation detail

On the other hand, it would be wasteful if the user of my function may have to recreate the same container from the iterator which would be bad for performance.

答: It seems like returning an iterator only makes sense if the underlying collection should not be modified or queried any other way, and you don't want the underlying collection to be iterated over multiple times with out the caller getting a new iterator. I might be missing some finer points of Python, though, as I am thinking about this in terms of Java's iterators.</p>

ContentLicense: CC BY-SA 3.0


问:
What advantages does developing applications for smartphones have over developing the same application as a web application?
Let's take the Facebook application as an example. Why did they develop an application when the users could just access to their page and do the same? For me that represents more maintenance and more cost because for each feature added to the web application that feature will have to be added to the smartphone application as well.

So why would I want to develop more than once (for each patform iOS, Android, etc) when I could just have one web application? What benefits do I get? The only one that comes to my mind is GPS feature.

EDIT:

My question is more oriented towards business applications that are going to be used only by some members of the company, it's not about selling the application (private use). So contrary to what some answers say about that by developing as a smartphone application it will benefit from more sells because of the "smartphone stores" for me this point is not important because the application is for private use.

By developing the application as a web application it means that it can be accessed through smartphone browser and also in a PC (any capable browser), but developing as a native application would limit this to only some kind of smartphone so we would be limiting  the use.  On the other hand developing it as a web application means that in order to access the application an Internet connection must be available.

So keeping this in mind how would you convince your boss to write the application for a given smartphone platform (iOS/Android) vs developing it as a web application?

答:
I am going to argue in favour of web-apps.

In the other examples given, they always point to Facebook. A brand that is completely ubiquitous has no need to worry about user buy-in, and can convice platforms to bundle their app.

Not so with startups or relative unknowns.  Being surfaced on the app store is far more difficult than on the web via a simple search.

Let's talk about UI. People are rolling out the argument that UI is better on a native app but that is unjustified. A web app can look exactly like a native app.  Loading times might be a little slower, and this is relevant to UI, but so is findability, where web apps win.

Native apps are not structured to allow links to their content. So you are preventing users from linking to content in blogs, emails, and social media. How is that usable?

And then commenters point to offline storage. Does the Facebook app work offline?

Of course there will always be business cases for native apps in some circumstances. But unless your payment model benefits from charging for the app, or you need specific functionality like access to camera API, a web app is going to be better.


问:
Which programming language for text editing?
I need a programming language for text editing and processing (replace, formatting, regular expressions, string comparison, word processing, text analysis, etc.). Which programming language is more powerful and has more functions for this purpose?

Since I work PHP for my web projects, I currently use PHP, but the fact is that PHP is a scripting language for web applications; my current project is offline.

I am curious if other programming languages such as Perl, Python, C, C++, Java, etc. have more functionality for this purpose, and worth of shifting the project?

答:
It REALLY depends on what you need to do. If you mainly want to recognize things, and your input is lines, each line consisting of fields delimited by spaces, AWK is easy to learn, easy to use, and quite effective for what it does.

I've never really studied Perl, so I can't really comment on it. Ditto for Ruby and Python.

I don't think there's anything that runs it today, but TECO on the PDP-10 was in fact a programming language for editing, that came with an interpreter. I wrote a complete #include file processor in TECO, back in the late 1970s. (It was all I had on that machine that was suitable.)

GNU Emacs is actually a Lisp system that had certain fundamental design decisions resolved in ways that made writing editors and editor extensions easier. It also has a lot of low-level editing stuff compiled into the "kernel".

SNOBOL, while ancient, was specifically designed for that kind of thing. I am given to understand that it is still available, even today.


问:
Finding an A* heuristic for a directed graph
In a previous question, I asked about finding a route (or path if you will) in a city. That is all dandy. The solution I chose was with the A* algorithm, which really seems to suit my needs. What I find puzzling is heuristic. How do I find one in an environment without constant distance between 2 nodes? Meaning, not every 2 nodes have the same distance between them.

What I have is nodes (junctures), streets with weight (which may also be one-way), a start/finish node (since the start and end is always in the same place) and a goal node. In an ordinary case, I would just use the same way I got to goal to go back, but since one of the streets could have been a one-way, that may not be possible.

The main question

How do I find a heuristic in a directed graph?

答: Finding the longest cycle is a novel concept in biochemical feedback loop analysis in systems biology. Biochemical networks are often represented as directed graphs in which vertices represent chemical compounds and edges represent chemical reactions between compounds. Therefore, a biochemical longest feedback loop can be formulated as the longest cycle in a directed graph. Because finding the longest cycle in a directed graph is NP-hard, in this paper, we proposed an intelligent heuristic algorithm to find the longest cycle in a directed graph. We tested the algorithm on both randomly generated complex networks and real biochemical networks extracted from the KEGG database. The results showed that our algorithm is able to find more than 70% of the real longest cycles in the 200 randomly generated complex networks and also can find the feedback loop in the longest pathway. Compared with the traditional breadth first search pathway finding algorithm, the search efficiency of the proposed algorithm has been improved dramatically. Among the feedbacks found from the KEGG database using the proposed algorithm, the longest feedback includes 8 compounds, 9 reactions, and 6 pathways across different modules.</p>


问:
Is there a language where collections can be used as objects without altering the behavior?
Is there a language where collections can be used as objects without altering the behavior?

As an example, first, imagine those functions work:

```<code>function capitalize(str)
    //suppose this *modifies* a string object capitalizing it
function greet(person):
    print("Hello, " + person)

capitalize("pedro")
>> "Pedro"

greet("Pedro")
>> "Hello, Pedro"
</code>```

Now, suppose we define a standard collection with some strings:

```<code>people = ["ed","steve","john"]
</code>```

Then, this will call toUpper() on each object on that list

```<code>people.toUpper()
>> ["Ed","Steve","John"]
</code>```

And this will call greet once for EACH people on the list, instead of sending the list as argument

```<code>greet(people)
>> "Hello, Ed"
>> "Hello, Steve"
>> "Hello, John"
</code>```

答:
Yes, there are such languages. Many of them.

In fact, this feature is pretty much the definition of an array language or vector language. Examples of array and vector languages include, but are not limited to, the APL family of languages with its successors, derivatives and cousins (E.g. APL, J, K) and pretty much all mathematical and statistical languages such as Mathematica, MATLAB, Octave, R, and S.

Fortran 90 and Ada also have this feature, as does Fortress.

Interestingly, many modern CPUs also support vector programming, e.g. the x86 architecture with the MMX, SSE, SSE2, SSE3 (Intel) and 3DNow! (AMD) instruction sets, the POWER and PowerPC architectures with the VMX and AltiVec instruction sets, Sparc, MIPS, even ARM.

The Cω language by Microsoft Research has the concept of streams (roughly similar to IEnumerable). Streams pretty much work exactly as you describe. Here's an example from the Cω documentation (emphasis mine):

A key programming feature of Cω is generalized member access: the familiar 'dot' operator is now much more powerful. Thus if the receiver is a stream, then the member access is mapped over the elements, e.g. zones.ToString() implicitly maps the method call over the elements of the stream zones and returns a value of type string*. This feature significantly reduces the burden on the programmer.

A very interesting property of this kind of programming is that it not only allows you to semantically think of "applying an operation to all elements at once", it also allows the language implementor to implement it by literally applying an operation to all elements at once, IOW in parallel.


问:
Is comparing cloud computing to main frames a bad analogy?
They both can be seen as centralized processing, but from a developer's perspective is it returning us to the days when access to computers you could program yourself were limited and expensive? To me that was the problem the PC solved.

Heard this on http://thisdeveloperslife.com/ 1.0.6 Abstraction.

答:
It is similar in the standpoint of cloud computing is implemented using virtual machines and Mainframes have been doing that for thirty years or longer. Mainframes also can be physically distributed while supporting a single logical instance.

One thing that strikes me as very different, is that real cloud solutions provide computing resources on demand. Now, not every cloud environment really supports this but the biggest ones all do in some way. So whether its just seamlessly replicating the application to more app servers as Google does, or by providing API's to add new virtual machines like Amazon does, either way you can immediately get more computing resources. Mainframes you can increase allocations to existing LPARs but bringing on a new LPAR is not trivial and neither is adding more processing power to the system (depends very much though on what you want to add and the system you are using).

Clouds are not centralized in the sense of having one large system support all these VMs, they are usually built on a distributed architecture even at the local level (lots of blade servers for example).


答:
You can get semantics very similar to what you're asking for in nearly all languages using the composite pattern.

Given you have some type similar to this:

```<code>// pseudocode
class CustomString
{
    CustomString Composite;
    string Value;
}
</code>```

... and a Greet method like this:

```<code>// pseudocode
public string Greet(CustomString cs)
{
    string ret;
    if (cs!= null)
        ret += "Hello " + cs.Value + newline;

    if (cs.Composite != null)
        ret += Greet(cs.Composite);
}
</code>```

... you can make calls like this:

```<code>writeln(Greet(new CustomString("snorfys")))
>> Hello snorfys

cs = new CustomString("snorfys") { Composite = new CustomString("Dokkat") }
writeln(Greet(cs))
>> Hello snorfys
>> Hello Dokkat
</code>```

If you do a lot of work with trees, programming in this way feels common quickly (that is to say that each tree node is, and can be treated as, a subtree).

Body:
Is there a language where collections can be used as objects without altering the behavior?

As an example, first, imagine those functions work:

```<code>function capitalize(str)
    //suppose this *modifies* a string object capitalizing it
function greet(person):
    print("Hello, " + person)

capitalize("pedro")
>> "Pedro"

greet("Pedro")
>> "Hello, Pedro"
</code>```

Now, suppose we define a standard collection with some strings:

```<code>people = ["ed","steve","john"]
</code>```

Then, this will call toUpper() on each object on that list

```<code>people.toUpper()
>> ["Ed","Steve","John"]
</code>```

And this will call greet once for EACH people on the list, instead of sending the list as argument

```<code>greet(people)
>> "Hello, Ed"
>> "Hello, Steve"
>> "Hello, John"
</code>```

Body:
You can get semantics very similar to what you're asking for in nearly all languages using the composite pattern.

Given you have some type similar to this:

// pseudocode
class CustomString
{
    CustomString Composite;
    string Value;
}

... and a Greet method like this:

// pseudocode
public string Greet(CustomString cs)
{
    string ret;
    if (cs!= null)
        ret += "Hello " + cs.Value + newline;

    if (cs.Composite != null)
        ret += Greet(cs.Composite);
}

... you can make calls like this:

writeln(Greet(new CustomString("snorfys")))
>> Hello snorfys

cs = new CustomString("snorfys") { Composite = new CustomString("Dokkat") }
writeln(Greet(cs))
>> Hello snorfys
>> Hello Dokkat

If you do a lot of work with trees, programming in this way feels common quickly (that is to say that each tree node is, and can be treated as, a subtree).


问:
Does heavy JavaScript use adversely impact Googleability?
I've been developing the client-side for my web-app in JavaScript.

The JavaScript can communicate with my server over REST (HTTP)[JSON, XML, CSV] or RPC (XML, JSON).

I'm writing writing this decoupled client in order to use the same code for both my main website and my PhoneGap mobile apps.

However recently I've been worrying that writing the website with almost no static content would prevent search-engines (like Google) from indexing my web-page.

I was taught about this restriction about 4 years ago, which is why I'm asking here, to see if this restriction is still in-place.

Does heavy JavaScript use adversely impact Googleability?

答:
Google (and I suspect Bing as well) have gotten much better at reading and indexing text found in JavaScript elements during the past 3-5 years or so. They do this for two reasons. First, to provide better indexing of content for users and, second, to detect and thwart various spamming techniques.

The problem is that you may not get indexed as well as you would like for the keywords you want or for long tail combos that may be valuable. Let's say that your topic was on dog training supplies. You might be able to rank for dog training supplies if your incoming links were good and other on-page elements fit the search engines' statistical profiles. However, since you have content for "German Shepard training supplies" or "Great Dane training supplies" buried inside a lot of replaceable text, you might not rank as easily for these terms. There are some ways to manage this but the best strategy will depend on specifics for your site.

Another thing to consider is that splitting off content into standard and mobile sections can cause ranking problems as well. Make sure that you use the canonical tag to indicate that your standard page is the one that should be considered the primary source. This avoids duplicate content filtering and possible penalties associated with the recent Google Panda update.


答: If most of your actual page content is in a database, and the only way the user actually sees it is if a JavaScript queries the DB via Ajax and inserts the result into the DOM, then there is basically no way for search engines to see it. This hasn't changed; if anything, it has got worse as Web sites are made less and less static.</p>

Body:
I've been developing the client-side for my web-app in JavaScript.

The JavaScript can communicate with my server over REST (HTTP)[JSON, XML, CSV] or RPC (XML, JSON).

I'm writing writing this decoupled client in order to use the same code for both my main website and my PhoneGap mobile apps.

However recently I've been worrying that writing the website with almost no static content would prevent search-engines (like Google) from indexing my web-page.

I was taught about this restriction about 4 years ago, which is why I'm asking here, to see if this restriction is still in-place.

Does heavy JavaScript use adversely impact Googleability?


答:
Actually you can use PHP on the command line, so the assertion that it cannot be used offline is false. If you're already familiar with PHP and its string handling functions you should look into it.

I used to work with PHP and there were some behind the scenes stuff done with PHP scripts that could be run on the command line (with cron jobs even). It was a little weird to do PHP scripts offline, because you still need the preprocessor tags (that is, <?php ... ?>), but it was doable.

Alternatively, we use Python scripts as well for behind-the-scenes stuff, but it was more a matter of personal preference than anything.

Title: Which programming language for text editing?

Body:
I need a programming language for text editing and processing (replace, formatting, regular expressions, string comparison, word processing, text analysis, etc.). Which programming language is more powerful and has more functions for this purpose?

Since I work PHP for my web projects, I currently use PHP, but the fact is that PHP is a scripting language for web applications; my current project is offline.

I am curious if other programming languages such as Perl, Python, C, C++, Java, etc. have more functionality for this purpose, and worth of shifting the project?


答:
Do an ajax get request on a typical web page rather than some API address and output the results as a string. That's what the spiders have to work with. Google is supposedly a little bit smarter and there are supposedly some workarounds but if you have static content for the indexing, why would you try to serve and build it via Ajax?

And yes, I've seen Android tutorials that suggest otherwise. You'd think Google engineers would be a little more google conscious but maybe that's the problem when all you have to do is tap somebody on the shoulder to have your junk show up on the first page of keyword terms you're targeting. In order to index your page, there has to be something to index. The more straightforward that process is for algorithms written by a bunch of Stanford Java guys... well, let's just say, duh.

It might be able to follow some JS-stuff if you do it right, or so I've heard but I've paid very little attention to this because really, you're solving the wrong problem 99 times out of 100 at that point. Serve static HTML from the server. Anything you want users to build or reference in ways that shouldn't "stick" to a given URL, is reasonably handled by Ajax and DOM work.

Why add more complexity to the issue when you can do it in a way that never stopped making sense in the first place? Faster rendering in JS? That's just ignoring the real problem which is that a given browser's HTML/CSS parsers need an upgrade.

Title: Does heavy JavaScript use adversely impact Googleability?


答:
Google, or any other search engine for that matter, will not execute/evaluate the JavaScript on your page.

So if you rely on JavaScript for retrieving the data to present to the user, then that data will not be seen/indexed by search engines.


问:
A completely free and open programming language
With Oracle vs Google trial, it seems that Java is not entirely Open and free (as free software) as I expected. Although there exists completely free/open JVM, it's hard to know what is a copyright infringement with Java, and what is not.

So I'd like to know if there is a completely Open and free language with open and free IDE (Eclipse-like) out there, Object Oriented if possible, and able to make window-based applications for the main OSs (Linux, Mac, Windows).

答: Would Mono with MonoDevelop be what you are looking for?</p>


问:
Pros and cons for open or close sourcing niche type products
One of the products I developed, is really a niche type application (2 or 3 other competitors in the market). Although for the most part, I'm the lone user of these applications, I'm thinking of selling the app right now.

My question is:

Because of the small market share and that it's a niche project would you advise I open or close my application?

答:
An open source project without contributors is really bad.

If the market is small, I doubt you will find any contributor. But I may be wrong. I don't know anything about your market.

You must do a market study.

If you can't afford it, try to release the software first. In free BETA to get more users, but you can do it as a paid edition too already.

As soon as you get users, ask them questions directly (chat with them, don't waste your time with surveys). They will like that very much, and they will always help you to improve your solution.

Ask them if they would contribute if you were open source.

Analyze the results.

Decide.


答:
Python

The reference implementation, CPython, is released under the Python Software Foundation License, an OSI approved licence. There are bindings for most popular platform-independent GUI toolkits, including:

Tkinter

wxWidgets

Qt

Gtk+

FLTK

FOX

OpenGL

As for an IDE, since you mentioned Eclipse, PyDev is probably what you're looking for. I prefer ActiveState's Komodo IDE, but it's not free.

C++

The core language and the standard library are ANSI/ISO standards, and although not strictly an open source language, all major C++ compilers are free to use:

gcc, open source, and available for Windows through MinGW,

Microsoft's C++ compiler, proprietary, freely available through Visual C++ 2010 Express,

Intel's C++ compiler, proprietary, freely available for non commercial use.

There are quite a few open source bindings / interfaces for most popular platform-independent GUI toolkits, just pick one and search for it. As for an IDE, well, Eclipse with CDT would be my choice.

Mono

Mono is multi-licensed under the MIT licence, GPLv2 and LGPLv2. When it comes to Microsoft's patents, insofar they've followed their promise, but who knows what the future will bring. Mono allows you to work with a variety of open source GUI toolkits, and MonoDevelop seems to be the IDE of choice.

FreePascal

FreePascal is a Pascal / Object Pascal compiler, licensed under the GPL. The Lazarus Component Library (LCL) and fpGUI are the more popular FreePascal GUI toolkits, and Lazarus the IDE of choice.

Title: A completely free and open programming language

Body:
With Oracle vs Google trial, it seems that Java is not entirely Open and free (as free software) as I expected. Although there exists completely free/open JVM, it's hard to know what is a copyright infringement with Java, and what is not.

So I'd like to know if there is a completely Open and free language with open and free IDE (Eclipse-like) out there, Object Oriented if possible, and able to make window-based applications for the main OSs (Linux, Mac, Windows).


答: I think the answer to this comes down to your personal principles, and how you feel about the concept of open source.  Do you want end-users or admins looking at, and possibly changing your code?  Are you concerned about people lifting your business logic, etc?  My guess is that the risk of exposing intellectual property to your competitors is small, since the market is not already saturated.  The other question is: what will you gain from making it open source?  If the build process is complicated, and your potential customer base is small, users won't want to go through the build process anyway.  Likewise, you probably won't find too many contributors, either.  But if you feel like this is the sort of technology that belongs to the whole world, then I say go ahead and make it open source.</p>

Title: Pros and cons for open or close sourcing niche type products

Body:
One of the products I developed, is really a niche type application (2 or 3 other competitors in the market). Although for the most part, I'm the lone user of these applications, I'm thinking of selling the app right now.

My question is:

Because of the small market share and that it's a niche project would you advise I open or close my application?


问:
Do people use const a lot when programming in Objective C?
Related: “sending 'const NSString *' to parameter of type 'NSString *' discards qualifiers” warning

Sometimes, I think it's useful though. I may need to pass an a table and want to make sure that the content of the table does not change.

However, in most Objective-C program samples, I never see const. My question is why?

答:
As far as Objective C goes - I don't program in it, so can't answer the question. The question I can answer though is "Should people use const a lot when programming in Objective C?"  - that one is a definite "Yes".

Constness is essentially a software security feature that is used to make programs more reliable and maintainable. Many programmers grow up without really appreciating the value of consts, until one day something bad happens and they have an "Ah ha" moment - "Oh, that's what const is used for".  It's entirely possible to write a program with no constants, is virtually impossible to make such a program reliable.

Many samples of code are not really programs, just snippets that are designed to show a specific feature. They don't use const as it distracts from the point the sample is trying to make.  The other type of code you see is code written by inexperienced programmers who base what they do on the examples they have learned from, or those that know about constants, and are too lazy to use them.


问:
Is it possible to know what programming language a web-site uses?
For example, stackexchange.com, without asking the site owner or Google their information about developing the website, is this possible to know what language is used in the back end?

Seems, the website don't have .extension bar, for example .php that can indicated which is developed in PHP, but without the extension, how can I know that?

答:
There are indicators. Some are easier to find, others are harder.

file extensions: .php indicates that the site is written in PHP, .asp indicates classic ASP, .aspx indicates ASP.NET, .jsp indicates Java JSPs, ...

cookie names: JSESSIONID is a widely used cookie name in Java servers

headers: some systems add HTTP headers to their responses

specific HTML content:

patterns such as lots of div-wrappers with a consistent class-naming scheme as used by CMSes like Drupal.

comments in the HTML or meta tags in the head directly/indirectly indicating tool usage

Default error messages or error page design (e.g. pinging a fake URL to see their 404)

Sometimes comment tags are placed in the page for versioning purposes which provide a clue

...

But all of those can be remove/changed/faked. Some are easier to change than others, but none are 100% reliable.

There are various reasons to change those indicators:

You change the underlying technology but don't want to change your URLs

You want to give as little information about your technology as possible

(related to previous) You'd rather not be the first stop for the script kiddie bus when known platform-wide vulnerabilities are discovered/publicized

You want to seem "in" (even 'though that currently means having extension-less REST-style URLs).

...


答: Maybe you could make use of a functional programming language. Haskell is an example. it's free.


答:
Due to the way that Objective-C objects work, const gives up being an enforcement and starts being a notation for the programmer. Consider this program:

```<code>int f(const int x) {
    return ++x;
}

int main(int argc, char *argv[]) {
    @autoreleasepool {
        int x = 3;
        NSLog(@"%d", f(x));
    }
    return 0;
}
</code>```

That actually won't compile here (I'm using clang): the compiler can detect the attempt to modify the primitive C type and emits an error. But now compare it with this program:

```<code>NSMutableString *f2(const NSMutableString * const x) {
    [x appendString: @" world!"];
    return x;
}

int main(int argc, char *argv[]) {
    @autoreleasepool {
        NSMutableString *x = [@"Hello" mutableCopy];
        NSLog(@"%@", f2(x));
    }
    return 0;
}
</code>```

Even though the function is passed a constant pointer to a constant object, it's still possible to mutate the object.

In object-oriented programming, the best way to enforce the constant nature of an object is to make that object immutable - i.e. don't provide any methods that can change its state. Imagine that the function above took an NSString argument instead of NSMutableString, and that I'd passed the literal @"Hello" instead of a mutable copy. There is now, reasonably speaking, no chance of mutating the passed-in object[*]. Objective-C doesn't have any way of enforcing that though, unlike const or final object references in other OO languages.

For comparison, const works entirely differently in C++. If I get a const reference to a C++ object, I'm only allowed to call const member functions on that object. These functions preserve the const-ness of the object, either by not making any changes or by only modifying member variables that have explicitly been marked mutable by the class designer. So imagine that I had some type MutableString in C++ that's equivalent to NSMutableString in Objective-C. The equivalent of my example above would look something like:

```<code>MutableString& f3(const MutableString& x) {
  x.appendString(" world!");
  return x;
}
</code>```

This definitely won't compile: in addition to appendString() not being a const operation, the function removes the const qualifier from the type reference which requires a const_cast.

[*]I expect there is some contorted way of doing it, but now we're into the realms of one programmer trying to sabotage another by doing "clever" things.

Title: Do people use const a lot when programming in Objective C?

Body:
Related: “sending 'const NSString *' to parameter of type 'NSString *' discards qualifiers” warning

Sometimes, I think it's useful though. I may need to pass an a table and want to make sure that the content of the table does not change.

However, in most Objective-C program samples, I never see const. My question is why?

Body:
Due to the way that Objective-C objects work, const gives up being an enforcement and starts being a notation for the programmer. Consider this program:

int f(const int x) {
    return ++x;
}

int main(int argc, char *argv[]) {
    @autoreleasepool {
        int x = 3;
        NSLog(@"%d", f(x));
    }
    return 0;
}

That actually won't compile here (I'm using clang): the compiler can detect the attempt to modify the primitive C type and emits an error. But now compare it with this program:

NSMutableString *f2(const NSMutableString * const x) {
    [x appendString: @" world!"];
    return x;
}

int main(int argc, char *argv[]) {
    @autoreleasepool {
        NSMutableString *x = [@"Hello" mutableCopy];
        NSLog(@"%@", f2(x));
    }
    return 0;
}

Even though the function is passed a constant pointer to a constant object, it's still possible to mutate the object.

In object-oriented programming, the best way to enforce the constant nature of an object is to make that object immutable - i.e. don't provide any methods that can change its state. Imagine that the function above took an NSString argument instead of NSMutableString, and that I'd passed the literal @"Hello" instead of a mutable copy. There is now, reasonably speaking, no chance of mutating the passed-in object[*]. Objective-C doesn't have any way of enforcing that though, unlike const or final object references in other OO languages.

For comparison, const works entirely differently in C++. If I get a const reference to a C++ object, I'm only allowed to call const member functions on that object. These functions preserve the const-ness of the object, either by not making any changes or by only modifying member variables that have explicitly been marked mutable by the class designer. So imagine that I had some type MutableString in C++ that's equivalent to NSMutableString in Objective-C. The equivalent of my example above would look something like:

MutableString& f3(const MutableString& x) {
  x.appendString(" world!");
  return x;
}

This definitely won't compile: in addition to appendString() not being a const operation, the function removes the const qualifier from the type reference which requires a const_cast.

[*]I expect there is some contorted way of doing it, but now we're into the realms of one programmer trying to sabotage another by doing "clever" things.


问:
Is there any reason in a Java program for a special naming for a function arguments?
I'd like to know, why would I want to have a special prefixes for a function arguments, like "p_name", "p_age", "p_sex"? On the one hand it helps to distinguish parameter from local variable or field further in the function body, but would it help? On the other hand, I didn't saw such naming recommendations anywhere including official Java language conventions. Please advise any reasons for using such naming policy</p>

答:
There is no reason to use such prefixes, since Java uses shadowing of class fields. Use the this keyword and your code remains readable.

I personally prefer to add a "_" prefix to every parameter. Useful with auto completion. When i type _ it filters the list to only parameters.


问:
today's multi-device world for web development
With the huge explosion of mobile devices and addition of HTML5/CSS3, there seems to be a shift towards "responsive" designs (i.e., adapting to smaller screen sizes) which seems to be achieved using CSS3's Media Queries.

My question is, given the current need of adapting to both desktop and mobile, is it common practice to actually organize two versions of your website (one for desktop and one for mobile)? Or is there just one version with different css files for targeting different devices and screens?

Handling just cross-browser (ie6, ff3, opera9, etc...) HTML4/5, CSS2/3 was already hard enough, but now we're expected to handle cross-device (phone, tablet, etc...) as well, so my assumption is company's would create a separate project for mobile and redirect based on the user agent, but this is just a guess.

答:
Having two versions is common, but usually it's one version for touch (aka "mobile") and one version for mouse. You end up offering very different UI flows based on what the input mechanism is.

Be careful about server-side redirection based on user agent because it's easy to get it wrong. When redirecting, pay attention to these things:

Always allow the user to change which version of the site/app they're looking at. Remember this setting.

External links should never redirect you to a generic landing page.

All content should be presented in both the desktop and mobile sites.

Just as was the case with multi-browser support, feature detection is more robust than user agent detection. For example, with windows 8 we can expect desktop users to start switching between metro (touch) and desktop (mouse) on-the-fly. What page do you present them?


答:
In C# for example there are extensions (add the functionality to the collection - underneath it would still be a loop, but nothing visible) and Linq - example:

```<code>public static IEnumerble<string> Capitalize(this IEnumerable<string> collection)
{
   var List<string> rtn = new List<string>(collection.Count());
   foreach (var item in collection)
   {
      var ci = Thread.CurrentThread.CurrentCulture;
      var textInfo = ci.TextInfo;

      rtn.Add(textInfo.ToTitleCase(item));
   }
   return rtn;
}
</code>```

[Note: I hand keyed this - so maybe some typos errors]

alternatively, ...

```<code>public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
{
   source.ThrowIfNull("source");
   action.ThrowIfNull("action");
   foreach (T element in source)
   {
        action(element);
   }
}
</code>```

with a function for capitalize

```<code>public static string Capitalize(this string str)
{
    var ci = Thread.CurrentThread.CurrentCulture;
    var textInfo = ci.TextInfo;

    return textInfo.ToTitleCase(str);
 }
</code>```

and then

```<code>myColl.ForEach(x => x.Capitalize());
</code>```

The difference is the second allows you to pass any function along and for any collection type.

```<code>myCollection.Where(employee => emplyee.Age > 50).ForEach(employee => employee.Fire());
</code>```

works too (in a heartless sort of way :D )

Title: Is there a language where collections can be used as objects without altering the behavior?

Body:
In C# for example there are extensions (add the functionality to the collection - underneath it would still be a loop, but nothing visible) and Linq - example:

public static IEnumerble<string> Capitalize(this IEnumerable<string> collection)
{
   var List<string> rtn = new List<string>(collection.Count());
   foreach (var item in collection)
   {
      var ci = Thread.CurrentThread.CurrentCulture;
      var textInfo = ci.TextInfo;

      rtn.Add(textInfo.ToTitleCase(item));
   }
   return rtn;
}

[Note: I hand keyed this - so maybe some typos errors]

alternatively, ...

public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
{
   source.ThrowIfNull("source");
   action.ThrowIfNull("action");
   foreach (T element in source)
   {
        action(element);
   }
}

with a function for capitalize

public static string Capitalize(this string str)
{
    var ci = Thread.CurrentThread.CurrentCulture;
    var textInfo = ci.TextInfo;

    return textInfo.ToTitleCase(str);
 }

and then

myColl.ForEach(x => x.Capitalize());

The difference is the second allows you to pass any function along and for any collection type.

myCollection.Where(employee => emplyee.Age > 50).ForEach(employee => employee.Fire());

works too (in a heartless sort of way :D )


问:
Architecture for interfacing multiple applications
Let's say you have a Master Database and a few External/Internal applications that use WebServices to interface data.

What would be your preferred architecture to interface data from and to those applications? Would you put some sort of Enterprise Service Bus in between? Like BizTalk? Or something cheaper?

We don't want to block applications while they are interfacing, but we do want to use return codes from the interfaces to determine if we need to take some actions in the originating application or not.

答:
When I have done this sort of thing before - database shared across applications, I find it best to have a single "engine" management service that handles the database - and all apps interface with that. This allows for single place for database code changes - new tables etc - and also managing access, turning on/off application access, security, downtime and maintenance tasks (including database moves/upgrades etc).

It is often worth the extra initial effort - and many appls can use the same code/sprocs etc without any need to know the database at all (abstracted away).

This does have some risks of course - it is a single point of failure across the platform (but so is the database itself if it is shared) and it has to be secured and signed to protect against illegal calls from suspect code.


问:
How to refuse to give an access to passwords to a customer without being unprofessional or rude?
Let's say you're creating a website for a customer. This website has its own registration (either combined with OpenID or not). The customer asks you to be able to see the passwords the users are choosing, given that the users will probably be using the same password on every website.

In general, I say:

either that it is impossible to retrieve the passwords, since they are not stored in plain text, but hashed,

or that I have no right to do that or that administrators must not be able to see the passwords of users, without giving any additional details.

The first one is false: even if the passwords are hashed, it is still possible to catch and store them on each logon (for example doing a strange sort of audit which will remember not only which user succeeded or failed to logon, but also with which password). The second one is rude.

How to refuse this request, without being either unprofessional or rude?

答:
Think I would first say that they are one-way encrypted, and then move on to requiring a written (on headed paper) request (from whoever is in charge) so I can present it to the police/FBI (or whatever country's equivalent is relevent)/etc if and when required. Stapple that to a copy of emails in both direction, then the ball is in their court. I can't see any company of any regard requesting this, so it's probably an individual and they would probably back down on the request.

If they give me the paperwork, then it's their data, their request, if they break their own privacy policy or the law, then it's their head.


问:
Is it possible to modify a video codec + distribute it?
this is my first question on this particular stackexchange node, not sure if it's the most appropriate place for this question (if not, guidance to the appropriate node would be appreciated).

the abstract: I'm interested in modifying existing video codecs and distributing my modded codecs in such a way as to make them easily added to a users codec library... for example to be added to their mpeg streamclip, ffmpeg etc.

some details: I've had some experience modifying codecs by hacking ffmpeg source files and compiling my hacked code (so that for ex: my version of ffmpeg has a very different h.263 than yours). I'm interested now in taking these modified codecs and somehow making them easily distributable, so others could "add them" to their "libraries." Also, I realize there are some tricky rights/patent issues here, this is in part my motivation. I'm interested in the patent quagmires, and welcome any thoughts on this as well.

ctx link: if it helps (to gauge where I'm coming from) here's a link to a previous codec-hacking project of mine http://nickbriz.com/glitchcodectutorial/

答:
I guess it depends on who owns the codec you are changing and the license that is associated with it. Also if you intend to sell or give away. Probably the best/safest way is to approach the codec owner - amybe they will even assess your hack with intent to absorb it into the codec itself. As with anything potentially coprighted, there are mine fields everywhere - some that come back and bite years later too. </p>

<p>(seen that happen, when permission WAS granted for supplying modified middlewear code to subsidiary partners of a large company as part of a solution by the middleware vendor - when almost a decade later, new ownership of the middleware company, then sued for multi-millions as one of the partners had split off and thus were no longer subsidairies, but still had the code - albeit no longer used - on their servers - it was settled out of court, rumour was for a million pounds sterling).</p>

Body:
I guess it depends on who owns the codec you are changing and the license that is associated with it. Also if you intend to sell or give away. Probably the best/safest way is to approach the codec owner - amybe they will even assess your hack with intent to absorb it into the codec itself. As with anything potentially coprighted, there are mine fields everywhere - some that come back and bite years later too.

(seen that happen, when permission WAS granted for supplying modified middlewear code to subsidiary partners of a large company as part of a solution by the middleware vendor - when almost a decade later, new ownership of the middleware company, then sued for multi-millions as one of the partners had split off and thus were no longer subsidairies, but still had the code - albeit no longer used - on their servers - it was settled out of court, rumour was for a million pounds sterling).


问:
International two-part date formats
Do people outside of the USA use two-part date abbreviations for the current year? For instance, representing the last day of May, you might see someone enter 5/31 into a date field.

Do international users do something similar? In a country that ordinarily uses dd/MM/yyyy would they use 31/5 or some such?

答:
There is a good map here http://en.wikipedia.org/wiki/Date_format_by_country that shows only really the States uses (and Belize!) Middle-Endian MM/DD/YYYY date format, most use Little-Endian DD/MM/YYYY and some use Big Endian (mostly Asian) YYYY-MM-DD.
Philipines uses both Little and Middle due to American influence, as does Saudi Arabia - must get very confusing there!</p>

Title: International two-part date formats


答:
No, it could rather hard if not impossible if the webmaster doesn't want to disclose. There are some characteristics of few frameworks, but they can be hidden.

file extensions: there is no real reason to use standard ones, and most modern MVCs use URL routing anyway. So unless site has been around for some time, you're probably not going to see any (eg. stackexchange does't use .aspx extension);

session IDs: for example PHPSESSID is default for PHP, but can be easily overridden;

headers with web server and scripting language versions: can be turned off or even faked.

Stuff that's harder to hide:

PHP handles multiple values for same query string variable by appending [] to the name, thus you'd see something like:  ...?var[]=1&var[]=3&.... AFAIK, it's the only web framework which handles it that way.

Title: Is it possible to know what programming language a web-site uses?

Body:
For example, stackexchange.com, without asking the site owner or Google their information about developing the website, is this possible to know what language is used in the back end?

Seems, the website don't have .extension bar, for example .php that can indicated which is developed in PHP, but without the extension, how can I know that?


答:
It is possible to write a site in such a way, that no clues about the server technology will be visible to the client.

However, when someone uses some frameworks, such as IceFaces for Java, it is practically impossible do do because you'll see something like that in your requests:

```<code>ice.submit.partial=true&ice.session=c4f4jxT36tM_38848488&ice.view=3&ice.focus=&rand=0.322803445
</code>```

Much of other frameworks have their characteristic stamps in either page body or requests/responses. Find them, google and you'll have an answer.

However, in each language, if you choose to create HTML from scratch (in Java world an example would be velocity templates) or choose pure AJAX way, where server returns/accepts only JSON messages, and client is entirely in JavaScript - a hard way, until you cause uncatched exception that reveals the technology under.

Body:
It is possible to write a site in such a way, that no clues about the server technology will be visible to the client.

However, when someone uses some frameworks, such as IceFaces for Java, it is practically impossible do do because you'll see something like that in your requests:

ice.submit.partial=true&ice.session=c4f4jxT36tM_38848488&ice.view=3&ice.focus=&rand=0.322803445

Much of other frameworks have their characteristic stamps in either page body or requests/responses. Find them, google and you'll have an answer.

However, in each language, if you choose to create HTML from scratch (in Java world an example would be velocity templates) or choose pure AJAX way, where server returns/accepts only JSON messages, and client is entirely in JavaScript - a hard way, until you cause uncatched exception that reveals the technology under.


问:
What's your favourite quote about programming?
What's your favourite quote about programming?

One quote per answer, and please check for duplicates before posting!

答:
The required techniques of effective reasoning are pretty formal, but as long as programming is done by people that don't master them, the software crisis will remain with us and will be considered an incurable disease. And you know what incurable diseases do: they invite the quacks and charlatans in, who in this case take the form of Software Engineering gurus.

-- Dijkstra

LastEditorDisplayName: Roger Pate

OwnerDisplayName: Andrew


答: I would if the market is made up of users who prefer open source. If the users are not developers, there is going to be an even smaller number of potential contributors. </p>


问:
SQL language drawbacks, The Third Manifesto
Sometime ago I read about SQL language drawbacks
(the basic language specification, not vendor specific),

and one of the drawbacks was that the language does not allow to create a set of tuples that don't come  from a table.

For instance,

```<code>SELECT firstName, lastName from people;
</code>```

this creates a set of tuples coming from the table people.

Now, if I don't have this table people, and I want to return a constant, I'd need something like this to return a set of two tuples (this would not require to have a table):

```<code>SELECT VALUES('james', 'dean'), ('tom', 'cruisse');
</code>```

Why I would need that?

Because of the same reasons that we can define constants (not only basic types, but objects and arrays also) in any advanced programming language.

Workarounds,

Yes, I could create a temporal table, fill the data, and SELECT from that table.
This is a hack, to overcome the drawbacks of the poor SQL language.

I think that I read about this somewhere in "The Third Manifesto",

but I don't find the paragraph/example talking about this concrete drawback anymore.

Do you know a reference about it?

答:
As far as I know the SQL standard defines a "row constructor".

So in standard SQL (and e.g. supported by PostgreSQL and DB2) it's valid to write

```<code>VALUES ('james', 'dean'), ('tom', 'cruise');
</code>```

anyhwere a table reference is allowed

OwnerDisplayName: David Portabella

Body:
As far as I know the SQL standard defines a "row constructor".

So in standard SQL (and e.g. supported by PostgreSQL and DB2) it's valid to write

VALUES ('james', 'dean'), ('tom', 'cruise');

anyhwere a table reference is allowed


问:
Hidden web standards behind Google "custom searchEngines"?
Today while playing with Google Chrome Omnibox, I notice a strange behavior. I guess there's some "hidden" web standard behind it, but can't figure it out. Here's how to reproduce:

Go to http://edition.cnn.com/

Use the search function at the higher right corner, Search a random keyword, for example: "abc"

Close the tabs.

Open a new tab, type until Chrome reminds you about http://edition.cnn.com/, then press "Tab"

The Omnibox now shows "Search CNN.com"! And when you type "abc" and press Enter, it uses the CNN search function to do the job, not Google!

I also tried it for several different sites. To some it won't work. But to some sites, like CNN, vnexpress.net, it works after I use the search function of that site once.

I also learnt about chrome://settings/searchEngines (type it in your chrome box and you will see), and learnt about you can add custom search engine in chrome. But the question is, why Chrome can realize the search URL automatically to some pages, and not others?

It's not because some site subscribe to Google service, because I can do the same method for my site (http://ledohoanglong.wordpress.com), and I'm sure that there's no subscription. So I guess there's a method to "expose" the search function of a site, so that Google Chrome can catch it (after I call the search function of that site once, of courses).

Does anyone know about how it works behind the scene?

答:
it's the open search standard, OpenSearch 1.1

a collection of technologies that allow publishing of search results in a format suitable for syndication and aggregation. It is a way for websites and search engines to publish search results in a standard and accessible format...

OpenSearch consists of:

OpenSearch Description files: XML files that identify and describe a search engine.

OpenSearch Query Syntax: describe where to retrieve the search results

OpenSearch RSS (in OpenSearch 1.0) or OpenSearch Response (in OpenSearch 1.1): format for providing open search results.

OpenSearch Aggregators: Sites that can display OpenSearch results.

OpenSearch "Auto-discovery" to signal the presence of a search plugin link to the user and the link embedded in the header of HTML pages

OpenSearch Description Documents list search result responses for the given website/tool. Version 1.0 of the specification only allowed one response, in RSS format; however, version 1.1 provides support for multiple responses, which may be in any format. RSS and Atom are the only ones formally supported by OpenSearch aggregators, however other types, such as HTML are perfectly acceptable...


答:
As a general rule, search engines do not crawl content generated by JavaScript or Ajax. The most notable exception being Google's crawlable Ajax. But that only applies to Google and even then that's a bad idea.

To make your site more search engine friendly you will need to make content available via static links. Without these you essentially have a one page website which is very difficult to rank well. But it can if you obtain enough incoming links which is possible if your game is very good.

Finally here is a good link from Google


问:
What software programming languages were used by the Soviet Union's space program?
I got interested in the Soviet space program and was interested to discover that the software on the Buran spacecraft circa 1988 was written in Prolog.

Does anyone know what languages might have been used in earlier missions, especially the Mars PrOP-M rover missions of the early 1970s which were somewhat autonomous and could navigate obstacles?

Edit

My source for the Buran Prolog is this declassified document from the CIA site from May 1990.  I couldn't find an OCR version, so here's the relevant quote from p. 0449:

According to open-source literature, the Soviets used the
  French-developed programming language known as Prolog to develop
  on-board system software for the Buran vehicle...

答:
I came across this article in ACM quote quad a few years ago,  "A History of APL in the USSR".  It was written by Andrei Kondrashev (Computing Center of the Russian Academy of Sciences) and Oleg Luksha (The Obninsk Educational Center).

An interesting quote from the article:

It may be of interest that APL was directly related to the design of
  the Soviet space shuttle "Buran." Heat protection is one of the major
  elements in the construction of apparatus of that type. It is made out
  of composition materials. Mathematical models of the process of drying
  and roasting of plates covering the hull were made with the help of
  APL. As a result, the percentage of defects during the production of
  the cover plates was reduced, saving a lot of money and effort.


问:
Content of AUTHORS file
GNU recommends making an AUTHORS file to list the authors and contributors of a program. But how many "levels" of authors and contributors should the file contain? E.g. if I write a program foo that actively use some library, should I include the authors of that library in the AUTHORS file? It seems that the answer is "yes," because total code of foo contains code from the library. But if yes, that means I should also include the authors of all other libraries, including standard libraries of the compiler, authors of the compiler and other tools for producing final executable code, authors of the OS... When I should stop?

答:
The authors of your libraries dependencies are not authors of your project. As you have pointed out, not assuming that can get out of control. Typically you just list people who have contributed something directly to the project, in particular code and documentation. If, however, a particular dependency or person has significantly influenced your project, then it might be appropriate to have a "special thanks" section identifying those projects, communities, or people.

Let me use GitHub as an example. Each project has an automatically generated "contributors" list. How do they decide who is on that list? I am not exactly sure, but it appears to be anyone who has had a commit pushed to the repository.

Title: Content of AUTHORS file


问:
Application / Code reviews for lone programmers?
Are there any services that 'for a reasonable price' will give and provide good and technical advice on applications. On a lot of projects, I'm usually the only developer, and sometimes, I think some of my work needs to be improved for efficiency, better MVC interactions, etc. It would be great if there was a professional service that actually can and will do such reviews</p>

答:
Not really for lone developers, but as a silo programmer working with other programmers I was able to convince management to allow for cross-training time where we would review each other's code on a rotating basis.

I claimed it would ease problems if a contractor left and there was no one ready to take over his projects.

We did peer 4:1 reviews once a week. It kind of worked and I did get some good advice from the others. And learned what projects to stay away from.


问:
What are best practices when switching between projects/coming back to projects frequently?
The nature of my job is that I have to switch back and forth between projects every few weeks. I find that one of the biggest impediments to my productivity is the ramp-up time to getting all the relevant pieces of code "back in my head" again after not seeing it for a period. This happens to a smaller and larger extent for briefer breaks / longer breaks.

Obviously, good design, documentation, commenting, and physical structure all help with this (not to mention switching between projects as infrequently as possible). But I'm wondering if there are practices/tools that I may be missing out on. What are your specific practices for improving on this?

答: the key IMO is a smart API of every of your projects. Also uploading the code to a repository such as GIT or others enables you to "time travel" through your commits to code.


答: It seems reasonable to me to assume that the dependency project should have its own AUTHORS file and the whole process would reduce down recursively. You are responsible for identifying the authors for code you wrote. The authors of the other libs should already be mentioned in the AUTHORS file of each lib.</p>

Title: Content of AUTHORS file

Body: GNU recommends making an AUTHORS file to list the authors and contributors of a program. But how many "levels" of authors and contributors should the file contain? E.g. if I write a program foo that actively use some library, should I include the authors of that library in the AUTHORS file? It seems that the answer is "yes," because total code of foo contains code from the library. But if yes, that means I should also include the authors of all other libraries, including standard libraries of the compiler, authors of the compiler and other tools for producing final executable code, authors of the OS... When I should stop?


答: Because I do development and production support for several clients, I switch projects multiple times per day. The two things that help me the most are never leaving one project until I have saved everything (And commit to a local branch if it isn't in the state I want to put it back to the main branch of my source control) and I set a breakpoint at the spot where I left off.  Just being able to quickly find the exact line where I left off, helps me get back in the swing of a project much faster. I also tend to create a todo list for each major project and check things off as they are done, so a quick review of that tells me where I am as well and reminds me of my thinking process on the project. I generally also write a quick note to myself of things that I was thinking about but hadn't done yet if I need to (things like: The XYZ still isn't working, try abcd next.)</p>

Title: What are best practices when switching between projects/coming back to projects frequently?

Body:
The nature of my job is that I have to switch back and forth between projects every few weeks. I find that one of the biggest impediments to my productivity is the ramp-up time to getting all the relevant pieces of code "back in my head" again after not seeing it for a period. This happens to a smaller and larger extent for briefer breaks / longer breaks.

Obviously, good design, documentation, commenting, and physical structure all help with this (not to mention switching between projects as infrequently as possible). But I'm wondering if there are practices/tools that I may be missing out on. What are your specific practices for improving on this?


问:
How would you represent an object that can be of multiple types, when storing it as a document in MongoDB?
Somewhat related to this question, say that I have an object category which, depending on which type of object I have, has different restrictions on what it contains.  (if you can reword the previous sentence to make more sense I'd appreciate it)

For example

```<code>var SomeSchema = new Schema({
  _id: ObjectID,
  [... large number of common fields ...]
  type: //Restricted somehow to members of a fixed array
  data: //depending on type, this might be restricted - sometimes an integer, sometimes array, etc...
});
</code>```

What's the idiosyncratic method for defining this type of schema? Is it appropriate to define a single schema, and handle the types inside of it's members, or am I better off with separate schema for each type?

答:
I believe that the general problem you are trying to solve is called "Single-table inheritance" or STI. Since Mongo is not a relational database, situations like this are usually solved in the model code, as I.renkerna suggested.

You usually set a column that will hold the model "type", and then handle different types appropriately in the rest of the application.

However, there are some guidelines that can be followed for Mongo:

http://talkminer.com/viewtalk.jsp?videoid=PIWVFUtBV1Q&q= (slides 25 and 26)

Outside of Mongo, you can get a better grasp of the concept from an example in Yii framework:

http://www.yiiframework.com/wiki/198/single-table-inheritance/

Best of luck!


问:
Is there a decent way to maintain development of wordpress sites using the same base?
We've been churning out wordpress sites for a while, and we'd like to keep a base repository that can be used when starting a new project, as well as updating existing sites with changes to the wordpress base.

Am I wrong in assuming this would be a good thing? We take care of updating the sites, so having a common base would make this easier.

I've been looking at solutions using git, such as forking a base repository and using it to pull changes to the wordpress base, but committing the site to it's own repository. Or maybe, if it's possible, storing the base as a git submodule, but this would require storing themes and plugins outside of that.

Is there any common way to go about this kind of website development?

答:
I am not the author of this article, and it uses Subversion as its repository, but there are good things that help to combine WordPress and version control in its content:

Creating a WordPress Site Using SVN


问:
Rewrote GNU GPL v2 code in another language: can I change a license?
I rewrote some parts of Mercurial (which is licensed under GNU GPL v2) in C#. Naturally, I looked a lot into original Python code and some parts are direct translations from Python to C#.

Is is possible have "my code" licensed under different terms or to even make a part of a closed-source commercial application? If not, can I re-license "my-code" under LGPL, open-source it and then use this open-sourced C# library in my closed-source commercial application?

答:
The text of the license specifically covers translations, so no, you wouldn't be able to relicense it.

The "Program", below, refers to any such program or work, and a "work
  based on the Program" means either the Program or any derivative work
  under copyright law: that is to say, a work containing the Program or
  a portion of it, either verbatim or with modifications
  and/or translated into another language.


答:
Based upon:

http://www.gnu.org/licenses/gpl-faq.html#AllCompatibility

You should be okay with the second scenario you portrayed.

The parts you copied remain under GPLv2, but your entire library can be released as LGPL v2.1 or later.  You can then link your closed source code to that library under the terms of the LGPL.

As always, do some digging and make sure you understand what the restrictions are.

Title: Rewrote GNU GPL v2 code in another language: can I change a license?

Body:
I rewrote some parts of Mercurial (which is licensed under GNU GPL v2) in C#. Naturally, I looked a lot into original Python code and some parts are direct translations from Python to C#.

Is is possible have "my code" licensed under different terms or to even make a part of a closed-source commercial application? If not, can I re-license "my-code" under LGPL, open-source it and then use this open-sourced C# library in my closed-source commercial application?


问:
Strategy/algorithm to divide fair teams based on history
We are a group of people playing floorball together on a regular basis. Every session starts with the daunting task of dividing teams...

So what would be better than an application to pick teams automatically?

So, given a history of team-combinations and results, and a list of people showing up for this particular session, what would be a good strategy to find the optimal teams? By optimal, I mean teams as equal as possible.

Any ideas?

Edit: To make it clear, the data that I have to base the picking on, would be something like this:

```<code>[{ team1: ["playerA", "playerB", "playerC"],
   team2: ["playerD", "playerE", "playerF"],
   goals_team1: 10,
   goals_team2:  8
 },
 { team1: ["playerD", "playerB", "playerC"],
   team2: ["playerA", "playerE", "playerG"],
   goals_team1:  2,
   goals_team2:  5
 },
 { team1: ["playerD", "playerB", "playerF"],
   team2: ["playerA", "playerE", "playerC"],
   goals_team1:  4,
   goals_team2:  2
 }]
</code>```

答:
If you don't want to dig into the heady world of Bayesian priors(pdf) and such, an interesting approach is to assign a total order to all players (based on win/loss ration, cumulative points, etc) and then divide into teams using the parity function as follows.

Take the sorted list of players (best to worst) and separate them into teams Even and Odd based on the number of 1 bits in their index (starting at 0).  That gives the following distribution:

0000 (best) - Even

0001 - Odd

0010 - Odd

0011 - Even

0100 - Odd

0101 - Even

0110 - Even

0111 - Odd

...etc.

The parity function will ensure an equal number of players on each team, for any even number of players.  It will then alternate giving the advantage of the odd numbered player to one team or the other in such a way that the effects tend to balance out over time.

This function works best when the distribution of player skill is flat.  In reality, player skill tends to follow the "sum of random values" distribution, a.k.a. the Gaussian (although beware blanket applications of that assumption in systems such as TruSkill.)

In order to compensate for large skill gaps, you can apply permutations to this list.  For example, to counter a very strong top player 0000, you can swap player 0011 with a lower-ranked Odd player, such as 0100.  This is where things get hand wavy, but at least it provides a good starting point that doesn't require an accurate measure of absolute skill, but simply an ordering based on relative skill.


问:
Do I need to add an index on a table with one row?
I'm creating a parameter table in our database.  This table will have 1 row with values that are environment specific (production, development, etc).

Is there any reason why I should define an index on this table?

Update

This table is a parameter table which will be used to drive our job queue system.  The table will be defined like this:

```<code>QueuePrm
  LogLvl    integer
  ShowMs    boolean
  Restart   boolean
</code>```

This table will only ever have 1 row.  No other table in our system will reference it.

答:
While it looks like there is no need now, tables like this become filled with values as the system progressively ages.  You might insist on multiple tables for keeping different parameters segregated, but eventually all tables like this expand.

It is best to start with a key, descriptive of the purpose if possible.  Future maintenance staff appreciate understandable names.


答:
At the very least, the primary key of the table (you DO have a PK identifier, yes?) should have an index, also created as the clustered index by default in MS SQL Server.

If you have any secondary keys (such as a 'name' identifier column) that will be a selection criterion, index it as well.

Title: Do I need to add an index on a table with one row?

Body:
I'm creating a parameter table in our database.  This table will have 1 row with values that are environment specific (production, development, etc).

Is there any reason why I should define an index on this table?

Update

This table is a parameter table which will be used to drive our job queue system.  The table will be defined like this:

```<code>QueuePrm
  LogLvl    integer
  ShowMs    boolean
  Restart   boolean
</code>```

This table will only ever have 1 row.  No other table in our system will reference it.


问:
Is it advisable to ask employees to create 'work' GitHub accounts?
I've moved all our company Git repositories to GitHub and now I want to add employees to the projects. Since most employees already have personal GitHub accounts, I'm wondering whether I should ask them to create a work GitHub account. The reason that I'm thinking of doing this is to decrease the chances of unauthorized access to our code base since their personal accounts may be well publicized through their personal activity on the site, increasing chances of targeted attacks. Furthermore, if their personal account is ever compromised it won't mean the whole company code is accessible to the hijacker. Since this will bring the burden of maintaining two accounts for the employees I'm wondering whether it is the correct approach and whether it even makes sense. I would love to hear your opinions on this.

Update
Thanks for all the useful insights. I won't set an answer as accepted because of the subjective nature of the question/answers and since I took the best points from several different answers.

I have decided to go forward this way: I will remind employees that work-related GitHub e-mail notifications will have to be sent to their work e-mail accounts for practical reasons. Therefore it would make more sense to create work GitHub accounts. If they are willing to use their personal GitHub accounts and connect it to their work e-mail accounts then that's fine. In any case, employees will have to agree in written form to a number  of conditions tied to using GitHub. These are related to account security: choosing a secure password using a secure random password generator that is not used with any other account, not accessing GitHub through computers not owned or administered by them, etc. At the end of the day employees will have to decide themselves whether a work account makes more sense for them or not.

答:
Is your company's code in public or private repositories? If they (or at least some) are public, and you allowed your employees to use their own GitHub accounts, then it would be an incentive for them to write good code. Their name would literally be attached to it, publicly. However, I'll assume that all of your repositories are private.

Overall, it sounds like you would prefer that your employee's accounts to not be publicly visible throughout GitHub. Unfortunately, they make money by selling GitHub Enterprise so I imagine that's one reason why they don't allow you to create private accounts for organizations. In either case, having (essentially) locked-down work accounts would be really counter-intuitive after choosing a very social site to host your repositories.

Lets imagine that you did set up work accounts for your employees. Would you enforce any restrictions on how they can use those accounts? Would you allow them to contribute code to non-work projects for work purposes? If so, then their accounts would become publicly visible, bringing you back to your initial concern. You could just allow them to make the contributions with their personal accounts, but then you're creating a logistical pain point for them. Personally, I would encourage my employees to contribute code to other projects as themselves. This not only gives them a confidence boost, it is allowing them to gain valuable experience and to build their credibility.

In any case, I don't think it's worth the effort to have work accounts. The GitHub interface allows you to easily control who has access to what, so removing access is simple either way. I also don't think that having separate accounts really "draws a line" between personal and work projects anymore than the GitHub interface already does.

Also, keep in mind how you plan on dealing with this as your company grows. Are the policies you set in place now going to be scalable from a management stand point? Managing 5 accounts right now might be fine, but what happens when you grow to 20 or 50? But once you get to that point, maybe GitHub Enterprise will be an approachable solution. In that case I would consider figuring out if GitHub accounts can be migrated to GitHub Enterprise installs. If so, I can see that being a one positive reason to have work accounts.


答:
Not out of the question, and actually a pretty good idea.

Regrettable as it may be, you need to plan on your employees leaving the organization at some point in the company's life.  How are you going to extricate their personal accounts from the company's repository at that point in time?

What are you going to do if the employee leaves on bad terms?  In an ideal world, everything will remain professional and there won't be any animosity between the firm and the ex-employee.  You would be prudent to plan for less-than-ideal circumstances.

While maintaining two accounts is a pain, your employees should welcome the opportunity.  It provides a cleaner line between what is theirs and what is the company's.

Edit: Of concern here is providing a clear separation between the employee's personal contributions to projects X, Y, Z, etc... and their paid work on your company's product.  Using a separate work account helps provide the delineation necessary to identify who owns what intellectual property and associated copyright.

For example, if an employee uses their personal account and contributes to both the company and Project X, how do you identify what role the employee was in at those points in time?  Was the contribution to X on behalf of your company or their own personal discretion?  Does the employee or the company own the copyright to that work given to X?  For that matter, if you allow outside contributions to your company's work, how do you distinguish if the employee was an employee or if it was a voluntary contribution?

In a broader sense, say you have an employee who builds up a reputation acting on the company's behalf by contributing to other projects.  When that employee leaves, how do you indicate that the personal user account is no longer associated with your firm?  Serious brand issues can occur without clean delineation of what a particular account is for.

It's pretty easy to fall down a rabbit trail of ownership, brand, and copyright concerns when you start thinking through the potential scenarios.  Using separate work accounts helps remove some of this ambiguity.  The company needs to be able to lay claim to contributions made in its name.

It's not about the technical aspects of separating the user account out, it's the legal questions that can trip you up.

Note that this may be a moot point if your company's products are all released as open source under permissive licensing and / or you're not worried at all about potential branding issues.

(Hat tip to Paul Biggar for requesting this edit)

Title: Is it advisable to ask employees to create 'work' GitHub accounts?

Body:
I've moved all our company Git repositories to GitHub and now I want to add employees to the projects. Since most employees already have personal GitHub accounts, I'm wondering whether I should ask them to create a work GitHub account. The reason that I'm thinking of doing this is to decrease the chances of unauthorized access to our code base since their personal accounts may be well publicized through their personal activity on the site, increasing chances of targeted attacks. Furthermore, if their personal account is ever compromised it won't mean the whole company code is accessible to the hijacker. Since this will bring the burden of maintaining two accounts for the employees I'm wondering whether it is the correct approach and whether it even makes sense. I would love to hear your opinions on this.

Update
Thanks for all the useful insights. I won't set an answer as accepted because of the subjective nature of the question/answers and since I took the best points from several different answers.

I have decided to go forward this way: I will remind employees that work-related GitHub e-mail notifications will have to be sent to their work e-mail accounts for practical reasons. Therefore it would make more sense to create work GitHub accounts. If they are willing to use their personal GitHub accounts and connect it to their work e-mail accounts then that's fine. In any case, employees will have to agree in written form to a number  of conditions tied to using GitHub. These are related to account security: choosing a secure password using a secure random password generator that is not used with any other account, not accessing GitHub through computers not owned or administered by them, etc. At the end of the day employees will have to decide themselves whether a work account makes more sense for them or not.


问:
How to unit test a jsp file?
I'm developing a Java 6 EE application and I'm testing my jsp code with another one with a testing version of the function calls and code used in the original one but it seems loose and impractical. Is there a good way to accomplish this kind of testing?</p>

答:
There exists a program (used by whatever application server you are using) that compiles a .jsp file into a .java file.  For example, the sun/oracle version jspc.

Once you have the .java that would be produced by the .jsp translation (you might even want to consider using this as part of the build process - precompiling the jsp for performance improvements on the first hit), you can then run tests against it by mocking the request and verifying the response is what you are expecting.

(edit with example:)

The key method for this is the _jspService(HttpServletRequest, HttpServletResponse) method.

A trivial hello world jsp:

```<code><html>
    <head>
        <title>Hello world</title>
    </head>
    <body>
        <h1>Hello world</h1>
        Today is: <%= new java.util.Date().toString() %>
    </body>
</html>
</code>```

(test.jsp located within a directory named 'webapp' and also an 'out' directory) When compiled with the command jspc -v -d out -compile -uriroot webapp/ test.jsp places into an out directory a file called test_jsp.java.  This file has within it (along with a fair bit of other configuration setup):

```<code>  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html");
      pageContext = _jspxFactory.getPageContext(this, request, response,
                null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("<html>\n\t<head>\n\t\t<title>Hello world</title>\n\t</head>\n\t<body>\n\t
\t<h1>Hello world</h1>\n\t\tToday is: ");
      out.print( new java.util.Date().toString() );
      out.write("\n\t</body>\n</html>\n\n");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
</code>```

At this point, its a check to make sure that the JspWriter is called with write or print and the contents of the call are what you expect it to be.

All that said, in an ideal world, one shouldn't have any logic within the jsp - such logic would either be in the controller or taglibs which are tested with other techniques.

Title: How to unit test a jsp file?

Body:
There exists a program (used by whatever application server you are using) that compiles a .jsp file into a .java file.  For example, the sun/oracle version jspc.

Once you have the .java that would be produced by the .jsp translation (you might even want to consider using this as part of the build process - precompiling the jsp for performance improvements on the first hit), you can then run tests against it by mocking the request and verifying the response is what you are expecting.

(edit with example:)

The key method for this is the _jspService(HttpServletRequest, HttpServletResponse) method.

A trivial hello world jsp:

<html>
    <head>
        <title>Hello world</title>
    </head>
    <body>
        <h1>Hello world</h1>
        Today is: <%= new java.util.Date().toString() %>
    </body>
</html>

(test.jsp located within a directory named 'webapp' and also an 'out' directory) When compiled with the command jspc -v -d out -compile -uriroot webapp/ test.jsp places into an out directory a file called test_jsp.java.  This file has within it (along with a fair bit of other configuration setup):

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html");
      pageContext = _jspxFactory.getPageContext(this, request, response,
                null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("<html>\n\t<head>\n\t\t<title>Hello world</title>\n\t</head>\n\t<body>\n\t
\t<h1>Hello world</h1>\n\t\tToday is: ");
      out.print( new java.util.Date().toString() );
      out.write("\n\t</body>\n</html>\n\n");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}

At this point, its a check to make sure that the JspWriter is called with write or print and the contents of the call are what you expect it to be.

All that said, in an ideal world, one shouldn't have any logic within the jsp - such logic would either be in the controller or taglibs which are tested with other techniques.


问:
Are there any real-world cases for C++ without exceptions?
In When to use C over C++, and C++ over C? there is a statement wrt. to code size / C++ exceptions:

Jerry answers (among other points):

(...) it tends to be more difficult to produce truly tiny executables with C++. For really small systems, you're rarely writing a lot of code anyway, and the extra (...)

to which I asked why that would be, to which Jerry responded:

the main thing is that C++ includes exception handling, which (at least usually) adds some minimum to the executable size. Most compilers will let you disable exception handling, but when you do the result isn't quite C++ anymore. (...)

which I do not really doubt on a technical real world level.

Therefore I'm interested (purely out of curiosity) to hear from real world examples where a project chose C++ as a language and then chose to disable exceptions. (Not just merely "not use" exceptions in user code, but disable them in the compiler, so that you can't throw or catch exceptions.) Why does a project chose to do so (still using C++ and not C, but no exceptions) - what are/were the (technical) reasons?

Addendum: For those wishing to elaborate on their answers, it would be nice to detail how the implications of no-exceptions are handled:

STL collections (vector, ...) do not work properly (allocation failure cannot be reported)

new can't throw

Constructors cannot fail

答:
In the Joint Strike Fighter C++ coding standard by Bjarne et. al., exceptions are banned, due to the hard real-time requirements of fighter jets.

JSF++ is for hard-real time and safety-critical applications (flight
control software). If a computation takes too long someone may die.
For that reason, we have to guarantee response times, and we can't -
with the current level of tool support - do that for exceptions. In
that context, even free store allocation is banned! Actually, the
JSF++ recommendations for error handling simulate the use of
exceptions in anticipation of the day where we have the tools to do
things right, i.e. using exceptions.

Quoted from Bjarne's C++ FAQ.

Remember, C++ probably runs the widest variety of software of all languages...


答:
No, you do not need an index for a one-row table, nor do you need a primary key.  The only purpose of an index is to speed certain operations by making it possible to locate a row without reading the entire table.

Many relational database implementations require indexes for foreign-key or uniqueness constraints (including primary keys).  That is not a logical necessity.  It is done because an index will be desired in almost all cases, and it isn't worth the trouble to support these constraints without an index.  When a table is so small that an index isn't useful, the index doesn't cost much.


答:
My father worked in ЦНИИ РТК and participated in the development of software for Buran manipulator ( http://www.buran-energia.com/bourane-buran/bourane-consti-bras.php )
Software was developed on ES EVM (Soviet clone of IBM S/360-370) using Fortran due to heavy computations.  </p>

Title: What software programming languages were used by the Soviet Union's space program?

Body:
I got interested in the Soviet space program and was interested to discover that the software on the Buran spacecraft circa 1988 was written in Prolog.

Does anyone know what languages might have been used in earlier missions, especially the Mars PrOP-M rover missions of the early 1970s which were somewhat autonomous and could navigate obstacles?

Edit

My source for the Buran Prolog is this declassified document from the CIA site from May 1990.  I couldn't find an OCR version, so here's the relevant quote from p. 0449:

According to open-source literature, the Soviets used the
  French-developed programming language known as Prolog to develop
  on-board system software for the Buran vehicle...


答:
Instead of making a one-row table with many columns, wouldn't it be neater to design it with many rows instead?
Like

```<code>ParamName | Value
------------------
LogLevel  | 5
BuildNr   | 3.0.9
ErrorMail | error@example.tld
</code>```

Here ParamName will be the Primary Key.

This has the added effect that when you need to add more parameters, you can just INSERT them without having to update your tables and possibly your SQL queries.

Body:
Instead of making a one-row table with many columns, wouldn't it be neater to design it with many rows instead?
Like

ParamName | Value
------------------
LogLevel  | 5
BuildNr   | 3.0.9
ErrorMail | error@example.tld

Here ParamName will be the Primary Key.

This has the added effect that when you need to add more parameters, you can just INSERT them without having to update your tables and possibly your SQL queries.


问:
Can modifications to open source project be considered trade secret?
While working for an employer if one modifies, rewrites, contributes or alters open source software in what cases can it ever be considered a trade secret?

A trade secret, FWIW, is defined by wikipedia as:

A trade secret is a formula, practice, process, design, instrument,
  pattern, or compilation of information which is not generally known or
  reasonably ascertainable, by which a business can obtain an economic
  advantage over competitors or customers. In some jurisdictions, such
  secrets are referred to as "confidential information", but should not
  be referred to as "classified information", due to the nature of the
  word in the USA.

答:
A trade secret, by definition, cannot be known to the public. Once a "trade secret" becomes common knowledge (though reverse engineering, for instance), it loses it's legal protection. If you want protection for this, you need something closer to a patent.

One of the differences between patents and trademarks ... and trade secrets...  is that trade secret is protected only when the secret is not disclosed.


答: And what do you mean by "trade secret"? Do you mean you don't want to share your changes with anyone else? If that's the case, you need to abide by the license that the open source software is released under. If the license requires any changes to be released as well, you are violating the terms of the license if you do not release these changes.</p>

Title: Can modifications to open source project be considered trade secret?

Body:
While working for an employer if one modifies, rewrites, contributes or alters open source software in what cases can it ever be considered a trade secret?

A trade secret, FWIW, is defined by wikipedia as:

A trade secret is a formula, practice, process, design, instrument,
  pattern, or compilation of information which is not generally known or
  reasonably ascertainable, by which a business can obtain an economic
  advantage over competitors or customers. In some jurisdictions, such
  secrets are referred to as "confidential information", but should not
  be referred to as "classified information", due to the nature of the
  word in the USA.