I am not an attorney, so nothing here should be taken as legal advice. It should be considered in the way it's written… as past experiences and pitfalls.
That being said, the first thing you must do when you want to start a company is spend a bit of time reviewing the legal side of things. Every engineer and geek I've ever met – myself included – believes that this can all be done by reading the law and following it to its logical conclusion. Although this seems logical, you have to remember that the enforcement of the law is based on two primary aspects: What is written vs How its been interpreted. The first is easily determined and googled. The second requires a bit of experience and arcane understanding of how Case Law works.
Personally, there are four different factors which immediately come to mind and seem to resurface the most commonly:
Organization of your business
Terms and Licensing of your work
Now let's break them down one by one…
I've written about Non-disclosure Agreements (or NDA's) before but the summary is that an NDA basically says something along the lines of “I have confidential information which I have to share with you to do your job and you agree not to give it to anyone else or use it for unauthorized purposes”. Whenever you want to start a business, check the contracts you've signed and see if you are covered by any NDA's which may be relevant. If you're staying in the same industry or working on a similar product, there may be some issues you need to have resolved and clarified. Before you do anything else, go speak to an attorney. There are many attorneys who focus on small business, entrepreneurs, etc and it is their job to figure out these intricacies. If you're in the US, check out your local Small Business Administration office as they'll most likely have a list of attorneys or maybe even some on staff you can speak to. Oh… and customer lists and contacts are almost always considered confidential information regardless if you signed anything. If you attempt to use this information, you're in for a world of hurt. Don't even consider it.
Non-compete agreements are a whole other animal and many companies attempt to combine them with NDA's. A non-compete basically says “our organization works in industry X, Y, Z and while you work for us and N days/months/years after, you can't compete against us”. The whole concept of “domain experience” goes against this and could make it difficult for you. This is another place where you want to speak to an attorney to determine where it is applicable and if it is enforceable. From my understanding (not legal advice here), the “enforcability” of a non-compete is based on the broadness of the agreement and whether it prevents you from making a living. When I was just starting off after college, I (mistakenly) signed a non-compete that said I wouldn't work for any competitor within 50 miles of the company's customers for a period of 2 years. Since one of their customers was the FBI, this covered every world capital and most of the continental United States. It was absurd and – according to a trusted attorney – wouldn't hold up if they attempted to enforce it. This is a place where geeks make a major mistake. They immediately ask their boss, get an okay, and move on their idea. BUZZT. WRONG.
Even if you get a verbal “okay” from a boss, supervisor, etc, who says they're authorized to make such a decision? What prevents them from making a new decision when you accidentally win over one of their customers? What prevents them from saying “no” and firing you outright?
This is *not* an area to screw up, especially since a company will rarely sue a competitor who's going under. They're going to wait until the revenue starts rolling in or when you've taken one of their customers. Even if the non-compete is totally unenforcable, a legal battle is a minefield you may not have the time, money, or credibility to navigate through. For reference, check out IBM v. SCO. SCO is losing and losing badly but they managed to taint the whole of Linux for quite a while…
Business incorporation is a bit simpler. The main things your incorporation determines are: ownership structure, legal exposure (called liability), and your taxation/filing requiremnts. Depending on the structure you choose, dividing ownership (eg. to Angel Investors or VC's) can be difficult or even impossible, so stop and look at what your goals are before you file the paperwork. In the US, the costs vary from state to state and even county to county, but I've found this to range anywhere from sub-$100 to multi-$100's. This is one thing that you can easily do yourself, especially if you visit a site like Nolo to get the basic template documents. Who knows, you may be the best off with a non-incorporated entity… but it's a decision worth thinking about.
The final aspect to consider is the Terms and Licensing of your work. If you're a 1099 for an organization, most likely you are “work-for-hire” and everything you do is theirs. If you're building a product to sell, you are not granting them “ownership” of anything except a license which has particular usage clauses. For example, although I “own” a CD set of Diablo II (old school, I know), I don't “own” Diablo II. I can't redistribute it, probably can't reverse engineer it, but probably can sell my license to someone else. Regardless of if you like it or now, this is how it works.
Alternatively, if you're doing custom software for someone, you have to determine the terms and “acceptable use” that applies. Do they own the software outright or do they have a license? Do they get access to the source code? Are they allowed to distribute it? Can they sell or transfer their license? Can they build things on top of it? Can they distribute those? Can their license be revoked? When does the license activate/expire… on delivery, on payment, or after N days?
For this, you MUST get legal advice. If you throw in terms or conditions that are inapplicable or illegal, you may end up nullifying sections and making enforcement much more difficult. If you're just starting off, this can be difficult, so you can go the route I did. Nolo has a variety of applicable contracts. I spent about $70 buying a few of their templates and filled in the details. Later, after the $'s were flowing, I had an attorney review and add a few terms. This was sub-$300 and well worth it. For example, when a customer of mine decided not to pay, I attempted to participate in mediation as defined by our contract. The mediator said almost immediately to the other person “you're going to lose, now the question is how much are you going to have to pay?” Having a clear cut contract laid out in advance is only going to help you by clarifying what is who's responsibility. The room for interpretation is much smaller.
In case you haven't figured it out, my goal here is to convince you that there are things you should handle and things that an attorney is best equipped to handle. Don't try to be a master at all things. Choose your thing and focus on that. Let the other pros handle the other things.