答:
How efficient a solution needs to be is dependent on a number of factors. The biggest thing is knowing what your user wants. Here's a few examples.

If you are the only user of a block of code, and it works just fine for you, then you are probably alright.

If your program is going to be sold, then you need to have a target platform in mind. Test it with this platform. If the program is exceptionally slow, then you need to work on making it more efficient. If it seems fine to you, hand it off to other users, and see if they agree.

Perhaps the program has other considerations. If you are building, say, a server based program, then you might need to work very hard to make the program as efficient as possible. Or, if it runs on a microprocessor, make sure it works there as well.

How to make your code more efficient:

The first step is to get an idea of what is taking the most time. The trick is to do something called profiling code. Look for what is taking the most time, and see if you can figure out a way to make it run quicker.

Perhaps the key limiting factor is memory. If that is the case, look for what is taking up large chunks of memory, and see how you might reduce it.

There is a whole field to optimization, but the two tips above should at least get you started.

Title: Is it important for a solution to be an efficient one?

Body:
I solve many problems, mostly from Top Coder. I will get answers for many, but most times I end up with an inefficient solution.

In real-world implementations - does it really matter that a solution to the problem is efficient? If so how I can improve it?


问:
Writing functional tests for a legacy project
I am trying to add a couple of tests to a legacy C project. The project basically consists of a command line tool that prints something to stdout every time an event happens. Now, since writing unit tests would be pretty hard given the fact that the modules are pretty tight coupled, I am trying to write some functional tests in order to validate the current behaviour and then I'll go on splitting the modules so I can unit test them.

Does it make sense to have the testing framework something like a few Python scripts (keep in mind that the project is pure C) that handles all the functional tests? Basically, Python should call my command line tool, fake its input and expect a valid output.

答:
Yes it does and is a wise Idea.

You can also go in the details using Cython and calling some of the legacy C functions.

OwnerDisplayName: hyperboreean

ContentLicense: CC BY-SA 3.0

OwnerDisplayName: fabrizioM


答:
Yes.

If the tests use the application as a black box, through the command line, then they don't need to be in the same language as the application. They can be in a language that is best suited for writing the tests.

Scripting languages, such as Python or Ruby, are generally a good fit for text parsing and calling command line applications, whereas with C it would be much harder. They also have good testing tools to help in writing those tests.

Title: Writing functional tests for a legacy project

Body:
I am trying to add a couple of tests to a legacy C project. The project basically consists of a command line tool that prints something to stdout every time an event happens. Now, since writing unit tests would be pretty hard given the fact that the modules are pretty tight coupled, I am trying to write some functional tests in order to validate the current behaviour and then I'll go on splitting the modules so I can unit test them.

Does it make sense to have the testing framework something like a few Python scripts (keep in mind that the project is pure C) that handles all the functional tests? Basically, Python should call my command line tool, fake its input and expect a valid output.

OwnerDisplayName: Esko Luontola


问:
How do programmers quit a job?
I'm thinking about leaving my current employer and wondering how one goes about that process in the programming world. We have a lot of projects on the go at the moment and I'm the only developer. We have 4-5 projects that are fairly big and need to be done in the next few months and even a few longer than that.

I'm leaving because I'm the only employee and that's doing me no good. I'm young and want to learn, so a team would be nice. It's also too much work and the company is managed horribly.

I have no contract to worry about so I could theoretically quit and just not come back without notice. Just wondering how this is normally handled.

Should I write a resignation letter

How much notice should I give

Should I give a reason for leaving

Should I go to my boss who is the main reason I'm leaving or go to his boss?

Overview of replies

From the feedback here, it looks as though it's best to give 2-4 weeks of notice, and present a written resignation. Don't go into detail explaining why you're leaving in most cases. Don't burn bridges. Be professional.

答:
You should just tell them, that the way things are, you are unwilling to stay.

Worst case, they take it very personally and start yelling at you. Since you intend to leave, you don't have to take it, just leave.

Maybe, they simply don't care. There's no discussion, they just let you go and you don't need to justify anything

Best outcome is, they engage in a discussion with you and show the willingness to address your problems, possibly by hiring other developers (you must be involved in that process. It's better working alone than teaming up with a bad developer).

In any way, it is neither particularly fair, nor neccessary to exclude your superiors from this decision. If they know anything about software, they understand that letting you - the only developer - go will cost them a hell of a lot more money than doubling your salary or hiring additional devs. And thus they will talk to you. If they don't understand that, don't bother trying to explain anything.

ContentLicense: CC BY-SA 2.5

Title: How do programmers quit a job?


问:
Is it important for a solution to be an efficient one?
I solve many problems, mostly from Top Coder. I will get answers for many, but most times I end up with an inefficient solution.

In real-world implementations - does it really matter that a solution to the problem is efficient? If so how I can improve it?

答:
For a competition you need to understand who the judges are and what they are about - if they are looking for great coders and nothing more, then you will get kudos for more efficient code.

As a rule, in the real world, it does not matter. One of the key ideas of software development is "Don't optimize what you don't know needs optimizing", then "Optimize only when it has been proven that it is required"

Many practitioners will argue that this leads to bloated, inefficient code that cannot be easily fixed, and in some edge cases (which they will crow about as if that's what most coders do all day every day) they are correct. However not many software development projects has it's measured outcomes "Performance: Faster than needed, Cost: Who cares, Delivery time : Sometime this decade", In the real world, it's usually "I want it cheap, I want it yesterday, I want it to work".


问:
What are the most known arbitrary precision arithmetic implementation approaches?
I'm going to write a class library for .NET which provide an implementation of arbitrary precision arithmetic for integer, rational and maybe complex numbers. What best known approaches should I become familiar with?

I tried to start with Knuth's TAOCP Vol.2 (Seminumerical Algorithms, Chapter 4 – Arithmetic) but it's too complicated. At least I couldn't get the ideas in a relatively short period of time.

答:
If you are using C# 4.0 or later, then you already have a BigInteger class. Starting from here and creating your own Rational class will save you a lot of time.

If you want to build everything yourself, then you will have to implement some complex algorithms, especially for multiplication. You could start with the naive multiplication algorithm that has time complexity O(n²). A lot of other algorithms will depend on multiplication (division, modular exponentiation, gcd, square roots, etc.). If you have have everything working and a solid set of unit tests, then you can replace the naive multiplication algorithm for something like 3-way Toom-Cook multiplication or an even more advanced algorithm.


答:
if you are sure to leave, give a resignation letter(write on it the date)  and keep a copy, it important. in some couturiers its by law to leave a two weeks upfront notice. if you don't, they could squeeze out of you another 2 week notice of work.

if you want to be nice, talk to them before you hand the letter over.

start looking for a job now, it takes time to find one.

good luck.

Title: How do programmers quit a job?

Body:
I'm thinking about leaving my current employer and wondering how one goes about that process in the programming world. We have a lot of projects on the go at the moment and I'm the only developer. We have 4-5 projects that are fairly big and need to be done in the next few months and even a few longer than that.

I'm leaving because I'm the only employee and that's doing me no good. I'm young and want to learn, so a team would be nice. It's also too much work and the company is managed horribly.

I have no contract to worry about so I could theoretically quit and just not come back without notice. Just wondering how this is normally handled.

Should I write a resignation letter

How much notice should I give

Should I give a reason for leaving

Should I go to my boss who is the main reason I'm leaving or go to his boss?

Overview of replies

From the feedback here, it looks as though it's best to give 2-4 weeks of notice, and present a written resignation. Don't go into detail explaining why you're leaving in most cases. Don't burn bridges. Be professional.


答:
The best solution is the one that is (in order of increasing importance) efficient, maintainable and done.

^^^That is the only thing you really need to take from this answer.^^^

Efficiency is important. Maybe a little less so than it used to be due to our abundance of hardware, but Performance is a Feature. In a contest, efficiency is obviously important. You should know how to write efficient code. More importantly you should know the best practices that will yield efficient, good performing code without sacrificing on the timeliness or maintainability of an application. This is really where depth of experience with a platform and language returns many yields.

More important though(in 95% of cases), is having a finished, maintainable solution. Without a finished product, it doesn't matter how efficient or maintainable the solution. If it takes you an extraordinary amount of time to track and fix a bug or add a new feature, it doesn't matter how efficient the solution. But, efficiency and performance are undoubtedly important, no matter what anybody might say.


问:
In Scrum, should tasks such as development environment set-up and capability development be managed as subtasks within actual user stories?
Sometimes in projects we need to spend time on tasks such as:

exploring alternate frameworks and tools

learning the framework and tools selected for the project

setting up the servers and project infrastructure (version control, build environments, databases, etc)

If we are using User Stories, where should all this work go?

One option is to make them all part of first user story (e.g. make the homepage for application). Another option is to do a spike for these tasks. A third option is to make task part of an Issue/Impediment (e.g. development environment not selected yet) rather than a user Story.

答: There's a name for making as many design decisions as possible up front before the "official" start of your project.  It's called waterfall.  There's nothing wrong with user stories like, "As a developer, I need to select a framework, so we have a starting point for the web site."  If that's too big to fit in an iteration, try breaking it down like, "As a developer, I need to implement a basic home page in Drupal, so we will know if it fits our needs."</p>


答:
Assuming that you've made your decision to leave, you should put it in writing. Whether this is an actual letter, an e-mail or a form you fill out will depend on the company and culture, but it should be written down and not a phone call, text message or even just face to face. If you do one of the latter things it's only polite to follow it up in writing.

The amount of notice should be in your contract - assuming you have one. Even if you didn't sign the contract you should abide by its terms. By working and getting paid you and the company are working to that contract even if it's not "official". If nothing else you'll be seen to be doing "the right thing" and it will be harder for your employer to get you to work longer. If they want you to leave straight away you still should get paid as though you were working.

You don't need to give any reasons for your decision.

You should leave all files etc. you've worked on so that they are accessible to your manager, co-workers and anyone who follows you. A short document explaining what's what would be polite. Don't delete anything. The files/data aren't yours they are your employers.

Once you've made your leaving official you should then talk to managers, co-workers etc. about how you can handle the hand over of information.

Title: How do programmers quit a job?


问:
Java IDE written in pure Java?
Is there a Java IDE written in Java?

I just got my year 9 DET laptop today at school, and there are all sorts of restrictions set in place. Somewhat annoyingly, you cannot run any executable other than the ones already installed on the system (for some reason they haven't disabled the use of Command Prompt, PowerShell, or strangely enough, regedit). They allow you to run Java executables, so I thought that would be the only way to be able to program on my crappy laptop at school (when I have finished all my work, naturally) :D

Edit:

By written in Java, I also mean that the executable, that is used to run the program, has the file extension ".jar", thus running on the JVM.

Edit 2:

I tried the DrJava IDE, and it worked great, thanks (I can compile and execute programs)! Regarding running Eclipse as through the command line using the command "java -jar "C:/Users.../org.eclipse..."". This results in an error producing a log saying file, the main error is:

MESSAGE An error occurred while automatically activating bundle org.eclipse.ui.workbench (182).

How do I fix this error (I much perfer working with Eclipse than any other IDE)?

Edit 3:

Regarding my last edit, just disregard it :D. I fixed the problem by downloading the latest version of Eclipse.

答:
One IDE I have been working with is Netbeans. It's a VERY popular IDE that's fully written in Java.

The best part, it's free, easy to use, and whatnot. I've found it to be very useful when trying to program Windows applications in Java. You can find some useful articles here.

Netbeans also has plugins, also written in Java if that's your interest, which can either put less weights on your shoulder and whatnot.  It also works for PHP and C/C++ so it's amazing.

Title: Java IDE written in pure Java?


答:
I guess Eclipse is written in Java and is also the best IDE.

Also check tIDE and BlueJ 2.

Title: Java IDE written in pure Java?

Body:
Is there a Java IDE written in Java?

I just got my year 9 DET laptop today at school, and there are all sorts of restrictions set in place. Somewhat annoyingly, you cannot run any executable other than the ones already installed on the system (for some reason they haven't disabled the use of Command Prompt, PowerShell, or strangely enough, regedit). They allow you to run Java executables, so I thought that would be the only way to be able to program on my crappy laptop at school (when I have finished all my work, naturally) :D

Edit:

By written in Java, I also mean that the executable, that is used to run the program, has the file extension ".jar", thus running on the JVM.

Edit 2:

I tried the DrJava IDE, and it worked great, thanks (I can compile and execute programs)! Regarding running Eclipse as through the command line using the command "java -jar "C:/Users.../org.eclipse..."". This results in an error producing a log saying file, the main error is:

MESSAGE An error occurred while automatically activating bundle org.eclipse.ui.workbench (182).

How do I fix this error (I much perfer working with Eclipse than any other IDE)?

Edit 3:

Regarding my last edit, just disregard it :D. I fixed the problem by downloading the latest version of Eclipse.


答:
Jetbrains has recently made much of their IntelliJ IDE, which is written in Java, as open-source. Mostly what is missing in the "Community Edition" is support for web-based and enterprise apps.

You can download a binary, or download the source and  source and  build it yourself using the JSDK and some additional libraries.

They also sell an academic version of the full version of the IDE for $99.  Here is a comparison of the free and paid versions.

Title: Java IDE written in pure Java?


问:
Sharing knowledge in activity-based working
My workplace will soon be shifting to the concept of 'activity based working', which moves from the idea of IT teams, BA teams, PM teams, etc to project-based work where people from across all facets of IT and the business involved on a project sit and work together. As a result, you wouldn't be sitting with your normal team colleagues on a day-to-day basis and sharing knowledge in that sort of organic way with the rest of your dev team won't really be happening.

What ways would you recommend to help preserve that team collaboration and knowledge sharing when people will not physically be co-existing alongside their teammates any longer? Not to mention preserving that 'geek spirit' (bad term perhaps) that sees devs encouraging and coaching each other to find better designs and solutions.

I've already thought about online collaboration tools such as Trello or Mingle, plus wikis or software such as Confluence to help collaboration and discussion. But I'd be interested to hear peoples opinions on what else could be done, or their own experiences with this approach to day-to-day work.

答: If you are going to work as a team from the Project's point of view, that's the best thing you can do and it will have a great impact of the project's success. Now your problem is how to be in touch with your home team. Dont go into tools unless they are essential (for some reason like distributed teams). Instead focus on face-to-face knowledge sharing or cascade sessions. Arrannge team building events. Pair with team members where possible</p>


问:
How do large-scale applications handle GUI creation?
I'm interested in developing GUI-based Windows applications in C++, but I'm not sure how it's done in professional or large-scale settings. It seems it would take a lot of development time to describe all the elements (e.g., dimensions and such) within code.

Presumably it's not all done visually, right? How is it normally done? What methods are used to prevent a lot of time wasted on defining each and every property a UI control might have?

答:
Qt and wxWidgets allow you to either layout elements with an editor or with code. Like most modern  guis it uses layout sizers, so instead of specifying the exact pixel coordinates of each element you just say that things are grouped into vertical sets within horizontal sets within vertical ... rather like HTML

This is necessary when you are programming for different platforms with different size controls and for mobile platforms with different sized screens and for different languages with different word lengths


问:
How should I handle negative campaigns against my application?
I developed an app a few years back: while it's outdated and useless compared to what's available today, it was helpful for people when it was first released.

I recently searched for my own name on Google, and came across a website that made the claim my app was malware that couldn't be uninstalled normally, and provided step-by-step instructions for removing it.

This is, of course, not true and I'm pretty frustrated by the implication.

How should I handle a situation like this? Should I confront the site owner, or handle it a different way?

答:
Depends how much value and money it's worth to you. Are you prepared to go to war with them, or do you just want you objection recorded.

I would contact (not confront) the site owner - I would start on the basis that the original software is not malware, and would like to help resolve difficulties people are having. I would ask for him to update the site with relevant information, and provide proof of his claim that the software is malware (Maybe you app got hijacked along the way, and a "version" does exist that is malware) I would ensure that my "fix" to the problem was linked to and/or provided from the site. I would also ask the site author to inform the readers that the software author had contacted you and was addressing issues.

After reasonable attempts at this (and if I was motivated enough, but likely not worth the effort and cost involved) I would consider contacting my lawyer and having a "cease and desist" letter sent to the site. Depending on the wording on the site, you may have numerous legal claims against it, however, if a simple letter does not work, the $$$ will mount up pretty quickly and probably not get what you want. Even one simple letter will cost $$$, and that's assuming it's operating in the same legal jurisdiction as you do - cross borders and it is hopeless.

An alternate approach would be contact the advertisers on the site, and inform them that the site was making dubious unproven claims that had legal implications. A copy of the "cease and desist" letter could be included.


问:
What's the difference between simulation and emulation
I frequently see  Simulation and Emulation in computer science. These two terms seem synonymous. Is there any difference between Simulation and Emulation?

答:
Both means something doing the job of something else.

The difference is that "Simulation" happens at a conscious level (with respect to the user) and is finalized typically to anticipate the result of a reality without touching the reality itself.

"Emulation" happens at an unconscious level, and has the purpose to replace an underlying component with another different one that -in respect to the user- works as the old one.

In other words, simulation happen in a "parallel world", while emulation happens in a "replaced world".


答:
Definitely write a resignation letter.

As far as notice go, I'd say "it depends". What's the legal minimum notice required? This varies a lot from country to country (and varies from US state to US state as well). It'd probably go for the highest of "legal minimum", "contractual minimim" and "two weeks".

I'd not volunteer a reason for leaving in the resignation letter, just say "I, Name, resign my position as blah with my last work day being date. Dated, signed, location". If the company wants to give you an exit interview, accept and explain your reasons for leaving there.

Hand your resignation letter to your boss on the same day as you sign (and date) it. Since it's all very impersonal, it shouldn't matter if you hand it to the boss or someone higher in the food-chain.

Definitely leave your corporate-related emails behind (you do have your private and your corporate mail separated, don't you?) and leave all documentation you wrote for the company time behind. Deleting that sort of things is petty and beneath you, even if it may feel good at the moment.

Title: How do programmers quit a job?


问:
Is MUMPS alive?
At my first workplace we were using Digital Standard MUMPS on a PDP 11-clone (TPA 440), then we've switched to Micronetics Standard MUMPS running on a Hewlett-Packard machine, HP-UX 9, around early 90's.

Is still MUMPS alive? Are there anyone using it? If yes, please write some words about it: are you using it in character mode, does it acts as web server? etc. (I mean Caché, too.)

If you've been used it, what was your feelings about it? Did you liked it?

答:
I am also new to g.tm, but I can answer this :

Yes, Mumps is alive. There are still people working on it.
here are some examples :

http://georgejames.com/ who wrote an Openstreetmap api server in gt.m that I am learning now.

There are also now modern enterprise web tools for g.tm
http://gradvs1.mgateway.com/main/

and the last proof that it is alive is that it has been ported to the latest GNU/linux  and cloud platforms.

mike

Title: Is MUMPS alive?


答:
It may or it may not apply in your case, but bear in mind that some websites are nothing more than spamdexing ads, which generate the same "negative campaign" articles for thousands of programs, whose names are harvested from some app listings. And all they do is just substituting the app name in the template.

A random example: http://www.how-to-uninstall-program.com/uninstaller/uninstall-FileStrongBox-1-4-0-FileStrongBox-1-4-0-removal-FileStrongBox-1-4-0-JanusSecurityCorporation-windows-uninstaller.html

This type of stuff does not look credible to me at first glance, but if the developer wasn't trying to make any money on that program anyway, my advice would be not to worry very much.

http://www.how-to-uninstall-program.com/uninstaller/uninstall-google-chrome-google-chrome-removal-google-chrome-windows-uninstaller.html - Chrome is getting slandered just the same on that website :)

Noone is likely to come across such an article lest they google up the name of your application, and if it is deprecated and useless now - as you're saying yours is - the author is probably the only person to ever google its name anymore.

In such scenario - which I believe to be quite common - the best thing to do is probably not contacting the website and neither a lawyer, but Google. What such websites are doing amounts to abusing SEO techniques and Google is capable of, and would be within their rights I believe, removing them from their search results, which solves the problem not only for the author, but also other programmers as well as gullible website visitors.

Title: How should I handle negative campaigns against my application?

Body:
I developed an app a few years back: while it's outdated and useless compared to what's available today, it was helpful for people when it was first released.

I recently searched for my own name on Google, and came across a website that made the claim my app was malware that couldn't be uninstalled normally, and provided step-by-step instructions for removing it.

This is, of course, not true and I'm pretty frustrated by the implication.

How should I handle a situation like this? Should I confront the site owner, or handle it a different way?


答:
A simulation is a model constructed of something else which reproduces some of that thing's features and leaves others out - obviously you want to preserve the features relevant to your query, and leave out the irrelevant ones.

For instance, a simulation of early-morning commuter traffic leaves out the commuter's names, and maybe even their identities (using a counter variable rather than an actual set of Commuter objects), but it cannot disregard their rate of arrival.

Emulation is the running of a software X created for platform A on platform B, without changing the software itself. This requires building a model of A that runs on B, and obviously it has to model everything about A that involves code execution. (In theory you could omit support for opcodes that you know this particular software won't ever use, but that is rare - doing an emulator is hard work, and it's much more worthwhile to do a thorough job and have something reusable than a kludge that works only for S.)

Title: What's the difference between simulation and emulation

Body: I frequently see  Simulation and Emulation in computer science. These two terms seem synonymous. Is there any difference between Simulation and Emulation?


答:
Most modern GUI frameworks use some kind of interface description language, basically a domain-specific language, to describe the GUI.

Qt has QML, Windows Presentation Foundation has XAML, Gnome uses Glade XML files, and so on.

Most of the modern web development frameworks are also declarative (Java Server Faces, ASP .NET), not only because they are based on HTLM (which is declarative), but also because they use pre-made components which are referenced by name in the page.

Many of these frameworks also have visual GUI designers, but many developers prefer to write the GUI in an editor, because it gives better control. At the same time, declarative GUI code is much less verbose than creating GUI widgets in code.

See e.g. this question for examples of declarative GUI languages:

https://stackoverflow.com/questions/2962874/what-are-the-open-source-alternatives-to-wpf-xaml

Title: How do large-scale applications handle GUI creation?

Body:
I'm interested in developing GUI-based Windows applications in C++, but I'm not sure how it's done in professional or large-scale settings. It seems it would take a lot of development time to describe all the elements (e.g., dimensions and such) within code.

Presumably it's not all done visually, right? How is it normally done? What methods are used to prevent a lot of time wasted on defining each and every property a UI control might have?


问:
Is it a good practice to use branches to maintain different editions of the same software?
We have a product that has a few different editions. The differences are minor: different strings here and there, very little additional logic in one, very little difference in logic in the other. When the software is being developed, most changes need to be added to each edition; however, there are a few that don't and a few that needs to differ. Is it a valid use of branches if I have release-editionA and release-editionB (..etc) branches? Are there any gotchas? Good practices?

Update: Thanks for the insight everyone, lots of good answers here. The general consensus seems to be that it is a bad idea to use branches for this purpose. For anyone wondering, my final solution to the problem is to externalize strings as configuration, and externalize the differing logic as plugins or scripts.

答:
I would think that's an good idea provided you can't do it within one branch without clustering the code to much.

I would prefer to be able to keep it in one branch and use localized and configuration files, especially if you say the differences are minor.

Another way could be different builds, for example your build file packs different files for different customers but I can also see the build tool checking out different branches. As you use git I would say no real gotchas. One branching strategy could be to develop on different branches for different tasks, check in to the master branch and merge from master to editionX and Y.


答:
This depends on the magnitude of the change, but I wouldn't consider it good practice for the differences you described.

Generally, you want a Git branch to be something that will be merged in the future or stored read-only for reference. Git branches that co-exist indefinitely mean work for everyone: Changes need to be propagated and merged, conflicts resolved, all the fun. If nothing else, every developer has to remember to push changes to five repositories instead of one.

If you have small changes, the whole merging and branch-keeping effort seems overkill when compared to the problem. Use your preprocessor or build system to differentiate between versions. Does a simple #ifdef do the trick? Then don't solve problems with git, it's overkill.

Title: Is it a good practice to use branches to maintain different editions of the same software?

Body:
We have a product that has a few different editions. The differences are minor: different strings here and there, very little additional logic in one, very little difference in logic in the other. When the software is being developed, most changes need to be added to each edition; however, there are a few that don't and a few that needs to differ. Is it a valid use of branches if I have release-editionA and release-editionB (..etc) branches? Are there any gotchas? Good practices?

Update: Thanks for the insight everyone, lots of good answers here. The general consensus seems to be that it is a bad idea to use branches for this purpose. For anyone wondering, my final solution to the problem is to externalize strings as configuration, and externalize the differing logic as plugins or scripts.


答: I would use branches only for significant changes, otherwise you end up adding every little change to numerous branches, which is not fun at all to do and is very error prone, especially if you're working with more people.</p>


答:
That's not really what branches are for. Branches are supposed to be short to mid-term side paths to your line of development, not long-term parallel versions of the same code.

I'd put all the different versions into the same branch, with a subdirectories for the parts that are different between editions, and set up your build process (you have an automated build, right?) so that it can output either edition on demand (or all of them at once).

After all, you want to keep a "single source of truth"; with branches, you'll be duplicating some code, but not all, and certain merges would in fact break your setup.


答:
Technically, they both do the same: do something in an environment that acts as if it were the real thing.

Conceptually, however, there is an important difference.

A simulation is supposed to be detached from the real world to a certain degree; the output of a simulation is not directly connected to the thing it simulates. For example, an aircraft simulator does not actually fly, and the pilot is not actually communicating with a real air traffic controller.

A simulation usually has the goal of testing or predicting some real-life process in a safe environment; because the simulation is disconnected from the real world, nothing really bad can happen (a crashed aircraft simulator never kills real people).

An emulation, by contrast, has the goal of taking the place of the real thing: for example, if you emulate a simple microcontroller using a more sophisticated programmable CPU, that CPU can be used in place of the original microcontroller; it will be physically connected to some machine, and it will actually control that machine just like the microcontroller would.

The goal of an emulation is to replace hardware or software components with functional equivalents when the original modules aren't available (or have become too expensive, if only to maintain). Emulation can also serve the goal of using hardware more flexibly - the same programmable microcontroller can double for several simpler controllers, switching emulation mode as needed.


答:
If you are releasing them all as different products then having multiple branches is recommended. If not, then it's still recommended to use something like a trunk or a master branch.

Also, I think this would depend on the development process you have, particularly deployment. If you have a process that only permits one branch to be rolled out to production and branches are being treated as "incremental builds" meaning release B can't be rolled out to production unless release A was rolled out first, given that all changes of A are already in B, then having multiple branches is the way to go. This will work if you have teams scattered all over the globe and you usually have changes ordered by priority.


答:
One solution - as people have pointed out - is to configure the build system to support different editions.

I would also consider implementing it as feature toggles and use a configuration file. The less you have to build, the better.

Have a look at this site.


答: The solution with the three different branches (for production, development and features) works really well. Lets say you discover some bug in your production code then you can apply a patch to that then release it. Just make sure you don't do any feature additions to the production branch or any major changes to the production branch. You and your team will have to self-discipline to not add any major feature changes to your production branch. The production branch should just be for minor bug fixes that don't warranty a major change in your production code base.</p>


问:
The term "interface" in C++
Java makes a clear distinction between class and interface. (I believe C# does also, but I have no experience with it). When writing C++ however there is no language enforced distinction between class and interface.

Consequently I've always viewed interface as a workaround for the lack of multiple inheritance in Java. Making such a distinction feels arbitrary and meaningless in C++.

I've always tended to go with the "write things in the most obvious way" approach, so if in C++ I've got what might be called an interface in Java, e.g.:

```<code>class Foo {
public:
  virtual void doStuff() = 0;
  ~Foo() = 0;
};
</code>```

and I then decided that most implementers of Foo wanted to share some common functionality I would probably write:

```<code>class Foo {
public:
  virtual void doStuff() = 0;
  ~Foo() {}
protected:
  // If it needs this to do its thing:
  int internalHelperThing(int);
  // Or if it doesn't need the this pointer:
  static int someOtherHelper(int);
};
</code>```

Which then makes this not an interface in the Java sense anymore.

Instead C++ has two important concepts, related to the same underlying inheritance problem:

virtual inhertiance

Classes with no member variables can occupy no extra space when used as a base

"Base class subobjects may have zero size"

Reference

Of those I try to avoid #1 wherever possible - it's rare to encounter a scenario where that genuinely is the "cleanest" design. #2 is however a subtle, but important difference between my understanding of the term "interface" and the C++ language features. As a result of this I currently (almost) never refer to things as "interfaces" in C++ and talk in terms of base classes and their sizes. I would say that in the context of C++ "interface" is a misnomer.

It has come to my attention though that not many people make such a distinction.

Do I stand to lose anything by allowing (e.g. protected) non-virtual functions to exist within an "interface" in C++? (My feeling is the exactly the opposite - a more natural location for shared code)

Is the term "interface" meaningful in C++ - does it imply only pure virtual or would it be fair to call C++ classes with no member variables an interface still?

答:
In C++, the term "interface" has not just one widely accepted definition - so whenever you are going to use it, you should say what you mean exactly - a virtual base class with or without default implementations, a header file, the public members of an arbitrary class and so on.

Concerning your example: in Java (and similar in C#), your code probably would imply a separation of concerns:

interface IFoo {/*  ... */} // here is your interface

class FooBase implements IFoo
{
     // make default implementations for interface methods
}

class Foo extends FooBase
{
}
```

In C++, you can do this but you are not forced to. And if you like to call a class an interface if it has no member variables, but contains default implementations for some methods, just do so, but make sure everyone you are talking to knows what you mean.

Title: The term "interface" in C++

Body:
In C++, the term "interface" has not just one widely accepted definition - so whenever you are going to use it, you should say what you mean exactly - a virtual base class with or without default implementations, a header file, the public members of an arbitrary class and so on.

Concerning your example: in Java (and similar in C#), your code probably would imply a separation of concerns:

interface IFoo {/*  ... */} // here is your interface

class FooBase implements IFoo
{
     // make default implementations for interface methods
}

class Foo extends FooBase
{
}

In C++, you can do this but you are not forced to. And if you like to call a class an interface if it has no member variables, but contains default implementations for some methods, just do so, but make sure everyone you are talking to knows what you mean.


答:
I'd agree with Mike Cellini, the one thing I'd add is.

Is something "efficient enough"? For example from a user point of view, there is not much difference between a function that completes in 0.00001 seconds or one that completes in 0.1 seconds even though one is much more efficient than the other. A function that completes in 10 minutes is not that much different (for the user) to one that completes in 12 minutes. In both cases the user would get a cup of coffee or get on with another task.

I've come to see efficiency as "an efficient user" not an efficient algorithm.


问:
Team Parallel development in ASP.NET
I am developing an application written in ASP.NET (C#) which heavily use on Master Page and Session.

As there will be enhancement in the same web application, and will be done by my teammate.

is there any good approach that can enable we to work on the same solution, and delivery the change to UAT / PDN separately?

the change control team of my company don't allow us to create 2 set of code in UAT and merge it into one set in PDN.

any idea is welcome.

Thanks.

答:
This sounds like a job for continuous integration. If you have only one team mate this is not necessary (I assume this is a typo). If you have just one team mate you should merge every time you pull his changes. This won't take too long unless you are scratching in the same code the whole time, which is a bad idea to begin with.

With multiple team members you can use a continuous integration solution like
TeamCity http://www.jetbrains.com/teamcity/
OR
CruiseControl .Net: http://sourceforge.net/projects/ccnet/

Let the CI server constantly pull and build changes in the repos and do some testing there to ensure that changes are working nicely. This still requires you to merge as often as you pull changes, which is the better way.

The longer you keep two development branches seperate the more painful the merge will be. So you should focus on constant building, merging and testing as your workflow. The CI server could have IIS and you can test the final product there before it goes to production.

Of course if you have a code base that is easily broken by changes your life will be difficult whatever you do. In that case you should focus on refactoring.

Your users should never test individual branches, they should test the merged end result of the branches that will go into production.

OwnerDisplayName: AlphaAu

Title: Team Parallel development in ASP.NET


答: The IDE DrJava developed at Rice University is entirely written in Java and is obtained as a jar file. It has many nice features for beginning programmers, including an Python-like interactive shell.  Get it here.</p>

Title: Java IDE written in pure Java?


答:
It sounds a little like you may have fallen into the trap of confusing the meaning of what it is that an interface is conceptually as both an implementation (the interface - lowercase 'i'), and an abstraction (An Interface - uppercase 'I').

With regards to your examples, your first bit of code is merely a class.  While your class has an interface in the sense that it provides methods to enable accesses to it's behavior, it isn't an Interface in the sense of an Interface declaration that provides a layer of abstraction representing a type of behavior that you may want classes to implement. Doc Brown's answer to your post shows you exactly what I am talking about here.

Interfaces are often touted as the "work-around" for languages that don't support multiple inheritance, but I feel that is more of a misconception than a hard truth (and I suspect I may get flamed for stating that!). Interfaces really have nothing to do with multiple inheritance in that they do not require either being inherited, or being an ancestor in order to provide functional compatibility between classes, or implementation abstraction for classes. In fact, they can allow you to effectively do away with inheritance entirely should you wish to implement your code in that way - not that I'd entirely recommend it, but I'm just saying you could do it. So the reality is that regardless of matters of inheritance, Interfaces provide a means by which class-types may be defined, establishing the rules which determine how objects may communicate with each other, thus they allow you to determine the behavior your classes should support without dictating the specific method used to implement that behavior.

Do I stand to lose anything by allowing (e.g. protected) non-virtual
  functions to exist within an "interface" in C++? (My feeling is the
  exactly the opposite - a more natural location for shared code)

A pure Interface is meant to be entirely abstract, because it allows the definition a contract of compatibility between classes which may not necessarily have inherited their behavior from a common ancestor. When implemented, you want to make a choice about whether to allow the implementation behavior to be extended in a subclass.  If your methods are not virtual, you lose the ability to extend that behavior later should you decide you need create descendant classes. Regardless of whether the implementation is virtual or not, the Interface defines behavioral compatibility in and of itself, while the class provides the implementation of that behavior for the instances that the class represents.

Is the term "interface" meaningful in C++ - does it imply only pure
  virtual or would it be fair to call C++ classes with no member
  variables an interface still?

Forgive me, but it's been a long time since I really wrote a serious application in C++.  I do recall that Interface is a keyword for the purposes of abstraction as I have described them here. I would not call C++ classes of any sort an Interface, I would instead say the class have an interface within the meanings that I have outlined above.  In that sense the term IS meaningful, but that really depends on the context.

Title: The term "interface" in C++

Body:
Java makes a clear distinction between class and interface. (I believe C# does also, but I have no experience with it). When writing C++ however there is no language enforced distinction between class and interface.

Consequently I've always viewed interface as a workaround for the lack of multiple inheritance in Java. Making such a distinction feels arbitrary and meaningless in C++.

I've always tended to go with the "write things in the most obvious way" approach, so if in C++ I've got what might be called an interface in Java, e.g.:

```<code>class Foo {
public:
  virtual void doStuff() = 0;
  ~Foo() = 0;
};
</code>```

and I then decided that most implementers of Foo wanted to share some common functionality I would probably write:

```<code>class Foo {
public:
  virtual void doStuff() = 0;
  ~Foo() {}
protected:
  // If it needs this to do its thing:
  int internalHelperThing(int);
  // Or if it doesn't need the this pointer:
  static int someOtherHelper(int);
};
</code>```

Which then makes this not an interface in the Java sense anymore.

Instead C++ has two important concepts, related to the same underlying inheritance problem:

virtual inhertiance

Classes with no member variables can occupy no extra space when used as a base

"Base class subobjects may have zero size"

Reference

Of those I try to avoid #1 wherever possible - it's rare to encounter a scenario where that genuinely is the "cleanest" design. #2 is however a subtle, but important difference between my understanding of the term "interface" and the C++ language features. As a result of this I currently (almost) never refer to things as "interfaces" in C++ and talk in terms of base classes and their sizes. I would say that in the context of C++ "interface" is a misnomer.

It has come to my attention though that not many people make such a distinction.

Do I stand to lose anything by allowing (e.g. protected) non-virtual functions to exist within an "interface" in C++? (My feeling is the exactly the opposite - a more natural location for shared code)

Is the term "interface" meaningful in C++ - does it imply only pure virtual or would it be fair to call C++ classes with no member variables an interface still?


问:
What are the practical uses of Windows Services?
I am new to working with Windows Services. Although I have learnt to create  Windows Services in VS2010  I would like to know some practical ways in which windows services could be used?

I tried Googling with the current context in mind only to find more tutorials on how to create Windows Services.

EDIT on Bounty Offer:

All the answers are great but I was looking for more practical examples on windows services and their implications? This will help developers know when it is appropriate to use them with the case study.

答:
Some time ago my team implemented 3 windows services on a bank here in Brazil, as below:

Interface between systems: We had a front-office application responsible of booking trades on the stock market, and a back-office application, responsible for accounting and calculating the trades fees. Initially, the intersystem communication was made directly on SQL Server, but too many locking and retention problemas made the system suffer from poor performance. A service was implemented to connect to both front and back databases and do the proper reading/writing using some kind of retention strategy (instead of writing every single trade on the SQL Server, we hold the data to some extend, say 1000 trades, and did a bulk insert, which was 40x faster than the original solution, and did not lock many of the involved tables for a long time).

Message Queue: Along with the previous solution, we wrote a custom message queue handler, so several batch processing procedures could run asynchronously. That was integrated with both MSMQ and IBM-MQSeries.

Centralization of business services: Several user applications needed common data as stock prices, for example, so we wrote a custom service responsible for receiving "price requests" and sending back the price information.

One of the aspects that led us to write services, instead of "robots", is that services can run as a specific user (as someone already pointed out on this thread), and can be initiated automatically when the machine boots up.

Services also do not need a desktop or a window management service to run. They can run on the background (well, they must run on the background).

And, if you are like some peers of mine that do not like to write user interfaces, services are great technological challenges, because usually they must not fail. So it's very fun to write a service. :)


答:
Yes, the concepts are different.

Simulation

A simulation is a system that behaves similar to something else, but is implemented in an entirely different way. It provides the basic behaviour of a system, but may not necessarily adhere to all of the rules of the system being simulated.  It is there to give you an idea about how something works.

Example

Think of a flight simulator as an example. It looks and feels like you are flying an airplane, but you are completely disconnected from the reality of flying the plane, and you can bend or break those rules as you see fit. For example, fly an Airbus A380 upside down between London and Sydney without breaking it.

Emulation

An emulation is a system that behaves exactly like something else, and adheres to all of the rules of the system being emulated. It is effectively a complete replication of another system, right down to being binary compatible with the emulated system's inputs and outputs, but operating in a different environment to the environment of the original emulated system. The rules are fixed, and cannot be changed, or the system fails.

Example

The M.A.M.E. system is built around this very premise.  All those old arcade systems that have been long forgotten, that were implemented almost entirely in hardware, or in the firmware of their hardware systems can be emulated right down to the original bugs and crashes that would occur when you reached the highest possible score.


答:
on exploring 2-3 alternate framework/tool

Sometimes this can happen if you have special requirement you have to do some POC to choose the best tool to solve the requirement. This is what spike is for because without knowing which framework you will use you most probably cannot estimate the story and store without estimate cannot be planned and divided into tasks.

then on learning the framework we select for the project

Well. This is quite dangerous. When customer pays you for a SW he expects that you are professional who already know how to use his tools. Customer doesn't pay you for learning or trial / fail development approach. It is developer responsibility to learn new tools in his free time or in special allocated time paid by his employee not by customer. Spending customer money for learning without informing customer is unprofessional.

If you really have to use something special (for example some customer's API or tool customer selected) which you never used before you must inform customer that price will be increased by time needed to learn how to use the API. Maybe customer will change his mind if the price increase will be too big.

Sure, I don't mean situation where you must look for some particular new problem in framework you have used many times. I mean the situation where you start using new API or framework without spending some significant time (outside of the project) for learning.

If you violate this it will be visible in your velocity anyway because you will deliver very small amount of business value per iteration. If customer is not aware of the reason he will most probably cancel the project.

This is still valid in case of internal projects - you must inform your manager / business about time needed for learning new API or tool. It has usually very bad consequences if manager counts with your normal productivity and your productivity is only fraction because of new API you are trying to learn during your tasks. That is obviously even worse if some sale people calculated with normal productivity when signed contract with the customer.

on setting up the servers (SVN, Databases, etc)

That are your infrastructure and internal costs. When you start the project it is expected that you have your infrastructure prepared. Setting up your development environment has no value for customer and should not be part of any project related indicators - for example velocity in Scrum. I saw this implemented as special pre-project iteration used just to setup environment, create basic infrastructure etc.

Title: In Scrum, should tasks such as development environment set-up and capability development be managed as subtasks within actual user stories?

Body:
Sometimes in projects we need to spend time on tasks such as:

exploring alternate frameworks and tools

learning the framework and tools selected for the project

setting up the servers and project infrastructure (version control, build environments, databases, etc)

If we are using User Stories, where should all this work go?

One option is to make them all part of first user story (e.g. make the homepage for application). Another option is to do a spike for these tasks. A third option is to make task part of an Issue/Impediment (e.g. development environment not selected yet) rather than a user Story.


问:
Open Source but not Free Software (or vice versa)
The definition of "Free Software" from the Free Software Foundation:

“Free software” is a matter of
  liberty, not price. To understand the
  concept, you should think of “free” as
  in “free speech,” not as in “free
  beer.”

Free software is a matter of the
  users' freedom to run, copy,
  distribute, study, change and improve
  the software. More precisely, it means
  that the program's users have the four
  essential freedoms:

The freedom to run the program, for
  any purpose (freedom 0).

The freedom
  to study how the program works, and
  change it to make it do what you wish
  (freedom 1). Access to the source
  code is a precondition for this.

The
  freedom to redistribute copies so you
  can help your neighbor (freedom 2).

The freedom to distribute copies of
  your modified versions to others
  (freedom 3). By doing this you can
  give the whole community a chance to
  benefit from your changes. Access to
  the source code is a precondition for
  this.

A program is free software if users
  have all of these freedoms. Thus, you
  should be free to redistribute copies,
  either with or without modifications,
  either gratis or charging a fee for
  distribution, to anyone anywhere.
  Being free to do these things means
  (among other things) that you do not
  have to ask or pay for permission to
  do so.

The definition of "Open Source Software" from the Open Source Initiative:

Open source doesn't just mean access
  to the source code. The distribution
  terms of open-source software must
  comply with the following criteria:

Free Redistribution The license shall not restrict any party from
  selling or giving away the software as
  a component of an aggregate software
  distribution containing programs from
  several different sources. The license
  shall not require a royalty or other
  fee for such sale.

Source Code The program must include source code, and must allow
  distribution in source code as well as
  compiled form. Where some form of a
  product is not distributed with source
  code, there must be a well-publicized
  means of obtaining the source code for
  no more than a reasonable reproduction
  cost preferably, downloading via the
  Internet without charge. The source
  code must be the preferred form in
  which a programmer would modify the
  program. Deliberately obfuscated
  source code is not allowed.
  Intermediate forms such as the output
  of a preprocessor or translator are
  not allowed.

Derived Works The license must allow modifications and derived works,
  and must allow them to be distributed
  under the same terms as the license of
  the original software.

Integrity of The Author's Source Code The license may restrict
  source-code from being distributed in
  modified form only if the license
  allows the distribution of "patch
  files" with the source code for the
  purpose of modifying the program at
  build time. The license must
  explicitly permit distribution of
  software built from modified source
  code. The license may require derived
  works to carry a different name or
  version number from the original
  software.

No Discrimination Against Persons or Groups The license must not
  discriminate against any person or
  group of persons.

No Discrimination Against Fields of Endeavor The license must not restrict
  anyone from making use of the program
  in a specific field of endeavor. For
  example, it may not restrict the
  program from being used in a business,
  or from being used for genetic
  research.

Distribution of License The rights attached to the program must apply to
  all to whom the program is
  redistributed without the need for
  execution of an additional license by
  those parties.

License Must Not Be Specific to a Product The rights attached to the
  program must not depend on the
  program's being part of a particular
  software distribution. If the program
  is extracted from that distribution
  and used or distributed within the
  terms of the program's license, all
  parties to whom the program is
  redistributed should have the same
  rights as those that are granted in
  conjunction with the original software
  distribution.

License Must Not Restrict Other Software The license must not place
  restrictions on other software that is
  distributed along with the licensed
  software. For example, the license
  must not insist that all other
  programs distributed on the same
  medium must be open-source software.

License Must Be Technology-Neutral No provision of the license may be
  predicated on any individual
  technology or style of interface.

These definitions, although they derive from very different ideologies, are broadly compatible, and most Free Software is also Open Source Software and vice versa. I believe, however, that it is possible for this not to be the case: It is possible for software to be Open Source without being Free, or to be Free without being Open Source.

Questions

Is my belief correct? Is it possible for software to fall into one camp and not the other?

Does any such software actually exist? Please give examples.

Clarification

I've already accepted an answer now, but I seem to have confused a lot of people, so perhaps a clarification is in order. I was not asking about the difference between copyleft (or "viral", though I don't like that term) and non-copyleft ("permissive") licenses. Nor was I asking about your personal idiosyncratic definitions of "Free" and "Open". I was asking about "Free Software as defined by the FSF" and "Open Source Software as defined by the OSI". Are the two always the same? Is it possible to be one without being the other?

And the answer, it seems, is that it's impossible to be Free without being Open, but possible to be Open without being Free. Thank you everyone who actually answered the question.

答:
I'm late on this one, but the conclusion by the questioner:

And the answer, it seems, is that it's impossible to be Free without being Open, but possible to be Open without being Free. Thank you everyone who actually answered the question.

is not true. There is the CeCILL License v2, which is Free (FSF-approved) but not Open. Seems it was rejected by the OSI in 2005, so CeCILL is not Open Source.

Just thought I would point this out, since no one here had mentioned CeCILL.


答:
Do I stand to lose anything by allowing (e.g. protected) non-virtual
  functions to exist within an "interface" in C++? (My feeling is the
  exactly the opposite - a more natural location for shared code)

You'd think that, but putting a protected, non-virtual method in an otherwise abstract class dictates implementation to anyone who writes a subclass.  Doing so defeats the purpose of an interface in its pure sense, which is to provide a veneer that hides what's underneath.

This is one of those instances where there isn't a one-size-fits-all answer and you have to use your experience and judgment to make a decision.  If you can say with 100% confidence that every possible subclass of your otherwise-fully-virtual class Foo will always need an implementation of the protected method bar(), then Foo is the right place for it.  Once you have a subclass Baz that doesn't need bar(), you either have to live with the fact that Baz will have access to code it shouldn't or go through the exercise of rearranging your class hierarchy.  The former isn't good practice and the latter can take more time than the few minutes it would have taken to arrange things properly in the first place.

Is the term "interface" meaningful in C++ - does it imply only pure
  virtual or would it be fair to call C++ classes with no member
  variables an interface still?

Section 10.4 of the C++ standard makes a passing mention of the use of abstract classes to implement interfaces but doesn't define them formally.  The term is meaningful in a general computer science context, and anyone competent should understand that "Foo is an interface for (whatever)" implies some form of abstraction.  Those with exposure to languages with defined interface constructs might think pure virtual, but anyone needing to actually work with Foo will look at its definition before proceeding.

Title: The term "interface" in C++


问:
Program more professionally (planning, notation, ...)
I program a data-analysis framework for my company (20000LOCs by now). There are 2 programmers who help writing individual module for interfaces I have predefined. So far I haven't used much planning or tools. I basically think of new classes in my head and write them down in Python+Eclipse. As Python is good for proto-typing I can easily modify it if I overlook one aspect. However, sometimes I need to refactor some structure and I wonder if that hadn't happened if I used planning tools.

What do you think is the most important start to plan programming more professionally? The project won't become too big as it's only for data analysis, but managing which data is processed which way is also tedious. Can you suggest methods, reading or tools?

My class hierarchy is pretty flat so I don't see much use in class diagrams. However, something like call diagrams and diagrams which show how objects reference each other might help. I've learned OOP by myself, but I'm confident that once I consider all requirements I can design a nice class structure.
What about TDD? For the moment I cannot imagine how to use it since most calculation are on network-like data with objects and many object references (links). Moreover data content hasn't been a problem yet.

Yet, I suspect that some more professional approach might be more efficient. Ideas?

答:
Is how you have been doing things working? Have you been successful meeting all of your deadlines and satisfying all of your customers? Is this the way you have always worked and are you planning on working with other software developers with slightly different expectations of you?

I could give you lots of recommendations about how I personally would be doing things, but the question really is what you and your team feels really works for you. If you are asking these questions merely out of interest, then perhaps you aren't yet ready to change the way you do things.  If on the other hand you have been feeling that you're tasks and workload have been getting the better of you, and you feel that they way you work isn't working, then perhaps you need to review your methodology and deal with these problems at a much higher level first.

Planning tools aren't going to help you to decide what needs refactoring. Those tools are merely there to help you to organize your work and parcel it out according to your preferred development methodology.

On the subject of TDD however, if you can't see how you might use it, then you either do not test your software enough or at all, or you have the most rigid testing regimen in place that it belies your need to unit test. TDD in itself is a very different way to write software in that you decide how you want your system to work, and before you implement it, you define how you will test it, then you write your code to pass the tests. It provides a means to streamline what you do, and shifts the focus from testing that your code works before you deliver it, to delivering working code confident that it already works.

If you feel a need to provide diagrams to show how your systems work, ask yourself where the value will be in producing and maintaining all of that additional documentation.  Sure, it can be useful to document how a particularly difficult to define system works at a high level, but the more detailed your documentation gets, the harder it will be to maintain.

From the content of your post, it sounds to me as if you haven't really learned HOW to write software.  If this is the case (you may be new or self-taught), then I would recommend at a minimum the following reading:

Head First Software Development - A good primer

Clean Code

Refactoring

Agile Software Development

I'd also recommend looking into Behaviour-Driven Development as an alternative to TDD. Learn how to write software without adding piles of additional and wasteful red tape that you may not need.

What makes a software developer professional is how you manage your relationship with your customers, how you approach problems, and how innovatively you solve them. Also, it's how you work toward minimizing the clutter in your code, how thoroughly you test and how quickly you adapt to change, how you manage your workflow, and how you keep up with commonly accepted industry best practices. Well, there's obviously more to it than that, but it's a place to start.


答:
In general, the most important solution to a problem is going to be the one that actually exists and is valid for the cases as they exist for your problem. In other-words, avoid premature optimization until such time that you actually know you have inefficient code, or efficient code that needs to be faster.

Also, don't forget that the best solution for your application may not be the general case solution. Case and point, a couple years back a professor gave our class a problem in which we were to print the first 10 numbers of a given type (sorry, my memory fails me as to the type, but it was one of the more unusual number classes) and we were given a test to check to ensure that the number was the given type. This was the extent of problem we were given and we were told it was due the next day with the most efficient solution receiving full credit. The following lecture the professor summarized the results:

Some students used a simple loop and the formula provided to check to ensure the numbers were correct and displayed them, slow but got the job done, O(n^3).

Other students did their research and found a formula that did a better job of checking to ensure that a given number was valid, these programs ran much faster, O(n^2).

One student used the slow formula to generate the values and then copied them into a constant array in their code and display the contents of that, O(n).

The final solution was judged the most efficient by the professor. Turns out that the problem was actually an exercise in fully understanding the problem and not just going out and finding the most efficient solution.

The point of the above is that when it comes to finding an efficient solution a problem it is generally better to spend the time to make sure you really understand what the problem is before going off and writing code, or attempting to optimize code. If you can store a set of reference values in a constant array then you are better off doing that from a performance standpoint than trying to write some fancy algorithm.

Likewise, don't forget that for most applications, the only people that tend to see inefficient code (when it is not needlessly inefficient!) are the developers themselves. If you write clean code that only does exactly what it needs to do then odds are that the majority of the time the users aren't going to notice performance issues when working with your program and when they do just optimize the parts that they mention to you.


答:
This sounds more like a job for different build configurations. thiton’s answer goes into this direction but I would take it much farther than #ifdef:

Use different build targets to build different editions of the software. Targets may differ by

the configuration they include,

the object or source files they include, or

the preprocessing of the source code.

This preprocessing may obviously include the classical C preprocessor but it could also entail using a custom preprocessor, a template engine to build custom views, …

This way, you avoid having to actively push every single change out to multiple branches, which violates DRY (of course that too can be automated but I don’t see the advantage).


问:
What licence for a FOSS that would sell packages on Mac and Windows but give them away on Linux?
The code should remains as open as possible, but I'm planning to sell it on Windows and Mac, and make free rmp/deb.

Does the licence even matter? It feels like I'm just selling the service of compiling and distributing the software here.

答:
Since the program is Open Source, anyone can take your Linux code and port it to Windows and Mac OSX. Therefore you're really only selling the compiling, distributing, support (etc...) services, and those aren't covered by a copyright license anyway.

E.g. the GPL makes it explicit that such additional services are entirely outside the scope of the license, and anyone may charge money for that (not just you).


问:
Non-viral open source license but with clause for source disclosure?
I'm looking for a license (for a C library) which basically says:

"Redistributions in binary form must be accompanied by the source code of Larger Work (My code + Your code)"

i.e., L = M + Y, with '+' here meaning, for example, static linking / dynamic linking.

And there must be no more restrictions other than this. If I choose my license 'X' as:

GPL - source code of Larger Work, both M and Y, must also be licensed as whole under GPL.

LGPL - My code continues to be LGPL, Your code can be kept closed-source if needed.

BSD - source code of neither M nor Y need be disclosed.

To be more clear, the binary must be under the license 'X' but source code of Larger Work must be made available -- under whatever license the Author of Larger Work wants, it need not be restricted to 'X'. LGPL comes close, but it does not mandate the source availability of Your code.

Example use case: Author of Larger Work must give the his recipient all of his source code (both M and Y) but can ask the recipient to sign an NDA restricting modification of Y, but the recipient is allowed to study Y.

In short,  'X' shouldn't have hereditary characteristics (like *GPL) yet source code availability should be mandated.

Is there such a "non-viral" FOSS license ?

Thanks in advance !

PS: I asked this question first on StackOverflow, someone there suggested that I post it in this site. That question was closed as off-topic there, and I've deleted it from SO.

答:
Eh, that wouldn't work. The reason that the GPL works is precisely because it is transitive (viral).

To show how your scheme is defeated: I set up a shell company X. I release my project to X as per your requirements: "source code of Larger Work must be made available -- under whatever license the Author of Larger Work wants". So, I don't put any obligations on X. In turn, X releases your sourcecode under BSD terms. I haven't violated your license terms, X hasn't violated my license terms, and X has no contractual obligations to you.


答:
While the etymology isn't strictly accurate, think about the difference between sympathy, "I can imagine what that must feel like" and empathy, "I know what that feels like." A simulation might include visual representation of a problem, but it might not. For example it might just print out columns of numbers representing how many people are lined up for something or total revenue or average speed. It has some characteristics that match reality, and some that don't.

Emulation, which is often used in the context of one platform pretending to be another platform, is far more complete. So Windows Phone developers can run or debug their phone apps on a Windows machine in an emulator, which looks like a phone and behaves like one too. You can run your old Commodore 64 games in an emulator, too.

The words aren't precise. Most flight simulators are more like emulators in my opinion, but the name has stuck from a time when they were not so immersive. Some people reserve the word emulator for the cross-platform case and reject it for anything else. You'll probably never be thought wrong if you do the same when speaking, but understand that some people may place the boundary between the two words a little differently, and make allowances when someone says "this is an emulation" for a really accurate and complete simulation.


答:
You're calling your requirements "non-viral", but in fact they are viral. Let's call it YVL (Your Viral License).

"Redistributions in binary form must be accompanied by the source code
  of Larger Work (My code + Your code)"

This is pretty much equivalent of GPLv2. Both GPL an YVL are viral, as L2 = L + Y2 <=> L2 = M + Y + Y2. Thus any code which uses any code that ever linked to yours, has to conform to YVL. Exactly analogous to GPL.

GPL - source code of Larger Work, both M and Y, must also be licensed
  as whole under GPL.

This is not true. Regardless if you use GPL or YVL, the "Larger Work" must be licensed as such. However, the code that you're not author of may be licensed under any compatible license (see: licenses compatible with GPL).

Title: Non-viral open source license but with clause for source disclosure?

Body:
I'm looking for a license (for a C library) which basically says:

"Redistributions in binary form must be accompanied by the source code of Larger Work (My code + Your code)"

i.e., L = M + Y, with '+' here meaning, for example, static linking / dynamic linking.

And there must be no more restrictions other than this. If I choose my license 'X' as:

GPL - source code of Larger Work, both M and Y, must also be licensed as whole under GPL.

LGPL - My code continues to be LGPL, Your code can be kept closed-source if needed.

BSD - source code of neither M nor Y need be disclosed.

To be more clear, the binary must be under the license 'X' but source code of Larger Work must be made available -- under whatever license the Author of Larger Work wants, it need not be restricted to 'X'. LGPL comes close, but it does not mandate the source availability of Your code.

Example use case: Author of Larger Work must give the his recipient all of his source code (both M and Y) but can ask the recipient to sign an NDA restricting modification of Y, but the recipient is allowed to study Y.

In short,  'X' shouldn't have hereditary characteristics (like *GPL) yet source code availability should be mandated.

Is there such a "non-viral" FOSS license ?

Thanks in advance !

PS: I asked this question first on StackOverflow, someone there suggested that I post it in this site. That question was closed as off-topic there, and I've deleted it from SO.


问:
How do programmers quit a job?
I'm thinking about leaving my current employer and wondering how one goes about that process in the programming world. We have a lot of projects on the go at the moment and I'm the only developer. We have 4-5 projects that are fairly big and need to be done in the next few months and even a few longer than that.

I'm leaving because I'm the only employee and that's doing me no good. I'm young and want to learn, so a team would be nice. It's also too much work and the company is managed horribly.

I have no contract to worry about so I could theoretically quit and just not come back without notice. Just wondering how this is normally handled.

Should I write a resignation letter

How much notice should I give

Should I give a reason for leaving

Should I go to my boss who is the main reason I'm leaving or go to his boss?

Overview of replies

From the feedback here, it looks as though it's best to give 2-4 weeks of notice, and present a written resignation. Don't go into detail explaining why you're leaving in most cases. Don't burn bridges. Be professional.

答:
I think a great thing to do is to hand in a resignation letter and then explain the situation.

Most important thing: be gentle and make the company understand why you're leaving, so that they can improve. Tell them it's not really their fault - it's you seeking new experiences.

Looking forward to hear about your progress!

Title: How do programmers quit a job?


问:
Minimum Software for Learning C#, ASP.NET, Winforms
What is the minimum software list that one should be looking at for learning C#, ASP.NET, WinForms.

I do have a system which has Windows 2003 installed in it.

I am looking at something like WAMP for C#.NET development. Do we have a listing? Something along the following lines

Visual Studio 2010 Express Edition

IIS

My SQL (anything specific to C#.NET or should it definitely be SQL Server 2005/2008 Express Edition)

LINQPad

Anything else?

答:
This is to answer your "anything else" part of your question:

A word of caution if you are beginning to learn this stuff: The Windows platform while live and well is becoming less glamorous in Windows 8. If you want to develop Windows application you should consider the new technology (Metro) that is supported in VS2011 (in Beta now) VS2011 Express First Looks. There are 2 other technologies that come with VS2010, namely: Silverlight and WPF for desktop (could be chosen over Windows Forms). Silverlight may be choosen over WPF for some applications. I suggest you don't invest too much time learning Windows Forms details unless you have to. Also, I suggest you focus on either Desktop or Web.


问:
Can I advance my career in the USA if I lack local networking?
I'm a web developer with 10 years of experience in the Microsoft stack. I was brought to the US by my company, but my contract has ended.

I want to continue pursuing a career in the US, but it seems there's a focus on networking while still in college. Due to my foreign education, my networking occurred elsewhere. However, because of this network effect, it seems most developers in the US only have to apply to one or two jobs throughout their career.

Am I handicapped by not having a professional network in the US?

答:
However, because of this network effect, it seems most developers in
  the US only have to apply to one or two jobs throughout their career.

This is false.

Am I handicapped by not having a professional network in the US?

Yes, Anyone who does not network is handicapped, your problem is not unique to you.  The solution is to network.


答:
I'm an American who didn't network in college.  I've gotten much better at networking since then.  I joined some local meetup groups, I've talked with recruiters, I've joined local tech groups on linkedIn, etc.  It's made a world of difference for me.

Growing up in a small city (20,000+ people), I found it much more difficult to network, so I moved to a large city (1 million+ people), and I find it much easier to network, many more opportunities, etc.

If you are in a small city, I encourage you to look at moving to a larger city.  If you are in a larger city, search for Microsoft programming groups that meet regularly, and try to join them.  Also, you may want to e-mail some recruiters in the area.  I know recruiters get a bad reputation within our industry, but they've really helped me with jobs in the past.

Title: Can I advance my career in the USA if I lack local networking?

Body:
I'm a web developer with 10 years of experience in the Microsoft stack. I was brought to the US by my company, but my contract has ended.

I want to continue pursuing a career in the US, but it seems there's a focus on networking while still in college. Due to my foreign education, my networking occurred elsewhere. However, because of this network effect, it seems most developers in the US only have to apply to one or two jobs throughout their career.

Am I handicapped by not having a professional network in the US?


问:
Is an 8 second (incremental) build time common?
My current project takes 8 seconds to build one C++ file. Is this common? Other files take 12-15 seconds but most at the moment are about 8 seconds. I use Visual Studio to tell me the time.

I have gone into the headers and removed things I didn't need and used forward declaration. It did save me about 2 seconds per file and one header takes about 4 seconds to go through alone. In that header I need all its declarations and using a lite version which removes private methods public functions I don't need.

Should I be happy it's 8 or so seconds or is that too long to compile one file?

答:
If you're using a really old compiler, then it can be nasty- they don't support things like concurrent compilation. Else, I'd suggest that your files are way too large and you need to split them up. Incremental build is per-file, as far as I'm aware. I've got some files in my current project where the header is a thousand lines of template metamachinery (plus a bunch of Standard headers) and the contents of the source file are expression template magic to create a type so large, Visual Studio crashes half the time trying to compile it.

But when it succeeds, it still only takes a second or so.


答:
What you are really looking at is a Dual License phenomenon. You can provide two version of licensing under different conditions.

one of best/notworthy example is QT licensing where commercial license will permit commercial usage more freely (essentially allowing selling of close source apps created using QT).

In other cases is MySQL which allows GPL for Open source projects but mandates OEM license for commercial projects which uses and extends MySQL engine.

Read this article from an OSS book and this from OSS Watch

Also, read this: Dual licensing with GPL library

Title: What licence for a FOSS that would sell packages on Mac and Windows but give them away on Linux?

Body:
The code should remains as open as possible, but I'm planning to sell it on Windows and Mac, and make free rmp/deb.

Does the licence even matter? It feels like I'm just selling the service of compiling and distributing the software here.


答: I just did an eight second test and compiled 46 files in that amount of time.  A lot of factors go into your compile time.  It's not just the code itself, but your processor speed, hard disk speed, amount of RAM, whether the files were in cache or not, whether your code is on a network drive, what else is running on your computer, etc.</p>

Title: Is an 8 second (incremental) build time common?

Body:
My current project takes 8 seconds to build one C++ file. Is this common? Other files take 12-15 seconds but most at the moment are about 8 seconds. I use Visual Studio to tell me the time.

I have gone into the headers and removed things I didn't need and used forward declaration. It did save me about 2 seconds per file and one header takes about 4 seconds to go through alone. In that header I need all its declarations and using a lite version which removes private methods public functions I don't need.

Should I be happy it's 8 or so seconds or is that too long to compile one file?


答:
C++ is a very complicated language, and due to many factors the compiler needs several passes to determine what a certain symbol is. The result is that C++ programs are slower to compile than programs of comparable complexity written in other languages. Here is an insightful article that covers the subject (it was written by Walter Bright, the creator of D and the author of the Digital Mars C and C++ compilers). Considering this, your 8 seconds compilation seems reasonable.

Good practices to increase compilation speed:

forward declaration whenever possible

precompiled headers

#pragma once (not standard, but both MSVC and GCC support it)

pimpl pattern


答:
Find a local meetup (or 4) and got to the meetings, better yet give talks. I have managed to do this around Tel Aviv quite well despite the fact that I don't actually speak Hebrew worth a darn. Its just a question of putting in the time.

(Also showing up early to help setup the chairs etc often is a good way to talk to people)


答:
Most answers miss the timing of the situation. It seems to me that @Jorge wants to get to a position in "now-time". This will deter all his networking efforts.

I had exactly the same discussion with friends of mine: There is an proper time to network and that is way before you need it. I have been into some meetups and saw people coming up almost like holding a "I want a job" sign. The problem is that networking applies soft influence: you've seen a person some times, you have similar interests, you saw him and approved in social surroundings and now that his contract is close to finish, you will help him find his next position.

If you just pop up now, it is very difficult for people to realize if you want to exploit the event, how good your skills are, if you care at all and mostly if you will say "yes" to everything in order to get a job. It has happened many times over: colleagues come and ask me something along the lines of: "If I get to that networking event, will I find a job?". I believe that this is not the case (plain luck excluded), same with employers: If I go to that event, will I hire a "ninja" employee? (No again, good IT people have options).

At that point, what you need is to visit job fairs or talk to a recruiting agency.


问:
Which licenses are free for commercial use?
I'm lost in a mass of licences - GPL, LGPL, Creative Commons, BSD, Apache, etc, and looking for a beginners guide.

When using a component under a popular licence like these, what are the restrictions for using them without paying in a commercial product?

E.g.

do I have to redistribute the source?

do I have to credit them?

what if I modify the component? etc.

From what I can tell from http://www.codeproject.com/info/Licenses.aspx, only GPL and Creative Commons force you to redistribute source?

答:
A great resource for understanding open source licenses is the very comprehensive, interactive license differentiator, from Oxford Universities OSS Watch.

This asks questions based on the assumption that you want to find a license for your own software, but turn it around and you could also use it to determine which licenses are are suitable depending on the way you want to use other peoples software.


答:
Java interfaces aren't a "workaround," they are a deliberate design decision to avoid some of the problems with multiple inheritance like diamond inheritance, and to encourage design practices that minimize coupling.

Your interface with protected methods is a textbook case of needing to "prefer composition over inheritance."  To quote from Sutter and Alexandrescu in the section by that name from their excellent C++ Coding Standards:

Avoid inheritance taxes:  Inheritance is the second-tightest coupling relationship in C++, second only to friendship.  Tight coupling is undesirable and should be avoided where possible.  Therefore, prefer composition to inheritance unless you know that the latter truly benefits your design.

By including your helper functions in your interface, you might be saving a little typing now, but you're introducing coupling that will hurt you down the road.  It's almost always better long term to make your helper functions separate and pass in a Foo*.

The STL is a pretty good example of this.  As many helper functions as possible are pulled out into <algorithm> instead of being in the container classes.  For example, since sort() uses the public container API to do its work, you know you can implement your own sorting algorithm without having to change any STL code.  This design enables libraries like boost, which enhance the STL instead of replacing it, without the STL needing to know anything about boost.

Title: The term "interface" in C++


问:
In an MVC system, where should the database persistence code sit?
I've seen multiple configurations for persisting information to the database. Generally, three types of designs seem common in my corner of the world:

Controller manages the persistence

Model manages the persistence

Third party library manages the persistence, usually requiring some sort of annotations on the model.

I'm wondering which configuration (if any) is, conceptually, the easiest to use/most compatible with an MVC architecture?

(If it's not one I listed, please give a quick outline/overview as part of the answer)

答: In a MVC  ( model-view-controller) system,  the model contain the data. So I believe, taht the database persistence should be in it.</p>


答:
Your second and third options are identical. The M in MVC is not the data model, but rather the domain model. This includes persistence, whether done directly or via an ORM, and both are perfectly correct.

The controller should manage the flow of the site and passes stuff off to the domain (sometimes via a service layer) to be handled, so persisting from there is wrong -- or at least semantically uncomfortable.

Title: In an MVC system, where should the database persistence code sit?

Body:
I've seen multiple configurations for persisting information to the database. Generally, three types of designs seem common in my corner of the world:

Controller manages the persistence

Model manages the persistence

Third party library manages the persistence, usually requiring some sort of annotations on the model.

I'm wondering which configuration (if any) is, conceptually, the easiest to use/most compatible with an MVC architecture?

(If it's not one I listed, please give a quick outline/overview as part of the answer)


问:
Java IDE written in pure Java?
Is there a Java IDE written in Java?

I just got my year 9 DET laptop today at school, and there are all sorts of restrictions set in place. Somewhat annoyingly, you cannot run any executable other than the ones already installed on the system (for some reason they haven't disabled the use of Command Prompt, PowerShell, or strangely enough, regedit). They allow you to run Java executables, so I thought that would be the only way to be able to program on my crappy laptop at school (when I have finished all my work, naturally) :D

Edit:

By written in Java, I also mean that the executable, that is used to run the program, has the file extension ".jar", thus running on the JVM.

Edit 2:

I tried the DrJava IDE, and it worked great, thanks (I can compile and execute programs)! Regarding running Eclipse as through the command line using the command "java -jar "C:/Users.../org.eclipse..."". This results in an error producing a log saying file, the main error is:

MESSAGE An error occurred while automatically activating bundle org.eclipse.ui.workbench (182).

How do I fix this error (I much perfer working with Eclipse than any other IDE)?

Edit 3:

Regarding my last edit, just disregard it :D. I fixed the problem by downloading the latest version of Eclipse.

答:
Eclipse is written in Java.

"Written in   Java" - http://en.wikipedia.org/wiki/Eclipse_%28software%29

EDIT: To address the question's edit about running the IDE as a .JAR file:

"Alternatively, you can launch Eclipse by directly invoking the JVM as follows:

java -jar eclipse/plugins/org.eclipse.equinox.launcher_1.0.0.v20070606.jar
  "

Source: http://wiki.eclipse.org/FAQ_How_do_I_run_Eclipse%3F

Title: Java IDE written in pure Java?