markneustadt.com

Performance – Using Try/Catch

I just wrote the stupidest program ever.  It is inefficient by design.  If anyone did this thinking “hey… this is great code” they should be fired.

Anyway… generally speaking, using try/catch blocks is not a great idea.  There are a myriad of reasons but it’s usually something along the lines of:

If you truly have an unexpected error it’s better to let the program crash and then fix the bug.

If you do have to use the try/catch exception handling block, you should only catch explicit exceptions.  For example catch a file access exception or a database invalid primary key exception.  Just catching the generic exception is poor practice.

There’s another reason to avoid try/catch though… it is a performance hog.

Read more

Performance – Inline SQL vs Parameterized Queries

In the search for better and better performance, there are many techniques developers can use.  A technique used early on by some entry level or “still learning” developers is to build inline SQL.  That looks something like this:

string name = "Mark";
string query = "SELECT * FROM users WHERE FirstName='" + name + "'";
OleDbCommand cmd = new OleDbCommand(query);
OleDbDataReader reader = cmd.ExecuteReader();

There are steps missing… this is just example code

 

This is something more seasoned developers learn to avoid almost immediately.  There’s a variety of reasons why inline SQL is bad.  The most important reason is security.

However, there’s another reason to avoid it.  Performance.

Read more

How much cellular data does a Speedtest.net test use?

Screen_Shot_2015-11-08_at_7_46_11_AM

Speedtest.net is a great tool.  It’s used by millions of people all the time when their internet connections slow down.  It’s used by internet service providers when people call up and complain.

I decided to use the mobile version of the tool and see how fast my LTE data connection was.  That’s a different post though.  I wondered just how much data running a speedtest.net test would use.  Well here are the results.

Read more

What was a challenge you had to overcome at your last job?

Challenges-ahead

I have recently started a new job.  Well… it’s been a little over four months, but that’s still pretty recent.  It’s recent enough to still remember the job search and the questions I would get asked.  I never had to answer the “If you were a starving hot dog, would you eat yourself?” type of question, but I did get some interesting ones.  But then there are the standards that you’re asked all the time.  Among those is “What was a challenge you had to overcome at your last job?  How did you overcome it?”

Read more

Inherited Object Serialization with Newtonsoft.JSON

Screen Shot 2015-05-12 at 10.19.09 AM

Wow… I’m coming up with some sexy titles for posts lately.

This is going to be how to deserialize JSON objects into native C# objects using Newtonsoft.JSON.  Serialization of objects to JSON is very straightforward.  Serializing objects inherited from a base class is pretty simple, but there’s a little bit of doing to do first. Converting those items back though… that’s a trick.

Read more

Scroll To Top