What is mean by Programming styles?

  • Heh... good point, Brian. And, (I forget who said it) sometimes you must unlearn what you have learnt in order to find and fix a problem.

    But, I believe the point being made is the kid didn't automatically label himself a Senior Software Engineer after the SMS fix. Carrying that title also carries a certain amount of responsibility for knowledge. While I appreciate the great zeal of the OP, that hasn't exactly been demonstrated on this or similar threads.

    Standing in the garage, doesn't make you a car. 😛

    --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.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden (11/23/2007)


    But, I believe the point being made is the kid didn't automatically label himself a Senior Software Engineer after the SMS fix. Carrying that title also carries a certain amount of responsibility for knowledge. While I appreciate the great zeal of the OP, that hasn't exactly been demonstrated on this or similar threads.

    I won't disagree there. However, if that's the title his company has chosen to bestow upon him, I won't fault him for using it. Granted, I would consider carefully before doing so. After all, a company might bestow upon a person, "Imperial Ruler of the Fiefdom of SQL Server," but if it were me, I certainly wouldn't use that in public.

    K. Brian Kelley
    @kbriankelley

  • Heh... I'd normally agree, but I can't buy that one in this case, Brian. Unless the company puts crack in the coffee machines, they're not going to give the title of "Senior Software Engineer" to someone with 1.8 years of IT experience and who's maybe still in school (or should go back to school). 😀

    --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.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • I've run across organizations who have titled folks "Senior Sybase DBA" for a guy who had 0 days of experience with the product when first receiving the title and putting folks who couldn't score out of the 200s on the SQL Server 6.5 Administration exam in charge of managing the SQL Server 6.5 servers, so anything is possible. I'm also the type, though, that tend to give the people the benefit of the doubt.

    With that said, Karthik, one of the things that tends to separate good people from not-so-good people in IT is curiosity. Do you have a desire to learn? Are you willing to admit you don't know something and then are willing to do something about that lack of knowledge? Your posts demonstrate that you are, and even if you aren't an expert in a particular technology area, if you continue down the path you are on, you surely could be.

    K. Brian Kelley
    @kbriankelley

  • Now, those sound like some pretty strange places... Senior Sybase DBA with 0 days experience... they must have had a death wish. 😉

    --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.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Guys,

    As per me programming styles consist of writing code way, commenting, query forming, readblitiy of code...

    is it correct ?

  • Yes... pretty much all of that and more... for example, you'll never see me use a While Loop to create a list of contiguous dates... I'll always use a Tally table for that (and a lot more). You won't see me use a triangular join to create a running total like most folks do. Some of the "style" of a programmer can be found in the performance techniques used.

    Another "style" thing might be found in how much a developer tries to put in a single query or how and what they use derived tables for.

    --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.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • I am in IT business for over 20 years, working as a database developer / DBA / data warehouse developer for the last 10 years, mostly working with Oracle and SQL Server. I don't consider myself as senior programmer except my age (don't ask me my age, I started my career at very young age :P). I still feel liked I don't know I lot of things, especially when I am looking for a job, the employers now ask people to know everything.

    Of course I have my own style of programming. However I always had to adept to the company standard. So my style changed a bit depending on what company I worked for.

  • you'll never see me use a While Loop to create a list of contiguous dates... I'll always use a Tally table for that (and a lot more).

    Sounds like a useful widget. Got an example?

    Steve G.

  • aureolin (11/24/2007)


    you'll never see me use a While Loop to create a list of contiguous dates... I'll always use a Tally table for that (and a lot more).

    Sounds like a useful widget. Got an example?

    Steve G.

    You bet... comin' right up...

    First, a "Tally" table (some folks call it a "Numbers" table) is nothing more than a table that contains a single column of very well indexed sequential numbers from 1 (or 0, your choice... some advantages to starting at "1", though) and running up to some predetermined number. I use 11,000 for that "end number" because 30 years * 365.25 days per year = 10957.50 days and that number is also greater than the maximum number of bytes that can be held in a VARCHAR(8000) or a VARIANT (8060). More on that later... here's how to make a Tally table...

    --===== Create and populate the Tally table on the fly

    SELECT TOP 11000 --equates to more than 30 years of dates

    IDENTITY(INT,1,1) AS N

    INTO dbo.Tally

    FROM Master.dbo.SysColumns sc1,

    Master.dbo.SysColumns sc2

    --===== Add a Primary Key to maximize performance

    ALTER TABLE dbo.Tally

    ADD CONSTRAINT PK_Tally_N

    PRIMARY KEY CLUSTERED (N) WITH FILLFACTOR = 100

    --===== Allow the general public to use it

    GRANT SELECT ON dbo.Tally TO PUBLIC

    Although some consider it a Taboo, some folks I know build it in the Master database so it's available in all databases by all users... it's that useful.

    For example, how to build a range of whole dates... let's say you wanted to work with all the dates from 20000101 to 20100101... with a Tally table, it's easy and it can be done in a derived table in another query (you could actually build a function to do it, if you'd like)...

    --===== Declare a couple of variables to identify the

    -- desired date range for this demo.

    DECLARE @StartDate DATETIME

    DECLARE @EndDate DATETIME

    SET @StartDate = '20000101'

    SET @EndDate = '20100101'

    --===== Create a result set that can be used either in a

    -- derived table or in a table variable function.

    SELECT CalculatedDate = DATEADD(dd,t.N-1,@StartDate)

    FROM dbo.Tally t

    WHERE t.N <= DATEDIFF(dd,@StartDate,@EndDate)+1

    Need a week's worth of dates and times split up in programmable minute slots?

    --===== Declare a couple of variables to identify the

    -- desired date range for this demo.

    DECLARE @StartDate DATETIME

    DECLARE @EndDate DATETIME

    DECLARE @Minutes INT

    SET @StartDate = '20000101'

    SET @EndDate = @StartDate+7

    SET @Minutes = 6

    --===== Create a result set that can be used either in a

    -- derived table or in a table variable function.

    SELECT CalculatedDate = DATEADD(mi,(t.N-1)*@Minutes,@StartDate)

    FROM dbo.Tally t

    WHERE t.N <= DATEDIFF(mi,@StartDate,@EndDate)/@Minutes

    Obviously, the number of minutes should evenly divide into 60, but you could do, say, whole hour increments or even 2 hour increments by using 60 and 120 respectively for the number of minutes. Because of the "11,000" max of the Tally table I provided, the smallest increment you can use is 1 minute... but you can easily make a much larger Tally table if that's what you need.

    The Tally table has dozen's of uses... it can be used in "Split String" functions, functions that "clean" a string, functions that return only string or numeric characters for a given string, etc, etc. It can even be used to split a whole table's worth of CSV's without a loop and without the overhead of a function... (the following code creates test data for the demo, as well)

    DROP TABLE JBMTest

    GO

    --===== Create and populate a test table.

    -- THIS IS NOT PART OF THE SOLUTION! IT JUST CREATES DATA TO DEMO WITH!

    SELECT TOP 10000

    RowNum = IDENTITY(INT,1,1),

    SomeInt = ABS(CHECKSUM(NEWID()))%50000+1,

    SomeLetters2 = CHAR(ABS(CHECKSUM(NEWID()))%26+65)

    + CHAR(ABS(CHECKSUM(NEWID()))%26+65),

    SomeCSV = CAST('Part01,Part02,Part03,Part04,Part05,Part06,Part07,Part08,Part09,Part10' AS VARCHAR(80)),

    SomeMoney = CAST(ABS(CHECKSUM(NEWID()))%10000 /100.0 AS MONEY),

    SomeDate = CAST(RAND(CHECKSUM(NEWID()))*3653.0+36524.0 AS DATETIME),

    SomeHex12 = RIGHT(NEWID(),12)

    INTO dbo.JBMTest

    FROM Master.dbo.SysColumns t1,

    Master.dbo.SysColumns t2 --Lack of join criteria makes this a CROSS-JOIN

    --===== A table is not properly formed unless a Primary Key has been assigned

    -- Takes about 12 seconds to execute.

    ALTER TABLE dbo.JBMTest

    ADD PRIMARY KEY CLUSTERED (RowNum)

    -------------------------------------------------------------------------------------------------------------------

    --DEMO THE WHOLE TABLE SPLIT

    --===== Declare a variable to hold the delimiter

    DECLARE @Delim CHAR(1)

    SET @Delim = ','

    --===== This does the actual split and provides ordered ordinal indexes for each row split

    SELECT RowNum,

    SomeInt,

    Val = SUBSTRING(@Delim+h.SomeCsv+@Delim, t.N+1, CHARINDEX(@Delim, @Delim+h.SomeCsv+@Delim, t.N+1)-t.N-1),

    Posit = t.N-LEN(REPLACE(LEFT(@Delim+h.SomeCsv+@Delim,t.N), @Delim, ''))

    FROM dbo.Tally t

    RIGHT OUTER JOIN --Necessary in case SomeCsv is NULL

    dbo.jbmTest h

    ON SUBSTRING(@Delim+h.SomeCsv+@Delim, t.N, 1) = @Delim

    AND t.N < LEN(@Delim+h.SomeCsv+@Delim)

    Useful "Widget"? Heh... yeeaauup! 😀 And it's nasty fast... not quite as fast as using some memory only functions with a While loop... but it's close. And, there are advantages... for example, how would you actually use a function to split a whole table of CSV's???

    --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.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • hi karthik,

    you are currently working In SQL Server/ In Development Programming.....

    I Read your Posts all are good and Fundamental..... Nice One, But the Thing is that Is you are really Need to Know this????/ just to increase your score.

  • Vinu,

    I have seen lot of people like you,basically they dont look at the main door instead they look back door. I think you comes under that category.

    My vision is to know about 'Programming Style'.I never thought to increase my score.

    karthik

Viewing 12 posts - 16 through 26 (of 26 total)

You must be logged in to reply to this topic. Login to reply