|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, August 05, 2010 5:19 AM
Points: 1,
Visits: 8
|
|
I also agree, that you must write SQL code maintainable. But NOT on the way they describe in this article. If you check VB.NET or C# developers, they all write in good maintainable code. If they use SQL, then it is an disaster. I have some good samples: When you use columns in a select statement, place the comma at firtst. Now you can easely comment a column: SELECT ColumnA , ColumnB -- , ColumnC FROM TABLE1 WITH (NOLOCK) WHERE STATEMENT1 = @p_PARAMETER AND STATEMENT2 = @l_PARAMETER I also places all columnnames on the same place and all signs and parameters. Now you can easily read the code.
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 7:18 AM
Points: 33,112,
Visits: 27,038
|
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Monday, November 12, 2007 6:32 AM
Points: 62,
Visits: 3
|
|
>>If you check VB.NET or C# developers, they all write in good maintainable code Being a .NET developer I can safely say that they do not all write in good maintainable code.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Today @ 7:52 AM
Points: 205,
Visits: 707
|
|
WHERE SvcTypeID IN (1, --Standalone Long Distance 2, --800 Service 3, --800 Pin 5, --Calling Card 1801 --Bundled Services )
whether this is commented "properly" or not, I ask why these values are not in a table. I know the knee-jerk response is that it's easier/faster to use this construct, but how often has easier/faster for the developer been the long term growth solution? If these values do not exist in a control table, why not? If they ARE, then why is the developer hard-coding this list of services into the procedure? In an article on maintainable SQL, I would have expected hard-coding to be absolutely forbidden.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Monday, November 15, 2010 9:15 AM
Points: 158,
Visits: 15
|
|
Just weighing in... good points in the article... I think some comments have their place, for example when you do something strange in the code for a good reason. An example I used recently is I had to create an in-line query that was nested twice. It was very unpleasant but it did the job. I commented it carefully so that developers who had to maintain the code could understand the thought process and why it was done like that. My only pet-peeve regarding comments is when developers comment out reams of code and LEAVE IT IN THE PROGRAM. Trying to read and decipher that is a difficult task. It is even more pointless if you are using a version maintenance tool, such as SourceSafe. Just remove it, add a comment if you must indicating that code was removed and refer to SourceSafe. When I have to maintain a new program, I do 2 things, one is add whitespace, as article author indicated, and two is delete commented out code. MikeZane
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 7:18 AM
Points: 33,112,
Visits: 27,038
|
|
Heh... I asked the same thing... and the answer is... crappola 3rd party software. So, Mike, you never hardcode anything? 
--Jeff Moden "RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Today @ 7:52 AM
Points: 205,
Visits: 707
|
|
nearly never. Absolutely never in a public example of maintainable code. 
I forced myself to develop a habit of taking the minor pain up front to set up and use the DB for data rather than the major pain returning to the project months later and having to figure things out.
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 7:18 AM
Points: 33,112,
Visits: 27,038
|
|
That's actually a pretty good plan and I agree with that... nice to see someone to spend a little time up front to save wads later on.
--Jeff Moden "RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
|
|
|
|