Life is like Code, you never know what you will create next

Whats up with Stored Procedures these days?

20. October 2008 14:22 by Scott in   //  Tags: ,   //   Comments (39)

 

 

When life throws you hard balls, you can either step back and take a swing or bunt the hell out of it.  I just recently went to an information session on T-SQL, Stored Procedures and now LINQ.  These folks discussed stored procedures and why they are so important in the world today.

 

They stated ideas such as:

  1. Stored Procedures optimize queries.
  2. They stop SQL Injection attacks.
  3. Stored procedures are concrete and cannot be changed.
 
I wanted to briefly state a counter argument against stored procedures and for T-SQL and LINQ:
 
  1. Stored procedures do not optimize queries.
    • A SP is not an optimized query, it does not save time.  SP’s used to save time and have been faster in the past, but more and more RAD development has been done without SP’s.  The development has caught up with SP’s and dynamic SQL has now caught up  and in some cases surpassed SP’s.  These days parameterized queries are now cached just like SP’swhich put them on an even playing field.
    • Microsoft LINQ and ADO teams both admit that SP’s are not faster than dynamic SQL.
    • Benchmarks have also been completed which explicitly show SP's are slower over small queries and tie dynamic queries over larger ones.
  2. Stored procedures do stop injection attacks, but you can also do it with parameterized queries. 
    • SP’s are good at this, but it can also be done with parameters.  Putting a value into a parameter means that it will not be a part SQL query string at all.
  3. Stored procedures are very concrete and are hard to change as a developer with a DBA.  This is the problem.
    • As a developer when you push a product out the door, you want to be fast at this.  Developers don’t want to learn two languages in order for their product to be pushed out the door and then go back to the database every time code needs to be changed.  They want dynamic abilities.  When SP’s are hard to change, it might be a bit harder and take longer when you have a DBA.  The inability for SP’s to be changed or created fast is the issue with this kind of development.
  4. SP’s mangle the three tier architecture designed for apps.
    • Instead of having a structure which separates logic from storage, you have storage and logic on the same tier.  This will cause potential problems down the road.
  5. Business logic in a SP does not scale.  Business logic should be in code and not in the storage center.
    • When you have multiple database servers, it is more difficult to keep the triggers and SP’s synced.
  6. There is no Version Control for SP’s.
    • In a place that can be disastrous if you screw up, it should have something.  This is one big reason why people like to avoid SP’s like the plague.  They run away and never move back into town.
  7. SP's are NOT cached and Are NOT Pre-Compiled
    • SQL Server 2000 and SQL Server version 7.0 incorporate a number of changes to statement processing that extend many of the performance benefits of stored procedures to all SQL statements. SQL Server 2000 and SQL Server 7.0 do not save a partially compiled plan for stored procedures when they are created. A stored procedure is compiled at execution time, like any other Transact-SQL statement. SQL Server 2000 and SQL Server 7.0 retain execution plans for all SQL statements in the procedure cache, not just stored procedure execution plans.
 
If you see the new technologies coming out of Microsoft now, there will be no need for SP’s in the future.  LINQ is taking care of most of this by allowing for a data layer cheaply and efficiently with very little effort by the developer. LINQ handles all these problems and if you truly like a confirmation on all the things I said, just search the internet for Stored Procedures v.s. Dynamic SQL.
 
The debate these days has two sides. Not “Republican or Democrat”, but “Progressive and Non-Progressive”.  The Progressive folks are not using Stored Procedures these days.
 

kick it on DotNetKicks.com
If you liked this post, please be sure to subscribe to my RSS Feed.

Starting a new endeavor

17. October 2008 12:45 by scott in   //  Tags:   //   Comments (4)

I have been piddling around with an idea for the past few weeks along with all my other ideas.  Today I met with one of my old bosses at Florida Tech about the idea. She works in the program development part of the school.  Its almost like the R&D department for events at FIT.  We discussed bringing an idea like TED's to the South-East corner of the states.  TED's is creative commons which allows it to be done anywhere with the name of TED's.  I like this fact because it allows us to have the name behind the same caliber of information given. 

We made a small timeline to shoot for March after or before spring break.  This will give us plenty of time to plan and make ready one of the best conferences for one of the best innovative organizations on this planet. I personally think, if done right this could be turned into something amazing!

For all that don't know what TED is, here is a brief synopsis:

TED - TED stands for Technology, Entertainment, Design. It started out (in 1984) as a conference bringing together people from those three worlds.

TED conferences include about 50 speakers world wide to come and express ideas that they have.  These ideas are here to help the world on a small and large scale.  Most ideas at TED have helped the human race as a whole and have brought together innovators from around the world.  These innovators then speak for no longer than 18 minutes.  They talk on what ever they have focused on in life.  They then could win scholarships to help with their ideas and network with CEO's of companies along with other various people.  This conference is top notch and you have the ability to learn so much in a very small amount of time.  It adds the ability to collaborate with thinkers and doers in the world in which they now communicate with each other.

The conference is what I will try to bring to the South East.  I hope to write more on this later.  I will try to keep my progress updated regularly.

Scott.

If you liked this post, please be sure to subscribe to my RSS Feed.

A Revolutionary way to take notes!

14. October 2008 20:55 by Scott in   //  Tags:   //   Comments (14)

For the past few weeks I have been testing out a piece of software for note taking.  I found the software by luck trolling through www.stackoverflow.com.  The software is called Evernote.  It can do almost everything that is need to do when you need to take a quick note.  All the notes live in an online repository.  Without the repository being Google, I worried that the information might not be there forever.  I decided to take a test drive and let me tell you that this thing just kicks ass.  I have it installed both on my phone and several computers where I can access the notes from anywhere.  I fully enjoy this because my last note taking software was the TASKS section from outlook.  Microsoft was doing a better job with them, but Evernotes ability to take notes anywhere is amazing.  To briefly go through what kind of notes it can take:

Desktop

  • It can take anything typed or from a web browser.  The browser part is quite extraordinary because all you have to do is click a button and it adds a note.  You can either highlight text or make the entire web page a note without highlighting and wa-la, you have a web page that you don't have to bookmark for later.  You can just go back to your notes which then unclogs the bookmarks for the real purpose of what bookmarks were made for.

Phone/PDA

  • Voice notes
  • Text note - Typed text
  • Ink Note - If you have a touch screen you can write on the note.
  • Snapshot - You can take a picture of some document or anything.  If you take a picture of the document, EverNote has the ability to capture the text off the document so it can be edited for later.
  • Upload a file - Currently this isn't on the desktop version, but you can upload a file which will be saved both on your dektops and the database.

Coding

  • I specifically use Evernote a lot when have some interesting piece of code that I want to make sure I have at home too.  Instead of emailing it to my self, I now place it in Evernote, tag it as code and then I am off!

For both os's, you can save, delete, tag, print, categorize each and every note.

I wanted to mention one more thing.  This program is FREE!  The service has limits unless you upgrade, but after using it for several weeks, I have yet to reach my limit.

I hope you will give EverNote a try.  It does also have a IPhone version out as well.

kick it on DotNetKicks.com

If you liked this post, please be sure to subscribe to my RSS Feed.

Another way of thinking about how to store data inspired by ASP.NET

14. October 2008 10:38 by Scott in   //  Tags: , ,   //   Comments (49)

A while back I witnessed how the profile properties of ASP.NET are stored in the database.  All the properties all stored in one string.  There is then another string that describes the properties and how to view them and pull them from the database.

For example you have this string:
SmtpServer:S:0:18:Port:S:18:2:Password:B:0:48:ApplicationID:S:20:1:EmailUsername:S:21:15:

Then you have another string that looks like this:
pop.abcdefgh.co.uk257abcdefghij-abcd

If you break it down correctly you could get something like this:

  • Property Name : SmtpServer
  • Property Type : string (S) <-- Or this could be the Serialize As Type
  • Property Start Index : 0
  • Property String Length : 18

Now the question that I ask my self is:
Does this actually increase performance of the system?

I would argue yes and no.  Since the system could have an infinite amount of members attached to it and a countless amount of profile properties.  It would need to have something like this to decrease the amount of rows owned by a single user in the profile table. To give an example, I could be one user with 20 propertie.  If the application had over 1,000,000 users, that would be 20,000,000 rows.  That is huge and you must design for scale when it comes to an application that could potentially be used by all the world.

I would argue no to small applications.  If you only ever expect 1,000 users to an application, then why build something this complex other than for the thrill of it. This is especially the case when you don't need to worry about space on the system.  Space is cheap, but time spent coding a solution for this sample could be huge depending on experience.

I personally would build a generic code base for two ideas of this kind.  You could first build the generic code for the example above, but there would be another generic sample to build for. Lets say that you knew you were only going to ever store numbers in your database for each user.  These numbers could be used for ID's of another tables real data.  So I only want to store ID's of a table for each user.

I would store them like:
1:56:34:39:6798:10:39:40

This is because I wouldn't need another cell to split them up with indexes.  I would just split the numbers by the Colon. I would love to hear everyone's thoughts on this and why or why not it is a good choice.  Thanks for the time to read this.

kick it on DotNetKicks.com

If you liked this post, please be sure to subscribe to my RSS Feed.

Windows Mobile CE 6.1 (and Compact Framework) Released!

13. October 2008 08:44 by Scott in   //  Tags: , ,   //   Comments (25)

If you haven't seen it yet.  Mobile 6.1 was just release two months ago.  I just found out and will be upgrading tonight.

New changes include but are not limited to:

  • Copy / Paste (finally!) - Only touch screens used to do this.
  • Domain Enroll in Settings (Enrolling in a domain will connect your device with company resources.)
  • New home screen (pan left and right to check out missed calls, notifications like email, sms, etc.)
  • Change Master Security Cod
  • Added text input settings
  • Recent Programs when pressing Start menu - Allows you to see recent programs launched.
  • Threaded SMS! - This makes it so MUCH EASIER to carry on conversations.
  • When you compose an email, or SMS, and start typing the name of the contact in the "To:" field, the contact names finally pop up like Windows Mobile Professional!
  • Internet Explorer now lets you define a homepage, and also zoom in and out using a nice and clean interface - ZOOMING feature is AMAZING!!!
  • Task Manager now shows CPU usage as a whole, and also lists it by process
  • Internet Explorer offers 6 zoom modes and copy / paste functionality
  • IE also uses a new font, which looks worlds better
  • ActiveSync will now try to automatically configure your Exchange settings once you enter an email address
  • Wi-Fi indicator in the status bar, just as in Windows Mobile Professional
  • New "Vista" home screen and theme
  • Video Share Calling
  • Remote Desktop Monitor
  • ONE Note Mobile!!!
  • PTT Button can now be reassigned under Start / Settings / Buttons.

 This new CE looks and feels so much better.

 I am two months short on this launch, but if your reading this then so are you!!!

kick it on DotNetKicks.com

If you liked this post, please be sure to subscribe to my RSS Feed.

The next 8 years with Technology.

12. October 2008 08:39 by scott in   //  Tags:   //   Comments (13)

Today I watched a Google Talk today about Technology.  The president nominee spoke about ideas on free Internet, Public opinion, technology within bills that get passed in the house and senate, Public knowledge of bills, and more.

I for one am a Republican with many views against democrats and especially left wing democrats, but I do think that Technology can SAVE THE WORLD.  I have not seen my parties stance on technology, but today I saw the democrats stance on technology.  I ask you to also look at this stance.  Republicans have not shown me what they plan on doing with technology, but democrats have.

So for me and the stance on technology, I lean towards the democratic view even though I am a republican.

I hope all of you also review this video and sit down for an hour and take the time out of your day to do so.  This has greatly increased my chances for voting democrat. 

Please understand, that I am not being political, but to show you what I think should be done in the technology market.

kick it on DotNetKicks.com

If you liked this post, please be sure to subscribe to my RSS Feed.

A LINQ lesson

2. October 2008 12:18 by Scott in   //  Tags:   //   Comments (47)

I needed to get a query completed like this in LINQ.

Select max(uid) as uid, Serial_Number from Table Group BY Serial_Number
I thought about it for a while but didn't get anywhere.  I kept testing until I asked another person and they came up with:
 
        using (DataContext dc = new DataContext())
        {
            var q = from t in dc.TableTests
                    group t by t.SerialNumber
                        into g
                        select new
                        {
                            SerialNumber = g.Key,
                            uid = (from t2 in g select t2.uid).Max()
                        };
        }
 
This code is very nice and sweet.  It allows you to select the all MAX Rows of a table with a grouped table column. 
Hope you enjoyed this little lesson.  I decided to save this syntact because it is something I will most likely come accross again.
Scott
If you liked this post, please be sure to subscribe to my RSS Feed.

Found Hacker news

1. October 2008 20:13 by Scott in   //  Tags:   //   Comments (1)

I found a website a few days ago that is very credible to things like Digg and technorati.  Its called Hacker news and is offered by YCombinator.com which is a nest for startups. Hacker news is a very narrowed view of haaackers who work all day to hack away at jobs.  The site is pretty simple in its design, but looks extremely valuable to the person looking to use the NITCH developer community.

 It also uses Open ID which is great so I don't have to register and remember yet another password.

Website can be found here.

Thanks for reading.

Scott

If you liked this post, please be sure to subscribe to my RSS Feed.

When is multi-threading not a good idea?

18. September 2008 09:40 by Scott in   //  Tags:   //   Comments (3)
 
I was recently asked when not to use mulit-threading so I gave them the best answer possible.  I think my answer below fits the bill pretty nicely.
  1. On a single processor machine and a desktop application, you use multi threads so you don't freeze the app but for nothing else really.
  2. On a single processor server and a web based app, no need for multi threading because IIS handles most of it.
  3. On a multi processor machine and desktop app, you are suggested to use multi threads and parallel programming. Make as many threads as there are processors.
  4. On a mulit processor server and a web based app, no need again for multi threads because IIS handles it.

In total, if you use multi threads for other than un-freezing desktop apps and any other generic answer, you will make the app slower over time IF you have a single core machine.

Why? Well because of the hardware switches. It takes time for the hardware to switch between threads in total. On a multi core box, go ahead and use 1 thread for each core and you will greatly see a ramp up in speed at the start and over time as the cores heat up.

kick it on DotNetKicks.com
If you liked this post, please be sure to subscribe to my RSS Feed.

StyleCop was just released!

12. September 2008 06:55 by Scott in   //  Tags:   //   Comments (69)

For those that don't know. StyleCop was just released!

For those that don't understand what StyleCop is.  It is a tool that formats your code to all standards that makes it readable and nicely organized for human consumption.  It makes you look like a Rock Star (<-- that phrase is so over used).  I have started to use it and I currently have well over 1000 style errors.  I guess I need to adjust to make it work with the standards set out by the coding gods.

I would suggest a download and you look at it.  It should be at least looked at.

kick it on DotNetKicks.com If you liked this post, please be sure to subscribe to my RSS Feed.