Why care about opening connections either?


If a business app developer shouldn't care about closing a connection, it should care less about opening it.

This step prior to executing any statement against a database seems natural to most of us today because it's what we've been doing for ages now. However, connecting to a database implies a lot of knowledge and a developer should never care about this.

Also lots of quite deep technical decisions are made at the connection statement. The "connection string" is usually a text blob of all sorts of potentially dangerous knobs and levers: resource restrictions (pool management params), timeouts, security configurations, etc.

How many apps fail to work when moved from dev to test and then to production because the connection string is "hardcoded" or is buried somewhere in an obscure .ini (or .config) and assumptions on one environment are simply wrong in another?

Again, connection to a db is a serious business. The underlying architecture in which a program or component runs should take care of that for all of us simple mortals writing "business logic". Database connectivity, location, security considerations are all a different "concern" and its better to keep it separated from the business code.

 

Comments (6)
  1. AT says:

    Willing to know who is guilty ? 😉

    Microsoft !!

    You waited too long to make it easy to call "Connection Settings" dialog like one from IDBPromptInitialize::PromptDataSource from managed enviroment ( at http://msdn.microsoft.com/library/en-us/oledb/htm/idbpromptinitializepromptdatasource.asp )

    I’ve suggested this 1 year and 21 days ago as 110191227 at betaplace.

    I’ve got an answer from Microsoft product groups that it was fixed. But answer were dated 2 April 2004 (too close to April Fools day 😉

  2. Ovidiu says:

    This has nothing to do with databases. It has a lot to do with good programming practices instead. You’re not supposed to hardcode constants in code (if you remember you programming 101 course), you’re supposed to group them somewhere and then decide whether they’re truly constant, or whether they are environment dependant but can be obtained automatically (like the Windows folder, for instance) or environment dependant and must be configured by an administrator (like the connection string).

    The SqlConnection is not the problem. Developers’ knowledge (or lack of it, thereof) is the main culprit.

  3. Steven says:

    You have a tag [a name = "feedback /] (angle brackets converted to square brackets, of course), which is invalid according to the HTML spec. The anchor tag is not an empty element according to the DTD specified in your doctype and therefore it is not permissible to use the shorthand of closing the element by ending the start tag wih /> . Standards-compliant browsers such as Mozilla then apply the a:hover style to all following text. This causes all feedback comments to turn white (visually: disappear) when the mouse cursor is over them… Simply change it to [a name="feedback"][/a] and you should be fine.

Comments are closed.

Skip to main content