答:
It's not a well-defined piece of technical jargon or a common term of art. Skeet is just using it in the ordinary English language sense: "non-trivial" means "not meaningless." </p>

<p>In that article, "in a non-trivial loop" means "in a loop that takes a meaningful length of time." </p>

Title: When is a loop "non-trivial"?

Body:
It's not a well-defined piece of technical jargon or a common term of art. Skeet is just using it in the ordinary English language sense: "non-trivial" means "not meaningless."

In that article, "in a non-trivial loop" means "in a loop that takes a meaningful length of time."


问:
How to design an algorithm-heavy and object-light application
Other than vertices, edges, faces and meshes, my geometry processing project/application has only about half a dozen other entities such as curves on surfaces. However the majority of my code is dedicated to geometry processing. Being a naive programmer when I started this project, I implemented the various geometry processing algorithms as methods of the few classes that I had. As a result, some of my classes are now very large because they implement geometry processing algorithms (and therefore span up to 5 *.cpp files) -- very bad. In some cases I also implemented the algorithms as classes in their own rights.  As such I now have classes that are not really entities. I now have a problem with this because I now believe that classes should be instantiable entities, and their methods the things that they do. Yet following this rule has led to large files. At the same time deviating from it has led to classes that do not make sense as instantiable  entities e.g. a Geodesic class.

Anyway I'm planning a redesign of this project and I'd appreciate advise on how to deign my classes. One of the options I've considered is to implement each algorithms as a collection of methods in a namespace. However as namespaces do not have instance variables, there will be lots of argument passing between the methods -- again not very nice.

答: I find that even with algorithm-centric problems, you can still find ways to separate responsibilities into separate classes.  You might be a little bit too rigid in your thinking of what should be an object.  If I had an algorithm I might have classes like FooCalculator and BarAccumulator and MyAlgorithmOrchestrator.  As far as I'm concerned those are perfectly valid "instantiable entities".  Just because they might not make sense as physical objects doesn't mean they don't make sense as algorithmic objects.</p>

ContentLicense: CC BY-SA 3.0


问:
The best method to get personal projects done
I have numerous personal projects I've begun and never seem to finish because I get sidetracked with other ideas. I was wondering what the best method to get personal projects done is? Any tricks or tips to it? </p>

<p>The problem is I get a spurt of inspiration on some projects, and I don't wanna lose track of my ideas and right now my method of "saving my ideas" is to just get as much stuff done on the ideas as possible in one night and then store some GitHub issues as to dos. I find that this makes me never get back to older projects tho. </p>

答:
I'm reminded of the 80 / 20 rule.  It takes 80 percent of the time to get 20 percent of the project done.  :-)

I'm currently working on implementing a stock market board game from the 1960's using Java.  I had a lot of fun figuring out how to draw the game board, and putting the user interface together.

The move algorithms turned out to be hard to implement.  Depending on the state of the game, you could land on as many as 3 different squares on a given dice roll.  I'm on the 3rd iteration of the move algorithms, and hopefully the 3rd time will be the charm.

I had no trouble motivating myself to draw the game board.  I had a lot of trouble motivating myself to work on those move algorithms.  But the move algorithms were what I needed to do to improve my design skills in other similar areas.

It's easy to do the fun stuff when coding.  It's harder to do the harder parts of a project, especially when you get the design wrong.  Twice.  But recognizing and learning from your mistakes is what will make you a better analyst, designer, and programmer.


问:
New Silverlight app. MVVM. RIA Services vs CSLA
Another 2 days of reading and watching demos and here we go.

For my enterprise LoB Silverlight app I'm going to use:

Prism for UI aspects and modularity.

MVVM pattern (using Prism)

??? to bring data over and validations...

Entity Framework for Data access

SQL Server for data

Ok, main dilemma is #3. If I won't use any framework then I will have to figure out how to do all CRUD stuff myself. I can do RESTful WCF, I can do SOAP. All that == MANUAL coding.

I can do RIA Services. I kind of see what it does and it is nice for direct match with my data layer BUT it is not that great if there will be lot of business logic. Where would I put it? In my ViewModel? Another question is how those services maintained. Once I generated it - I should maintain them by hand if data changes?

I also found CSLA which seems to be nice on one hand but receives lot's of critique.. CSLA will allow me to write business logic and shape object as I needed and than I can pass it "through" ViewModel and all is well.

Something tells me that RIA Services will be much quicker to write. Also, I like the fact that I don't have to include extra dependencies.

There is no blogs or mentioning of RIA Services since 2010. Is it going under table? Not widely accepted? Not scaling well for big apps?

I'm trying to decide which one I need to bet on. CSLA or RIA Services. OR?

答:
I have recently been working on some line-of-business Silverlight projects.  For one we used straight WCF and did all the CRUD, state tracking, entity relationship, etc. ourselves.  For the second project we are using RIA Services and had it manage all of that stuff for us.

However, we did NOT have RIA Services directly generate services based on our ORM model.  We had a layer of interfaces and "dumb objects" in between.  So we had a distinct data tier, business logic tier, and service tier.  RIA Services was only involved at the service tier.

If you are going to use RIA Services, I recommend limiting how much of the layers of your application you let it influence.  It does force you down certain paths as far as design is concerned, so the more you contain it the more flexibility you will have.  This advice is probably sound for CSLA as well.  If you are going to "bet" on a particular framework, hedge your bet as much as possible.

In summary, RIA Services will definitely save you time, but it does limit your flexibility a bit compared with raw WCF.  And it has some kinks and weaker areas that still need improvement.

I haven't worked with CSLA, but I have seen Rocky Lhotka give talks on it several times so I know the basics.  It seems like a solid framework.  However, the main disadvantage it will have compared with RIA Services is that it isn't directly from Microsoft, so CSLA won't mesh as cohesively with other MS stuff as much as RIA Services will.  Also, in the long run I'm guessing it will be easier to find people that know RIA Services versus people that know CSLA.

If it helps, I gave a talk on RIA Services you can find the presentation and some sample code on my blog.

http://rationalgeek.com/blog/post/WCF-RIA-Services-Silverlight-Guild.aspx


问:
When is a loop "non-trivial"?
Is it correct to call a loop that you do not know the limit at compile time "non-trivial"?

If you know that you will be using a value from a class that will be in a range e.g. between 0-1000, is that still non-trivial?

e.g.
Where ISomeInterface.MAX_LIMIT is always between 1-1000:

```<code>public bool someMethod(Type someType, int someId, int someVariable)
{
    bool returnFlag = false;
    int maxLimit = (Activator.CreateInstance(someType) as ISomeInterface).MAX_LIMIT;

    for (int i = 0; i < maxLimit; i++) //is this a non-trivial loop?
    {
        if (_someSerivce.SomeOtherMethod(someType, someId, someVariable, i))
        {
            returnFlag= true;
        }
    }
    return returnFlag;
}
</code>```

Edit:
Was uncertain as to whether this was a meaningful piece of terminology.

I originally read it in one of Jon Skeet's pieces from yoda.arachsys: http://www.yoda.arachsys.com/csharp/stringbuilder.html (see the section headed Rules Of Thumb).

Do you use this as technical terminology at all?

答:
When I've used the term it's usually been in relation to compiler optimizations ... in that context a trivial loop was one that the compiler could fully unroll without creating adverse conditions (ie increasing the block count, removing the ability to inline other code etc) ...

So we generally meant loops with a small number of instructions or few number of iterations (the later being the more common meaning).

With that said, it's definitely a non-standard term without a solid technical definition.

Title: When is a loop "non-trivial"?


答:
I am working on a WPF and Silverlight (two separate clients) project that makes heavy use of the CSLA.NET Framework. We've had very little trouble from the CSLA.NET Framework which is mature, very well tested, has excellent support from Rocky and the community, and provides solutions to a lot of the problems one has developing modern .NET applications (data-binding, data-access, validation, authentication, to name just a few).

The CSLA.NET is not perfect, perhaps in that it doesn't fit perfectly into the message bus type architectures; but if your goal is a line-of-business application sat on top a database, then CSLA.NET is a sensible choice. Perhaps another issue is the learning curve but the educational material is comprehensive and well written.

Title: New Silverlight app. MVVM. RIA Services vs CSLA

Body:
Another 2 days of reading and watching demos and here we go.

For my enterprise LoB Silverlight app I'm going to use:

Prism for UI aspects and modularity.

MVVM pattern (using Prism)

??? to bring data over and validations...

Entity Framework for Data access

SQL Server for data

Ok, main dilemma is #3. If I won't use any framework then I will have to figure out how to do all CRUD stuff myself. I can do RESTful WCF, I can do SOAP. All that == MANUAL coding.

I can do RIA Services. I kind of see what it does and it is nice for direct match with my data layer BUT it is not that great if there will be lot of business logic. Where would I put it? In my ViewModel? Another question is how those services maintained. Once I generated it - I should maintain them by hand if data changes?

I also found CSLA which seems to be nice on one hand but receives lot's of critique.. CSLA will allow me to write business logic and shape object as I needed and than I can pass it "through" ViewModel and all is well.

Something tells me that RIA Services will be much quicker to write. Also, I like the fact that I don't have to include extra dependencies.

There is no blogs or mentioning of RIA Services since 2010. Is it going under table? Not widely accepted? Not scaling well for big apps?

I'm trying to decide which one I need to bet on. CSLA or RIA Services. OR?


问:
Should we choose Java over C# for a new project?
We have a team of .NET developers (C#) with a range of experience from 2 to 6 years. Over the last few years we have been developing Silverlight, ASP.NET MVC, and WPF applications. However, there is a new two year project which means we will develop a HTML5 application on Linux.

The company I work for would like all developers across their offices to use the same programming language which is Java. Although there is talk of using Mono but using the same language and sharing modules, services, etc. already created in Java is the main reason for moving to Java.

Some of the developers here are upset. How do I find something positive in moving over that will convince the other developers?

There will be a training budget, but the thought of learning to work with Java libraries and a new platform (Linux) will be scaring a lot of the guys.

What should I do?

答:
I'd like to supplement Justin Shield's answer.

Mono has matured beyond anyone's (besides Miguel) expectations. The team really needs people like your company to prove it's viability. They have to get credible traction somewhere.

Having said that, I nor anyone else would guarantee a painless transition from the .NET Framework to Mono. Think of Mono as a strict version of the .NET Framework. They implemented it based on the public API and information released to ECMA. Microsoft loves to make developers lifes easier by making things work that really shouldn't. They will probably never stop this practice. The Mono team can only know when Microsoft has done this when someone has come across an issue. Ensure the new code is CLR compliant.

There is also another solution your company can take a hard look at. IKVM. It is a Java Virtual Machine written in C#. Yes, a full JVM written on the .NET platform. Not only that, but it has a compiler to convert any Java Byte code to IL code and uses a converted version of the OpenJDK. It's another solution that needs more proving with commercial use.


问:
Importance of hobby projects
I want to know, how important is it to program in your spare time? Is it necessary to work your 9-5 as a programmer and then get home and work on your hobby to become a better programmer?

This said, I know you only get better at programming by, well, programming.

Do prospective employers take hobby programming into account in an interview or do they ask this just out of curiosity?

I feel guilty for not having a hobby project, but everything I can think of doing has already been done. So I am kind of in two minds about this, start something that has already been done or leave it until I come up with something original?

答:
If you really have the interest and energy for those projects, by all means do them. But I wouldn't go as far as saying that it is a must for any serious programmer. If you work full-time with programming, doing it in your free time as well will not necessarily increase your interest in it, it may very well have the opposite effect. Personally I used to do hobby projects, but I have stopped. I were already programming 5 days a week and to me it seemed healthier to do something entirely different in my free time.

Also, if your employer doesn't give you room to test out new things at work, study and improve continuously, then you should probably look for a new job rather than doing those things on your free time. A good employer will realize that it is in their own interest to keep your skills refreshed, improved and expanded.

From the employer's point of view (I am one of those), hobby projects will be a merit if you have no actual work experience. All hobby- and school projects will then be very important to bring up as reference during the interview.

But if you do have experience they are less relevant: while they might indicate a passion for your trade, they might at the same time indicate that you are a bit of a nerd. From my personal experience I can't really find any connection between hobby projects and good/bad candidates, I don't think they are particularly relevant unless you are fresh out of school applying for your first job.

Title: Importance of hobby projects


问:
Price Comparison Database Scema
I have a bunch of data from multiple retailers. Each product that each retailer sells may or may not be sold by another retailer in the database. If multiple retailers sell the same product, then the product can be identified by a SKU. I currently have 1 database for each retailer. I'm having a problem trying to conceptualize an appropriate database schema to identify how many retailers are selling the same product.

Should I have 1 table with all retailers?

答: In answer to your question the very last thing you want to do is separate out the data by retailer if you need to compare retailers. There should be commonality of data for the most important things. If the files from each retailer are different that is just a matter of transforming the data to your format. It is best to ask them to provide ina common format. If a retailer has some addtional information that the others do not you can either add that as an nvarchar(max) field that is retailerdescription  or add a related table for that retailer that is only used when calling up the details about that product (not for comparisons). Or you can add extra fields that allow nulls to handle the data that some reatilers provide that others do not. </p>

Title: Price Comparison Database Scema


问:
Java class version specific naming conventions
I have to create an Adapter between two software (mech. simulation, non-cs). Assuming we have a class named ThatThing. I have to handle various vendor specific implementations. These versions don't have meaningful names (unlike eclipse helios, indigo etc.).

1. How should I name a class that should express version number?

I find class like ThatThing_3_6_Impl, ThatThing_3_7_Impl quite awkward.

答:
It doesn't matter a lot.  Pick a convention that expresses everything you need it to express and stick with it.

You could use ThatThing3_6 for "That Thing 3.6".


答:
First of all, in a broader sense, I would colloquially define non-trivial code by code whose implementation and execution has a significant impact on the nature of the project as a whole. This is obviously somewhat situational, making the term an imprecise one. Context is a big factor in relation to the meaning of non-trivial when talking about a specific piece of code, whether it is a loop or any other structure. There are a few possible scenarios:

Performance

Design

Maintainability

Portability

In each of these cases, a code block can be non-trivial, and it means something different in every case.

For your example, you seem to be talking about performance. In the context of performance, I believe a good metric for non-trivial would be its Big-O performance. In your example, the loop is O(n), which in many scenarios is a perfectly acceptable performance, and is the Big-O of a large percentage of for loops.

In the context of performance, one might also say code is non-trivial if its execution time is very large with respect to the total execution time of the whole program.

Title: When is a loop "non-trivial"?

Body:
Is it correct to call a loop that you do not know the limit at compile time "non-trivial"?

If you know that you will be using a value from a class that will be in a range e.g. between 0-1000, is that still non-trivial?

e.g.
Where ISomeInterface.MAX_LIMIT is always between 1-1000:

```<code>public bool someMethod(Type someType, int someId, int someVariable)
{
    bool returnFlag = false;
    int maxLimit = (Activator.CreateInstance(someType) as ISomeInterface).MAX_LIMIT;

    for (int i = 0; i < maxLimit; i++) //is this a non-trivial loop?
    {
        if (_someSerivce.SomeOtherMethod(someType, someId, someVariable, i))
        {
            returnFlag= true;
        }
    }
    return returnFlag;
}
</code>```

Edit:
Was uncertain as to whether this was a meaningful piece of terminology.

I originally read it in one of Jon Skeet's pieces from yoda.arachsys: http://www.yoda.arachsys.com/csharp/stringbuilder.html (see the section headed Rules Of Thumb).

Do you use this as technical terminology at all?


问:
Standard/Proper way of counting lines of code?
How should I count the lines of code in a project?

In C++ for example, should I count the lines of the header files with my class definition? Should I count the header of a (non standard) library I am linking against?

In Qt (or any other GUI framework), should I count the lines of the form's design?

Should I count the Makefile too?

I ask because it is a simple way to measure the size of the project and/or effort involved. Even though a GUI file is not code per se the programmer might have spent hours doing it.

EDIT Most of you did not understand the question and/or are assuming that I want to use the magical number of LOC as the ONE AND ONLY metric to rate a project or even a day of work.

I consider a negative LOC day a very nice day. It means I've somehow managed to understand and model the problem better and more efficiently. Comments like "Why do you need this" are not interesting.

Like it or not, the number is out there, Wikipedia says Windows XP is rated at 45M LOC, Linux 2.6.35 at 13.5M, I could go on.

Maybe I could have asked better.

Anyway, my original intent was to know how those numbers in Wikipedia were calculated and not the subjective nature of them.

I found this in a MSDN blog, very useful as it shows how VS2008 does it:

答:
Many people have reacted somewhat negatively to this question. I would, instead look upon it as an opportunity.

Nearly the only reasonable excuse for counting lines of code is that it's been demanded by somebody higher up the food chain (who's clearly clueless, or he wouldn't ask for that). As such, you should get that person involved -- preferably doing something like heading a committee (that includes as many of the least useful of your co-workers as possible) researching the most efficacious way(s) to count lines of code.

As far as the specific method itself, such momentous decisions obviously require the input of the entire committee. Your job is to supply them with plenty of raw data, measuring lines of code every which way you can (at least without expending any more than a minimum of effort). You should, however, meter the rate at which you supply them with this information -- if, heaven forbid, they get close to a final decision, you need to give them an exciting new option that forces them to go back to the drawing board to spend at least a few more months studying the problem and considering how best to incorporate this new option into a company-wide line-counting strategy!

This has two good effects. First of all, it obviously distracts them from other things that are likely to be more harmful to productivity. Second, you can bolster their self esteem by supplying them with at least a little data that they will eventually realize is even more worthless than the rest, so when they write their three-volume guideline on the proper ways to count lines of code, they can make some good, solid recommendations about at least a few things to avoid, so at the end of it all they can really know they've accomplished something useful. In addition, they will have shown you mere peons that without their brilliant, seasoned leadership, you'd be making all sorts of foolish mistakes in this most crucial of tasks.

Lest you should mistake this for being entirely facetious, I'll point out that this really is quite important -- without something like this to occupy their time, they'll start to study something like ISO 9001 conformance. The minute they decide to go ahead with something like that, you might as well write off at least a solid month that will be dedicated to writing up detailed documentation of how you do your job (which, to give you any hope of passing an inspection, will end with something like: "and if none of that works, we will exercise our judgement and do what seems reasonable.") With a little care in its application, a small investment in line counting software can prevent, or least delay, such disasters for a considerable time.


答:
Use a different package name.

```<code>com.example.version36.ThatThing
com.example.version37.ThatThing
</code>```

This allows you to keep all the "things" for specific versions together.

Apache Commons Lang used this format when releasing their "version 3" rewrites.

Since you need to be able to reference both version in a single class, I would shorten the names to:

```<code>ThatThing36
ThatThing37
</code>```

In your case, this seems to be descriptive enough, and it removes the ugly Impl and _'s.

Title: Java class version specific naming conventions

Body:
I have to create an Adapter between two software (mech. simulation, non-cs). Assuming we have a class named ThatThing. I have to handle various vendor specific implementations. These versions don't have meaningful names (unlike eclipse helios, indigo etc.).

1. How should I name a class that should express version number?

I find class like ThatThing_3_6_Impl, ThatThing_3_7_Impl quite awkward.

Body:
Use a different package name.

com.example.version36.ThatThing
com.example.version37.ThatThing

This allows you to keep all the "things" for specific versions together.

Apache Commons Lang used this format when releasing their "version 3" rewrites.

Since you need to be able to reference both version in a single class, I would shorten the names to:

ThatThing36
ThatThing37

In your case, this seems to be descriptive enough, and it removes the ugly Impl and _'s.


问:
Is it a good idea to do contract work for a former full time employer?
Assuming:

The employee and company are parting on good terms

The new company is OK with a little contract work as long as it doesn't distract from the new job

The former company wants the help and the employee is willing to work a few hours a week

Is it a good idea to do contract work for a former full time employer?

Has anyone ever done this?  How did it work out for you?  I can see some possible pitfalls, so I wonder how good an idea it really is.  What difficulties do you encounter doing development work outside the office and on a different schedule from the rest of the programming staff and how can they be overcome?

If I  do go forward, what would be a fair amount to request as compared to current salary?

答: Lots of people do this. We have two people that I know of doing it right now for our company. The key is to keep the work separate from the new job and make it clear you will be working on this only after hours and that you are not available for questions during hours when you are at your new job. Whatever you do, you don't want to risk your new job, so make it clear that if your new job tells you that you can no longer do this, you will be giving notice. Keep everything in Source control of course and make sure the repository is kept up-to-date in a branch that you update after each work seesion, so the old company can access the code you are working on if something becomes too urgent to wait until you can work on it that night. Negotiate how long this will go on if you only want to do this for the short-term until someone else gets up-to-speed. You can usually get them to give you a higher hourly wage than when you worked for them as well. </p>


问:
Are there any notable examples of business disasters directly attrutible to open-source software?
In "enterprise" environments, I've observed a strong prejudice towards proprietary software. Even in large business that use Java, it is unusual to find MySQL or PostgreSQL, and WebSphere and WebLogic are strongly preferred over JBoss or Tomcat.

This is very understandable. While many developers prefer Tomcat or Postgres to WebSphere or Oracle DB, they are not the ones that make the final decisions in these matters. Whoever does make the decision regarding which DBs and application servers will be used in production will find that the licence fees seem quite small compared to being fired for choosing the free software that caused something really, really, bad to happen.

I'm not asking the question of whether Postgres is as good as Oracle. That's not the point. Oracle doesn't get chosen over Postgres after a careful considerations of features and benchmarks. Postgres doesn't enter the conversation, because free software isn't trusted in certain places.

I'm curious if this lack of trust came about in response to any specific events.
So my question is this: Are there any documented cases of business calamities (failures, significant loss of revenue, significant loss of corporate data, etc.) that were shown to be the result of deficiencies in open-source software?

Clarification: If you have experience with enterprise level companies that fully embrace OSS, that have to prejudice in the matter but make choices based on the needs of the particular situation, then Good for you! Your experience doesn't change the fact that other enterprise companies have a very different attitude, and my question is valid even if these companies are in the minority.

答:
Are there some prejudices, yes perhaps in some cases.  For large organizations however this path to expensive proprietary application servers and other expensive software suites given them some advantages and securities that some rarely think about.

1) Support: Typically when a large corporation has million dollar software the support is built into the contract.  I don't need to delve into the advantages of having application support.

2) Leverage: Expensive proprietary software, especially niche software have fewer clients and independent users.  If a large corporate client decides not to renew a contract then it can seriously affect the bottom line of the vendor.  Many of them use this leverage to push for features and fixes that they may not be able to influence into open-source software.  The argument for open-source states that the large corporation can contribute its own changes and features into the project for the good of all, but that would involve developers time which they try to avoid.

3) Security: And I don't mean as in encryption and firewalls and stuff.  Open source projects come and go, some are widely supported and surpass the proprietary software.  Many fail or just lose contributors over time.  If they are stuck with this software for 20 years down the road is the open source community going to continue to support this?  With proprietary software, the money you pay as a client encourages the vendor to stay in business as long as you continue to pay him.

As far as a story where open source blew up in my companies face, a long running project that was started on an uncommonly heard of ORM mapper that was open source.  The project just stopped as the main contributor died or something, then the company was left with an expensive refactoring effort to move to a proprietary library.  It happens and these kinds of scenarios scare the crap out of large corporations.


答:
I haven't ever heard of any problems that were the result of using an Open Source product.  I think the reason for the concern isn't due to some historical failure, but something else.

When you use a commercial product for some task, and something goes wrong, you usually have someone you can call for support.  That person (and company) usually has a vested interest in helping you resolve the problem, because if they don't help there's always the threat that you will stop giving them money.

With an open source product, whom can you call or contact?  The community?  Since you haven't given them anything for the use of the product, there isn't anything you can threaten to take away.  You can file a report and hope that it's fixed in the next release, but it's very difficult to pass on a sense of urgency to a nebulous community of people volunteering their own time.

So, the open source product can be vastly superior to a commercial alternative, but at least in my experience, in a corporate environment where you have to plan for contingencies if something goes wrong with it, not having anyone to get support from is a big deal.

That's the barrier I've always seen.

Title: Are there any notable examples of business disasters directly attrutible to open-source software?

Body:
In "enterprise" environments, I've observed a strong prejudice towards proprietary software. Even in large business that use Java, it is unusual to find MySQL or PostgreSQL, and WebSphere and WebLogic are strongly preferred over JBoss or Tomcat.

This is very understandable. While many developers prefer Tomcat or Postgres to WebSphere or Oracle DB, they are not the ones that make the final decisions in these matters. Whoever does make the decision regarding which DBs and application servers will be used in production will find that the licence fees seem quite small compared to being fired for choosing the free software that caused something really, really, bad to happen.

I'm not asking the question of whether Postgres is as good as Oracle. That's not the point. Oracle doesn't get chosen over Postgres after a careful considerations of features and benchmarks. Postgres doesn't enter the conversation, because free software isn't trusted in certain places.

I'm curious if this lack of trust came about in response to any specific events.
So my question is this: Are there any documented cases of business calamities (failures, significant loss of revenue, significant loss of corporate data, etc.) that were shown to be the result of deficiencies in open-source software?

Clarification: If you have experience with enterprise level companies that fully embrace OSS, that have to prejudice in the matter but make choices based on the needs of the particular situation, then Good for you! Your experience doesn't change the fact that other enterprise companies have a very different attitude, and my question is valid even if these companies are in the minority.


答:
I suspect that companies like Oracle are more relatable to other "for profit" companies; they can't imagine that an organization could turn out a product that's as good as Oracle without also having a profit motive.  Of course, PostGres isn't entirely non-profit; there's a whole ecosystem of service providers available that will sell you support.

If you really want to know what the Achilles heel of any product is, you can do a Google search for "[name of product] sucks."  It works for any product, including Oracle's.  In PostGres' case, you find Postgres DDL Transaction Control Sucks, in which someone describes a hypothetical situation where data was lost on a test server.  Of course, losing data is possible on any SQL database if it is mis-handled.

All that said, I haven't heard of any real calamities that have befallen companies because they decided to use an open source database.  The quality of the software available in that space is quite good, rivaling and (in some cases) exceeding their commercial counterparts.


问:
Wrapping basic functions in high-level functional-programming languages
I'd like to know if there's a general guide or best practice for wrapping basic functions.

Let's take J for example. It has several 1-or-2 character "functions" called primitives. Examples:

, : Flatten a matrix or append to a vector

{ : Catalogue combinations or take nth item of a matrix

{. : Take first or n elements of a matrix

} : Amend items in a matrix

Some J programmers think it best to use them as such, other will wrap them in functions like so:

Append =: ,

TakeFirst =: {.

I found that's not always practical because I'm used to the actual "symbols", but that basically means I'm biased.

So, any advice on the best practice to use? To wrap or not to wrap?

答:
The people who are wrapping functions must be from the Visual Basic (VB) crowd, or their ilk.  Languages like VB are more English-like, and use less symbols than the C-like languages, and other languages that are more symbolic. Wrapping the functions makes them easier to read for these folks, but it probably makes things harder for those people who are already used to the symbolic style.

I was originally a VB programmer, but switched to C# when I changed jobs, and now I prefer the more terse, symbolic style of C#.


答:
Many years ago, before the legions of Pascal programmers had been routed by the C hordes, some Pascalians tried to adapt to the new reality by doing this:

```<code>#define BEGIN {
#define END }
</code>```

so that they could write:

```<code>void main(int i)
BEGIN
    printf("Hello, world!");
END
</code>```

There were often other, similar macros designed to hang onto even more Pascal syntax. It wasn't long before they realized that they were only torturing themselves and either gave themselves over to the C side willingly, or perished.

If you're going to use a language, use the language. That may require learning it first. Gluing on a bunch of nonstandard names for standard operators may make things easier for you to grasp in the very short term, but you end up with code that can't easily be understood by other people well versed in the same language.

Wrappers make sense when you need to adapt one class or language to another. For example, you might have a Java class that wraps calls to C or C++ functions to make that functionality easier to use and more accessible for Java developers. If you're going to use a wrapper, make sure that it really does simplify the code, prevent bugs, or otherwise adds value. Don't do it just to avoid learning the syntax.

Title: Wrapping basic functions in high-level functional-programming languages

Body:
I'd like to know if there's a general guide or best practice for wrapping basic functions.

Let's take J for example. It has several 1-or-2 character "functions" called primitives. Examples:

, : Flatten a matrix or append to a vector

{ : Catalogue combinations or take nth item of a matrix

{. : Take first or n elements of a matrix

} : Amend items in a matrix

Some J programmers think it best to use them as such, other will wrap them in functions like so:

Append =: ,

TakeFirst =: {.

I found that's not always practical because I'm used to the actual "symbols", but that basically means I'm biased.

So, any advice on the best practice to use? To wrap or not to wrap?

Body:
Many years ago, before the legions of Pascal programmers had been routed by the C hordes, some Pascalians tried to adapt to the new reality by doing this:

#define BEGIN {
#define END }

so that they could write:

void main(int i)
BEGIN
    printf("Hello, world!");
END

There were often other, similar macros designed to hang onto even more Pascal syntax. It wasn't long before they realized that they were only torturing themselves and either gave themselves over to the C side willingly, or perished.

If you're going to use a language, use the language. That may require learning it first. Gluing on a bunch of nonstandard names for standard operators may make things easier for you to grasp in the very short term, but you end up with code that can't easily be understood by other people well versed in the same language.

Wrappers make sense when you need to adapt one class or language to another. For example, you might have a Java class that wraps calls to C or C++ functions to make that functionality easier to use and more accessible for Java developers. If you're going to use a wrapper, make sure that it really does simplify the code, prevent bugs, or otherwise adds value. Don't do it just to avoid learning the syntax.


问:
Functional testing must be done by external party to avoid bias?
Our developers demand that someone external to the development team completes the functional testing. Their argument is that they are biased and cannot test their own code as they are too close to it. Our last round of testing is with the client in the form of UAT.

To be clear by 'functional testing' I mean testing the code against the specs, eg. when you click on 'submit' the index page should load. By UAT I mean the client comes in and runs through use cases on the release candidate.

While I understand this argument of bias, is it reasonable for the developers to demand someone else complete their functional testing or is this just a way to avoid doing their job?

答: Usually once the initial developer finishes writing the software AND testing it, another developer should look over the code again and retest it. Once 2 developers have looked at the code then it would be reasonable to pass it to a QAer for use case testing. But it IS the developers' responsibility to test the functionality of their own code.</p>

OwnerDisplayName: bobbyz


答:
It is true that developers have a bias when testing their own code. This is both a positive and a negative. For one, they know where the tricky parts are and therefore can do a good job writing tests that target them. On the other hand, they can have blind spots to other areas of the code. It's very easy to fall into the trap of thinking "this path through the code can't possibly break" or "nobody would ever use the tool this way, why test it?".

Testing requires a pragmatic approach. If you can afford it, yes, you should have people other than the developers that wrote the code do some testing. Not all teams can afford such a luxury.

To answer your specific question, then, the answer is yes. It's quite reasonable for them to make such demands.

Title: Functional testing must be done by external party to avoid bias?

Body:
Our developers demand that someone external to the development team completes the functional testing. Their argument is that they are biased and cannot test their own code as they are too close to it. Our last round of testing is with the client in the form of UAT.

To be clear by 'functional testing' I mean testing the code against the specs, eg. when you click on 'submit' the index page should load. By UAT I mean the client comes in and runs through use cases on the release candidate.

While I understand this argument of bias, is it reasonable for the developers to demand someone else complete their functional testing or is this just a way to avoid doing their job?

OwnerDisplayName: Bryan Oakley


答:
If there's one thing more annoying than being asked to code productively in an environment you have no experience in, it's being on a team where no one has experience in the technology. The Blind Leading the Blind.

Get a Trainer/Coach/Consultant who knows the stack you're going to be moving to. Have them be part of the team and make them primarily responsible for helping your team. (Don't assign them any tasks, but ask them to rotate around and pair with the developers.) This will give your team an "old hand" to go to when they have questions about the new environment. (If you're already an agile team that does pairing, it will be easier on the uptake.)

Title: Should we choose Java over C# for a new project?

Body:
We have a team of .NET developers (C#) with a range of experience from 2 to 6 years. Over the last few years we have been developing Silverlight, ASP.NET MVC, and WPF applications. However, there is a new two year project which means we will develop a HTML5 application on Linux.

The company I work for would like all developers across their offices to use the same programming language which is Java. Although there is talk of using Mono but using the same language and sharing modules, services, etc. already created in Java is the main reason for moving to Java.

Some of the developers here are upset. How do I find something positive in moving over that will convince the other developers?

There will be a training budget, but the thought of learning to work with Java libraries and a new platform (Linux) will be scaring a lot of the guys.

What should I do?


答:
Not only is it a reasonable demand, but I think a necessity for creating a good product. The end user should be testing to ensure not only that the product works, but that the product does what they need it to do. A good relationship between the developer and a user testing in goodwill creates a far superior product than anything created and tested by only the developer.

That said...

A developer should test all the code he has written.

A developer should test all the code he has written again.

If possible, a developer should find another developer to test his code.

The end user should be running through the product before a final release to ensure it works well. They have a better understanding of the nuances of the data and in all likelihood will find a small detail that they forgot to tell you or something you just missed.

In summary, the developer should test his product well so when the user gets it there are no or very few obvious errors. However, an end-user should test the product to catch more of the non-trivial bugs and of course any obvious bugs that were missed. This is especially important in mission critical and/or large/complicated projects.


答:
It's a case of using what is popular/established versus new and presumed less tested. Has anyone gotten fired for using Apache? I'm sure a few websites running it have been hacked to the point of costing money, but did they blame Open Source or those responsible for a poor installation? What is the ironclad propriety alternative?

The question is an attempt to defend one solution, so what is the problem?. Your company doesn't want to use open source software and their arguement of instability is not substantiated by any anecdotal evidence. Create a side project and prove they're wrong. They can pay you the money they save on licensing fees.

Most companies don't publish bad news, so you're lucky if you can get the dirty version from the street.


问:
Choosing between CL and Python for web development
I'm coming from a Java background and after I read this little essay by Paul Graham I started wondering about picking up a new language namely Common Lisp to speed up my work (I'm a web developer).

I'm writing pet projects currently but I have some business plans for the future. Paul speaks about LISP in his essay as a "Secret weapon". I don't know if this statement is true after 10 years but I dipped my toes into a nice CL tutorial and it looks like that LISP may be superior for web development.

Paul also mentions Python as a nice choice which I actually familiar with. My question is: which one should I choose for my future web projects?

What I was thinking about:

I'm not going to develop desktop applications so I can choose whatever language I prefer.

python seems to have a very large community thus a mutch more libraries / frameworks compared to lisp

I found out that lisp has some functionality (like macros) which cannot be found anywhere else

I mostly work alone or with 1-2 other programmers but finding someone with lisp knowledge can be hard

So what do you think?

答:
I would recommend using Lisp if you are a self-motivated person that is amenable to working up your own libraries of code over long periods of time, enjoys pushing the limits of your language, and don't mind the occasional hitch in configuration. If you are self-employed, it's likely to be a productivity booster over the long run due to its macro features.

Python is not as flexible, as fast, or as powerful. It's nearly trivial to learn compared to many other languages. It is very Blubby, in fact. It has wide support, it is the fad language du jour, and has a ton of libraries. It's probably a bit better if you have to work with people who complain about learning new languages.

If I was reviewing for hire someone who was good in a Lisp compared to someone who was good in Python, I would immediately presume the Lisp person was a better programmer & computer scientist than the Python person (all other things being equal).

I am atrociously biased, I'm sure.


问:
I'm questioning my education choice because they say there's no place for old programmers

Possible Duplicate:

  How old is "too old"?

I'm about to start CS next year. I love both the coding and the mathematical aspects of programming. However, recently I encountered multiple rants about how it's impossible to actually be a programmer over 45, unless you're in a managing position or filling a very specific niche.

Any advice?
I'm seriously questioning my career choice here, and would be grateful for some input.

答: In about 1984 before I started college in CS (1985) and probably before you were born, I read an article in Omni magazine that advised against going into CS because by 2000 there would be no jobs for programmers since it would all be automated. In about 2003, Omni was closed down and I have never regretted being a programmer. Tech related jobs can gainfully employ every human on the planet and will in some form over time. There are plenty of old programmers.</p>

OwnerDisplayName: ecaligo

OwnerDisplayName: joemooney


答:
Insteaad of fixating on age and whether or not you're too old for programming, you should focus on the fact that you actually do love programming and the aspects of it. As long as you have the desire and drive to get into the field and you enjoy it, you'll find something eventually.

Besides, worse case you can always freelance or become a teacher ;)

Title: I'm questioning my education choice because they say there's no place for old programmers

Body:
Possible Duplicate:

  How old is "too old"?

I'm about to start CS next year. I love both the coding and the mathematical aspects of programming. However, recently I encountered multiple rants about how it's impossible to actually be a programmer over 45, unless you're in a managing position or filling a very specific niche.

Any advice?
I'm seriously questioning my career choice here, and would be grateful for some input.


答:
There is some truth in the idea that older people (like me) can't easily do the jobs that young programmers do. That's because young programmers mostly lack the ability to think, and rely on mindless memorization of a huge number of facts and associations, and tools (like auto-completion) that restrict their choices enough to avoid the bulk of errors they would otherwise produce. We used to call this "canned programming" (like heating a can of soup or whatever for dinner, rather than real cooking), but today, since that's overwhelmingly what programmers do, it's a seldom used term.

Older people can't in general do this mindless kind of programming because (1) our brains have sacrificed the memorization ability for ability to reason (like, heuristics, example problems/solutions, so on), and because (2) it is to large degree a social thing, picking up hints about the latest ephemeral mayfly technology from one's multitude of friends & online activity.

Conversely, where the programming calls for some reasoning ability, older people are best.

Here's a science fiction book that is both fun and interesting, dealing with this problem:

Rainbow's End by Vernor Vinge.

Cheers & hth., only my opinions of course,

OwnerDisplayName: Alf P. Steinbach


答:
I've done this and not particularly well.  Here's some tips from experience:

1)  Don't go dark.  HLGEMs answer of checking in every day is a great one.  Also bill promptly or on a pre-established schedule.  In many cases the trust you've established as an employee erodes quickly as a contractor, you want to be as transparent and visible as possible.  Also consider any travel or deadline obligations you might have with the new position and how that might affect your ability to do two jobs.  Set expectations accordingly and live up to that standard.

2) As far as staying synched up with the rest of the team, make sure you send regular emails/IMs/wiki updates just saying what you're working on and reminding people you're out there.  In a less formal way, try to get a couple former coworkers to keep you in the loop.  Depending on how much of a problem this is, you might commit to taking a late lunch once a week and calling someone just to "water cooler chat" and keep the communication channel open.

3)  Decide how long you want to do this.  If you want to work two jobs, I would suggest setting up a retainer and/or an agreed support level (Up to x hours a week/month).  Unlimited support on two jobs will burn you out and there will always be priority conflicts.  If you're just helping out, you should provide incentive for your former employer to replace you quickly so you can move on.  In that case I would charge at least 3x your previous salary as your hourly rate.  That's fairly standard as they're no longer providing you any benefits other than a paycheck.  If you want to stick with it for awhile you might pick a smaller number.

4)  Assuming this is in US, familiarize yourself with 1099s and how this will affect your tax situation.  There are a lot of wrinkles that aren't obvious if you've been a "normal" employee all your life.

Body:
Assuming:

The employee and company are parting on good terms

The new company is OK with a little contract work as long as it doesn't distract from the new job

The former company wants the help and the employee is willing to work a few hours a week

Is it a good idea to do contract work for a former full time employer?

Has anyone ever done this?  How did it work out for you?  I can see some possible pitfalls, so I wonder how good an idea it really is.  What difficulties do you encounter doing development work outside the office and on a different schedule from the rest of the programming staff and how can they be overcome?

If I  do go forward, what would be a fair amount to request as compared to current salary?


答:
To counter the argument of OSS as risc factor I like to give the counter-example of SAP, which is often cited as a major factor in insolvencies of small and medium enterprises - one example is given here: http://www.intl-spectrum.com/article/359/Migration_to_SAP_from_U2_Causes_Bankruptcy_of_Company.aspx

This claims to be a list of the top 10 corporate IT failures: http://www.computerworld.com/computerworld/records/images/pdf/44NfailChart.pdf

It lists introductions of SAP products three times.


问:
function pointers are so complex to me
I found this code sample in this answer by Armen Tsirunyan.

```<code>class MyClass
{
   public:
   typedef void (*funcPtr)(int, int);
   MyClass(funcPtr whatToCall)
   {
     callme = whatToCall;
   }
   void myClass::callMain()
   {
       callSomeApi(callme, <some arguments>);  //callme function pointer is passed as argument
   }
private:
   funcPtr callme;
};

void f(int a, int b) {blah blah blah};

int main()
{
   MyClass myObject(f);
   myObject.callMain(); //will call the api function with f passed as argument
}
</code>```

I would like to know the advantages to use such a function pointer as a class member. If there are more, I should be overwhelmed to their uses and calls. Do you have some tips to help me memorise its usage?

答:
Function pointers as class members are very useful for customization.  The example I'm most familiar with comes from Delphi's visual component library, but it would be equally valid for C++.

Delphi ships with a widget library called the VCL.  There's a control for a form, a control for a button, a control for a textbox, etc.  Each of these is its own class.  It has a form designer so you can create forms visually.  But once you do that, all you have is a layout.  Then what?

This is where function pointers come in.  If you placed a button on the form, you need to specify what that button is supposed to do.  It has a function pointer member for that.  You write an event handler (a method whose signature corresponds to the signature of the function pointer) and attach it to the button's OnClick event, (event = function pointer,) and then at runtime, when you click the button, there's code that says "if this event handler is assigned, call it."

That makes the button customizable beyond the basic functionality that's built into it.  For stuff like generic widgets, that's essential, because they can't hard-code what the button is supposed to do in your program into the basic button object.  Events and event handlers is a very useful pattern to know anytime you need to write a similarly customizable object.

Title: function pointers are so complex to me


问:
What are the most common mistakes and anti-patterns NHibernate user programmers make?
What are the most common mistakes and anti-patterns NHibernate user programmers make? Please explain why those are bad practices or give link to resource for further reading.

For example:

One anti-pattern common for new NHibernate programmers is to use identity/native POID's instead of ORM style onces. Read more here...

答:
The "Select N+1 Problem".

This is where you end up executing A select for each entity you want to manipulate (N), and a select to get the list of entities (+1), instead of a single select of all entities and their attributes.

OwnerDisplayName: Darius Kucinskas


问:
Making money from developing Open Source Software. How does that work?

Possible Duplicate:

  Making money with Open Source as a developer?

I've been hearing recently that more and more developers contribute their efforts to many open-source products. Being a novice in many aspects of software development I've never thought about myself as being a member of a team that builds a product almost anybody can use for free.

But this trend is getting more and more attention, and today it is almost considered that any self-respected software engineer should have at least one example when they participated in an open-source project. It gives you a few more credits on the interview, it's cool, it means something very good, especially if the product is popular and successful. However, it seems that it's not just cool, but somehow it is prosperous business today. Not just some students or passionate enthusiasts anymore, but well known developers quit their jobs and start spending most of their time in that sector, proprietary companies spend good amount of money to support them.

I understand there are many different types of licensing and stuff. But I simply don't understand, how those developers get paid? How the companies make their revenue of it? I don't believe that behind all that is just people's altruistic nature, and they just happy to work for virtually nothing.

Can you explain me taking any well known project as an example, the business model of it?

How can somebody participate? What should you know first? How can you monetize your efforts? Is there any "guide to beginners" or "complete manual for idiots" to start with?

答:
Consulting is huge.  Just because a piece of software is open source, it does not mean it is easy to configure and/ or use.  If you are a subject matter expert on something like, say MySQL, you can definitely charge to build and/ or support a MySQL implementation.

Support and customization I think are the biggest moneymakers.

OwnerDisplayName: Agzam

OwnerDisplayName: Jeremy


答:
The short answer is that there are several kinds of open source:

Open source with no intention of making money - GNU, most Apache projects, Wiki, etc (and possibly beg for donations)

Open source with the intention of making money - MySQL, formerly Solr¹, Cloudera²

Technically open source, but not in spirit - Android³

Does that make sense?

¹ Most committers were from one company, and they deliberately didn't fix add in outside commits that fixed stuff because their main business was Solr consulting/setup! The Solr project has since been restructured due to complaints by members outside this company.

² Cloudera has their own Hadoop distribution, and they make money consulting.

³ Android has an open source license but is not a community project. All developers are employees of Google and no outside input is accepted.

Title: Making money from developing Open Source Software. How does that work?

Body:
Possible Duplicate:

  Making money with Open Source as a developer?

I've been hearing recently that more and more developers contribute their efforts to many open-source products. Being a novice in many aspects of software development I've never thought about myself as being a member of a team that builds a product almost anybody can use for free.

But this trend is getting more and more attention, and today it is almost considered that any self-respected software engineer should have at least one example when they participated in an open-source project. It gives you a few more credits on the interview, it's cool, it means something very good, especially if the product is popular and successful. However, it seems that it's not just cool, but somehow it is prosperous business today. Not just some students or passionate enthusiasts anymore, but well known developers quit their jobs and start spending most of their time in that sector, proprietary companies spend good amount of money to support them.

I understand there are many different types of licensing and stuff. But I simply don't understand, how those developers get paid? How the companies make their revenue of it? I don't believe that behind all that is just people's altruistic nature, and they just happy to work for virtually nothing.

Can you explain me taking any well known project as an example, the business model of it?

How can somebody participate? What should you know first? How can you monetize your efforts? Is there any "guide to beginners" or "complete manual for idiots" to start with?

OwnerDisplayName: GatoVolador


答:
Quite simply, they shouldn't, and should never be used unless you have to be binary compatible. Boost, TR1 and C++0x all offer a vastly superior solution in the form of function<>, a class template which can accept function pointers and function objects like those produced by bind and lambda functions. Function pointers are a major code smell in C++.

Basically, they are code that can be swapped in and out at run-time. This enables you to write code that performs a function without having to actually know what that function does- Mason provides the excellent example of a button. Without such function objects, it would be near impossible to write a generic button.

Title: function pointers are so complex to me

Body:
I found this code sample in this answer by Armen Tsirunyan.

```<code>class MyClass
{
   public:
   typedef void (*funcPtr)(int, int);
   MyClass(funcPtr whatToCall)
   {
     callme = whatToCall;
   }
   void myClass::callMain()
   {
       callSomeApi(callme, <some arguments>);  //callme function pointer is passed as argument
   }
private:
   funcPtr callme;
};

void f(int a, int b) {blah blah blah};

int main()
{
   MyClass myObject(f);
   myObject.callMain(); //will call the api function with f passed as argument
}
</code>```

I would like to know the advantages to use such a function pointer as a class member. If there are more, I should be overwhelmed to their uses and calls. Do you have some tips to help me memorise its usage?


答:
Function pointers are critical for customizing runtime engines that need to be able to call user specified code in response to known events.  The biggest utility of a function pointer is the callback.

Consider a graphics library.  Let's suppose that you're writing a class-based graphics library.  You want the user to be able to specify their own Draw function so they can draw whatever they want, but you want your library to call their Draw function any time the screen needs to be redrawn (maybe the draw window was covered up by another window for a moment, or maybe the draw window was minimized and maximized again) - regardless of why, you want your library to handle it without the user having to call it over and over again.  (That's part of the whole point of your library, right?)

Well, how can your library possibly know what function to call?  You've got a couple of options.  First, you could insist that they name their function  void Draw()  and include it somewhere that your library can get to..  not particularly useful.  The second is you can allow your library to accept a function pointer to their draw function:

```
class BabyDolphinDrawLibrary
{
private:
    void (*RedrawCallback)();

public:
    void OnRedraw( void(*redrawCallback)() );
    void Redraw();
};

void BabyDolphinDrawLibrary::OnRedraw( void(*redrawCallback)() )
{
    RedrawCallback = redrawCallback;
}

void BabyDolphinDrawLibrary::Redraw()
{
    RedrawCallback();
}
```

Then, the user specifies they want some function they've declared to be called by your code any time a redraw needs to happen:

```

#include "BabyDolphinDrawingLibrary.h"
void myDrawingCode()
{
   // daVinci eat your heart out.
}

int main()
{
    BabyDolphinDrawLibrary render;
    render.OnRedraw(myDrawingCode);

    render.Redraw();
}
```

This is a fairly rough example, as graphics engines generally don't get instantiated as an object, but this gives you an example of how it gets put to use.  Similarly with buttons on a GUI, as @Mason Wheeler pointed out.  You have a GUI framework, and the button has something along the lines of an OnClick function pointer.  You tell the Button what function to call when it's clicked.

Title: function pointers are so complex to me

Body:
Function pointers are critical for customizing runtime engines that need to be able to call user specified code in response to known events.  The biggest utility of a function pointer is the callback.

Consider a graphics library.  Let's suppose that you're writing a class-based graphics library.  You want the user to be able to specify their own Draw function so they can draw whatever they want, but you want your library to call their Draw function any time the screen needs to be redrawn (maybe the draw window was covered up by another window for a moment, or maybe the draw window was minimized and maximized again) - regardless of why, you want your library to handle it without the user having to call it over and over again.  (That's part of the whole point of your library, right?)

Well, how can your library possibly know what function to call?  You've got a couple of options.  First, you could insist that they name their function  void Draw()  and include it somewhere that your library can get to..  not particularly useful.  The second is you can allow your library to accept a function pointer to their draw function:

class BabyDolphinDrawLibrary
{
private:
    void (*RedrawCallback)();

public:
    void OnRedraw( void(*redrawCallback)() );
    void Redraw();
};

void BabyDolphinDrawLibrary::OnRedraw( void(*redrawCallback)() )
{
    RedrawCallback = redrawCallback;
}

void BabyDolphinDrawLibrary::Redraw()
{
    RedrawCallback();
}

Then, the user specifies they want some function they've declared to be called by your code any time a redraw needs to happen:

#include "BabyDolphinDrawingLibrary.h"
void myDrawingCode()
{
   // daVinci eat your heart out.
}

int main()
{
    BabyDolphinDrawLibrary render;
    render.OnRedraw(myDrawingCode);

    render.Redraw();
}

This is a fairly rough example, as graphics engines generally don't get instantiated as an object, but this gives you an example of how it gets put to use.  Similarly with buttons on a GUI, as @Mason Wheeler pointed out.  You have a GUI framework, and the button has something along the lines of an OnClick function pointer.  You tell the Button what function to call when it's clicked.


答:
The majority of employees are using opensource as part of their company's work and contribute fixes back.

I have used openCV, openscenegraph, wxWidgets and many other projects in commercial products  and have contributed back improvements I have made with my employers blessing.

Basically it was worth a great deal to my company to have a good graphics library but since we made a very specialist product it wasn't much of a business threat that a competitor would benefit enough from also having access to some fixes to the same library that it would outweigh our expertise in our industry sector.


答:
Sometimes this is the easiest client to start off with. You really have to make sure to identify how the ground rules have changed.  You can also do this to if you are reluctant to leave in the middle of a project. Offer it as a suggestion if you feel you're going to be downsized, but make sure you're able to look for a full-time job.

Even if you have no intentions of going back, the people at your old firm can be a great source of referals.

It really gets interesting when they don't want to use you as a consultant, something goes wrong (they thought they could do it without you) and now they want to 'hire' you. They may think they can pay you the same salary and not factor the differences between an employee and the over-head a consultant has to cover. They feel taken advantage of in their time of need.

Title: Is it a good idea to do contract work for a former full time employer?


问:
Why is there still case sensitivity in some programming languages?
I don't see any use for case sensitivity in a programming language, apart from obfuscating code.

Why implement this in a programming language?

Update:

It looks like someone you know made a statement on this.

答:
When a language is case-sensitive, I take advantage of it to reproduce conventional case usage in mathematics and science. Here is a list (by no means exhaustive) of some case conventions:

In probability theory, lower case f usually represents a probability density function (pdf), while upper case F represents the corresponding cumulative distribution function (cdf).

Also in probability theory, upper case letters denote random variables X, and the corresponding lower case letters denote their realizations x, as in $Pr[X=x] \leq  0.05$.

In linear algebra, upper case letters are generally used to refer to matrices while lower case letters generally are used to refer to numbers, e.g., $A=[a_{ij}]$.

Unit symbols are written in lower case letters (e.g., m for meter) except for liter (L) and those units derived from the name of a person (W for Watt, Pa for Pascal, N for Newton, and so on).

Symbols of prefixes that mean a million or more are capitalized (M for mega (millions)), and those less than a million are lower case (m for milli (thousandths)).

ContentLicense: CC BY-SA 2.5


答:
Sorry for the double-answer, but seeing the original post makes it a lot more clear what you're looking for, and it's a related but kind of different use of function pointers.  What you have there is a callback.

Let's say you want a function to download a file from the Internet.  So you write:

```<code>void DownloadFile(std::string URL, std::string discLocation);
</code>```

Now, that's great, right up until you try to download a very large file.  Suddenly DownloadFile is taking a long time to finish, and you don't know how long it'll be.  Boy, things would be a lot easier if you only had a progress indicator of some sort to let you know how far along you are!  But DownloadFile can't return until it's finished, and you don't want to teach DownloadFile itself about your progress indicator, because that would lead to high coupling and make it harder to reuse DownloadFile in another context.

What you can do instead is give it a callback, a function pointer that DownloadFile uses to call you back after you call it.  In fact, you'd probably want two:

```<code>void DownloadFile(std::string URL, std::string discLocation,
  intFunction FileSize, intFunction FileProgress);
</code>```

(Where intFunction is a function pointer that takes one int as an argument.)  It would call FileSize once to set the size of the file, and FileProgress repeatedly to inform you of how far along it is in the download.  With these two pieces of information available, you can wire up a progress bar or some other type of progress indicator, without having to couple DownloadFile directly to the progress bar control.

That's the sort of power that callbacks make available.  You see them a lot in code that deals with long-running events.  Downloads, for example, or code for playing sound and music.  In a music callback, you can perform custom edits to the sound as it's being played to add effects, or read the sound buffer and display a representation of it on an equalizer.

Title: function pointers are so complex to me

Body:
Sorry for the double-answer, but seeing the original post makes it a lot more clear what you're looking for, and it's a related but kind of different use of function pointers.  What you have there is a callback.

Let's say you want a function to download a file from the Internet.  So you write:

void DownloadFile(std::string URL, std::string discLocation);

Now, that's great, right up until you try to download a very large file.  Suddenly DownloadFile is taking a long time to finish, and you don't know how long it'll be.  Boy, things would be a lot easier if you only had a progress indicator of some sort to let you know how far along you are!  But DownloadFile can't return until it's finished, and you don't want to teach DownloadFile itself about your progress indicator, because that would lead to high coupling and make it harder to reuse DownloadFile in another context.

What you can do instead is give it a callback, a function pointer that DownloadFile uses to call you back after you call it.  In fact, you'd probably want two:

void DownloadFile(std::string URL, std::string discLocation,
  intFunction FileSize, intFunction FileProgress);

(Where intFunction is a function pointer that takes one int as an argument.)  It would call FileSize once to set the size of the file, and FileProgress repeatedly to inform you of how far along it is in the download.  With these two pieces of information available, you can wire up a progress bar or some other type of progress indicator, without having to couple DownloadFile directly to the progress bar control.

That's the sort of power that callbacks make available.  You see them a lot in code that deals with long-running events.  Downloads, for example, or code for playing sound and music.  In a music callback, you can perform custom edits to the sound as it's being played to add effects, or read the sound buffer and display a representation of it on an equalizer.


问:
When should you rewrite?

Possible Duplicate:

  When is a BIG Rewrite the answer?

In Joel Spolsky's famous (or infamous) article Thins You Should Never Do, Part I, he makes the case that doing a rewrite is always a wrong move because:

It automatically puts you behind (your competitors/schedule/etc.)

The code probably isn't as bad as the programmers believe (anything someone else wrote is always a mess, although some are bigger messes than others - and even then)

It's probably easier/quicker/cheaper to fix what's truly wrong with it than to rewrite from scratch.

In rewriting from scratch, you are probably going to re-introduce bugs that were fixed in previous versions the original code.

Instead, he recommends fixing what's wrong with the code.

I assume this is a good summary of his post, and I'll postulate that it is generally true.

I'm trying to collect a set of rules/guideline for my team, and one of them (based on Joel's article) is

```<code>We don’t re-write ... ever!
- But we can refactor large portions of the code.
  (this exception takes care of ugly/problematic code issues)
</code>```

One question that has cropped up is "What about when technology changes and you can no longer get support for older versions?". This is what I think of as the Sisyphean Upgrade path.

E.g., I recall when Oracle moved from SQL*Forms 2.x/3.x through to Forms 6i and beyond, Forms that were originality developed in the old .inp format were no longer supported with the current version of Oracle and Oracle Forms.

So you had a choice of sticking with an unsupported database with unsupported tools or rewriting the Forms from scratch (or converted with 3rd party tools and then gone over with a fine toothed comb). Which I will call porting, particularly when you are doing a faithful line by line/function by function translation into the new tech and not adding any functionality.

The rule then became:

```<code>We don’t re-write ... ever!
- But we can refactor large portions of the code.
- And we can port the code to a new platform when we *truly* have no other
  choice.
</code>```

(and by truly I mean, you can't even buy your way out of the problem for 2x the cost of porting it)

Are there any other exceptions that I've missed?

答:
Probably...but

There are probably additional exceptions - at some point 'large scale refactoring' and 'rewriting' are indistinguishable - when every line of code changes!

But what I'm wondering is: what is the purpose of making hard-and-fast rules for situations you have yet to encounter? Joel's example was an extreme case (NetScape) not a common case. If you have the wrong design or have outgrown the architecture or changed platforms et al, rewriting may be a valid option. If your team never gets to that point, then the rules debate is a waste of breath. When you get to that point, the situation may be so different that the hard-fought rules you come up with today no longer apply.

Title: When should you rewrite?


问:
Making money with Open Source as a developer?
I'm currently a student (Applied Information Technology) and we do most of our programming in C# and Java. I was wondering how can I as a developer, make money with open source. I know there is the story of give support, or provide services, but I'm not a sysadmin and I don't like sysadmin work. Actually I would love to get my hands on some C and C++ in the future and do some low level development.

So my actual question is: Is there money to be made with the development of Open Source software, and how?

Edit: Just pointing out that starting my own Open Source project is not a requirement.

答:
Make a website about an opensource product (your application, a forum, a support site, etc.), and place some ads in there.

That would do the trick.

OwnerDisplayName: Haproli

OwnerDisplayName: friol


答:
Because you are the creator of this system, you are the 'ultimate expert'. For-profit companies that use or wish to use your software may bring you in for some consulting work. Also, you would qualify to speak at conventions which i hear is well paid.

Contributing code to an existing project is also a good way to get your name out there. The more you contribute, the more cred' you have when looking for contract work.

Title: Making money with Open Source as a developer?

Body:
I'm currently a student (Applied Information Technology) and we do most of our programming in C# and Java. I was wondering how can I as a developer, make money with open source. I know there is the story of give support, or provide services, but I'm not a sysadmin and I don't like sysadmin work. Actually I would love to get my hands on some C and C++ in the future and do some low level development.

So my actual question is: Is there money to be made with the development of Open Source software, and how?

Edit: Just pointing out that starting my own Open Source project is not a requirement.

OwnerDisplayName: Dimitry


答: If you actually want to make money by making your own open source project, I think it is a pretty long shot. On the other hand, there are many well paid jobs that require work with Open source technologies or developing open source software in companies like Red Hat, Sun, IBM, even Microsoft.</p>

OwnerDisplayName: Nemanja Trifunovic


答:
Here's an example.

If you hang around in the Qmail community, you'll find there's a few people who know Qmail inside out. Just a couple of them become the go-to guys if you want an extension to Qmail's functionality. They get contracting jobs which involve them sitting at home, writing a Qmail extension, and getting paid for it.

If that sounds like a lifestyle you could go for, try it - find a niche, and take contract jobs. You might offer different terms to your clients, depending on whether they wanted to own the code you produce closed-source, or whether you release the code as open source, but they get to use it.

Think of it this way - there's lots of situations where the client simply wants this code to exist. They don't then care whether or not they have exclusive access to it.

OwnerDisplayName: slim


答:
I've made money inadvertently through open source software, as has a friend. We had similar cases, but I'll only talk about my own: I wrote an open source VCDiff decoder, basically because the spec looked nice. (Long story, but I was originally going to write it on company time, but ended up doing it on a Friday night instead.)

A few years later, I was approached by a company which wanted to use it in a commercial package, but without the required attribution. They were happy to pay a licence fee for this, and presented me with an extremely reasonable non-exclusive licence. We did the deal, and both sides were happy.

The aim was never to make money - that just happened as a side-effect of producing something that another party wanted, basically.

OwnerDisplayName: Jon Skeet


答: In my experience, writing OSS doesn't give you any money; but it does makes you a lot more valuable, and therefore employable.  Both because of the highly-tuned abilities you get from practice, and because when you're able to use existing OSS, your familiarity with the ecosystem lets you waste far less time evaluating what's already there to avoid rewriting the wheel.</p>

OwnerDisplayName: Javier


答:
Most of the time, businesses make money using the beekeeper model.  Essentially, your open source contributors get to use your latest and greatest for free while your customers get a reliable, mature product.  Red Hat, Novell, and Sun all use variations of this model.

Another option is consulting and training.  If you have a lot of experience using a certain product (or better yet, you invented it), then people may be willing to pay you money to teach them to use it.  This is the model that Canonical uses.  This doesn't necessarily mean that you have to do sysadmin type work unless that's your thing.  After all, programmers, end users, and executives need training too.

Thirdly, as a student, you should seriously consider Google Summer of Code next summer.

Overall, I'd say that open source contributions are worth it whether or not you directly make money off of them.  Although, I'm afraid that you probably won't realize the benefits in the short term.

OwnerDisplayName: Jason Baker


答:
Just developing an open source software project probably isn't going to make you much money. Providing premium support, customizations, etc. can. I make a pretty good chunk of change on the side by developing extensions and custom builds of Firefox, Thunderbird, Red5, and a few other open source projects. A large part of what I create is also provided back to the open source community.

There is also the possibility of a dual-licensing system. For instance, you can release the software under a GPL type license, and also under a commercial license where somebody who purchases a commercial license is allowed to keep any modifications proprietary and to sell it without releasing the source code.

OwnerDisplayName: Gerald


答:
By its nature, you can't generally make money from the code directly - since it's open. You could dual-license, but that can put the OSS community off, too.

Possibly the easiest way is to work for a company which produces open source software. You get paid for writing code, and the company makes money from support or whatever, but you don't have to be involved with that side of things directly.

Or you can write OSS to build a rep and hopefully get contract work / full-time work on the back of it.

OwnerDisplayName: Draemon


答:
The answer to your actual question

is there money to be made with the development of Open Source software, and how?

Is yes, and there are different ways. If you just want to be a developer, i.e. not starting your own business, the best thing to start with is to participate to the project(s) you like. Then, you might find opportunities like this: http://webapps.ubuntu.com/employment/canonical_GDOS/ (there are many of those in different fields, MySQL, just to mention another "big" name).

Then, create your profile on LinkedIn and join the OSS groups relevant to your skills and/or interests.

Last, but not least, join a local group (e.g. LUG, JUG) and read the mailing list. Often in those lists many job offerings appear (unfortunately I discovered only after I get the job).

OwnerDisplayName: Davide


答:
I think a common scenario is that they have paid jobs as well. A lot of open source work derives from developers' spare time, and from elements of their paid work.

An example might be creating a solution to solve a specific problem at work, and open sourcing the solution to help other developers faced with a similar scenario.

OwnerDisplayName: Mark Embling


答:
It really depends. Many just do open source development as a hobby, and have a day job (which is often, though not always, software development as well).

Some are paid by companies which have an interest in the open source project. LWN.net posted an article about who pays Linux kernel devs, for example:

http://lwn.net/Articles/222773/

Turns out many companies fund Linux kernel development, and not only Linux distributors.

Some developers also run a consulting business, and use software development to support their main work, or as a showcase.

OwnerDisplayName: sleske


答: Nowadays, some (a lot ?) of companies pay developper to contribute to opensource software as their business is based on opensource software or derived from opensource software.</p>

OwnerDisplayName: neuro


答:
Some open source software companies provides services and earn money. (Like application hosting etc) In most cases they provides some customizations according to the customer's requirement and provides support and maintenance over time.

I don't think the "Donations" can make a big change but there is some impact from them as well.

This is one good example for a Sri Lankan company that is based on opensource products.

WSO2

OwnerDisplayName: Chathuranga Chandrasekara


答:
there are quite a few different ways

Funding by another company (take for instance google which pays Guido van Rossum to work on Python half of his time)

Selling support services

Selling consulting services

Building a profile for yourself through opensource hoping it leads to other things like speaking, book authoring, getting a good paid job

Spinning of a commercial version of the product for "enterprise" customers for instance

and then the biggest ones I think are extending their knowledge and getting love from users of their products.

OwnerDisplayName: olle


答:
You can do this a number of ways.  Right now the freemium model is popular.

Alternatively as others have posted open source work is sidelined.  The model I use is to use open source at my place of employment and contribute my contributions back to the mainline.  You need to have buy-in from management but it works.  Also remember in the words of Stallman Free as in Freedom


答:
I see two questions here:

1) How do developers make money.

Most developers don't do it for the money.The reasons may be many but if we narrow them down, it comes down to 1) Scratching an itch 2)For gaining credibility 3)To enhance knowledge in that particular language/domain.

2)How do business' make money.

Usually from support, training ,certification and enhancement. But then the question arises : if your product is really good, then it won't need much support. So it has to be what Joel call's  Consultingware.

OwnerDisplayName: krishna


答:
There are two successful, profitable open source companies that I know reasonably well:

SleepyCat Software, until they were bought by Oracle, made money by supporting and enhancing Berkeley DB.  Although one of the founders had a day job, the other did not, and they had a dozen employees.

Chez Scheme makes money by adding enhancements to their compiler and by selling native-code versions of their compiler.  Typical enhancements might include a new back end; a more ambitious recent enhancement was a native threads package.  The founder (Kent Dybvig) has a day job; I don't know how many employees he has.  Chez is unusual in that the interpreter is open source but the compiler is not.

Cygnus and Red Hat both sell "support" as well as specialized versions of their software, but the software is also given away.  I don't really understand this business model.

What I take away from these examples is that if your software is outstanding in its class, people will pay you to help them use your stuff to solve problems.  So it's almost like consultancy.

OwnerDisplayName: Haproli

OwnerDisplayName: Norman Ramsey


答:
I think its an accepted fact by now that software, once installed becomes worth more than its price because it has now become "already there". I am speaking of more enterprise-style apps.

A lot of companies charge you when you purchase the software, then keep their foot in your door with maintenance contracts, winding up making more $$ from you that if you had bought it 7 times over. I know that is certainly the case where I work with some proprietary software that is >30 years old!

It just so happens that this software is free to install (think of it as the "free drugs at first" business model).  The challenge of course is picking a project that is well maintained and has a good support community online.  But then again that is the same with non-free software too.

Migrating onto and off of Open source tends to be a lot easier than proprietary apps because they tend to support open formats more often.  Proprietary apps will usually "give away" the service of migrating onto them, and other services to make it easier for you to stay with them.

O/S apps tend to have a higher learning curve at first which pretty much necessitates maintenance contracts, so there is plenty of opportunities to make $$

In my opinion, neither business model is better, just different.  The proprietary model just happens to be more widespread.

OwnerDisplayName: KevinDeus


答:
This answer summarises many of the answers to the following questions, along with some additional research and opinion.

Open Source: Balancing Altruism and making a wage

Making money with Open Source as a developer?

Synopsis

Open source can be a viable primary or auxiliary business model, both directly through specific project work and indirectly through the acquisition of skills, experience and reputation. There may also be additional, motivations; the satisfaction of producing software that is useful to others, the "scratching of one's personal itch" (the first step towards any good piece of open source software, according to Eric S. Raymond), or philosophical reasons, normally based around the notion of free software, either the copyleft approach advocated by Richard Stallman, or the more permissive approach of the BSD licenses.

Ways to earn money through Open Source

1. Sponsorship by a company

This can happen in several ways.

Permanent job to continue work on high-profile project. This is probably the rarest case. If you are a senior member of a major open source project, someone like Linus Torvalds, Guido van Rossum or Theo de Raadt, then you will probably be able to continue working on your project while being financially supported by a major company such as Google or IBM. Although this mode of support is relatively uncommon, you don't necessarily have to be an open source superstar to secure this type of funding; many Linux kernel developers are partially or wholly funded by companies like Red Hat.

Paid for specific features or extensions. Some companies offer bounties to have specific features implemented in open source software that they use for business functions. Often there is no need for the feature to remain closed source, so significant code is contributed back to the community. This has been described as the beekeeper model of open source development. In some cases the additional features are required to remain proprietary, but are based upon an open source codebase. In both cases, open source expertise is a clear advantage for a developer.

Your day job code can be open-sourced. A related case is where aspects of the code you write for a company in the course of your day-to-day job may be open-sourced without harm to the company. The code may or may not be based on an existing FOSS project. Generically useful tools and libraries may often be released in this way, and anecdotal evidence suggests such projects can often accelerate once they become volunteer-driven.

2. Add value to existing projects

An individual or company can position themselves as a primary provider that adds value to an existing open-source project or projects. There are many examples of companies who provide a service by packaging, layering, combining or extending existing projects. They broadly fall into two categories.

Support. Enthought adds value by packaging a custom Python distribution focusing on scientific libraries. Redhat and the other Linux distributions add value by collating and testing many disparate open source projects, and providing easy-to-use install and upgrade mechanisms. These companies sell support services in the same way as many proprietary providers do.

Freemium model. Under this model, a basic version of the software or service is free; additional 'premium' features normally cost extra. Sleepycat software provided extra features for the Berkeley DB under a proprietary license. Cedega provides a reimplementation of the Windows API under Linux, released as a mixture of free and proprietary code. This model need not be open source; Gmail for organizations is one example of a service that offers both free (as in beer) and premium options.

3. Offer code under a dual-licensing model

A powerful approach is to offer software under two alternative licenses, a copyleft license requiring modifications to be released back to the community if the software is distributed, and a commercial license allowing the use of the software without open-source restrictions. This approach has been successfully applied by large projects such as Qt and Open Office, as well as to small one-off projects.

4. Consult

Open-source work can provide a way to gain valuable community visibility.

Showcasing of abilities. Being able to verify a developer's work and competence by looking at open source projects they have been involved in is a powerful draw for prospective employers.

Reputation building. Having a high profile reputation in an open source community can lead to speaking engagements, training requests or book writing offers based on your expertise.

Being the expert. Being a significant player in a technology that companies need, means being in demand for custom consulting, support and training in that technology. This can lead to the creation of a specific job niche in your area of expertise.

5. Auxiliary channels

Finally, income can be derived through auxiliary channels such as advertising (as Stackoverflow does), donations, or through the use of nagware techniques in the software itself that aim to annoy a user into providing financial contributions to the author. These techniques are not specific to Open Source development models. For example, they are often used by non-free shareware products.


问:
Is learning how to use C (or C++) a requirement in order to be a good (excellent) programmer?
When I first started to learn how to program, real programmers could write assembly in their sleep. Any serious schooling in computer science would include a hefty bit of training and practice in programming using assembly. That has since changed, to the point where I see Computer Science degrees with assembly, if included at all, is relegated to one assignment, and one chapter, for a total of two weeks' work out of 4 years' schooling.

C/C++ programming seems to have followed a similar path. I'm no longer surprised to interview university graduates who have not spent more than two weeks programming in C++, and have only read of C in a book somewhere. While the most serious CS degrees still seem to include significant time learning and using one or both of the languages, the trend is clearly towards less enforced C/C++ in school.

It's clearly possible to make a career producing good work without ever reading or writing a single line of C or C++ code.

Given all of that, is learning the two languages worth the effort? Are they at all required to excel? (beyond the obvious, non-language specific advice, such as "a good selection of languages is probably important for a comprehensive education", and "it's probably a good idea to keep trying out and learning new languages throughout a programmers' career, just to stretch the gray cells")

答: It is not necessary to learn C or C++ to be a good (excellent) programmer however it is necessary to learn Assembly in order to be a good (excellent) programmer.  Excellent programming means optimizing across memory, Mhz, bandwidth, power constraints and then choosing the best design and/or implementation to accomplish the task at hand.  Among computer scientists the primary weakness is still, after decades of evolving technologies, with managing data optimally.  This is a set of skills taught by writing Assembly (any assembly; it could be ARM, or MIPS, or x86, or a microcontroller, or a DSP, or even lower than that, via verilog/VHDL).</p>