问:
Is writing software in the absence of requirements a skill to possess or a situation I should avoid?
I find that some software developers are very adept at this, and often times are praised for their ability to deliver a working concept with abstract requirements. Frankly, this drives me crazy, and I don't like "making it up" as I go. I used to think this was problematic, but I've started to sense a shift, and I'm wondering if I need to adjust my thought (and programming) process when given very little direction. Should I begin to acquire this ability as a skill, or stick to the idea that requirement's gathering and business rules are the first priority?</p>

答:
I've often found that in some situations I need to act as a business analyst, discovering exactly how the business currently works, how people think it works (often very different things), and how they would like it to work.

I've found success by always being clear about the decisions I'm being forced to make in order to build the software. I explain my reasoning, write documentation on what I've discovered, make graphs and distribute them to everyone, etc.

You probably won't make a very good impression by refusing to do any work until complete requirements are handed over. But by gathering good quality requirements yourself (without necessarily drawing attention to the fact), you will reach the same goal of quality software.

And yes, as other commenters have said, always build the software assuming that it will change. Change is the one constant you can rely upon. Always build your software flexible and modular enough so that it won't be painful to update it when some new requirements suddenly appear.


问:
get weighted random item
I have, for example, this table

```
+-----------------+
| fruit  | weight |
+-----------------+
| apple  |   4    |
| orange |   2    |
| lemon  |   1    |
+-----------------+
```

I need to return a random fruit. But apple should be picked 4 times as frequent as Lemon and 2 times as frequent as orange.

In more general case it should be f(weight) times frequently.

What is a good general algorithm to implement this behavior?

Or maybe there are some ready gems on Ruby? :)

PS

I've implemented current algorithm in Ruby https://github.com/fl00r/pickup

答:
Already present answers are good and I'll expand on them a bit.

As Benjamin suggested cumulative sums are typically used in this kind of problem:

```<code>+------------------------+
| fruit  | weight | csum |
+------------------------+
| apple  |   4    |   4  |
| orange |   2    |   6  |
| lemon  |   1    |   7  |
+------------------------+
</code>```

To find an item in this structure, you can use something like Nevermind's piece of code. This piece of C# code that I usually use:

```<code>double r = Random.Next() * totalSum;
for(int i = 0; i < fruit.Count; i++)
{
    if (csum[i] > r)
        return fruit[i];
}
</code>```

Now to the interesting part. How efficient is this approach and what's most efficient solution? My piece of code requires O(n) memory and run in O(n) time. I don't think it can be done with less than O(n) space but time complexity can be much lower, O(log n) in fact. The trick is to use binary search instead of regular for loop.

```<code>double r = Random.Next() * totalSum;
int lowGuess = 0;
int highGuess = fruit.Count - 1;

while (highGuess >= lowGuess)
{
    int guess = (lowGuess + highGuess) / 2;
    if ( csum[guess] < r)
        lowGuess = guess + 1;
    else if ( csum[guess] - weight[guess] > r)
        highGuess = guess - 1;
    else
        return fruit[guess];
}
</code>```

There is also a story about updating weights. In the worst case updating weight for one element causes the update of cumulative sums for all elements increasing the update complexity to O(n). That too can be cut down to O(log n) using binary indexed tree.

ContentLicense: CC BY-SA 4.0

Title: get weighted random item

Body:
Already present answers are good and I'll expand on them a bit.

As Benjamin suggested cumulative sums are typically used in this kind of problem:

+------------------------+
| fruit  | weight | csum |
+------------------------+
| apple  |   4    |   4  |
| orange |   2    |   6  |
| lemon  |   1    |   7  |
+------------------------+

To find an item in this structure, you can use something like Nevermind's piece of code. This piece of C# code that I usually use:

double r = Random.Next() * totalSum;
for(int i = 0; i < fruit.Count; i++)
{
    if (csum[i] > r)
        return fruit[i];
}

Now to the interesting part. How efficient is this approach and what's most efficient solution? My piece of code requires O(n) memory and run in O(n) time. I don't think it can be done with less than O(n) space but time complexity can be much lower, O(log n) in fact. The trick is to use binary search instead of regular for loop.

double r = Random.Next() * totalSum;
int lowGuess = 0;
int highGuess = fruit.Count - 1;

while (highGuess >= lowGuess)
{
    int guess = (lowGuess + highGuess) / 2;
    if ( csum[guess] < r)
        lowGuess = guess + 1;
    else if ( csum[guess] - weight[guess] > r)
        highGuess = guess - 1;
    else
        return fruit[guess];
}

There is also a story about updating weights. In the worst case updating weight for one element causes the update of cumulative sums for all elements increasing the update complexity to O(n). That too can be cut down to O(log n) using binary indexed tree.

ContentLicense: CC BY-SA 3.0


问:
Is it safe to use CamelCased file names?
I'm developing a simple CMS which I'd like to make it open source.

For the file structure, do you think it's safe to use names like:

```<code>AppData
FileUploads
</code>```

instead of

```<code>app-data
file-uploads
</code>```

?

Because I heard some servers have problems with the camelCase.

答:
There are a few different naming conventions knocking about, but personally I don't see any problem with using upper-case letters in file names.

If you're using autoloaders (which you should), then you're very likely to need to use upper-case letters.  Again, it depends on how you name classes, but most people begin all class names with a capital.  Of course you could use strtolower() in your autoloader function, but that's just messy.

So in summary, if you're using OOP, then you should be using upper-case letters in file names.  But I'd probably stay away from upper-case letters in file names that aren't classes- again, just convention.


问:
Is it a bad practice to store large files (10 MB) in a database?
I am currently creating a web application that allows users to store and share files, 1 MB - 10 MB in size.

It seems to me that storing the files in a database will significantly slow down database access.

Is this a valid concern? Is it better to store the files in the file system and save the file name and path in the database? Are there any best practices related to storing files when working with a database?

I am working in PHP and MySQL for this project, but is the issue the same for most environments (Ruby on Rails, PHP, .NET) and databases (MySQL, PostgreSQL).

答:
Yes, it is a bad practice.

Performance impact on the DB:

if you do a SELECT with any BLOB column, you will always do a disk access, while without BLOBs you have a chance to get data straight from RAM (high throughput DB will be optimized to fit tables in RAM);

replication will be slow, replication delay high, as it will have to push BLOB to slaves. High replication delay will be causing all kinds of race conditions and other synchronization problems, unless you explicitly take that in account;

DB backups/restore will take lot longer;

Speed advantage — none! While some older filesystems would not handle well directories with millions of files, most modern have no problem at all and in fact use same kind of data structures as BDs (typically B-trees). For example ext4 (default Linux filesystem) uses Htree.

Conclusion: it will hinder your DB performance and will not improve file retrieval performance.

Also, since you're talking about web application — serving static files directly from filesystem  using modern webserver, which can do sendfile() syscall is tremendous performance improvement. This is of course not possible if you're fetching files from DB. Consider for example this benchmark, showing Ngnix doing 25K req/s with 1000 concurrent connections on a low end laptop. That kind of load would fry any kind of DB.


答:
Famous Tom Kyte has written that they (the Oracle) are using the Oracle database as file server and it's working perfectly fine, even faster that normal filesystem, with full transactionality, no performance loss and with single backup.

Yes, but note, they are the producer of the Oracle DB, and for any other user there are cost issues. Using commercial DB such as Oracle for storage of files is simply cost ineffective.

However, with PostgreSQL for example, you can simply run another DB instance only for blob storage. You have then full transactional support. But transactionality costs DB space. There is the need for database to store multiple blob instances for multiple concurrent transactions. On PostgreSQL it is the most painful, since this database stores the duplicates of blobs made for transaction are stored even if they are not needed anymore, until VACUUM process is done.

With filesystem storage, on the other hand, you must be very carefull when someone modifies the file, because transaction can be rolled back and the copy of the file must be kept until the old version is no longer visible.

In the system where files are only added and deleted, and transactional access to files is not an issue, the filesystem storage will be IMHO the best choice.

Title: Is it a bad practice to store large files (10 MB) in a database?

Body:
I am currently creating a web application that allows users to store and share files, 1 MB - 10 MB in size.

It seems to me that storing the files in a database will significantly slow down database access.

Is this a valid concern? Is it better to store the files in the file system and save the file name and path in the database? Are there any best practices related to storing files when working with a database?

I am working in PHP and MySQL for this project, but is the issue the same for most environments (Ruby on Rails, PHP, .NET) and databases (MySQL, PostgreSQL).


答: It's usually best to store large BLOBs in a separate table and just keep a foreign key reference to the BLOB in your main table.  That way, you can still retrieve the file from the database (so you don't need any special code) and you avoid the problems surrounding external DB dependencies (keeping the DB and filesystem in sync, etc), but you only incur that overhead if you explicitly join to that table (or make a separate call).  10MB isn't terribly large, most modern commercial databases won't have a problem.  The only reason I'd store a file in the filesystem is to cut down on database bandwidth.  If your database is going to be shuffling a lot of these files, then you may need to split the workload and only store a file descriptor of some sort.  Then you can have a separate call to load the file from another server, so you aren't tying up your database connections (and network connections on your database server) with all those file transfers.</p>


问:
What are some ways to maintain codebases written in two languages that implement the same logic?
I have a logic intensive algorithm that I need to code in two languages (actually I finished it in one language satisfactorily and am about to start coding in the other language).  By logic intensive I mean the algorithm is non trivial, needs careful understanding and, importantly, could be having bugs (due to complexity and carelessness, you know) that would have to be patched in the future.

Also, I want to make sure that when this code changes hands, eventually, it must not overwhelm the new programmers.

Given this scenario, what are some ways that would help maintain the codebases and keep they in sync? By ways I mean software tools, best practices etc.

FYI the two languages are C++ and Java. C++ for Windows/Linux and Java for "everything else" including Android.

答:
In addition to the excelent advice to use a common external test suite you may want to look into literate programming. Literate programming tools give you the ability to produce multiple files from a single source file.

The traditional use of LP is to allow you to interleave documentation with code in a manner which allows you to keep the documentation very close to the source code. A single noweb file (for example) could be used to generate a documenation file which could be compiled into a larger document using (say) LaTex, and produce a .cpp and .h file which could be compiled into your application.

In your case, it could allow you to keep both code bases and documentation together, producing a .java file too.

Keeping the documentation and different code versions together in a single file, broken up into logically equivalent sections, should make it much easier to keep them all in sync with each other.


问:
Should we document stand-up meetings?
Another team in my company start to document their stand-up meetings, but I believe it is a waste of time. As far as I know, stand-up meetings are for communication not for status reporting (please, correct me if I am wrong)

So, Should we document stand-up meetings?

答:
Does it add value? Do people later look at the documentation of the meetings? If not, then it just a waste of time. And I seriously doubt that they are. Writing a document that nobody reads is a waste of time.

At some point in time we did actually document and archive status changes from our daily scrum, i.e. who worked on which task, who had performed a peer review, etc. This was done only because someone felt it necessary in order to be compliant with the requirement of traceability from system requirement to code because we were developing software for medical devices.

Later we managed to convince management that this was not really the case, and the practice has been abandoned to much joy for those responsible for this documentation.

Title: Should we document stand-up meetings?


答:
Yes.

Are you making decisions about (a) who is responsible for a work item and/or (b) the importance of a work item relative to other items?

If you are, write these decisions down. Otherwise you will rehash them, and decisions just like them, endlessly.

If you aren't, don't hold the meetings.

Title: Should we document stand-up meetings?

Body:
Another team in my company start to document their stand-up meetings, but I believe it is a waste of time. As far as I know, stand-up meetings are for communication not for status reporting (please, correct me if I am wrong)

So, Should we document stand-up meetings?


问:
Transaction Design Pattern for MVC and location of responsibility?
I'm designing a pretty standard Spring MVC application, and I'm trying to figure out where the responsibility for transaction management should lie.

I've been reading Java Transaction Design Strategies, and the one that I think best suits is the Server Delegate one, where the controller is what manages the transactions, and the services and DAOs are oblivious to the transactions.

Somehow, this doesn't feel right.  My gut feeling is that the services are the ones that should control the transactions, but I have cases where a controller may call several services to perform an action.

How have you handled Transactions in MVC applications before, and where do you consider the best place for handling the transactions is?

答:
It's my understanding that the controller should mainly be responsible for communicating with the business layer and preparing the view data when necessary. In that case, it shouldn't have any knowledge about transactions; they should be kept at a lower layer.

When the controller needs to execute some logic that consists of multiple steps where a single transaction would be desired, that logic should be rolled up into a method in the business layer. When managing transactions with Spring, you can easily define a service method as transactional, and how nested calls should handle their transactions: whether to pick up the existing transaction if available, always create new, etc.


答:
Disclaimer

As mentioned in previous, posts, if you don't really have another choice, then.

Answer

Several practical suggestions, instead of a single answer:

(1) Use common structures, even, if the same stuff can be done different.

Example: I had to have the same code in "Object Pascal" & "C++", where the "if" sentence exists in both, the parenthesis in "C++" is required, but, not in "object Pascal".

```<code>// Object Pascal
...
if MyBollExpression
begin
  ...
end;
...

// C++
...
if (MyBollExpression)
{
  ...
}
...
</code>```

Changed to:

```<code>// Object Pascal
...
if (MyBollExpression)
begin
  ...
end;
...

// C++
...
if (MyBollExpression)
{
  ...
}
...
</code>```

Added parenthesis to both languages. Another case will be optional namespaces versus required namespaces ( "packages" ).

(3) Keep identifiers names, case sensitiveness, specially types, similar, use aliases, subclassing, wrapping:

```<code>// Java
//
import java.io.*;

...
System.out("Hello World\n");
...

// C++
//
include <iostream>

...
cout << "Hello World\n";
...
</code>```

Into:

```<code>// Java
//
import java.io.*;

static class ConsoleOut
{
   void Out(string Msg)
   {
     System.out("Hello World\n");
   }
}

...
ConsoleOut MyConsole = new ConsoleOut();
...
MyConsole.out("Hello World\n");
...

// C++
//
include <iostream>

public class ConsoleOut
{
   void Out(string Msg)
   {
     cout << "Hello World\n";
   }
}

...
ConsoleOut MyConsole = new ConsoleOut();
...
MyConsole.out("Hello World\n");
</code>```

...

Summary

I usually have to work with several programming languages, and there are some custom "core" libraries, that I keep in several programming languages.

Good Luck.

Title: What are some ways to maintain codebases written in two languages that implement the same logic?

Body:
I have a logic intensive algorithm that I need to code in two languages (actually I finished it in one language satisfactorily and am about to start coding in the other language).  By logic intensive I mean the algorithm is non trivial, needs careful understanding and, importantly, could be having bugs (due to complexity and carelessness, you know) that would have to be patched in the future.

Also, I want to make sure that when this code changes hands, eventually, it must not overwhelm the new programmers.

Given this scenario, what are some ways that would help maintain the codebases and keep they in sync? By ways I mean software tools, best practices etc.

FYI the two languages are C++ and Java. C++ for Windows/Linux and Java for "everything else" including Android.

Body:
Disclaimer

As mentioned in previous, posts, if you don't really have another choice, then.

Answer

Several practical suggestions, instead of a single answer:

(1) Use common structures, even, if the same stuff can be done different.

Example: I had to have the same code in "Object Pascal" & "C++", where the "if" sentence exists in both, the parenthesis in "C++" is required, but, not in "object Pascal".

// Object Pascal
...
if MyBollExpression
begin
  ...
end;
...

// C++
...
if (MyBollExpression)
{
  ...
}
...

Changed to:

// Object Pascal
...
if (MyBollExpression)
begin
  ...
end;
...

// C++
...
if (MyBollExpression)
{
  ...
}
...

Added parenthesis to both languages. Another case will be optional namespaces versus required namespaces ( "packages" ).

(3) Keep identifiers names, case sensitiveness, specially types, similar, use aliases, subclassing, wrapping:

// Java
//
import java.io.*;

...
System.out("Hello World\n");
...

// C++
//
include <iostream>

...
cout << "Hello World\n";
...

Into:

// Java
//
import java.io.*;

static class ConsoleOut
{
   void Out(string Msg)
   {
     System.out("Hello World\n");
   }
}

...
ConsoleOut MyConsole = new ConsoleOut();
...
MyConsole.out("Hello World\n");
...

// C++
//
include <iostream>

public class ConsoleOut
{
   void Out(string Msg)
   {
     cout << "Hello World\n";
   }
}

...
ConsoleOut MyConsole = new ConsoleOut();
...
MyConsole.out("Hello World\n");

...

Summary

I usually have to work with several programming languages, and there are some custom "core" libraries, that I keep in several programming languages.

Good Luck.


问:
Stuck due to "knowing too much"
Note more discussion at http://news.ycombinator.com/item?id=4037794

I have a relatively simple development task, but every time I try to attack it, I end up spiraling in deep thoughts - how could it extending the future, what are the 2nd generation clients going to need, how does it affect "non functional" aspects (e.g. Performance, authorization...), how would it best to architect to allow change...

I remember myself a while ago, younger and, perhaps, more eager. The "me" I was then wouldn't have given a thought about all that - he would've gone ahead and wrote something, then rewrote it, then rewrote it again (and again...). The "me" today is more hesitant, more careful.

I find it much easier today to sit and plan and instruct other people on how to do things than to actually go ahead and do them myself - not because I don't like to code - the opposite, I love to! - but because every time I sit at the keyboard, I end up in that same annoying place.

Is this wrong? Is this a natural evolution, or did I drive myself into a rut?

Fair disclosure - in the past I was a developer, today my job title is a "system architect". Good luck figuring what it means - but that's the title.

Wow. I honestly didn't expect this question to generate that many responses. I'll try to sum it up.

Reasons:

Analysis paralysis / Over engineering / gold plating / (any other "too much thinking up-front can hurt you").

Too much experience for the given task.

Not focusing on what's important.

Not enough experience (and realizing that).

Solutions (not matched to reasons):

Testing first.

Start coding (+ for fun)

One to throw away (+ one API to throw away).

Set time constraints.

Strip away the fluff, stay with the stuff.

Make flexible code (kinda opposite to "one to throw away", no?).

Thanks to everyone - I think the major benefit here was to realize that I'm not alone in this experience. I have, actually, already started coding and some of the too-big things have fallen off, naturally.

Since this question is closed, I'll accept the answer with most votes as of today. When/if it changes - I'll try to follow.

答:
No, you don't know enough, yet.

Enrich your knowledge e.g. by these simple rules:

KISS: Keep it small and simple.

YAGNI: You ain't gonna need it.

Worse is Better: Some worse solutions are actually better in maintainability terms.

Do not overengineer. Be ready for change by having refactoring skills, but do not encode every possible change in code. If you see that over time, a class or function grows too big, change it. Divide and conquer. Use interfaces, use more functions. If you feel that you've divided too much (i.e. it became somehow fancier, but less readable), undo your last change.

In summary: Make your code flexible enough, but not more. Instead, make your self flexible, buy a book on refactoring.

Title: Stuck due to "knowing too much"


答:
This is a good example of where tests can be helpful.

I would suggest having a single test suite that both your code base run against.  Then you know that your code bases both conform to the same specification!

(and, have good test coverage!)


问:
In need of a divide and conquer approach for re-writing small open-source utilities
Preamble (Skip if you don't like to read)

I've been learning C/C++ in school for a year now and all the assignments in the book, after reading through the chapters, were not too difficult to implement. Some examples of programs I've written are abstract data types like binary trees, queues, stacks, lists, and other types of programs were palindrome searching, encrypting and decrypting files, and other similar first-year type programs. As stated, after reading the chapters, I was easily able to implement and understand the algorithms used to solve many of the problems. So I feel comfortable with the syntax and logic of these small manageable problems.

Background (You can skip this part)

In preparation for my transfer to UCSD in the fall, I installed Linux on my machine and switched to using Vi -- definitely a change from Visual Studio. To keep my mind sharp and venture into real-world programs, I decided to download the source for a famous Linux console utility called Wget (http://www.gnu.org/software/wget/), with the intentions of re-writing the program as a C++ object-oriented version. The challenge I am facing is the program, while being a simple single-purpose utility, is still quite enormous when staring at the code.

...The Question (You CAN'T skip this part)

How does one begin to look at a program they didn't write and study it in order to try to re-write it, change it, etc? I guess I'm looking for advice/guidance on a divide and conquer type approach to studying a program written by other people in order to try to re-write it. I understand massive programs like OpenOffice, the Linux kernel, Gnome, etc. don't fall into this "I'm going to re-write them" sort of thinking. But small utilities I would imagine do.

答:
I think a really good approach is to study any unit tests that are in the system. Unit-tests, by definition, only focus on one (usually small) section of the code in isolation. This means you can work through the unit test suites and understand the code one module at a time.

If there aren't any tests (or not enough), you can try to write them yourself. This is an even better way to learn the codebase since you have to directly use it. Again, because it's unit tests, you are really focusing on a small unit of code, which helps compartmentalize your study of the source code.


问:
How would you unit-test or perform the most effective automated testing on graphics code for OpenGL?
I'm writing a game and the accompanying graphics engine on top of OpenGL in C++. Im also a fan of good coding processes and automated testing. Graphics code + testing seems pretty immiscible, since the output is often visual only, or very heavily visual-oriented.

For example, imagine analyzing the raw image-stream that is rendered to the screen byte-by-byte - you need test-data to compare with, which is hard to create/obtain, and often the rendered images aren't identical on a byte level when running at different times - small changes in algorithms will wreck this approach completely.

I'm thinking of creating a visual unit-test suite, in which I can basically render different test-scenes, showing stuff like shadow mapping, animation, etc etc etc. As part of CI, these scenes would then be rendered to a video file (or possibly leave it as a executable) with different metrics. This would still require manual inspection of the video file, but atleast it would be somewhat automated and standardised.

What do you think? I'm hoping there are better ways?

答: The opencv image processing library does it by saving the image and comparing it to a reference image - it has a bunch of c++ test functions and macros to handle approximate image matching etc. </p>


问:
Do people in non-English-speaking countries code in English?
I've heard it said (by coworkers) that everyone "codes in English" regardless of where they're from. I find that difficult to believe, however I wouldn't be surprised if, for most programming languages, the supported character set is relatively narrow.

Have you ever worked in a country where English is not the primary language?

If so, what did their code look like?

答:
I'm from Egypt. I think we switch to English by default when we talk, or even think about code. Most of the learning resources - regular ones like books, and even blogs, podcasts and so on - are in English. Switching to your mother tongue means turning your back to lots of great resources.

I guess this post might convey my point, via Jeff Atwood:
http://www.codinghorror.com/blog/2009/03/the-ugly-american-programmer.html


答:
I wouldn't call wget a small utility. It can communicate over several different protocols, has numerous command-line options, features very robust (and tuneable) error handling, etc. It only looks simple because the designers must have put a lot of thought and effort into making it easy to use.

As for your issue of understanding a project, learn to appreciate find and grep. Also, I've found that I can understand what a program is doing just by running it through strace and (occasionally) ltrace. If you really want to get your hands dirty, look at the commit logs in the version control, but that's a bit extreme.

Title: In need of a divide and conquer approach for re-writing small open-source utilities

Body:
Preamble (Skip if you don't like to read)

I've been learning C/C++ in school for a year now and all the assignments in the book, after reading through the chapters, were not too difficult to implement. Some examples of programs I've written are abstract data types like binary trees, queues, stacks, lists, and other types of programs were palindrome searching, encrypting and decrypting files, and other similar first-year type programs. As stated, after reading the chapters, I was easily able to implement and understand the algorithms used to solve many of the problems. So I feel comfortable with the syntax and logic of these small manageable problems.

Background (You can skip this part)

In preparation for my transfer to UCSD in the fall, I installed Linux on my machine and switched to using Vi -- definitely a change from Visual Studio. To keep my mind sharp and venture into real-world programs, I decided to download the source for a famous Linux console utility called Wget (http://www.gnu.org/software/wget/), with the intentions of re-writing the program as a C++ object-oriented version. The challenge I am facing is the program, while being a simple single-purpose utility, is still quite enormous when staring at the code.

...The Question (You CAN'T skip this part)

How does one begin to look at a program they didn't write and study it in order to try to re-write it, change it, etc? I guess I'm looking for advice/guidance on a divide and conquer type approach to studying a program written by other people in order to try to re-write it. I understand massive programs like OpenOffice, the Linux kernel, Gnome, etc. don't fall into this "I'm going to re-write them" sort of thinking. But small utilities I would imagine do.


问:
How do certain iPhone apps allow purchases without IAP?
According to section 11.2 of the App Store Review Guidelines,

```<code>Apps utilizing a system other than the In App Purchase API (IAP)
to purchase content, functionality, or services in an app will be rejected.
</code>```

Various apps like JetSetter, Gilt, and Kayak include in-app purchasing flows that either collect credit card information directly, or use a UIWebView to direct the user to a third-party website to purchase goods and services.

What provision allows apps to do this, and what are the limitations to purchasing physical goods and services in an iPhone app without using IAP?

答: It's all spelled out pretty clearly in the developer agreement, I think. If I remember correctly, you must use IAP to purchase content for your app, and you must not use IAP to purchase real-world goods and services. I haven't looked at the apps you mention, but a service like Kayak is surely selling real-world services (flights, hotel stays, etc.) rather than app content.


问:
Is hiring a "chief intern" a good idea?
I'm starting an internship program for our software department and I was wondering about creating a position ("chief intern", intern supervisor, or whatever one should call it) with the following responsibilities:

Train interns

Coach interns

Manage projects and tasks for interns

Supervise intern's work in terms of rhythm and quality

Act as a liaison between the main team's needs and interns performance/aspirations

Evaluate and facilitate intern's progress when they want to grab a higher-level domain-specific task (at this point, a main dev team member can do mentoring)

Get freely involved in the main team's software development tasks so that he himself can grow, and have full mentorship from the main dev team.

I'm thinking that an apprentice-level engineer (below Jr., or Jr.; but being a graduate and working full-time) can handle this for a while (he will be trained by the main dev team first), until one of two things happen:

He/she decides to move on to the main dev team by recommending an appropriate replacement (or me finding another one as a new hire)

Keep leading the interns while still being able to grow to Jr. Eng., Eng., Sr. Eng

I know the notion of a "chief intern" is common within the medical world, but I don't really know about that in the software world (I was a freelancer for most of my university years).

A side-intention to this is also that, if this ends up being a higher rotation position (organically) because the intern supervisor wants to join the main dev team, this could help interns that aspire this position emerge as leaders.

My main intention for this, though, is removing distractions from the main team but without making the interns suffer the lack of attention, which could lead to boredom and little intern retention.

Is this "chief intern" idea common (or good at least)?, are there any obvious risks to it that I might not be seeing?

Edit: I have a draft plan for the kind of work the interns would be doing: https://softwareengineering.stackexchange.com/questions/149866/are-rd-mini-projects-a-good-activity-for-interns

Edit #2:  My intention is not keeping them isolated, but having someone focus on giving attention to them when we cannot.

Edit #3: I'm now convince it is a good idea, but I will take the organic approach to hiring someone in such position: do it myself until I cannot. This way I'll know better what to expect from a person I hire for this role in the future, as well as what works and what doesn't with interns.

答:
As a recent graduate this is something that I would love to be able to do myself.  I feel that I have a lot of skills but my depth is shallow.  I know enough about software development but have never really managed a team.

Something like this can totally work if you set it up correctly.

Consider only the strongest interns for the position

Set them up for success by having small and manageable projects for them to take on

Provide resources (especially access to more senior developers) and proper tools

3 is absolutely essential.  If you can afford it, dedicate at least 1 of your more senior developers as a mentor for this person.  They don't need to be available 24/7 but at the very least the chief intern should have somewhat immediate access to the mentor.

Overall, I think this is an awesome idea and would give really strong candidates an opportunity to do something challenging and meaningful that will hopefully help your bottom line as well.  It's a win for everyone if done properly.

Title: Is hiring a "chief intern" a good idea?


答:
I find it useful to implement a Service Facade that decouples the implementation of services from the service contract.  The Controller from the presentation tier (your MVC stuff) should be able to make a single call to a Service Facade, which then orchestrates the calls to one or more "service" objects/methods, and returns whatever the service contract says it needs to return.

In this architecture, the Service Facade would also be the place to hook in your transaction management.

Title: Transaction Design Pattern for MVC and location of responsibility?

Body:
I'm designing a pretty standard Spring MVC application, and I'm trying to figure out where the responsibility for transaction management should lie.

I've been reading Java Transaction Design Strategies, and the one that I think best suits is the Server Delegate one, where the controller is what manages the transactions, and the services and DAOs are oblivious to the transactions.

Somehow, this doesn't feel right.  My gut feeling is that the services are the ones that should control the transactions, but I have cases where a controller may call several services to perform an action.

How have you handled Transactions in MVC applications before, and where do you consider the best place for handling the transactions is?


答:
I'm uneasy about this, at the very least you will need a senior dev, acting as a safety net, making sure your 'chief intern' isn't 'the blind leading the blind'.

Really I think you are best having your best people working with your interns, yes it means they will be slightly less productive, but your interns should become more productive sooner.

Your best people should be able to cope with the burden of training interns and producing their own stuff, that's why they are your best people!

Title: Is hiring a "chief intern" a good idea?

Body:
I'm starting an internship program for our software department and I was wondering about creating a position ("chief intern", intern supervisor, or whatever one should call it) with the following responsibilities:

Train interns

Coach interns

Manage projects and tasks for interns

Supervise intern's work in terms of rhythm and quality

Act as a liaison between the main team's needs and interns performance/aspirations

Evaluate and facilitate intern's progress when they want to grab a higher-level domain-specific task (at this point, a main dev team member can do mentoring)

Get freely involved in the main team's software development tasks so that he himself can grow, and have full mentorship from the main dev team.

I'm thinking that an apprentice-level engineer (below Jr., or Jr.; but being a graduate and working full-time) can handle this for a while (he will be trained by the main dev team first), until one of two things happen:

He/she decides to move on to the main dev team by recommending an appropriate replacement (or me finding another one as a new hire)

Keep leading the interns while still being able to grow to Jr. Eng., Eng., Sr. Eng

I know the notion of a "chief intern" is common within the medical world, but I don't really know about that in the software world (I was a freelancer for most of my university years).

A side-intention to this is also that, if this ends up being a higher rotation position (organically) because the intern supervisor wants to join the main dev team, this could help interns that aspire this position emerge as leaders.

My main intention for this, though, is removing distractions from the main team but without making the interns suffer the lack of attention, which could lead to boredom and little intern retention.

Is this "chief intern" idea common (or good at least)?, are there any obvious risks to it that I might not be seeing?

Edit: I have a draft plan for the kind of work the interns would be doing: https://softwareengineering.stackexchange.com/questions/149866/are-rd-mini-projects-a-good-activity-for-interns

Edit #2:  My intention is not keeping them isolated, but having someone focus on giving attention to them when we cannot.

Edit #3: I'm now convince it is a good idea, but I will take the organic approach to hiring someone in such position: do it myself until I cannot. This way I'll know better what to expect from a person I hire for this role in the future, as well as what works and what doesn't with interns.


答:
The service layer is most naturally suited place for transaction demarcation in MVC apps no matter which service layer pattern you use.

However, sometimes concessions should be made for a specific application when it makes sense, so I would not be overly dogmatic about it. Just make sure that you use declarative transaction management so you can move transactions around to the most appropriate place without affecting your application code.


问:
Why is quicksort better than other sorting algorithms in practice?
This is a repost of a question on cs.SE by Janoma. Full credits and spoils to him or cs.SE.

In a standard algorithms course we are taught that quicksort is O(n log n) on average and O(n²) in the worst case. At the same time, other sorting algorithms are studied which are O(n log n) in the worst case (like mergesort and heapsort), and even linear time in the best case (like bubblesort) but with some additional needs of memory.

After a quick glance at some more running times it is natural to say that quicksort should not be as efficient as others.

Also, consider that students learn in basic programming courses that recursion is not really good in general because it could use too much memory, etc. Therefore (and even though this is not a real argument), this gives the idea that quicksort might not be really good because it is a recursive algorithm.

Why, then, does quicksort outperform other sorting algorithms in practice? Does it have to do with the structure of real-world data? Does it have to do with the way memory works in computers? I know that some memories are way faster than others, but I don't know if that's the real reason for this counter-intuitive performance (when compared to theoretical estimates).

答:
The actual performance of algorithms depends on the platform, as well as the language, the compiler, programmer attention to implementation detail, specific optimization effort, et cetera.  So, the "constant factor advantage" of quicksort isn't very well-defined -- it's a subjective judgement based on currently-available tools, and a rough estimation of "equivalent implementation effort" by whoever actually does the comparative performance study...

That said, I believe quicksort performs well (for randomized input) because it is simple, and because its recursive structure is relatively cache-friendly.  On the other hand, because its worst case is easy to trigger, any practical use of a quicksort will need to be more complex than its textbook description would indicate: thus, modified versions such as introsort.

Over time, as the dominant platform changes, different algorithms may gain or lose their (ill-defined) relative advantage.  Conventional wisdom on relative performance may well lag behind this shift, so if you're really unsure which algorithm is best for your application, you should implement both, and test them.


答:
When I was an intern (and also a junior employee), in order to write
program code, I still needed to obtain exact technical specifications
from a developer.  If I am supposed to do coding and the lead intern
actually knows these specifications, that would be a great help.

How well this would work seems to me to depend on what tasks I
would have done as an intern (I have done these tasks both as
an intern and as a student employee):

1 Testing

It is easier to understand what a valid
test case is than it is to write code to
match a valid interface

2 Coding

To write code, especially as a junior employee
it is important to discuss specifications with someone
who is familiar with them in detail - someone
with direct experience.

3 Flowcharts/Process Diagrams

I have written flowcharts for software as a student
employee, but in order to do this I had to be
able to meet face to face with the stakeholders.

Title: Is hiring a "chief intern" a good idea?


问:
Best Practice of making a Composite Control with a repeater activity
Best Practice of making a Composite Control with a repeater activity

It's Templated-Based,
have paging support via a DropDown and 2 Buttons
It should have Event-Handling also
Needed to work as a package for
( so didn't want to give template-editability
or much programming options )

Key Parts to answer :

A Custom Repeater, A Composite Control , A Custom Control with
functionality similar to repeater or CompositeDataControl?

How prepare and get the data to avoid repetition of the processes
I did all controls creation and initiation in CreateChildControls

but seems that it is running in every request, Is it good to let all the controls created on every Postback or We have to Control this process, How do you suggest

Cause we want to Bind via the repeater should we do anything
regarding of Data Binding inside the Composite Control ? In my
example I binded the repeater (just the repeater) in a method that
will run in each run in every serious event like OnLoad
(Conceptually we binded the repeater, not the CC)

How to make a property such as Page Number persistent via postbacks
 use viewStates or if any click we pass the new Page info from session to the    control it should do the job ? What is your Paging Strategy, In simple Lines

Should I store anything of the Repeater in ViewState/Control
State and assign a property for them ?

want to know your decision, best-practice other professionals know and suggest

答: Though this is not a comprehensive answer for your question. But if you disable view state, then event handling for components inside the repeater will stop working. I did write a blog post about it, and a workaround for that problem. http://petesdotnet.blogspot.com/2009/08/asp.html</p>


问:
Are there any good reasons to use, learn, or recommend XSLT?
I am a developer for the last 8 years. We used XSLT primarily to transform XML into HTML. We also used it for XML to XML transformation.

But we have replacement for everything now. HTML can be comfortably created through programming languages such as ASP.Net. XML can be read and manupulated in any standard highlevel languages. As programming in XSLT is a little complex, any one would prefer working on latest programming languages.

Now my question:
Will XSLT be a significant choice in future, not considering the fact of maintaining already developed XSLT? Can I recommend new programmers to study XSLT?

答:
XSLT is not human-readable. The meta-information (the tags) take too much place over the real information (text, xpath requests). A good code should look like a documentation and this is fairly not the case of XSLT. It is rather a good persistence format for mapping tools.

A good transformation language should allow to preview the transformation result and view the transformation flow (IF, ELSE, FOR, WHILE) simultaneously. this is important for the maintainability. Regarding this aspect Velocity or GenearateXY are better than XSLT. GenerateXY is even a bit better since it separates the preview and the flow while with Velocity you would have to unfortunately break the preview indentation to provide a readable flow.

The only good point in XSLT is that it cares about modularity by using and even abusing of the "xsl:template" elements. The problem with this is that it is good for a data processing language (Java, C, ...) but very secondary for a presentation language.


答:
Yes.

If you serve a file from your filesystem, your Web server can use kernel code like sendfile() on BSD or Linux to copy the file directly to the socket. It's very fast and very efficient.

Serving files out of the database means you have to copy data from the database server's disk to database server memory, then from db server's memory to the db server's network port, then in from the network to your Web server process, then out again to the outgoing network connection.

Unless you have a really good reason not to, it's always better to serve static files from the file system.


答: Some Enterpirse Content Management Systems, like SiteCore, are using one database to store page data and another database to store files. They're using MS SQL  Server.</p>


答:
Your test framework can render its test image into a buffer, retrieve the rendered image, and compare it to a "golden" reference image which has been previously generated for that purpose.

This will not work as well for cases in which the results of your test are not expected to remain exactly the same.  However, you can compute the squared difference of the test and reference images, and compare it against a threshold.

You may also want to provide for logging and checking performance data, since a major regression in performance is another possible failure mode.

Title: How would you unit-test or perform the most effective automated testing on graphics code for OpenGL?

Body:
I'm writing a game and the accompanying graphics engine on top of OpenGL in C++. Im also a fan of good coding processes and automated testing. Graphics code + testing seems pretty immiscible, since the output is often visual only, or very heavily visual-oriented.

For example, imagine analyzing the raw image-stream that is rendered to the screen byte-by-byte - you need test-data to compare with, which is hard to create/obtain, and often the rendered images aren't identical on a byte level when running at different times - small changes in algorithms will wreck this approach completely.

I'm thinking of creating a visual unit-test suite, in which I can basically render different test-scenes, showing stuff like shadow mapping, animation, etc etc etc. As part of CI, these scenes would then be rendered to a video file (or possibly leave it as a executable) with different metrics. This would still require manual inspection of the video file, but atleast it would be somewhat automated and standardised.

What do you think? I'm hoping there are better ways?


答:
Having interns focus on proof of concept/R&D work sounds like a good, potentially productive way to keep them out of your hair if that's the problem. Their exposure to staff, however, should be direct if infrequent. It's what they're paying for by not being paid well (or not paid at all).

The other issue is that internships can be competitive. By having one intern rise above the rest, you could end up with somebody who's willing to make his competition look like chumps at the expense of their work and experience with your company. In my experience, devs tend to see through office politics better than most but it still happens, especially with the types of aggressively competitive college kids that score internships.

Title: Is hiring a "chief intern" a good idea?


答: Even if you can't compare the output images, at least you'll be able to test that your renders complete appropriately (no crashes, long waits, etc, etc). Finding a way to check the images is better, of course, but even without it you'll have gained something from the tests.</p>


问:
Asynchronous Designing and Programming
Me and a friend are looking to team up for some freelance web designing. We both are very strong PHP coders and website designers, but I am better at design and he is better at PHP. So, I'll be controlling the stuff the user sees, he'll be controlling the stuff the user does.

In order to speed up development, I'm wondering if anyone has experience or recommendations for asynchronous web designing and coding. So far my best idea is to create a doctrine of which tags and classes every element should be wrapped in (if any), then have us developing via FTP. He would create the code that spits out snippets of HTML, and I would simply style those snippets and wrap it in the page. Does anyone know of a better way?

So, any ideas?

答:
I tell you this out of sheer experience: get a @#$! graphic designer. Your clients will be able to tell the difference from developer designs (even if they are paid templates) and graphic designers' designs. If possible, get a web designer.

If you are the one with the best design feel, take the role of creative director and filter the graphic designer's input as you implement it. You can then focus on other related things such as UX.

If you want to do things right, you might also want to seek a copywriter or at least train yourself and/or your friend in copywriting, books 1-4 of Copyhackers are a great start. Believe me, content matters.

Functionality (sadly) won't matter to your clients as much as design and content. Once you nail design and content you can focus on functionality.

In my experience, these two factors will define your success.

Oh, yeah, and regarding your actual question, you might want to try Mercurial instead of using an FTP. And you might want to look into Joomla and Drupal as platforms (CMSs)for your web sites, so you can focus on developing what matters and not reinventing the wheel.

P.S.: I like Joomla better because of Gantry

Title: Asynchronous Designing and Programming


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

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

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

Any ideas?

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

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

答:
Easiest solution would be to provide a grade/weight of the estimated skill and try to balance the score for each team.

From there, you could seed a bayesian network with these values and then you'd infer backwards based on the observed result of each matchup in the historical data you have.

As a point of interest on my part: Infer.NET makes this relatively easy to envision and potentially implement, and it could predict the odds of a win given team matchups. Infer.NET is something that I'm really starting to get into lately.


答:
Quick and dirty approach:

Calculate a score for every player that is the total points for the side that player was on divided by the total points in the game for every game they participated in.  Then sort players by score.  Place the first player on team A.  Then for each player, add them to the team with the lowest aggregate score until half the players are on one team.  All remaining players go on the other team.

Title: Strategy/algorithm to divide fair teams based on history

Body:
We are a group of people playing floorball together on a regular basis. Every session starts with the daunting task of dividing teams...

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

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

Any ideas?

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

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


问:
Front end first or Back end first. Of the two which is a Good system design pratice?
I have a client right now requiring me to develop a school enrollment system. Now this is the first time im having this kind of challenge. Most of the past software that i created are not that complex.

I know most all of you have created complex softwares, i just want your advise on this. Should i design first the front end or back end?

thanks!

Here's a conclusion of an article I found in the internet a while ago. Just whant to share

http://www.skitoy.com/p/front-end-vs-back-end-developers-my-take/157

Front-end vs. back-end developers (my take)

My personal take

Again it’s a matter of training, some broad stroke generalizations:

Front end developers

Typically don’t have a CS degree, or
have a CS degree from a 3rd tier
school.

Work in languages that similar to
basic (see PHP is Basic)

Have a visual skill in converting
photoshop documents to CSS/HTML/etc.

Have a high tolerance for iterative
programming, due to type free
languages

Back end developers

Have a CS degree or lots of
experience

Tend to me more systematic in their
problem solving approach

Don’t mind spending days finding the
one object that is leaking

Try and build tools to solve problems

答: Yes I realized the OP asked a while back.  Start at the back end but MOCK UP the front end to allow the user to see what you envision.  The front end, for all it is worth, is just the bells and whistles.  The back end is where the money is, and once you have that straight, the FE is just the gravy over the meat.</p>

ContentLicense: CC BY-SA 2.5


问:
Fluid VS Responsive Website Development Questions
As I understand these form the basis for targeting a wide array of devices based on the browser size, given it would be a time consuming to generate different layouts targeting different/specific devices and their resolutions.

Questions:

Firstly right to the jargon, is there any actual difference between the two or do they mean the same?

Is it safe to classify the current development mainly a html5/css3 based one?

What popular frameworks are available to easily implement this?

What testing methods used in this regard?

What are the most common compatibility issues in terms of different browser types?

I understand there are methods like this http://css-tricks.com/resolution-specific-stylesheets/  which does this come under?.

Are there any external browser detection methods besides the API calls specific to the browser that are employed in this regard?

Points of interest [Prior Research before asking these questions]

Why shouldn't "responsive" web design be a consideration?

Responsive Web Design Tips, Best Practices and Dynamic Image Scaling Techniques

A recent list of tutorials 30 Responsive Web Design and Development
Tutorials by Eric Shafer on May 14, 2012

Update

Ive been reading that the basic point of designing content for different layouts to facilitate a responsive web design is to present the most relevant information.
now obviously between the smallest screen width and the highest we are missing out on design elements.

I gather from here http://flashsolver.com/2012/03/24/5-top-commercial-responsive-web-designs/  The top of the line design layouts (widths) are

desktop layout (980px)

tablet layout (768px)

smartphone layout – landscape (480px)

smartphone layout – portrait (320px)

Also we have a popular responsive website testing site http://resizemybrowser.com/ which lists different screen resolutions.

I've also come across this while trying to find out the optimal highest layout size to account for https://stackoverflow.com/questions/10538599/default-web-page-width-1024px-or-980px  which brings to light seemingly that 1366x768 is a popular web resolution.

Is it safe to assume that just accounting for proper scaling from width 980px onwards to the maximum size would be sufficient to accommodate this? given we aren't presenting any new information for the new size.

Does it make sense to have additional information ( which conflicts with purpose of responsive web design) to utilize the top size and beyond?

答:
Firstly right to the jargon ,is there any actual difference between
the two or do they mean the same?

Fluid in its historical context meant it was NOT fixed i.e it expanded if a wider screen was available. Precursor to responsive. Fluid does not mean it adapts to smalleer/tablet/smartphone screens.

Responsive means, it adapts to device/screensize.

Is it safe to classify the current development mainly a html5/css3
based one ?

This feature is based on Media Queries which I think is a feature of CSS3, so CSS3 is a prerequisite.

What Popular frameworks are available to easily implement this?

Bootstrap is one.

What are the most common compatibility issues in terms of different browser types?

Volumes could be written on incompatibilities. But you just should be aware that there are differences. Proper resets have been developed and improved. Keep an eye on those and try to test as much as you can. Newer features have varying level of compliance in different browsers, so  be aware of that.

I understand there are methods like this http://css-tricks.com/resolution-specific-stylesheets/ which does this come under?.

This is an example of media query. The feature which makes responsive design work.

Are there any external browser detection methods besides the api calls specific to the >browser that are employed in this regard?

I am not sure, but generally, browsers have an identifier which is part of the HTTP request. It is not strictly speaking "reliable" as you can easily craft an HTTP request and claim to be from Chrome, but practically, it works.

Is it safe to assume that just accounting for proper scaling from width 980px onwards to the maximum size would be sufficient to accommodate this? given we aren't presenting any new information for the new size.

Just because the industry trend is to lock at 980px does not mean you cannot design for a bigger screen. If your usecase mandates that you present a more richer content to bigger screen, perhaps you can tinker with it. But generally the practice is that 980 is the max contemporary designers consider desktop top be, considering there is no new content. (but this assumption is not set in stone - you can decide to ditch it if it makes sense)

Does it make sense to have additional information ( which conflicts with purpose of responsive web design) to utilize the top size and beyond?

Actually this debate is still ongoing, but I personally think, responsive design means you have the opportunity to present content differently, and even different content. So what is best for a smart phone is not going to be sufficient for a desktop. In the end it would be your personal judgement based on your requirements.


问:
How do you deal with the anxiety of not knowing enough?
I just finished college a couple of months ago and I'm taking time out to improve my knowledge. I love programming but I feel like I don't know enough to be confident if I went for an interview. Last night I was browsing through questions and came across a question that asks interviewees how to work out a linked list. I learned these at college but if I was asked on the spot how to do it I wouldn't know. So that's another thing added to the list of what to learn.

This is when the anxiety hit me because I have so much to learn in so little time (at least it feels that way). Upon introspection, I think this anxiety is related to my perfectionism even though being perfect isn't rational e.g. Shakespeare and Einstein failed 80% of the time.

So the questions are, have you felt this anxiety of not knowing enough? If so, how did you deal with it? I suppose there's a point in time when you begin to feel comfortable in your abilities?

答:
There will always be more stuff to know than you, or anyone else, can possibly know.

So you shouldn't really concern yourself, mostly, with whether you do or do not know something.

What you should have confidence in, is your ability to learn. If you have the attitude that whatever you need to know you can learn, then you will be fine.


问:
Am I deluding myself? Business analyst transition to programmer
Current job: Working as the lead business analyst for a Big 4 firm, leading a team of developers and testers working on a large scale re-platforming project (4 onshore dev, 4 offshore devs, several onshore/offshore testers).  Also work in a similar capacity on other smaller scale projects.

Extent of my role: Gathering/writing out requirements, creating functional specifications, designing the UI (basically mapping out all front-end aspects of the system), working closely with devs to communicate/clarify requirements and come up with solutions when we hit roadblocks, writing test cases (and doing much of the testing), working with senior management and key stakeholders, managing beta testers, creating user guides and leading training sessions, providing key technical support.

I also write quite a few macros in Excel using VBA (several of my macros are now used across the entire firm, so there are maybe around 1000 people using them) and use SQL on a daily basis, both on the SQL compact files the program relies on, our SQL Server data and any Access databases I create.  The developers feel that I am quite good in this role because I understand a lot about programming, inherent system limitations, structure of the databases, etc so it's easier for me to communicate ideas and come up with suggestions when we face problems.

What really interests me is developing software.  I do a fair amount of programming in VBA and have been wanting to learn C# for awhile (the dev team uses C# - I review code occasionally for my own sake but have not had any practical experience using it).  I'm interested in not just the business process but also the technical side of things, so the traditional BA role doesn't really whet my appetite for the kind of stuff I want to do.  Right now I have a few small projects that managers have given me and I'm finding new ways to do them (like building custom Access applications), so there's a bit here and there to keep me interested.

My question is this: what I would like to do is create custom Excel or Access applications for small businesses as a freelance business (working as a one-man shop; maybe having an occasional contractor depending on a project's complexity).  This would obviously start out as a part-time venture while I have a day job, but eventually become a full-time job.  Am I deluding myself to thinking I can go from BA/part-time VBA programmer to making a full-time go of a freelance business (where I would be starting out just writing custom Excel/Access apps in VBA)?  Or is this type of thing not usually attempted until someone gains years of full-time programming experience?  And is there even a market for these types of applications amongst small businesses (and maybe medium-sized) businesses?

答:
No, you are not deluding yourself, it can be done! One of the guys here did that, though I don't know the details of how but I think he started as an underwriter, became a BA for underwriting interal software development, then somehow transitioned into full-time development. I would guess that he already had a technical background, like you do.

It might work better if you try to do it first with your current employer than going it solo. You'd have a lot more support and help. Maybe talk to your manager and ask how you could transition to a development role within the organization, probably on the same team to start off. That way you already know everyone and they know you and what you are already capable of and can help train you further. If you're  really really really lucky, your company will have a budget to send you on courses to catch up even faster.


答: It can be done.  It won't be easy, especially if you want to get good at it, since software development is an engineering discipline with non-obvious problems and pitfalls you'll need to learn to recognize and avoid.  That'll take a few years of serious study and practice, but if you can wrap your head around the concepts, you can definitely become a programmer even if your background is in something different.</p>

Title: Am I deluding myself? Business analyst transition to programmer

Body:
Current job: Working as the lead business analyst for a Big 4 firm, leading a team of developers and testers working on a large scale re-platforming project (4 onshore dev, 4 offshore devs, several onshore/offshore testers).  Also work in a similar capacity on other smaller scale projects.

Extent of my role: Gathering/writing out requirements, creating functional specifications, designing the UI (basically mapping out all front-end aspects of the system), working closely with devs to communicate/clarify requirements and come up with solutions when we hit roadblocks, writing test cases (and doing much of the testing), working with senior management and key stakeholders, managing beta testers, creating user guides and leading training sessions, providing key technical support.

I also write quite a few macros in Excel using VBA (several of my macros are now used across the entire firm, so there are maybe around 1000 people using them) and use SQL on a daily basis, both on the SQL compact files the program relies on, our SQL Server data and any Access databases I create.  The developers feel that I am quite good in this role because I understand a lot about programming, inherent system limitations, structure of the databases, etc so it's easier for me to communicate ideas and come up with suggestions when we face problems.

What really interests me is developing software.  I do a fair amount of programming in VBA and have been wanting to learn C# for awhile (the dev team uses C# - I review code occasionally for my own sake but have not had any practical experience using it).  I'm interested in not just the business process but also the technical side of things, so the traditional BA role doesn't really whet my appetite for the kind of stuff I want to do.  Right now I have a few small projects that managers have given me and I'm finding new ways to do them (like building custom Access applications), so there's a bit here and there to keep me interested.

My question is this: what I would like to do is create custom Excel or Access applications for small businesses as a freelance business (working as a one-man shop; maybe having an occasional contractor depending on a project's complexity).  This would obviously start out as a part-time venture while I have a day job, but eventually become a full-time job.  Am I deluding myself to thinking I can go from BA/part-time VBA programmer to making a full-time go of a freelance business (where I would be starting out just writing custom Excel/Access apps in VBA)?  Or is this type of thing not usually attempted until someone gains years of full-time programming experience?  And is there even a market for these types of applications amongst small businesses (and maybe medium-sized) businesses?


答:
How ridiculous do you want to get?  You can always use multiple linear regression to generate coefficients for each player based on the scores of their teams in previous games.  Then sort the list and select.

In reality it probably wouldn't work since it doesn't model the dynamic between players, but it'll give you a reason to play around with R.  (<-- see, I kept it programming related)


问:
Improving performance for grepping over a huge file
I have FILE_A which has over 300,000 lines and FILE_B which has over 30 million lines. I created a Bash script that greps each line in FILE_A over in FILE_B and writes the result of the grep to a new file.

This whole process is taking over 5 hours.

How can I improve the performance of my script?

I'm using grep -F -m 1 as the grep command. FILE_A looks like this:

```<code>123456789
123455321
</code>```

and FILE_B is like this:

```<code>123456789,123456789,730025400149993,
123455321,123455321,730025400126097,
</code>```

So with Bash I have a while loop that picks the next line in FILE_A and greps it over in FILE_B. When the pattern is found in FILE_B, I write it to file result.txt.

```<code>while read -r line; do
   grep -F -m1 $line 30MFile
done < 300KFile
</code>```

答:
Try using grep --file==FILE_A.  It almost certainly loads the patterns into memory, meaning it will only scan FILE_B once.

```<code>grep -F -m1 --file==300KFile 30MFile
</code>```

Body:
Try using grep --file==FILE_A.  It almost certainly loads the patterns into memory, meaning it will only scan FILE_B once.

grep -F -m1 --file==300KFile 30MFile


答:
Let us assume for the sake of discussion you can assign each player an integer value and those values add up, that is a player with score X is as valuable as three players with scores A,B and C, if A+B+C = X. The goal is then to separate the group into two teams so that both teams have about equal summed value.

This is the optimisation version of the famous PARTITION problem which is NP-complete. Therefore, your problem is for all we know hard to solve. However, PARTITION is weakly NP-complete and admits some reasonable approximation strategies.

One example is a greedy approach similar to what Steven proposes. This is a 4/3-approximation, that is the stronger team is never more than about 33% stronger than an in optimal split.

Note that you probably have additional constraints such as you need at least a fixed amount of players per team. So if you put Michael Jordan in a class of preschoolers, you won't be able to create nearly fair teams that have full number. Such a (constant) lower bound on team size should not impact the hardness of the underlying problem but it might destroy approximation bounds valid for the general problem.


答:
If you don't mind some more involved programming, consider using suffix trees (or a variant).

You can preprocess FILE_B using Ukkonen's algorithm in linear time. Then, you query each line in FILE_A in time linear in line length and get all the line numbers that match (might need to adapt the tree a tad) which you can write to a result file.

The whole procedure runs in time O(n + Nm) if n is the length of FILE_B, N is the number of lines in FILE_A and m is the length of the longest line in FILE_A -- this is essentially linear runtime. Beats the quadratic time your original approach needs by magnitudes.

Title: Improving performance for grepping over a huge file

Body:
I have FILE_A which has over 300,000 lines and FILE_B which has over 30 million lines. I created a Bash script that greps each line in FILE_A over in FILE_B and writes the result of the grep to a new file.

This whole process is taking over 5 hours.

How can I improve the performance of my script?

I'm using grep -F -m 1 as the grep command. FILE_A looks like this:

```<code>123456789
123455321
</code>```

and FILE_B is like this:

```<code>123456789,123456789,730025400149993,
123455321,123455321,730025400126097,
</code>```

So with Bash I have a while loop that picks the next line in FILE_A and greps it over in FILE_B. When the pattern is found in FILE_B, I write it to file result.txt.

```<code>while read -r line; do
   grep -F -m1 $line 30MFile
done < 300KFile
</code>```


答:
Whether it will take years or year is largely up to you, your schedule, but most importantly, your interest level which tends to be tied to aptitude. If you happen to live or work in a city and have the option of mass commuting, take it and use that built-in commute time to read tech books. Anything that interests you.

As far as the audacity of thinking you can, don't sweat it. Deciding that you could probably handle that <insert unknowable pile of complexity here> is what devs do. That's not arrogance, it's just taking the first step.

Arrogant in developer land is calling yourself a professional dev when you have one solution for everything and you haven't learned anything new since college. That's the rub with development. When you stop learning your career starts going downhill, so interest is kind of key. Sounds like you have that.

So go for it.

You've got your target in sight. The rest is breaking the big scary problems into little not-so-scary ones. Repeat ad nauseum and you'll be a paid full-time developer who wishes there were more bigger/scarier problems than there used to be sooner than you might think.


答:
I found the --mmap flag lately, didn't have a chance to test it, but I'll be happy to hear about your findings. Here is the description from man page:

```<code>--mmap If  possible, use the mmap(2) system call to read input, instead
      of the default read(2) system call.  In some situations,  --mmap
      yields  better performance.  However, --mmap can cause undefined
      behavior (including core dumps) if an input file  shrinks  while
      grep is operating, or if an I/O error occurs.
</code>```

See this or this for further info about mmap.

Body:
I found the --mmap flag lately, didn't have a chance to test it, but I'll be happy to hear about your findings. Here is the description from man page:

--mmap If  possible, use the mmap(2) system call to read input, instead
      of the default read(2) system call.  In some situations,  --mmap
      yields  better performance.  However, --mmap can cause undefined
      behavior (including core dumps) if an input file  shrinks  while
      grep is operating, or if an I/O error occurs.

See this or this for further info about mmap.


问:
Fear of releasing a hobby project - how to overcome?
I don't know if this question is strictly related to software development, but still I'll give it a try:

Like a lot of programmers, I love to work on hobby projects. Sometimes, seemingly good ideas turn out to be not so good, so I drop the project. But sometimes, something useful comes out of the project. So, I could release it, present it to the world, right?

Wrong. Somehow, I don't seem to be able to make this step. I fear that my code is not good enough, I can always think of things which are suboptimal, of features which could be added. So, I don't release anything, I lose interest, and at one point abandon the project.

Is this normal? How do you overcome such a situation?

答:
Here's one reason to release unfinished software: to start building a community. If you want your project to become a useful open source tool, you need other developers. One way to attract them is to release it early, and then continue to (publicly) make improvements. Don't add those features in secret - do them publicly, on the Github page, or wherever. That generates activity in the history.

Other developers don't want to work on an apparently abandoned project. So doing your development work in public demonstrates active, ongoing interest. It's worth intentionally keeping a few features up your sleeve so you can add them in public.


问:
Single Responsibility Principle - How Can I Avoid Code Fragmentation?
I'm working on a team where the team leader is a virulent advocate of SOLID development principles. However, he lacks a lot of experience in getting complex software out of the door.

We have a situation where he has applied SRP to what was already quite a complex code base, which has now become very highly fragmented and difficult to understand and debug.

We now have a problem not only with code fragmentation, but also encapsulation, as methods within a class that may have been private or protected have been judged to represent a 'reason to change' and have been extracted to public or internal classes and interfaces which is not in keeping with the encapsulation goals of the application.

We have some class constructors which take over 20 interface parameters, so our IoC registration and resolution is becoming a monster in its own right.

I want to know if there is any 'refactor away from SRP' approach we could use to help fix some of these issues. I have read that it doesn't violate SOLID if I create a number of empty coarser-grained classes that 'wrap' a number of closely related classes to provide a single-point of access to the sum of their functionality (i.e. mimicking a less overly SRP'd class implementation).

Apart from that, I cannot think of a solution which will allow us to pragmatically continue with our development efforts, while keeping everyone happy.

Any suggestions ?

答:
I agree with your team-lead decision [update=2012.05.31]that SRP is generally a good think. But i totally agree to @ Spoike -s comment that a constructor with 20 interface arguments is far to much.[/update]:

Introducing SRP with IoC moves complexety from one "multi-responsible-class" to many srp-classes and a much more complicated initialisation for the benefit of

easier unit-testability/tdd (testing one srp-class in isolation at a time)

but at the cost of

a much more difficuilt code initialisation and integration and

more difficuilt debugging

fragmentation (= distribution of code over several files/directories)

I am afraid you cannot reduce codefragmentation without sacrifying srp.

But you can "ease the pain" of codeinitialisation by implementing a syntactic sugar class that hides the complexity of initialisation in a constructor.

```<code>   class MySrpClass {
      MySrpClass(Interface1 parm1, Interface2 param2, .... Interface20 param2) {
      }
   }

   class MySyntaxSugarClass : MySrpClass {
      MySyntaxSugarClass() {
         super(new MyInterface1Implementation(), new MyImpl2(), ....)
      }
   }
</code>```

OwnerDisplayName: Dean Chalk

Body:
I agree with your team-lead decision [update=2012.05.31]that SRP is generally a good think. But i totally agree to @ Spoike -s comment that a constructor with 20 interface arguments is far to much.[/update]:

Introducing SRP with IoC moves complexety from one "multi-responsible-class" to many srp-classes and a much more complicated initialisation for the benefit of

easier unit-testability/tdd (testing one srp-class in isolation at a time)

but at the cost of

a much more difficuilt code initialisation and integration and

more difficuilt debugging

fragmentation (= distribution of code over several files/directories)

I am afraid you cannot reduce codefragmentation without sacrifying srp.

But you can "ease the pain" of codeinitialisation by implementing a syntactic sugar class that hides the complexity of initialisation in a constructor.

   class MySrpClass {
      MySrpClass(Interface1 parm1, Interface2 param2, .... Interface20 param2) {
      }
   }

   class MySyntaxSugarClass : MySrpClass {
      MySyntaxSugarClass() {
         super(new MyInterface1Implementation(), new MyImpl2(), ....)
      }
   }


答:
I'd say (if you want to kickstart things) go with SICP - Structure and Interpretation of Computer Programs. I should link to it, but it's more than just a book; nowadays you can find also other people to study the course with online. It's a really hard book - completing all exercises is something most developers can't do (unfortunately), but it is the best book available. MIT OCW is also good, but IMHO it's a watered down version of SICP for programming. Python is designed to hide away complexity, rather than make you enjoy it in a sick manner (as SICP does).

Also, you need to distinguish between programming as a profession, and programming as a skill. One requires dedication to things like beautiful, clean and extensible code, while the other requires nothing but algorithmic skills (which is quite a lot, actually). The 'benevolent dictator' of Python, Guido van Rossum, argues that programming will be an essential skill in the years to come, but software development skills won't be, in any case. Most non-developers write code to throw it away (developers do this often, too). The thing is programming as a career includes a lot more things than programming and it's important to straight your priorities.

Most important: Be sure to love programming, not just like it. It's more than a 9 to 5 job, it's to embrace the constant-learning philosophy: most engineers get trained during their BS or MSc and do not see significant change in their field of expertise. A lifelong career in programming will make you see at least 10 paradigm shifts (not just languages, but tools, DBs, etc.), so you better be ready (and willing) to accept this.


答:
Neither. What does your app need to be able to do? Make sure the hot valve delivers hot water, the cold valve delivers cold water, that the water flows in the first place, that you can extend pipes wherever needed and then worry about implementing actual plumbing to all rooms of the house or what the house will actually look like exactly.

The front end is just a mask with some switches and levers on it. The back end is just a thing that receives requests to retrieve and process data. Get to a point where you can rapidly implement both in any desired combination first.

But whatever you do, don't let the design of one dictate the design of the other. That way madness lies.

Get the tools in place to let your devs build whatever the heck they need for your client, regardless of how many times they change their mind. Then build it to specifications and rejigger it until the little cusses are finally happy.

Also, comparing front end devs to back end devs in 2008 is a long time ago in web years. For the sake of fun, I'd like to correct/add a few things to that old chestnut since we've linked it in the question, but also (hopefully) embed a few tips within:

Front end developers

Typically don’t have a CS degree, or have a CS degree from a 3rd tier school.

Show of hands. How many people with CS degrees have been taught best practices on the front end? Or how to not make a mess with JavaScript? Or how to handle CSS problems from IE6-IE9? The textbook industry, which runs academia, is too fat lazy and bloated to handle constantly shifting technology so it has received very little 'serious' attention in colleges. This has been excellent for late-bloomers like myself.

Work in languages that similar to basic (see PHP is Basic)

Because PHP is client-side technology? Or because JavaScript, which was inspired primarily by Scheme has more in common with Basic then Visual Basic which is now no longer a going concern on the front end and never really was but is still available for back end .NET web applications? The blog compares self-taught open source web developers with CS grad web developers using corporate-popular tech at this point I think. I've run into insufferable and competent in equal shares on both sides of that particular fight but he's still way OT there.

Have a visual skill in converting photoshop documents to CSS/HTML/etc.

More attention to detail than "visual skill" which is a bit broad. Not all of us have any aesthetic design skills whatsoever. But yes, most of us have to learn this stuff at the Jr. level and it's actually quite thoroughly critical to writing good UI that doesn't use JS hammers when CSS scalpels will do.

Have a high tolerance for iterative programming, due to type free languages

This is why you want the pieces I mentioned earlier in place first. We pass on the buttons pressed, you produce/retrieve the goods. We package and deliver them. There is no reason for these things to in any way be tightly bound to each other. Also really, strict typing should not interfere with an iterative process if you don't suck at OOP which most people who like to get haughty about a language not technically having classes, in fact do, typically. But even if they do stink, the front end only needs a predictable point of access and you can do whatever the heck you want on the back end as long as you don't do something silly like dynamically write JavaScript that isn't JSON or tightly bind successful back end behavior to HTML structure being "just so." *cough* java devs */cough*

Title: Front end first or Back end first. Of the two which is a Good system design pratice?

Body:
I have a client right now requiring me to develop a school enrollment system. Now this is the first time im having this kind of challenge. Most of the past software that i created are not that complex.

I know most all of you have created complex softwares, i just want your advise on this. Should i design first the front end or back end?

thanks!

Here's a conclusion of an article I found in the internet a while ago. Just whant to share

http://www.skitoy.com/p/front-end-vs-back-end-developers-my-take/157

Front-end vs. back-end developers (my take)

My personal take

Again it’s a matter of training, some broad stroke generalizations:

Front end developers

Typically don’t have a CS degree, or
have a CS degree from a 3rd tier
school.

Work in languages that similar to
basic (see PHP is Basic)

Have a visual skill in converting
photoshop documents to CSS/HTML/etc.

Have a high tolerance for iterative
programming, due to type free
languages

Back end developers

Have a CS degree or lots of
experience

Tend to me more systematic in their
problem solving approach

Don’t mind spending days finding the
one object that is leaking

Try and build tools to solve problems


问:
Wisdom of using open source code in a commercial software product
I'm looking at using some open source code in my ASP.NET web app (specifically dapper).  Management is not a fan, because open source is seen as a risk that has bitten us before.  Apparently previous developers have had to rewrite things after having open-source components fail.

The pros seem to be:

It does a lot of stuff for me that would otherwise involve either lots of boilerplate code or Microsoft's recommended but slower solution (Entity Framework).

Cons:

It's complex enough that if it were to fail suddenly in production, I would be hard pressed to fix it.  However, it's in use on a much higher-traffic site than mine, so I don't think it'll end up being a high risk portion of the project.

What is the consensus here?  Is it unwise to use open source code in my project that I don't know/understand as well as I do my own code?

答:
It's a choice that you'll have to make based on the specific circumstances. You can mitigate your risks by:

testing the framework thoroughly, avoiding the likelihood of nasty surprises biting you in a production environment, and

using loose coupling to minimize the amount of code that depends on the framework directly, so you can change to your own implementation if you have to without rewriting your entire product.

Ultimately, with a heavily-used open-source project you're likely to spend a lot more time writing your own than fixing the few issues you run into.


答:
I think it wise if sufficient due diligence is done and it appears that you've already done some homework with respect to the history and activity of a particular project. The ability to extend/add features in the source code is also a big pro.  With sufficient testing you can minimize the risk on the con side.  It is hard to completely understand all dependencies in your code, but at least in that case you will be able to fully debug and view the code if necessary.

Ask the management why it had failed before, was sufficient due diligence done?

Title: Wisdom of using open source code in a commercial software product

Body:
I'm looking at using some open source code in my ASP.NET web app (specifically dapper).  Management is not a fan, because open source is seen as a risk that has bitten us before.  Apparently previous developers have had to rewrite things after having open-source components fail.

The pros seem to be:

It does a lot of stuff for me that would otherwise involve either lots of boilerplate code or Microsoft's recommended but slower solution (Entity Framework).

Cons:

It's complex enough that if it were to fail suddenly in production, I would be hard pressed to fix it.  However, it's in use on a much higher-traffic site than mine, so I don't think it'll end up being a high risk portion of the project.

What is the consensus here?  Is it unwise to use open source code in my project that I don't know/understand as well as I do my own code?


答:
The bad news is that doing good front end work isn't about being a designer. There's a ton of best practices out there worth picking up that you'd do well to advise yourself on but here's some of the bigger ones:

The separation trinity - You separate HTML (content), from CSS (presentation), from JavaScript (behavior) by linking files and avoiding inline/embedded styles and keeping JS completely out of the HTML. Just try it. It makes your job easier. And yes, there are gray areas. That's okay. Nobody punishes you for violating/bending these rules. Just consider them as you work. Because it's easier.

Semantic HTML - HTML describes content. Div and spans are not blanks to be fired at will. We do not wrap things willy nilly unless it saves gobs of time and effort to (once in a rare while) do so. So no, knock it off with the HTML wrapper business and yes you can tell the Drupal and Joomla communities that I hate them. WordPress is okay. Again. Sounds strict. Makes front end work easier. There are also accessibility and SEO wins that are IMO, oversold compared to the reduction of HTML bloat factor.

Unobtrusive JavaScript - tied to the separation principle but the general idea is to wire your event logic from behind the scenes not at the source via onclick handlers. Considered a gray area by too many, IMO, I find it's almost like an index for your front end app's behavior to have all event handlers in one centralized area. Again, it makes your job easier. That's the intent. Lazy developers think about this stuff, not ones that like to work hard.

Use JQuery. Sorry but it's pretty much duh. Most people don't have time to normalize and reduce DOM cruft and boilerplate looping of large HTML collections.

Don't overuse JQuery. Learn JQuery so you don't become overly reliant on plugins and libraries. Because they tend to stink. Also make sure you learn enough to know how to DIY outside of a JQuery context. Not everybody uses it after all.

Learn new stuff about CSS and JavaScript daily. There is a lot to know. No, it never ends. No, if you want to be a pro at it you have to know how to DIY before you can even pick the tools that don't stink unless you're just focusing on temporary disposable one-off sites for the sorts of people who go to advertising/interactive agencies looking for web sites.

Start with DRY and loose coupling (google). Then learn OOP principles when you feel like they might start to matter to you.

Title: Asynchronous Designing and Programming

Body:
Me and a friend are looking to team up for some freelance web designing. We both are very strong PHP coders and website designers, but I am better at design and he is better at PHP. So, I'll be controlling the stuff the user sees, he'll be controlling the stuff the user does.

In order to speed up development, I'm wondering if anyone has experience or recommendations for asynchronous web designing and coding. So far my best idea is to create a doctrine of which tags and classes every element should be wrapped in (if any), then have us developing via FTP. He would create the code that spits out snippets of HTML, and I would simply style those snippets and wrap it in the page. Does anyone know of a better way?

So, any ideas?


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

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

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

答:
If you are confident that given a programming test in that technology as part of the interview, you would manage it, then it is fine.

If you were to say,

actually I haven't used X in a while
  so I am a bit rusty...

Probably best not to list it as a skill. Doesn't mean you can't mention elsewhere on previous projects you have worked on.


答:
Are you sure that managements problem are technical concerns.

I say this as mixing OS and commercial activity is a legal mine field, and more than one manager has had a "Please Explain" from the legal team / CEO or worse, from another organization. Most managers I know, even those that actively embrace OS software, are (rightly) very cautious to fully understand the legal situations they are exposing the origination to.
If you adopt OS software and make changes, you are obligated to return those changes to the community. In some cases, this obligation is legal, in others moral. In some OS licenses, everything you do becomes OS just by linking to them.

From a technical viewpoint, it's really just a decision between competing products - Ask some basic questions -  Can you get the support you need for the package you choose?, How long to get a fix to a reported defect, how much will it cost per developer, per year or one off etc. OS has lots 0's in the $ column, but often has blanks in the others - only you and your boss can decide is the 0's out weight the blanks or not.

And one other point to remember - "No one ever got fired buying IBM". (i.e. management speak for "If you spend a lot of money it must be a better product than one that is free"


答:
I've worked on a number of successful projects for a large company that used substantial bits of open source software.  In particular, I've used Curl, SQLite and Webkit all for a very large company on successful projects that shipped to end users.  As others have said, it's just a matter of being careful about licenses and ideally having a lawyer look them over.

There are hundreds of open source licenses, but generally they fall into two categories, BSD style and GPL style.  BSD style licenses don't require you to open source your own code, and generally just have some sort of attribution clause.  GPL style licenses do require you to open source your own code.  Most companies (including mine) generally look askance at that so you'll want to avoid GPL style.  Dapper appears to use the Apache license, which is BSD style.  Always figure out what the general license terms are before you start coding.

There's also the LGPL, which is an interesting border case in that you can use these while not opening your own code if you restrict access to a binary boundary.  (I.e. access the library only as a dynamic library.)  LGPL library usage is very doable, you just have to be more careful.

In my experience, open source code is no more likely to turn out to be buggy or fail than for-pay solutions, or, for that matter, roll-your-own solutions.  If you look at some of the more prominent open source tools, the quality is very high.

You probably do want to avoid projects that are small, or not complete.  It can be tempting to grab something that seems to meet your needs, but if they were something put together by a couple of people, never completed and unsupported, it is probably not worth the effort.  (Unless you are willing to work on the code directly.)