Code Writing Code

  • Comments posted to this topic are about the item Code Writing Code

  • Another nice editorial Steve.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Thanks , I guess someone else is working late

  • Working late comes with the territory.

    As far as the editorial, I try to implement as many automated solutions as I can - limits the hours. I couldn't imagine the hours if I didn't have automated solutions. 🙂

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • curse the double post...

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • CirquedeSQLeil (3/9/2010)


    curse the double post...

    "Curse of the Double Post"...wasn't that a 1950's horror B movie???

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

  • One of my all time favourite projects was a 2 years ago. I help developed a Development Framework where one thing I did was create a PowerShell Cmdlet designer for Visual Studio. You selected/changed the options for a cmdlet and it generated the code. You just had to implement the function that did the work.

    It was brilliant. I am usually a little more modest than that but it enabled developers who didn't quite get PowerShell to be productive straight away. They weren't scared of using the tool so it made it easier to learn writing cmdlets. I am still waiting for the time to redevelop it using T4.

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

  • "It's the future!" - as we say about anything even remotely cool that we've done where I work. And, naturally, this includes code that writes code.

    A few years ago I used a tool called CodeSmith to write code for me while developing a web site. I'd add a table to my database and then run the CodeSmith templates I'd created and BANG! all my CRUD sprocs and VB.NET class code was auto-generated in seconds.

    Good times indeed 🙂

  • Dont mean to put a downer on the conversation, but I was looking at a code generated query today which was running very slowly - subquery upon subquery upon subquery joined to derived table with subquery upon subquery upon subquery, union all, repeated a few times. Maybe it saved some development time, but it cost the organisation in support and downtime.

  • I would need to differentiate between "home grown" generators and "off the shelf" generators. Home grown addresses your specific needs and has a much narrower focus, whereas off the shelf need to be everything to everybody so they generate often inefficient, and ugly code, that works anywhere.

    Everything we write is really just a pattern that has been written before and will be written again. "Let the code be the code" - apologies to Shakespeare or the guy some people say wrote the Shakespeare stuff.

    PS - 4:30 is late?? I thought that was early!

    <><
    Livin' down on the cube farm. Left, left, then a right.

  • I think the problem is when the generators try to be too generic. Rather than solving a well understood in an efficient manner they solve most scenarios but often badly.

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

  • As a developer more than a DBA, it would probably take me five times as long to finish a project if I didn't have, at the very least, Visual Studio generating tons of code when new pages, controls, sql data adapters, etc. are created. And intellisense (a deviation of code writing code) -- wow what a great invention! It's too bad that intellisense for SQL is difficult to use because we are all used to writing "select <column list> from tablename" where intellisense can't help with the column list until the table name is known.

    I have to agree that Microsoft doesn't always follow their own preferred methodology when generating code, so I still have to reorganize some things to meet my conventions, but having the code generated is well worth the hassle. In my opinion anything that can help speed up a project and take out the tedious work of writing repetitive code is a plus.

  • Once you start becoming a "lazy dba" and writing code that generates code - you begin the ascension into being efficient.

    One absolutely stupid thing that I "picked up" was the use of Concatenate in Excel - people love sending data to be loaded or changed and they don't always import well - generating sql with that function speeds up mundane tasks, copy/cut/paste/F5 voila!

    Cheers
    http://twitter.com/widba
    http://widba.blogspot.com/

  • I do a lot of automation and do write code to save time. My limitation is that the code I write has to be understood and possible maintained by some of the lesser exerienced people in my department.

  • Allow me to be the voice of caution. T-SQL is one of the worst languages around when it comes to sheer drudgery so code-writing programs can indeed be extremely helpful.

    However. 🙂

    You have to be even more careful to design a structure that can support code-writing programs. Auditing is a good example. I'm in a situation where auditing is kind of important. We need full CRUD auditing, but we *also* need critical field auditing, and frankly that can't be generic. Certain fields have to have the old contents written to the log but those fields have no defining characteristics, it just depends on how the field is used in the application.

    So CWC (code-writing code) can be helpful, but in many cases it can't be done well because the underlying database structure won't support it.

    Having said that, *targeted* narrow-purpose CWC can still be a god-send. Visual Studio forms are a prime example.

    It gets even more fun when you're using an ERD designer as your database documentation/change synchronization tool. XML anyone? 🙂

Viewing 15 posts - 1 through 15 (of 34 total)

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