答:
You need few things:

1. Copy right notice:

Any work originated by any author in any field first requires a proof of its author ship. This is similar to publisher putting a simple copyright text Copy right 2012, m0s . This is enough to be carried along with text file in your source or binary package. However, it is better if you have it in About dialog box or some part of display in application.

2. Warranties and liabilities and terms of support

You may want to disclaim (only since you are giving things for free) that any usage which may cause any direct or indirect harm to any individual or material is liability of the end user and not to the author.

Mind you, in the world of viruses, you may better safeguard yourself with this clause. Warranties and Liabilities are two different things; i am only giving you an overall idea. Read samples of EULA to understand. You may want to specify explicit condition, charge for support etc.

3. Information privacy

You may want to declare whether or not the application/software in any form carrying/collecting any user information in direct (such as username) or indirect form (such as statistic).  And if it does, the user agrees before installing and using the application.

4. Revocation/Termination of license

You may want to put the clause that the above license can be revoked or terminated and you may decide to provide alternative license to any user after the user has downloaded it. This is necessary if you later feel that some large company is using your software and making good money!

Remember this is possible only if you are giving away something for free. If i buy something from you, i won't accept such condition.

5. Prohibitions on distribution, modification

You may put the condition that user may/may not distribute it free or otherwise and may/may not modify (such as tempering, reverse engineering etc.) to your code at all. (or without your permission.)

6. Patent disclosure

You may disclose that your given software implements the following patents. And that End user is subject to any patent liability upon use.

Again, this is only if you make download/distribution subject to condition that user agrees to such a thing. Even if you give software free, but if it infringes the patent, by default since you are making the device and distributing, you are infringing the patent; unless the end user is accepting the liability.

7. Restriction of Use

If there is any specific usage you may want to prevent. For example, use for academic but not commercial; no usage in activities related to defense - anything that may be relevant.

8. Trademarks

You may declare any of your logos, and other trademark as yours and that
a. you may want disclosure if anyone using the tool. (credit) BUT
b. you may want that no one uses this information in advertising the same.
(See Apache license to learn more of this).

9. Jurisdiction

I don't know if this is must, but since software can travel the whole world, you may specify which countries law are applicable for the above world. This implies, that if jurisdiction is a US, and if anyone in India has a problem with this affair, they can file a suit against you in US and not in India and it can only be in terms of law of US.

NOTE: PLEASE DO NOT USE EXACT WORDS I WROTE HERE. Do your research for drafting.
This is only to give you a general idea.

Title: What license/EULA do I need for free to use software?

Body:
I am not sure what exactly I am looking for here, but here are the facts:

I will be offering a free to use software, free as in $0 cost only(not OSS). I need a piece of text included in the installer with agree/disagree, that would protect my rights. Specifically that I don't guarantee anything and shouldn't be held liable for their losses that the software might cause. I want to allow them to use the software for anything they like, but not allow to redistribute, sell, or reverse engineer it.

I am not even sure whether this text is technically a license, disclaimer, or end user license agreement. I doubt there is a ready to go template for what I am looking for, but any pointers would be greatly appreciated.


问:
Why does a Java source file bear the name of the public class it contains?
I am a newbie learning Java. In Java every source file must contain a public class and that source file should have the same name as that public class. Moreover, no source file can contain two public classes. Why is this restriction?</p>

答:
In one of his Java Specialists' Newsletters, Heinz Kabutz digs through the Oak Language Specifications. He writes:

Why is each public class in a separate file? (Section 1)

This is a question that I have frequently been asked during my
  courses. Up to now I have not had a good answer to this question. In
  section 1, we read: "Although each Oak compilation unit can contain
  multiple classes or interfaces, at most one class or interface per
  compilation unit can be public".

In the sidebar it explains why: "This restriction is not yet enforced
  by the compiler, although it's necessary for efficient package
  importation"

It's pretty obvious - like most things are once you know the design
  reasons - the compiler would have to make an additional pass through
  all the compilation units (.java files) to figure out what classes
  were where, and that would make the compilation even slower.

http://www.javaspecialists.eu/archive/Issue055.html

ContentLicense: CC BY-SA 3.0


答:
Reasons I can think of

Makes finding other classes slightly easier for the compiler in the beginning since it doesn't have to search all the potentially thousands of class files for a random public class, it can just go to the file.

This probably doesn't matter anymore but just started the early convention that never changed

In compilation a change to a file only affects that file. If there are multiple classes then everything has to be recompiled

Best practice - Having multiple public classes in the same file makes things confusing. The purpose of files is to organize the source code, the purpose of folders is to organize the files. If all the classes of a particular package are in a single 100 MB super file then you've lost all the advantages and gained none of the benefits of files (plus adding lots of headache when editing)

Title: Why does a Java source file bear the name of the public class it contains?

Body: I am a newbie learning Java. In Java every source file must contain a public class and that source file should have the same name as that public class. Moreover, no source file can contain two public classes. Why is this restriction?</p>


问:
A good schema to represent integer numbers from 0 to infinity, assuming you have infinite linear binary storage?
I would like a schema to represent integer numbers starting with 0, without any limit (assuming access to infinite linear storage).

Here's a schema that can represent numbers from 0 to 255:

Use the first byte of the storage (address 0) to store the integer.

Now, suppose I want to represent numbers larger than 255. Of course, I could use more than 1 byte to represent the integer, but as long as it's a fixed number, there will be eventually an integer so large that it cannot be represented by the original schema.

Here's another schema that should be able to do the task, but it's probably far from efficient.

Just use some sort of unique "end of number" byte, and use all the previous bytes to represent the number. Obviously, this "end of number" byte cannot be used anywhere in the number representation, but this can be achieved by using a base-255 (instead of base-256) numbering system.

However, that's slow and probably inefficient. I want to have a better one that performs better with low values and scales well.

Essentially, it's a UUID system. I want to see if it's possible to create a fast-performing UUID system that can theoretically scale to use for years, thousands of years, millions of years, without having to be redesigned.

答:
How about that:
One byte for length, then n bytes for the number (least significant byte first).
Repeat length+number as long as the previous length was 255.

This allows for arbitrarily large numbers, but is still easy to handle and doesn't waste too much memory.


问:
Meaningful concise method naming guidelines
Recently I started releasing an open source project, while I was the only user of the library I did not care about the names, but know I want to assign clever names to each methods to make it easier to learn, but I also need to use concise names so they are easy to write as well.

I was thinking about some guidelines about the naming, I am aware of lots of guidelines that only care about letters casing or some simple notes. Here, I am looking after guidelines for meaningful but yet concise naming.

For example, this could be part of the guidelines I am looking after:

Use Add when an existing item is going to be added to a target, Use
Create when a new item is being created and added to a target.

Use Remove when an existing item is going to be removed from a target,
Use delete when an item is going to be removed permanently.

Pair AddXXX methods with RemoveXXX and Pair CreateXXX methods with
DeleteXXX methods, but do not mix them.

As the above samples show,I would like to find some online material helping me with naming methods and other item complying with English grammar and word meanings.

The above guidance may be intuitive for native English speakers, but for me that English is my second language I need to be told about things like this.

答:
Do not worry about the length of method names. Make sure the method names clearly reflect what they are doing. This is paramount to anything else. If you feel that the method name is too long, use a thesaurus to find a shorter word that means the same thing. For example use Find instead of Retrieve.

Also what is just as important is the names you choose for your classes. These provide lots of context when looking at method names. A method signature like so:

```<code>public User Find(int userId);
</code>```

is easier to understand than:

```<code>public Person Find(int personId);
</code>```

because the context obtained from the class name User tells the programmer that Find() is for locating a specific type of person, the user of your system. The version that uses the Person class doesn't give you any context about why you would even need to use the method in the first place.

Body:
Do not worry about the length of method names. Make sure the method names clearly reflect what they are doing. This is paramount to anything else. If you feel that the method name is too long, use a thesaurus to find a shorter word that means the same thing. For example use Find instead of Retrieve.

Also what is just as important is the names you choose for your classes. These provide lots of context when looking at method names. A method signature like so:

public User Find(int userId);

is easier to understand than:

public Person Find(int personId);

because the context obtained from the class name User tells the programmer that Find() is for locating a specific type of person, the user of your system. The version that uses the Person class doesn't give you any context about why you would even need to use the method in the first place.


问:
Managers X Motivation
As a programmer what do you think that is the thing that your manager does that mostly decreases your motivation?

My manager insists in blocking web content (this week was msdn content and Microsoft domain sites) This is so stupid, make me think I am not a reliable professional or that I am stealing his internet. And not, it is not a small business. It is a huge enterprise where such dinossaurs should not exist anymore.

答: I think the most demotivating thing of all (and I do not have this issue in my current company) is being expected to work overtime for no pay to meet some arbitrary deadline and then watching him get rewarded financially for the successful project completion but not me. Remind me again why I should give up my personal time so you can get a big bonus?</p>

ContentLicense: CC BY-SA 2.5

Title: Managers X Motivation


答:
How about let the number of leading 1's plus the first 0 be the size (sizeSize) of the number size (numSize) in bits.  The numSize is a binary number that gives the size of the number representation in bytes including the size bits.  The remaining bits are the number (num) in binary.  For a positive integer scheme, here are some sample example numbers:</p>

```<code>Number              sizeSize  numSize    num
63:                 0 (1)     1 (1)      111111
1048575:            10 (2)    11 (3)     1111 11111111 11111111
1125899906842623:   110 (3)   111 (7)    11 11111111 11111111 11111111 11111111 11111111 11111111
5.19.. e+33:        1110 (4)  1111 (15)  11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111
</code>```

Title: A good schema to represent integer numbers from 0 to infinity, assuming you have infinite linear binary storage?

Body:
I would like a schema to represent integer numbers starting with 0, without any limit (assuming access to infinite linear storage).

Here's a schema that can represent numbers from 0 to 255:

Use the first byte of the storage (address 0) to store the integer.

Now, suppose I want to represent numbers larger than 255. Of course, I could use more than 1 byte to represent the integer, but as long as it's a fixed number, there will be eventually an integer so large that it cannot be represented by the original schema.

Here's another schema that should be able to do the task, but it's probably far from efficient.

Just use some sort of unique "end of number" byte, and use all the previous bytes to represent the number. Obviously, this "end of number" byte cannot be used anywhere in the number representation, but this can be achieved by using a base-255 (instead of base-256) numbering system.

However, that's slow and probably inefficient. I want to have a better one that performs better with low values and scales well.

Essentially, it's a UUID system. I want to see if it's possible to create a fast-performing UUID system that can theoretically scale to use for years, thousands of years, millions of years, without having to be redesigned.

Body:
How about let the number of leading 1's plus the first 0 be the size (sizeSize) of the number size (numSize) in bits.  The numSize is a binary number that gives the size of the number representation in bytes including the size bits.  The remaining bits are the number (num) in binary.  For a positive integer scheme, here are some sample example numbers:

Number              sizeSize  numSize    num
63:                 0 (1)     1 (1)      111111
1048575:            10 (2)    11 (3)     1111 11111111 11111111
1125899906842623:   110 (3)   111 (7)    11 11111111 11111111 11111111 11111111 11111111 11111111
5.19.. e+33:        1110 (4)  1111 (15)  11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111


答:
Finding a good naming is always a compromise between more factors. You will never be fully satisfied.

That said, even if your native language is not that way, consider that English is the language whose programming languages tokens are formed. Using English-like syntax makes code reading more "fluent" since there are no "broken reading rules" every time a keyword is found.

In general, consider things like object.method(parameters) to match a scheme like subject.verb(complements).

The key point, if you have to support generic programming, is choose a good and consistent set of "verbs" (especially the ones that need to be used in generic algorithms).

About nouns, classes should be named for what they are (in term of concept), while objects for what they are for.

That said, between list.add(component) and component.add_to(list) prefer the first. In general "active transitive" verbs better represent actions respect to their passive or reflexive counterparts. Unless design constrains foce you.

Title: Meaningful concise method naming guidelines

Body:
Recently I started releasing an open source project, while I was the only user of the library I did not care about the names, but know I want to assign clever names to each methods to make it easier to learn, but I also need to use concise names so they are easy to write as well.

I was thinking about some guidelines about the naming, I am aware of lots of guidelines that only care about letters casing or some simple notes. Here, I am looking after guidelines for meaningful but yet concise naming.

For example, this could be part of the guidelines I am looking after:

Use Add when an existing item is going to be added to a target, Use
Create when a new item is being created and added to a target.

Use Remove when an existing item is going to be removed from a target,
Use delete when an item is going to be removed permanently.

Pair AddXXX methods with RemoveXXX and Pair CreateXXX methods with
DeleteXXX methods, but do not mix them.

As the above samples show,I would like to find some online material helping me with naming methods and other item complying with English grammar and word meanings.

The above guidance may be intuitive for native English speakers, but for me that English is my second language I need to be told about things like this.


问:
At which point do you "know" a technology enough to list it on a resume
I recently had a programmer in for an interview, who listed Python, PHP, Rails and ASP as a few of their skills. In the interview however, they interviewee didn't enough know what control structures and basic logic were, they had only followed a few demo tutorials.

So my question is this: At which point can you add a technology to your resume accurately. Is it when you can demonstrate all basic concepts, write a useful program in it, or are just comfortable using it without having to refer to the documentation every 30 seconds.

I don't believe this is overly subjective, a baseline should easily be established based on feedback.

答: Would you feel comfortable using it on a new project? Are you willing to work with it again? If so, then put it there. You don't have to say "Guru" or "Newb" just list it as a tech that you are familiar with. If they ask in an interview about your experience then you can explain the details. They probably won't expect you to know everything, but will probably expect you to be able/willing to learn the parts you don't when when you need them.


答:
Why are you creating a laundry list of technologies? Instead, include information about the project and mention the key technologies, frameworks, libraries, and tools used there. This achieves a couple of things. First, you are demonstrating your knowledge and skills with something to projects, which makes it contextually relevant. Second, you are making your resume more about what you have done and not simply what you know.

In this case, when you are talking about your job and responsibilities, you can include how you learned and used Hibernate (and other technologies) in order to make a whatever-it-is-you-made. If I'm interested in your abilities with Hibernate, it's something I'd ask about during a phone screening or an interview. I'd then expect you to tell me some information about what the project was, how you used Hibernate, and what you were able to learn. In addition, any automated resume scanners will pick up the keyword, yet your resume is still human-friendly.

Title: At which point do you "know" a technology enough to list it on a resume

Body:
I recently had a programmer in for an interview, who listed Python, PHP, Rails and ASP as a few of their skills. In the interview however, they interviewee didn't enough know what control structures and basic logic were, they had only followed a few demo tutorials.

So my question is this: At which point can you add a technology to your resume accurately. Is it when you can demonstrate all basic concepts, write a useful program in it, or are just comfortable using it without having to refer to the documentation every 30 seconds.

I don't believe this is overly subjective, a baseline should easily be established based on feedback.


问:
Version Control based on portable storage?
I develop personal projects on two machines without use of a shared server or a network connection between the two.

Do any common version control systems reliably support use of portable storage (such as a USB flash device) as the shared repository?

答:
Use a DVCS such as Git or Mercurial.

Distributed version control systems do not have a shared central server.

With a DVCS, every copy of a repository holds the complete history - everything. This means, that when used on a USB key any changes you make are make to the repository on the USB key and when moved between computers will hold this history.


问:
What timestamp to use when pulling files from a VCS system?
Yesterday, a colleague asked me how to configure our VCS to timestamp the local copy of files pulled from the repository with the modification time in the repository.  I've always believed that they should be timestamped with the time they were pulled so that if you make a change, build, then back out by overwriting the changed file with the repository's copy, everything that depends on that file will build correctly.

I thought about it overnight, but couldn't come up with a good reason to have timestamped with the repository modification time.  What would be the advantages of doing it that way?

(Bonus question: repository modification time and local modification time are the only timestamping strategies that I'm aware of.  Are there others in use by VCS systems?)

答:
Broadly speaking, if you use the repository timestamp then everything is consistent across multiple machines if you use the pull time you haven't got a clue.

Further, if you use the commit timestamp you can see, just by looking at the file, when it was last modified whereas if you use the pull time... well all you know is the last pull time.

This becomes particularly fun if, for example, you're trying to work out if file on a website is right and which files (when its a small number from a bit site) need to be updated.

Now that I've calmed down a teeny bit I do actually understand what you mean about the build issues but pragmatically its easy enough to force a complete rebuild (or it should be) but once you lose a timestamp you can't get it back.

Put bluntly, I've had a lot of pain doing it your way and avoided a lot doing it the other way (though that may in turn be a reflection of the dev tools and deployment issues I have)


问:
What is the best way to structure workshops for starting programmers?
We are planning to organize programming workshops for Java web developers with basic coding but no design experience. The goal of the workshops is to introduce these programmers to clean code.

Focus Areas:

TDD

Four Rules of Simple Design

runs all the tests

contains no duplications

expresses the intent of the programmers

minimizes the number of classes and methods

Structure:

6 full day coached workshops spread over 3 months using pair programming and pair-switching

Each workshop contains

four 15 minute presentations/demos

four 90 minute problem solving exercises

4 minute pecha kucha's by every programmer

Planned Katas for first workshop:

prime numbers

bowling game

tennis scoring

Arabic to Roman numerals conversion

prime factors

Do you think this is a good way to structure a programming workshop? Are there any elements that I could introduce to the workshops to make them more interactive and create more interest among developers?

Edit 1:
Summary of the feedback

Create an interest in reading books.

Have real project examples.

Have contact with the group during off days.

答: Sounds like you're on the right track, but for students to really get the material and use it day to day you need to have some time where they can bring in their real code from their day job or whatever, and practice on that.</p>


问:
Why do organizations limit source code access to engineers?
Most organizations restrict access to the source code to engineers, and even at places like Google, the Android source code is kept off-limits to most engineers within the company. Why?

Note: I am not talking about write access for everyone in the company, I'm talking about read access.

答:
Because source code (being a major component of a company's product) is a valuable asset. And like any good company, you protect your assets.

In the case of physical assets, you put them behind locked doors to prevent them from being stolen. Only the trusted are given keys to those doors.

For source code, you restrict access to those who need it, which is pretty much just the engineers who are working on it. Everyone else just needs the compiled binaries.


答:
Off the top of my head:

1) Security Issues: If everyone had even just read access to source code, then a hacker would have a wider range of possibilities for accessing the source code. Further, it widens the possibilities for malicious hackers to exploit weaknesses in the code by seeing the source (eg knowing password rules to crack secured data).

2) Intellectual property issues: along similar lines of 1), it would be easier for individuals to copy the source code for illicit use. Code could be expropriated by third-parties, unauthorized versions could be compiled for use, etc.

And that's just with read access. With write access you open up even bigger cans of worms: accidental and/or malicious removal or edits of code, commits of code from unusual locations, messed up code revision trees, etc.

Think of this way: would you let just anyone open up your computer/car/body and let them poke around? Even if they didn't have explicit tools or access to some aspects of it/them? What could possibly go wrong?

Title: Why do organizations limit source code access to engineers?

Body:
Most organizations restrict access to the source code to engineers, and even at places like Google, the Android source code is kept off-limits to most engineers within the company. Why?

Note: I am not talking about write access for everyone in the company, I'm talking about read access.


答:
Sounds perfect to me, I've had experiences organizing one. I'd recommend having sessions on morning followed by a design example and then developing the test cases for the same design in the afternoon.(something like that to be cohesive with the pattern of teaching). I have had hands-on session on the morning and had received complaints from candidates in the past requesting the hands-on session to be handled on the afternoon rather than on morning.

The feedback also stressed on more time on hands-on because people get more doubts that way than understanding something on theory. Hope it helps :) Good luck!

Title: What is the best way to structure workshops for starting programmers?

Body:
We are planning to organize programming workshops for Java web developers with basic coding but no design experience. The goal of the workshops is to introduce these programmers to clean code.

Focus Areas:

TDD

Four Rules of Simple Design

runs all the tests

contains no duplications

expresses the intent of the programmers

minimizes the number of classes and methods

Structure:

6 full day coached workshops spread over 3 months using pair programming and pair-switching

Each workshop contains

four 15 minute presentations/demos

four 90 minute problem solving exercises

4 minute pecha kucha's by every programmer

Planned Katas for first workshop:

prime numbers

bowling game

tennis scoring

Arabic to Roman numerals conversion

prime factors

Do you think this is a good way to structure a programming workshop? Are there any elements that I could introduce to the workshops to make them more interactive and create more interest among developers?

Edit 1:
Summary of the feedback

Create an interest in reading books.

Have real project examples.

Have contact with the group during off days.


答: This workshop sounds solid.  I would definitely make sure there are documents or 'take-home' suggested readings.  Some may argue that attendees will not read the materials you give them, but I contest that if it is interesting, and there is value added, the developers will follow through.  The Head First Design Patterns book is fantastic, and a super fun read.  Maybe introduce excerpts from there, and allow the developers to see its value, and then suggest they read it in between sessions.  It averages $25 (I think) and is worth every penny.</p>


答:
The focus areas and structure sound good.  Some thoughts:

Since once key is to introduce people to clean code, ensure that every single piece of example code is actually clean unless you're using it as a negative example. Seems like a no-brainer, but often bad code sneaks in and ruins your ethos (reputation) as an instructor.

Use negative examples in a constructive way. Showing negative examples, especially when they don't belong to anyone in the group, is often a way to get group buy-in to the process, allows for some good brainstorming ("why on earth did they do X?" and so on) without it looking like you're attacking any one learner in the group.  You can start with finding just the worst possible example ever, but then make other negative examples less difficult to critique as the workshops move forward.

Having participants be responsible for some of the content (via pecha kuchas) is a good idea. This will help them become good communicators about development in addition to the content they're learning.

Tie exercises, presentations, examples, to the work they're doing "for real" wherever possible.

Try to have some sort of check-in or contact with the group during the off weeks (the weeks between the workshop meetings) -- maybe something to hold them accountable to the continuation of the learning experience, if even just a blog post or an addition to a group wiki.


问:
Do you have to be good at math to be a good programmer?
It seems that conventional wisdom suggests that good programmers are also good at math. Or that the two are somehow intrinsically linked. Many programming books I have read provide many examples that are solutions to math problems, or are somehow related to math as if these examples are what make sense to most people.

So the question I would like to float is: do you have to be good at math to be a good programmer?

答:
I think math would help.  I have an undergraduate in applied math and a master's in MIS.  I did get an MBA sequentially - but for the most part what has helped me stay in the IT field, most of which has been a developer (database and datatwarehouse programming), was the math.

I see computer programming as a "logical math" - but then again I see math as a language.  As someone earlier stated, it helps in communicating complex ideas.  The first programmers were actually mathematicians and engineers.  A lot of people I know who are great programmers have an engineering degree.

If you want to be a programmer/analyst, math will help.  It's the logic set necessary, and the discipline.  I see relational databases as more of linear algebra anyway.
There is a great paper on "Fast Monte Carlo Algorithms for Matrices:  Approximating Matrix Multiplication".  It is math-based.

Computer Science Majors are often part of the Mathematical Sciences Dept. at Universities.  There is a reason for that.

Ultimately, there's not a "one size fits all" approach.  I think they are a good compliment to one another - math and computers.

The most fundamental attribute for being a great computer programmer is being able to solve puzzles.  There's always some bit of information missing, or information that is ambiguous.

Ask yourself this:  "Would you rather have a 10,000 piece jigsaw puzzle with all the pieces there and no picture on the box to guide you, or would you rather have the same jigsaw puzzle with the picture on the box and have 10 pieces missing?"

I hope this helps !

OwnerDisplayName: Charles Roper


答:
I guess to some extent, "the thing that your manager does that mostly decreases your motivation" depends on what motivates you personally :p

If you agree with Daniel Pink's take on motivation, that we are driven by three key needs:

autonomy

mastery

purpose

...then I'd say that management can kill your motivation by encouraging or demonstrating behaviour that runs counter to that:

taking away autonomy, e.g. not
trusting that you can determine how
best to do your job

encouraging mediocrity

taking away the meaning in your work.
For example, by chasing goals or
exhibiting values that aren't
meaningful to you

Ultimately, I for me, I had to be clear on what I was all about before I could really put my finger on why "management" wasn't motivating me.

Title: Managers X Motivation

Body:
As a programmer what do you think that is the thing that your manager does that mostly decreases your motivation?

My manager insists in blocking web content (this week was msdn content and Microsoft domain sites) This is so stupid, make me think I am not a reliable professional or that I am stealing his internet. And not, it is not a small business. It is a huge enterprise where such dinossaurs should not exist anymore.


答:
Apart from GIT, Mercurial etc suggested above, also have a look at Fossil - It has the advantages that the run time binaries are small (1Meg or so for Windows and Linux), portable and zero installation needed. Therefore unlike the others (as far as I am aware of) it can be put onto the storage device and run on any machine the storage is plugged into, without first having to install the app on the machine.  It includes a Wiki and change/defect tracking system with the repo. It also has a gui built in.  </p>

<p>I have not used it seriously (I mostly use GIT), but was impressed by it's light weight approach and the inclusion of a Wiki and defect tracker makes it ideal for small projects. My only concern was that some of the more powerful features of GIT may not be possible, and unlike GIT, the user community is not so large that it's easy to find answers to questions. </p>

Title: Version Control based on portable storage?

Body:
I develop personal projects on two machines without use of a shared server or a network connection between the two.

Do any common version control systems reliably support use of portable storage (such as a USB flash device) as the shared repository?

Body:
Apart from GIT, Mercurial etc suggested above, also have a look at Fossil - It has the advantages that the run time binaries are small (1Meg or so for Windows and Linux), portable and zero installation needed. Therefore unlike the others (as far as I am aware of) it can be put onto the storage device and run on any machine the storage is plugged into, without first having to install the app on the machine.  It includes a Wiki and change/defect tracking system with the repo. It also has a gui built in.

I have not used it seriously (I mostly use GIT), but was impressed by it's light weight approach and the inclusion of a Wiki and defect tracker makes it ideal for small projects. My only concern was that some of the more powerful features of GIT may not be possible, and unlike GIT, the user community is not so large that it's easy to find answers to questions.


问:
Need help with deciding elements for icon creating application
I'm trying to practice programing by creating a simple application which, I think, I can manage to do in .Net C# in Visual Studio 2010.

I'm working on simple application which will let me to create small pictures (icons) in sizes such as 8x8, 16x16, 32x32 (etc) pixels. I will be creating a grid representing each size by scaling to amount of pixels. Each pixel will be represented in a small square which will be able to click to change color etc.

So here's my question regarding what elements such app should have:

What VS tool would let me to create a grid for my project? Keeping in mind that each small square should be generated automatically by using X/Y size provided by user and boxes should be clickable. Also, I probably should be able to be able to click one pixel and drag mouse to select other pixels.

What simple functions should such small app have? For example choosing colors.

What minimal functions should I have?

I'm trying to get the general idea of how to make such small app work and what user might expect when opening small, icon creating, application.

答:
Without getting into the specifics for your particular application, I think you should just create the application with the core functionality first, then add more features later. Make a list of what the application needs to do at a minimum and implement the items in that list first. Make another list of what the application can or should also have and then implement the items in that list next.

For reference, look at the MoSCoW method for creating these lists.


答:
Source code should probably be open for all employees, at least those that have signed a non-disclosure agreement, or whatever the company in question feels they need to threaten people with.

The "security" concern is vastly overblown. It's an open secret that bespoke enterprise software has had little concern for security in its design and construction.  Anyone with a fuzzer can generally find as many security holes as they want. That's why most enterprises have their intranets heavily firewalled, and some even have an air-gapped "engineering network" for production systems. Any of the multiplicity of developers that work on any given application can pretty much crash them at will.

The only security concern that's viable is if developers keep passwords (oracle, or OS or whatever) in the source code.  But that's a completely separate concern really.  Any decent security standard will forbid that absolutely.

Mathematically, there's no security advantage to closed source.  See this and
this and the first part of this.  Anecdotally, reality works as the math says.

"Intellectual Property" issues are an entirely different beast.  Given revelations in the SCO Linux Trials, companies may be protecting themselves from outside legal threats as much as their keeping their own "IP" from leaking out. Nevertheless, the benefit obtained by opening up may be greater than the detriments imposed by legal threats. Very few data points exist, so I believe that the "IP" lawyers or the "Risk Managers" are declaring source closed solely out of superstition.  It's easier to say "no" than it is to say "yes" for the usual aparatchik in a corporation.


问:
What is the current state of Google's Dart programming language?
Dart has been out for ages (in internet years), but judging by Google Trends , it hasn't gotten much hype, and the fact that it only works in Chrome doesn't help either. Nonetheless, Chrome is gaining market share every day, which lends itself to a better view on Dart.

What is the big picture now? What state is the language in? Do people regard highly of it? Market share? Web App showcase? Some feature implementations that make you go "I have to use it"?

答:
Dart has been out for ages (in internet years)

It isn't even used extensively and it is immature. Production ready technologies have existed for 10-15+ years... for Dart you can't even say it's a pre-alpha. New technologies always look good, on paper, when no one is using it.

it hasn't gotten much hype

I think the opposite. It's a shame such a bad, backward language got so positive reviews. It's going back from beautiful Ecma/Java Script OOP with parasitic inheritance, closures and callbacks to some wooden, decade old OOP taken from Java with all horrible programming practices Java comes with.

Some feature implementations that make you go "I have to use it"?

None. If you know java and you have intolerance for knowledge to learn Ecma/JavaScript properly Dart is probably only thing that'll work for you.

You know how google works. They use Java a lot, so probably that's why they produced such horrible language... they're just acustomed to it.

Beside it's further fragmenting the web and i can only hope Mozilla and Opera never implement this (because MS won't add support for some google java like language for sure). Beside the whole concept is DATED, we should get rid of languages like C++ or Java at least when coding UIs because these are very ineffective. It's like replacing C++ with Assembler, because coders in their late 50s refuse to learn new things.


答:
You can't measure programming language age in "internet years". In fact, you can't measure any actual technology in internet years. All you can really measure in internet years are hypes, but hypes don't reflect reality.

Dart is public since 3 months now. Compare that to the "fresh" and "hot" techs in the field, like CoffeeScript or Node.js, which are public since 2 years and almost 3 years respectively. Also it's worth noting that both are relatively small steps compared to Dart. Basically CoffeeScript meant plugging a JavaScript-generator into a Ruby-based parser and Node.js meant binding non-blocking I/O to the Google V8.

Dart is an attempt to redesign front end web programming at all levels, i.e. syntax, language features, runtime environment, APIs. Comparing Dart to CoffeeScript for example, is like comparing a prototype of a solar energy powered, auto-piloted personal aircraft with a 1968 Shelby GT. Sure, the former has far more potential, but investing in it, let alone boarding it requires a lot of audacity. The latter has a lot of known deficiencies, but they are known, which makes the whole thing predictable and reliable.

Of course this is just speculation, but I think Dart is a dead end, that will eventually be salvaged for moving JavaScript forward, or other solutions. If you want a dynamic language, CoffeeScript and Parenscript already do what Dart promises. If you rather prefer a statically typed language, then haXe and Opa will do the trick. All the four have a head start on Dart. And all of them are designed to be compiled to JavaScript as a default, not just as a fallback.

Title: What is the current state of Google's Dart programming language?

Body:
Dart has been out for ages (in internet years), but judging by Google Trends , it hasn't gotten much hype, and the fact that it only works in Chrome doesn't help either. Nonetheless, Chrome is gaining market share every day, which lends itself to a better view on Dart.

What is the big picture now? What state is the language in? Do people regard highly of it? Market share? Web App showcase? Some feature implementations that make you go "I have to use it"?


问:
Does using new techniques hurt productivity?
It seems that as experience with the specific set of tools you have to work with grows, the incentive to try out new things weakens.

When I was new at this programming job, trying out new things, researching online, made me more productive, because I often found a way (or library) that made the task easier that the code framework already in place. So using something new -- to me as well as in the context of the given codebase -- made me more productive.

Now I noticed, that there are more and more instances where, for a given problem, I know that there probably is a better solution "out there", and finding it would -- presumably -- improve the code. However, given my now intimate knowledge of the code base, it is by far easier to use the suboptimal tools we have, and get a solution (including tests) running than find someting new and "better" and "improve" the codebase.

So there is this tension: "do it properly" vs. "get the job decently done".

Is this something that happens to a lot of developers? Is this a known specific problem? (Is it a real problem after all?) Does it actually have to do with increasing levels of experience?

Oh, and note: I still like my job and like to keep it. It's just that it seems the -- always interesting! -- research part get's smaller as I learn the code base and problem sets we face with our app.

答:
Yes it can hurt productivity. My ex was asked to do some boring data processing job once, so she decided that it would be better to write a long program to deal with the data and then run it - which would fix the problem in seconds.

Took her a week to write it of course, but the problem did get solved in seconds after that.

I think the same applies to your question: yes, you can increase your productivity by learning new things, but you would still be better off applying your existing knowledge to the task and overall getting it done quicker. Who cares about finding and learning a new library, if you can write your own in less time.

Don't forget as well, often getting it decently done with existing tooling is a better solution than putting the new stuff in. Every time you add new, you increase the maintenance surface that's required, which in turn slows everyone else down (and can make your code quite messy - I think of the layers of 'new' tech that passed into legacy over time but are still in our code making things horrible. Looking back, it would have been better to just use the old C ways instead of adding all that COM and all that VB and all that .NET and now shovelling HTML into it too)


答:
Dart is still in technical preview. At the moment the language specification has the version 0.0.6, a 0.0.7 is expected somewhere this week. It is far from "complete". There are several example in the repository:
http://www.dartlang.org/samples/index.html

Here is one view on what is better in syntax terms than in JavaScript:
http://www.grobmeier.de/10-reasons-why-dart-is-cooler-than-javascript-03012012.html
Disclaimer: it is my post. I need to say here I like JavaScript, but at some points it has quirks, which I don't like very much.

There is also a growing community around it:
http://www.dartosphere.org

Some people have managed to port Box2D to Dart, another guy connected to CouchDB. Anyway, there is nothing you should use in production.

Before a while Josh Blochua has joined the team to work on a refactoring of the API. You can expect some changes even in the Core API.

Browser support: you can transcompile Dart to JavaScript, preferably with Frog (not DartC, it compiles to huge javascript files). Dartium is one of the browsers which supports native Dart, a controvers discussed Webkit branch is somewhere too.

My personal expectation is to get something more concrete in the middle of next year. From my experience Google Devs are doing lots to make the language proper and good, borrowing not only from Java, but also from Erlang and JavaScript.

Here is an example, a game ported from JavaScript:
http://blog.sethladd.com/2011/12/10-lessons-from-porting-javascript-to.html

One can expect Dart to arrive to Android, maybe even as a "main language". People are saying it will come to AppEngine.

Personally I think Dart is very elegant and already pretty nice. In addition I think it will have a marketshare once it is complete.

You'll find many of your questions answered in this FAQ:
http://www.dartlang.org/support/faq.html#compare-to-coffeescript


问:
How long would it take to learn Python?
I have decided to take the time out after work to learn Python. Python appeals to me because at work (Web and eLearning Company), I have to follow out very repetitive tasks like delete all these tags, rename all these tasks and even more advanced repetive tasks. Additionally it would be good for me to get an understanding of Python first because of its fairly easy to learn syntax.

How long would it take to learn the basics of Python?

答:
If you're not currently proficient (i.e., comfortable undertaking significant projects) in another programming language, you should go for a tutorial/study program geared toward new programmers.

Personally, I don't like the "learn x in ten minutes" or "learn y in twenty-four hours" typ of books, because people learn at their own pace, so I prefer resources geared toward self-pacing.

The Head First series from O'Reilly are excellent books that use principles from learning theory and cognitive science to enhance retention. I've used some of their books, and I've heard good things about Head-First Python.

In addition, one of the most popular tutorials out there is Learn Python The Hard Way, by Zed Shaw. It's available as print, eBook, video classes, and (for free!) an online HTML version. It's called 'The Hard Way' because he forces you to learn the basics in a practical manner rather than just throwing exercises at you that don't really help you truly understand how to create software in the language (which is my criticism of some of the 'in 24 hours' books).

In addition, keep with it, and when you get stuck, ask for help. This site (for general questions), and Stack Overflow are invaluable. Once you have working code you'd like to improve, you can ask for help at Code Review. Start with solid training (the books above, plus a plethora of online video tutorials and screencasts), and then take advantage of the wide community of developers who are willing to help new programmers find their footing.

Title: How long would it take to learn Python?


问:
Are there any benefits to checking in commented out code into version control?
I've found, what I personally believe to be a bad habit that a lot of developers seem to have adopted. Code in various places in the applications I have seen are commented out (lots of it) and checked into the mainline. Now, I don't have a problem with people doing this with their own branches, but is it a good idea to comment out 60 or so lines of code and check it into trunk? A colleague of mines has unearthed a lot of this and had spend half a day removing the commented out code just to tidy things up. Is there any benefit in checking in commented out code and leaving it for another developer to have to tidy up after you? After all, version control does have a history, so you can easy pull back any code that's been removed.</p>

答: commented out code also acts as a quick and simple version history. If you don't see the comments, you don't know what was there - regardless of the versioning. I tend to comment out blocks as I'm developing, and happily check them in. However, the caveat is that I will happily remove comment blocks for freshly-checked out code, the intention being that the next revision will always have the comment in there for the next dev to see when debuggging (assuming I make a mistake, they can instantly see what it used to be when it worked) but after that revision it becomes redundant and can be removed. Obviously you need to apply a little common-sense to this, sometimes the comment should be left in for a bit longer, and it doesn't apply to all commented out code.</p>


答:
Just throwing some suggestions out there:

Perhaps the source code is sitting on a separate repository, which means admins may have to set up new accounts for every Tom, Dick and Harry who wants read access. In that case the admins are likely to only set up accounts for those in the team. This is true at my work, even though we have only about 300 people.

Perhaps they don't want to support dozens of different versions all downloaded from random versions from the trunk


答:
Dart is a flawed concept following in Javascript's footsteps. Google should be collaborating on creating a standard runtime for web browsers (sort of like an HTML 6). Similar to java byte code or microsoft's IL.

We should not be standardizing on specific languages, but on runtimes.  The "browser is an operating system".  Right? WTF google? Follow your own vision!!!


问:
Agile unified process vs. agile lifecycle process
I wanted to know the difference between agile lifecycle and agile unified process(AUP). I do understand that AUP is a modified version of RUP using agile methodology. Can you please elaborate on the differences between the two</p>

答:
Pretty sure AUP is a specific flavor of Agile and describes an Agile lifecycle.  So you are kinda comparing apples to fruit (a specific process to a general family of processes).

Check here (specifically here).


问:
Omitting inheritance in programming languages
I am developing my own programming language. It's a general purpose language (think staticlly typed Python for the desktop, i.e. int x = 1; ) not intended for the cloud.

Do you think it's okay not to allow inheritance or Mixins? (given that the user would at least have interfaces)

For example:
Google Go, A systems language that shocked the programming community by not allowing inheritance.

答:
Yes.

I think not allowing inheritance is fine, particularly if your language is dynamically typed. You can achieve similar code reuse by, for example, delegation or composition. For example, I have written some moderately complicated programs--okay, not that complicated :)--in JavaScript without any inheritance. I basically used objects as algebraic data structures with some functions attached as methods. I also had a bunch of functions which were not methods that operated on these objects.

If you have dynamic typing--and I'm assuming you do--you can have polymorphism without inheritance as well. Also, if you allow adding arbitrary methods to objects at runtime, you won't really need things like mixins very much.

Another option--which I think is a good one--is to emulate JavaScript and use prototypes. These are simpler than classes yet also very flexible. Just something to consider.

So, all told, I'd go for it.


答:
No.

If you want to remove a base language feature, then you are universally declaring that it is never, ever necessary (or unjustifiably diffficult to implement, which does not apply here). And "never" is a strong word in software engineering. You would need a very powerful justification to make such a statement.

Title: Omitting inheritance in programming languages

Body:
I am developing my own programming language. It's a general purpose language (think staticlly typed Python for the desktop, i.e. int x = 1; ) not intended for the cloud.

Do you think it's okay not to allow inheritance or Mixins? (given that the user would at least have interfaces)

For example:
Google Go, A systems language that shocked the programming community by not allowing inheritance.


答:
When I first ran across the fact that VB6 classes don't support inheritance (only interfaces), it really annoyed me (and still does).

However, the reason it's so bad is that it didn't have constructor parameters either, so you couldn't do normal dependency injection (DI).  If you have DI then that's more important than inheritance because you can follow the principle of favoring composition over inheritance.  That's a better way to re-use code anyway.

Not having Mixins though?  If you want to implement an interface and delegate all the work of that interface to an object set through dependency injection, then Mixins are ideal.  Otherwise you have to write all the boilerplate code to delegate every method and/or property to the child object.  I do it alot (thanks to C#) and it's one thing I wish I didn't have to do.


答:
Using a DCVS is probably a good idea, but it's not the only option.

I have a small CVS repository on a USB thumb drive.  When I want to access it, I just need to use cvs -d <path> or set $CVSROOT to the path of the root of the repository (which of course requires the thumb drive to be mounted on the system).

If you're already accustomed to use CVS, this should be workable.  The same should apply to SVN.  It just means your central repository is on the thumb drive, and isn't always visible.

There are arguments for using a DCVS rather than CVS in general.  I don't think those arguments are particularly affected by whether the central repository is on a thumb drive or somewhere else.  For example, you could just as easily create a git repository on the thumb drive.


答:
Yes, it's a perfectly reasonable design decision to omit inheritance.

There are in fact very good reasons to remove implementation inheritance, as it can produce some extremely complex and hard to maintain code. I'd even go so far as to regard inheritance (as it is typically implemented in most OOP languages) as a misfeature.

Clojure, for example, doesn't provide implementation inheritance, preferring to provide a set of orthogonal features (protocols, data, functions, macros) that can be used to achieve the same results but much more cleanly.

Here's a video that I found very enlightening on this general topic, where Rich Hickey identifies fundamental sources of complexity in programming languages (including inheritance) and presents alternatives for each: Simple made easy


答:
You will probably have to create a Custom Control for the drawing surface. If you are creating a WinForms application, you can start by inheriting from System.Windows.Forms.Control. Then you override the OnPaint method and draw pixels as desired. I gave this advice to someone wanting to draw a LED-board, which looks pretty much like a zoomed icon. Here is the original answer with a VB example.

Here the translated example in C#

```<code>public class LedBoard : Control
{
    private Random _rand = new Random();

    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        e.Graphics.FillRectangle(Brushes.Black, 0, 0, Width, Height);

        const int nx = 40;
        const int ny = 25;

        int w = (Width - 1) / nx - 1;
        int h = (Height - 1) / ny - 1;
        for (int x = 0; x <= nx - 1; x++) {
            for (int y = 0; y <= ny - 1; y++) {
                if (_rand.NextDouble() < 0.8) {
                    e.Graphics.FillRectangle(Brushes.Red, x * (w + 1) + 1, y * (h + 1) + 1, w, h);
                }
            }
        }
    }
}
</code>```

It is just to give you an idea. If you want to "draw" an icon with buttons or labels for each pixel, you will need 32 x 32 = 1024 controls! A Custom Control allows you to do more than just draw the pixels of the icon. You could also draw selection marks, for instance.

Start with a minimum of functions. Color selection and drawing single pixels is enough for the beginning. Then add the functions that you miss most.

Title: Need help with deciding elements for icon creating application

Body:
I'm trying to practice programing by creating a simple application which, I think, I can manage to do in .Net C# in Visual Studio 2010.

I'm working on simple application which will let me to create small pictures (icons) in sizes such as 8x8, 16x16, 32x32 (etc) pixels. I will be creating a grid representing each size by scaling to amount of pixels. Each pixel will be represented in a small square which will be able to click to change color etc.

So here's my question regarding what elements such app should have:

What VS tool would let me to create a grid for my project? Keeping in mind that each small square should be generated automatically by using X/Y size provided by user and boxes should be clickable. Also, I probably should be able to be able to click one pixel and drag mouse to select other pixels.

What simple functions should such small app have? For example choosing colors.

What minimal functions should I have?

I'm trying to get the general idea of how to make such small app work and what user might expect when opening small, icon creating, application.

Body:
You will probably have to create a Custom Control for the drawing surface. If you are creating a WinForms application, you can start by inheriting from System.Windows.Forms.Control. Then you override the OnPaint method and draw pixels as desired. I gave this advice to someone wanting to draw a LED-board, which looks pretty much like a zoomed icon. Here is the original answer with a VB example.

Here the translated example in C#

public class LedBoard : Control
{
    private Random _rand = new Random();

    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        e.Graphics.FillRectangle(Brushes.Black, 0, 0, Width, Height);

        const int nx = 40;
        const int ny = 25;

        int w = (Width - 1) / nx - 1;
        int h = (Height - 1) / ny - 1;
        for (int x = 0; x <= nx - 1; x++) {
            for (int y = 0; y <= ny - 1; y++) {
                if (_rand.NextDouble() < 0.8) {
                    e.Graphics.FillRectangle(Brushes.Red, x * (w + 1) + 1, y * (h + 1) + 1, w, h);
                }
            }
        }
    }
}

It is just to give you an idea. If you want to "draw" an icon with buttons or labels for each pixel, you will need 32 x 32 = 1024 controls! A Custom Control allows you to do more than just draw the pixels of the icon. You could also draw selection marks, for instance.

Start with a minimum of functions. Color selection and drawing single pixels is enough for the beginning. Then add the functions that you miss most.


答:
First of all, thanks to everyone who contributed great answers to my relatively vague and abstract question.

I'd like to contribute a potential answer that I've thought of after thinking about other answers. It's not a direct answer to the question asked, but it is relevant.

As some people pointed out, using an integer of 64/128/256 bit size already gives you a very large space for UUIDs. Obviously it is not infinite, but...

Perhaps it might be a good idea to just use a fixed size int (say, 64-bit to begin) until 64-bits is not enough (or close to it). Then, assuming you have such access to all previous instances of the UUIDs, just upgrade them all to 128-bit ints and take that to be your fixed-size of integer.

If the system allows such pauses/interruption of service, and because such "rebuild" operations should occur quite infrequently, perhaps the benefits (a very simple, fast, easy to implement system) will overweigh the disadvantages (having to rebuild all previously allocated integers to a new integer bit size).


问:
Would it make more sense to use a framework to build an commerce site, or build it from the ground up?
Keep in mind, I know PHP as I learned it for this specific project. Also, I thought about just using magento, but as I went through it, I realized I would have to learn their framework. I am very opposed to putting more time into learning a framework rather than continue expanding my PHP knowledge. I took a computer science course in which rather than make us use already made objects and functions, we had to create those as to learn how they actually worked. That was an amazing learning experience. I know that their is a lot of work involved in doing this, due mainly to the fact that others have done similar things, but my main two reasons for this are:

I would only build what I need, no extra features I do not.

I would have specific needs, stuff that I would need to code anyways.

The only thing I would need would be simple e-commerce features like user authentication, products pages(user, admin), and shopping cart, and obviously a database. Everything else I need would be tailored to the specific needs of the site and the way I will be implementing it. If this helps in giving a picture of where I am at, what would the best recommendation be from professionals. Thank you.

答:
Framework.

Why worry about the plumbing when you don't have to? If you need to improve the performance after profiling and determining that certain parts of the framework are in fact the bottleneck, then improve the framework in question and contribute back to the community.

People who have written those frameworks in question have much more expertise in the language/technology than you do (given your explanation). You can learn much from using (and stepping through) framework code.


答:
If trying to learn a new technology,  I would recommend not using a framework.  You learn more about what you are building and why when you build without a framework.  If building a production enterprise application, use a framework, its proven, testable, documented and likely has a large community who support it.

Thinks roses and thorns, everything is a tradeoff, nothing is free.

Title: Would it make more sense to use a framework to build an commerce site, or build it from the ground up?

Body:
Keep in mind, I know PHP as I learned it for this specific project. Also, I thought about just using magento, but as I went through it, I realized I would have to learn their framework. I am very opposed to putting more time into learning a framework rather than continue expanding my PHP knowledge. I took a computer science course in which rather than make us use already made objects and functions, we had to create those as to learn how they actually worked. That was an amazing learning experience. I know that their is a lot of work involved in doing this, due mainly to the fact that others have done similar things, but my main two reasons for this are:

I would only build what I need, no extra features I do not.

I would have specific needs, stuff that I would need to code anyways.

The only thing I would need would be simple e-commerce features like user authentication, products pages(user, admin), and shopping cart, and obviously a database. Everything else I need would be tailored to the specific needs of the site and the way I will be implementing it. If this helps in giving a picture of where I am at, what would the best recommendation be from professionals. Thank you.


答:
I once had to directly ask my manager not to be negative about our situation as a company when he talks to me, because while I'm aware that we have our ups and downs, I tend to be depressed and unmotivated when he tells me we're not doing well.

I also asked him to provide me with more positive feedback, because people tend to come to me with all the complaints about bugs etc., and when stuff works they just go about their day.

Title: Managers X Motivation


答:
To disagree with another answer: no, you throw out features when they're incompatible with something you want more. Java (and other GC'd languages) threw out explicit memory management because it wanted type safety more. Haskell threw out mutation because it wanted equational reasoning and fancy types more. Even C threw out (or declared illegal) certain kinds of aliasing and other behavior because it wanted compiler optimizations more.

So the question is: What do you want more than inheritance?


问:
Why is it optimal to schedule shorter jobs first on a uniprocessor?
On a uniprocessor, it is apparently optimal to schedule jobs that take less time first assuming non-preemptive scheduling - once a job runs, it must finish. Why?

I am confused about how the ordering would change the overall latency. Since a uniprocessor can only take on a single process at a time, wouldn't the latency be the same regardless of order?

答:
Although this algorithm was designed to provide maximum throughput in all the scenarios, this is not correct for all situations. What if the processor has a lot of small processes? It will definitely lead to starvation. The turnaround time of small processes will be low, whereas that of large processes will be large as compared to other scheduling algorithms.

Wikipedia says:

Since turnaround time is based on waiting time plus processing time,
  longer processes are significantly affected by this. Overall waiting
  time is smaller than FIFO, however since no process has to wait for
  the termination of the longest process.

If you schedule larger jobs first, lots of small processes would have to wait for the process to terminate (as this is non-preemptive). And since turnaround time is total time between submission of a process and its completion, this would definitely be low. But in SJF, very few large processes wait for some small processes, so turnaround time of only those large processes would be affected.

Check out this link for a comparison of various techniques.


答:
The short answer to "What's the state of Dart?" is: it's in Technology Preview. That's a special way of saying, "we launched early so we can open source everything and work in the open."  "Technology preview" also means "we're not even in Alpha yet, we have a lot of work to do, but there's enough there for you to play with and give feedback."

Internet time may work for news stories or consumer product iterations, but probably not for something as ambitious and broad as the Dart effort. Remember, Dart is more than just a language. It's also a set of libraries, a better DOM interface, a virtual machine, an Editor, and integration with Chrome. The team is working very hard on a lot of parallel threads, but I personally expect it'll be six months before we have most of the pieces in place.

It's not true that Dart only works in Chrome. Dart compiles to JavaScript and targets modern browsers. Sure, Chrome will be the first to launch with native Dart support, but ensuring Dart compiles to performant and effective JavaScript is a core constraint and feature of the project.

The big picture is that Dart will become a "batteries includes" development environment for modern web apps. Dart's driving goal is to help ensure the web remains a productive and enjoyable platform for app development and deployment. This means a lot of pieces need to fall into place: language, libraries, editors, virtual machines, and browser integration. Put all together, we believe Dart will be a compelling option for modern web app developers.

The big big BIG picture is that we want to bring app developers to the web, and we want web developers to write more complex web apps. If they use Dart, that's great. But at the end of the day, the language doesn't matter. The only thing that matters is that complex, client side, high fidelity, low latency, beautiful modern web apps are being built.

The language is in a state of development. We see new releases to the spec approximately once per month. Major features are missing, such as reflection, but we keep iterating. We just added map() support to Collection, for example. Gilad Bracha, a guy who knows his languages (having created NewSpeak and worked on the Java Lang Spec) and Josh Bloch, a guy who knows his libraries (having written Effective Java and worked on the Java Collection libraries) are working on the language and libraries, along with the greater team.

Do people regard highly of Dart is hard to generalize, and it probably doesn't matter too much to you. You should draw your own conclusions after having played with Dart. My experience is that app developers from other platforms such as Java, C#, or Flex find Dart attractive and familiar. My experience with JavaScript developers is split. If that JavaScript developer has also built apps on other platforms, they are cautiously optimistic about Dart (or, at least, the solution it's trying to provide). If that JavaScript developer grew up on JavaScript and has only programmed in JavaScript, there's more hesitation. This could be some fundamental concern about the language, or hesitation in leaving a comfort zone, or simply just not running into edge cases with JavaScript. This is just generalization, but I've seen plenty of people become productive in Dart extremely quickly.

As for market share, it's extremely early in the game. It's probably not the right question to ask, as Dart isn't even shipping. A more interesting question would be, "What is the market share of apps on the web?" and then go figure out how we can address that.

As for a Web App showcase, the Dart team built Swarm, a slick newsreader. Unfortunately, we only have it in source code right now: http://www.dartlang.org/samples/index.html

As for some "killer" features, I would say there are a few pretty interesting ones:

optional types are slick, they add annotations and documentations for humans and machines.

Isolates is a great way to achieve concurrency in a safe manner.

Libraries (modularity) is sorely needed for the web stack, and Dart has libraries and classes.

Snapshots will allow for extremely fast start-up

Bundled libraries (like collections, Stopwatch, etc) will unify code bases and shrink shippable code

Nice new DOM interface, which makes working with DOM much more enjoyable. It feels like native Dart code.

I hope I've answered your questions. I think the only question that matters is, "Does my language help me build complex, high fidelity, low latency, modular, modern web apps?" The end state of all of this is simply helping more app developers deliver more successful apps to the modern web.


问:
Who decided on the terminology downcasting and upcasting?
As far as I know, the terminology comes from how the inheritance hierarchy is traditionally displayed, with the extending types at the bottom, and the parent types at the top.

This is a bit pointless, unless you feel like calling the following leftcasting and rightcasting.

I am not looking for opinions why the terminology is as is, but they are more than welcome as comments. I am looking for references on who first introduced up and downcasting, and why they decided on that name.

答:
The oldest reference I've found yet is from Sep 1990, in a Usenet post.

The library referenced there is the NIHCL (available from the Software Preservation Group), which contains this code (MI is "multiple inheritance"):

```<code>#ifdef MI

#define DECLARE_CASTDOWN(classname) \
    static classname& castdown(Object& p) \
        { return *(classname*)(&p ? p._safe_castdown(*desc()) : 0); } \
    static const classname& castdown(const Object& p) \
        { return *(const classname*)(&p ? p._safe_castdown(*desc()) : 0); } \
    static classname* castdown(Object* p) \
        { return (classname*)(p ? p->_safe_castdown(*desc()) : 0); } \
    static const classname* castdown(const Object* p) \
        { return (const classname*)(p ? p->_safe_castdown(*desc()) : 0); } \

#else

#define DECLARE_CASTDOWN(classname) \
    static classname& castdown(Object& p)           { return (classname&)p; } \
    static const classname& castdown(const Object& p)   { return (const classname&)p; } \
    static classname* castdown(Object* p)           { return (classname*)p; } \
    static const classname* castdown(const Object* p)   { return (const classname*)p; } \

#endif
</code>```

The book that this code was included with (Data Abstraction and Object-Oriented Programming in C++) also uses the term "castdown".

The term "castdown" also seems to predate "downcast", at least on Usenet.

Body:
The oldest reference I've found yet is from Sep 1990, in a Usenet post.

The library referenced there is the NIHCL (available from the Software Preservation Group), which contains this code (MI is "multiple inheritance"):

#ifdef MI

#define DECLARE_CASTDOWN(classname) \
    static classname& castdown(Object& p) \
        { return *(classname*)(&p ? p._safe_castdown(*desc()) : 0); } \
    static const classname& castdown(const Object& p) \
        { return *(const classname*)(&p ? p._safe_castdown(*desc()) : 0); } \
    static classname* castdown(Object* p) \
        { return (classname*)(p ? p->_safe_castdown(*desc()) : 0); } \
    static const classname* castdown(const Object* p) \
        { return (const classname*)(p ? p->_safe_castdown(*desc()) : 0); } \

#else

#define DECLARE_CASTDOWN(classname) \
    static classname& castdown(Object& p)           { return (classname&)p; } \
    static const classname& castdown(const Object& p)   { return (const classname&)p; } \
    static classname* castdown(Object* p)           { return (classname*)p; } \
    static const classname* castdown(const Object* p)   { return (const classname*)p; } \

#endif

The book that this code was included with (Data Abstraction and Object-Oriented Programming in C++) also uses the term "castdown".

The term "castdown" also seems to predate "downcast", at least on Usenet.


问:
A simple ways to improve the release quality in RAD environment
A bit of a background here - we are a small team (of 5) of RAD developers responsible for internal software development in a big non-software company. "Internal software" varies from a desktop .NET application using MSSQL server as a backend to Python scripts running on the background  to MS Word documents and templates - a zoo of technologies.

The whole team consist of all-arounders able to get the requirements from users, code it up, test it and deploy into production. Once the software in the production it is being looked after by another team but it usually easy for us to intervene if something goes wrong.

All sounds good so far, but there is a problem - being a RAD team we have to release often, and there is no day going by without us releasing new versions of one or two applications(or it could be a script, updated word document, C++ console app, etc) into the production. We do a development testing and also do involve end-users by letting them run the software in UAT environment ...

... but the bugs are creeping in to production anyway. Users do understand that these bugs and the occasional instability is the price they are paying for getting what they want really quickly, but at the same time it got us thinking - perhaps we could improve our development or a release practices to improve the stability of the software and reduce the number of bugs we introduce when adding a new functionality.

The good thing - we don't really have much of the processes in the first place, so it should be easy to start improving, the bad thing - being a small RAD team we don't really have the much time and resources to implement something big, but we have been thinking about the following initiatives and would welcome any feedback, tips, hints and suggestions.

Currently some of the applications are being released into the production straight after the developer testing, bypassing the user acceptance testing. That practice should be discontinued and even a small change has to be tested by a end-user. Each application will have a dedicated beta-tester selected from the end-users. Only after a beta-tester has ok-ed the new release it is promoted from test to production environment.

We don't conduct code reviews - but we'll start doing code reviews before one of us checkin the changeset. I was also thinking about a "rollout review" - basically one of the developers has to sit next with the other watch him/her doing the software rollout (copy binaries, update configs, add new table to database, etc) - it usually only takes a 5-10 minutes so it won't take much of a "rollout review" time.

How to miminise the rollback time when a new release is proven to be buggy enough to be pullout from production and to be replaced by a good previous version. We do store a history of all releases (as a binaries) to make it easy to go one version back - and though it is quick "overwrite a newly released binaries with a previous versions binaries" it is still a manual process which is error prone and demanding at times "what if the rollback will fail and will render the system unusable instead of buggy".

This is where we ran out of our ideas and we'd like to get your feedback on these and if you could share some simple release / dev process improvement advices - that would be awesome.

答:
You've already identified that you know there are problems with your processes which affect the quality of your software, and while this question will provoke a range of answers, my suggestion would be to look at the topic of software engineering and try and learn what developers in the main are finding themselves doing more and more of in that area.  I suggest you start reading a few good resources to get yourself kicked off.  A few that come to mind:

Lean Software Development by Mary and Tom Poppendeick provides a great read for people interested in learning how to identify "waste", and what to do about changing processes to become leaner and more efficient.

Head First Software Development by Dan Pilone and Russ Miles is a bit like one of those "for dummies" books at first glance, but by looking a little past the chaotic presentation style, it contains most of the information relating to the basics of software engineering and has a brief write up about Test Driven Development.

Introducing BDD is Dan North's page about getting into Behaviour Driven Development, or perhaps you'd prefer a BDD Wiki.  These are starter references for BDD and you will probably want to look into tools and frameworks to help you.  The important thing to understand is that BDD is effectively TDD taken to a higher conceptual level.  It allows you to think about testing as you are thinking about specifications, and to test in the same language you use when you write specs.  The frameworks generally integrate with other unit testing frameworks, so you get the best of both worlds if you decide that your testing might not necessarily benefit from the BDD syntax.

Wikipedia's Agile Software Development Article is a good primer all about agile software development, and provides a number of useful references and links to articles by some of the development community's more respected people.

In order to improve HOW you work, you need to allow yourself to be completely open-minded, and willing to step well outside your comfort zone in order to learn to improve the things that you do without clinging to certain concepts that you may find are more comfortable to hang on to. Speaking from personal experience, this is probably the hardest thing to do, or to encourage in others.

Change is hard at the best of times, even if you feel you are actively seeking change, so the best advice that I can really give you is to look at the various Agile methodologies that have been developed over the years to familiarize yourself with the practices that are considered to be most important (eg: Unit Testing, Continuous Integration, Refactoring, etc...), and then pick the methodology that seems closest to what you and your team will feel most comfortable with.  Once you've made your decision, tune the practices and your development process so that it suits how your team would prefer to work, keeping in mind those lean principals and how you wish to work so that your team can produce the greatest value with the least waste. Finally, always look forward yet allow yourselves to second-guess your choices just enough to always seek to improve your processes over time, and introduce the changes to your processes in stages, so that it will be easier to swallow, and will become second nature to you as time passes and your processes are slowly improved.

If you feel your processes merely need tweaking, yet you are concerned that your tool chain isn't quite keeping up with your needs, then perhaps look to improvements there.  At a minimum, a continuous integration integration product (such as Continuum, Cruise Control or  Hudson), and an Issue Tracking system (such as Jira, or Redmine) should be a priority to help you to automate some of your build and release processes, and to keep your bugs and feature requests in check.

The reality is that no matter how RAD your processes are, if you don't put in the investment of time to getting things "right" for your team, your problems will only continue to grow with time, and your perception of available time will shrink accordingly.  Big changes are usually out of the question when under heavy time pressure, but try and give yourself a little "wiggle room" in order to put systems into place to help you to take baby steps towards your team's vision of an ideal methodology.


问:
What copyright date for an update to an open-source project from last year?
In 2011, I released some open-source code that was licensed using the Apache license. As such, all the source files have this boiler plate message at the top:

```<code>/*
   Copyright 2011 My Name

   Licensed under the Apache License... <blah blah>
*/
</code>```

So now it's 2012, and I am readying to release a version 1.1. As such, most all of the source files have been touched in some way. And some new source code files have been added.

How do I update the copyright date on the existing files?  Is the following the correct update to each source file? (i.e. change 2011 to "2011-2012")

```<code>/*
   Copyright 2011-2012 My Name

   Licensed under the Apache License... <blah blah>
*/
</code>```

Do the new source files get Copyright 2011-2012 applied equally as well? Or does the new code just get Copyright 2012?

答:
Well, I am not a lawyer, but if I got this right

Copyright Notice: Is the Year Really Necessary?

then "2011" (as the year of first publication) is sufficient. It would be also sufficient to not include any disclaimer for the copyright at all, since you own the copyright with or without a disclaimer. The "license" is different from that, since it defines the terms what other people are allowed to do with your code.

ContentLicense: CC BY-SA 4.0


答:
In our company, legal dept. suggests to only update the copyright year for major releases only.

In source code I would definitely not bother.

Title: What copyright date for an update to an open-source project from last year?

Body:
In 2011, I released some open-source code that was licensed using the Apache license. As such, all the source files have this boiler plate message at the top:

```<code>/*
   Copyright 2011 My Name

   Licensed under the Apache License... <blah blah>
*/
</code>```

So now it's 2012, and I am readying to release a version 1.1. As such, most all of the source files have been touched in some way. And some new source code files have been added.

How do I update the copyright date on the existing files?  Is the following the correct update to each source file? (i.e. change 2011 to "2011-2012")

```<code>/*
   Copyright 2011-2012 My Name

   Licensed under the Apache License... <blah blah>
*/
</code>```

Do the new source files get Copyright 2011-2012 applied equally as well? Or does the new code just get Copyright 2012?


问:
Private interfaces within a package
This is basically the same as Coding to interfaces, but played out in the real world of com when there are various engineering complexities such as immutability of published interfaces and implementations, etc.

Consider the following situation:

A OS-level object-oriented library with a set of published interfaces and an implementation provided by the OS.

Some extension points are provided so that third parties can extend specific behaviors by implementing a subset of the published interfaces and registering them with the OS.

A programmer looks at the whole set of published interfaces, and says to self, "it seems like I can re-implement most of the functionalities (with better algorithms), including those areas which aren't designated as extensible." And so the programmer worketh.

Only when the programmer's own implementation mash up (COM-style) with the OS implementation and fails miserably, did the programmer realize that the suite of objects as implemented by the OS rely heavily on communications using non-published interfaces, because the published interface was minimalistic and blocked many opportunities to optimizations(*).

(*) In encoding/decoding/trans-coding (of data/image/sound/video compression) tasks, it is well known that certain pipelines stages can cancel each other if they perform the exact opposite operation / inverse, e.g. G(F(x)) == x.

A typical interaction is like:

Consumer asks Producer if it implements a special interface X that only vendor V knows.

If yes, Consumer talks to Producer using interface X and see if they are exact opposite (#1).

If yes, Consumer asks Producer for its "upper stage" (i.e. bypassing Producer) (#2) so that in effect both are being cancelled out.

(#1) and (#2) are capabilities that are missing in the minimalistic published interface. On first glance it seems that the vendor might have a chance to provide them as well, but choose not to.

It might also be the case that providing those performance-oriented interfaces would severely pollute the namespace.

The end result is that whenever a programmer provides its own implementation of a certain class, it would either (i) fail miserably, or (ii) perform very slowly, because it could not interact with the rest of the suite using the performance-enhanced internal interfaces only known to that suite.

Is this a more frequent problem with some flavors of Object-Oriented technology? Or is it more common with some flavors of Component-based Engineering?

Advocates of OOP will argue that Refactoring and Publishing those interfaces would solve the problem. This assumes that it is possible to distribute a new version of the library along with new set of interface. For some technology this is not possible.

The way it matters to com is that its QueryInterface method allows run-time query (and run-time response) of additional interfaces implemented by a class. Its Java equivalent would be like a library that makes heavy use of instanceof for interfaces internal to the package.

To Reviewers: I'm open to suggestions on trimming down the question to its essence.

The correct term seems to be Mixin, thanks to this question.

This answer is partly relevant, but my example focuses on the lost opportunities for optimizations within a single library. Basically, if a third-party implementer didn't do both:

Implement both encoder and decoder

Implement its own proprietary interface on both the encoder and decoder, in order to detect and bypassing operations that cancel out each other

Then the implementation will only get "baseline performance" when inter-operating with different encoders/decoders from other vendors.

答:
As a general rule, Public API should not change over time (or should at least be stable) so that existing applications that depends on them doesn't break while more functionality for additional applications are supported.

On the contrary, Private API should be allowed (nearly freely) without which it is not quite possible to effectively bring that evolution we really need.

If you are finding that given Public API is cause of bottleneck, then it is the issue with the prior API at the first place. In your specific case, for transcoding example (which is what i work on), the Encoding API and Decoding API should NOT change, but both modules should have additional API that support transcoding.

Of courses, within such API, the change should be controlled such that internal/private classes don't arbitrary change their roles/ else there are chances to break the original behavior.

Is this a more frequent problem with some flavors of Object-Oriented
  technology? Or is it more common with some flavors of Component-based
  Engineering?

NO. It's only dependent on the design not inherently a limitation of OO or Components.

Title: Private interfaces within a package


答:
Speaking from a strictly C++ perpective, inheritance is useful for two main purposes:

It allows code resusability

In combination with overriding in a child class, it allows you to use a base class pointer to handle to a child class object without knowing its type.

For point 1 as long as you have some way to share code without having to indulge in too much acrobatics, you can do away with inheritance.
For point 2. You can go the java way and insist on an interface to implement this feature.

The benefits of removing inheritance is

prevent long hierarchies and its associated problems. Your code-sharing mechanism should be good enough for that.

Avoid changes in parent classes from breaking child classes.

THe tradeoff is largely between "Dont Repeat Yourself" and Flexibility on one side and problem-avoidance on the other side. Personally i would hate to see inheritance go from C++ simply becuase some other developer may not be smart enough to forsee the problems.


答:
Use a framework, as a rule it make no sense to reinvent the wheel. It is almost certain what you will develop is a cut down buggy version of something thats already avalible for free. It will have a user community of one, making it a lonely life (who will support you when things are not doing what you think they should), and limited life span once you loose interest in the project.

The only reason I consider not using a framework acceptable is you are doing for learning and you have a back ground in computer science, not computer engineering.

It will not help job prospects putting "roled my own" on a resume.

In response to your specific concerns,

1) A good framework does not make you add features you don't want to.

2) Using a feamework allows you to focus on those "specific needs" and frees you from the tasks that everyone needs, and have no added value.

Does an carpenter build a house with a hand saw and hammer? Although he needs to know how to use these, and does for specific problems, he reaches for the power saw and nail gun most of the time, you should too.


答: This workshop will perfectly match the goal. There are some good books avaiable in the market like TDD approach by Kent Beck, Refactoring - Improve the Design of Existing Code - Martin Fowler, Clean Code - A Hand book of Agile Craftman Ship by Robert C.Martin. You should recommend the attendess to go through book where in these concepts have described in detail bocz we cant cover everything in single workshop.</p>


问:
Why is a Bayes classifier used for spam filtering?
I've been reading about Bayesian spam filtering and I think I understand the theory, but I just don't see why this approach is needed in order to calculate the likelihood of a message being spam, given that it contains a certain word.

If we have a set of messages already classified by the user as either 'spam' or 'ham' and we receive a new message (containing the chosen word) which we want to classify, then surely all we need to do is divide the number of spam messages that contain the word, by the total number of messages that contain the word... Why all the equations?

答:
Alright, first off, there is not only positive evidence but also negative evidence. Some words make an email message very likely to be spam, some make it very likely to be real. Other words make a message very likely to be spam by their absence, while yet others have the opposite effect. For instance, if you research drosophila for a living and frequently correspond with colleagues about them, the presence of that term is almost like a password, because no mass-mail campaign will be able to customize their texts to your habits that well - it would destroy the economies of scale that make spam viable in the first place.

Also, performance of a filter cannot be measured with just one metric. Detecting spam is very easy, indeed trivial, if you simply classify everything as spam - but then the false positives (detecting real mail as spam) are intolerably high. Detecting nothing solves that problem, but then the false negatives (classifying bad samples as good) make your life miserable. A good filter must reach good values on both counts, which makes it much more complicated than just a super-sensitive detector of something.

So right from the start you have not just one 'List of bad words', but at least four lists, and not just one criterion, but at least two. So far, Bayesian filtering really is the simplest method that does this well. If you find better one,  by all means let's hear it.


答:
If you want to put the shop on the web use a framework!

A battle proven framework is the only way I would consider for a critical system like a shop. You have to tackle so many areas that are new to you, that you will eventually screw up.

Security

Scalability

Handling payments

Handling user data

Invoices

These things are hard and have serious consequences if they break.


答: If the short job (A) runs before the long job (B), then A has to wait only its own length for completion, while B has to wait its own length + the length of A. If B goes first, it has to wait only its own length, but A has to wait the entire length of B plus its own. In other words, you have a total wait time of 2B+A rather than 2A+B. Since the denominator is 2 in either case, the former solution is better. That's all there is to that rule.</p>

Title: Why is it optimal to schedule shorter jobs first on a uniprocessor?

Body:
On a uniprocessor, it is apparently optimal to schedule jobs that take less time first assuming non-preemptive scheduling - once a job runs, it must finish. Why?

I am confused about how the ordering would change the overall latency. Since a uniprocessor can only take on a single process at a time, wouldn't the latency be the same regardless of order?


答:
Reasoning about whether inheritance (or any single feature, really) is necessary or not without also considering the rest of the language's semantics is pointless; you're arguing in a vacuum.

What you need is a consistent language design philosophy; the language needs to be able to elegantly solve the problems that it's designed for. The model to achieve this may or may not require inheritance, but it's hard to judge this without the big picture.

If, for example, your language has first-class functions, partial function application, polymorphic data types, type variables and generic types, you have pretty much covered the same bases as you would have with classic OOP inheritance, but using a different paradigm.

If you have late binding, dynamic typing, methods-as-properties, flexible function arguments, and first-class functions, you also cover the same grounds, but again, using a different paradigm.

(Finding examples for the two paradigms outlined is left as an exercise for the reader.)

So, think about the kind of semantics you want, play around with them and see if they are sufficient without inheritance. If they are not, you may either decide to throw inheritance into the mix, or you may decide that something else is missing.


问:
Version Control based on portable storage?
I develop personal projects on two machines without use of a shared server or a network connection between the two.

Do any common version control systems reliably support use of portable storage (such as a USB flash device) as the shared repository?

答:
As an addition to the other answers:

While a DVCS fits this problem very well, you could technically also use Subversion, if you feel more comfortable with it. Subversion can use a local directory instead of a central server. You could just put that onto a thumb drive, and use it.

The disadvantage, compared to a DVCS, would be that you can only work with Subversion (i.e. commit, view logs etc.) while the thumb drive is plugged in. Also, it must always be the same thumb drive (or at least an up-to-date copy), because with Subversion you should not use more than one repository (that's the non-distributed part). So if you ever forget your thumb drive, you can't use it, unlike with Git or Mercurial.

Note:

As explained above, and in the comments, a DVCS is really a better fit for your problem. I only mentioned Subversion for completeness sake, and in case you have some special reason to use Subversion.