Installing SQL Server Express 2008 on Windows Home Server

March 7, 2010

I have an old EX470 MediaSmart machine that I use for various purposes.  I use it for backing up my existing machines, I use it as a media center extender with my XBOX, a Subversion source code server, and today I setup SQL Server 2008 Express on this machine.

*Disclaimer* – I’m sure this is not approved or condoned by Microsoft for Windows Home Server owners, so do this at your own risk.  If you brick/break/fubar your machine, please do not email me about it.

Here are the steps I followed:

Step 1:

Remote desktop into your Windows Home Server machine.  “Start > Run > mstsc”.   From here enter your home server machine name (i.e. HOME-SERVER).  Once prompted, enter your username as “Administrator” and enter the root administrator password you selected when you setup your machine.

Step 2:

Download Microsoft Windows Installer 4.5 (if you have not previously done this) as it is required to install SQL Express 2008.   Here is the download link (http://www.microsoft.com/downloads/details.aspx?FamilyID=5a58b56f-60b6-4412-95b9-54d056d6f9f4&displaylang=en).  I believe a reboot is required here.

Step 3:

Download SQLEXPR_x86_ENU.exe from this Microsoft download link (http://www.microsoft.com/downloads/details.aspx?FamilyID=58ce885d-508b-45c8-9fd3-118edd8e6fff&displaylang=en).

Step 4:

Run the setup program, and under the “Installation” tab, select “New SQL Server stand-alone installation”.  Follow the steps required for the installation process.  I would  reboot after installing this as well.

Step 5:

Click Start > Programs > Microsoft SQL 2008 > Configuration Tools > Configuration Manager

Step 6:

Follow steps 1 – 9 here in order to enable remote connections as this will not be enabled by default.   Steps 10 and later will not work because SQL Express Management Studio cannot be installed on a Windows Server 2003 installation (to my knowledge).

Step 7:

On your home server, under control panel, select “Windows Firewall”.   Select the exceptions tab, and add a program exception for: c:\program files\microsoft sql server\mssql10.sqlexpress\mssql\binn\sqlservr.exe

Step 8:

On your desktop machine now, enter the following command into your command prompt:

C:\>SQLCMD -U sa -P <the-sa-password-you-set> -S YourHomeServerName\SQLEXPRESS,1122

(note: 1122 is the port # of the server.   This is the default, but you can see this changed from the TCP/IP protocol settings inside SQL Server configuration manager).

If this worked, you should be given a prompt such as “1>” to enter sql commands on that server.  Just enter “QUIT” once you have confirmed it worked.

Step #9:

Install Microsoft SQL Express 2008 Management Studio (http://www.microsoft.com/downloads/details.aspx?familyid=08e52ac2-1d62-45f6-9a4a-4b76a8564a2b&displaylang=en).   When prompted for connection details, specify “YOUR-HOME-SERVER\SQLEXPRESS,1122″ (without quotes), pick SQL Server Authentication, and enter your “sa” credentials.   Note the 1122 in the location.  This not a well documented feature, but this is how you specify the port # for a connection.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Day of Mobile – Illinois Institute of Chicago

March 7, 2010

I spent yesterday listening to talks from “Uncle Bob” Bob Martin, Jay Freeman, Jason Shah, and Chris Grove.   All the talks were very informative, with only one or two notable exceptions which were lacking in actual content.

Bob Martin spoke about dynamic languages and some of the history of typed vs. non-typed languages and the benefits of each.   Jay Freeman spoke about the politics involved in app store development, as well as fielded questions on some of the very impressive work he has done for the jailbroken phone community.   Jason spoke about how to integrate multimedia development on the Android platform, and Chris Grove spoke to us about strategies for cross-platform development.

All the information was incredibly useful, and well worth the $40 price of admission.   The “Tech in the Middle” organizers did a really great job at setting this whole thing up and I would definitely attend any future conferences they may setup as well.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Debugging DotNetNuke 5 with Visual Studio 2008 and IIS7

February 20, 2010

I have my DotNetNuke configuration setup as listed in this post.  I believe this works with the standard installation guidelines (outlined here) .

I normally set the “Property Pages” of the web project to look like the following.  You can get here by right clicking the web project, and selecting “Property Pages”.

Property Pages

To begin debugging, select “Debug > Attach to Process” from Visual Studio 2008.  Check the boxes labeled “Show processes from all users” and “Show processes in all sessions”.  Once listed, you may select w3wp.exe and select “attach”.  (note:  I believe if you are using IIS6 (Server 2003, XP) then it would be aspnet_wp.exe).

Debugging screen

Once done, you will be able to put breakpoints in your project and step through the source code.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Setup and Debug DotNetNuke 5 with Visual Studio 2008, Vista, IIS7, and SQL 2008

February 20, 2010

I had a lot of headaches trying to find a single point of information on how to properly configure DotNetNuke 5 along with my current machine configuration. I hope this post serves as a good reference for properly configuring a new DotNetNuke source installation.

Note: This tutorial assumes you already have IIS7, Visual Studio 2008 (standard or higher), and SQL Server 2008 (express or higher) installed. If you do not, please follow the step by step guide located here.

Disclaimer:  If you are a new developer, or have Visual Studio Express, please follow the DNN5 installation guide here.  My setup method deviates from the recommended settings established by DotNetNuke, however I have found they work better for me.

Step #1: Download the latest “Source Code (New Install + Source Code) release from http://dotnetnuke.codeplex.com/

Step #2: Unzip the latest release onto your local machine @ C:\inetpub\wwwroot\YourProjectName (replace ‘YourProjectName’ with what you would like the name of your project to be.

Step #3: Open IIS7, and right click the “Sites” menu item and select “Add Web Site”

Step #4: Inside the “Add Web Site” dialog, enter the name of your site (I used ‘BlogDemoDNN’) and point to the \Website directory inside the original directory you unzipped your files in step #2 (I used C:\inetpub\wwwroot\BlogDemo\DNN\Website\).

Add New Web Site

(note: if you get a dialog about binding to ‘*:80′ being assigned to another site, you may select ‘Yes’ to allow this duplicate binding).

Your new website should have a globe next to it, without a “stop icon” (like the one below)

Website Listing

If it does not have the globe, select the one that does and use the “Stop” menu item in the right hand rail, to stop that one.  And use the “Start” menu item in the right rail to start your new website.

Step #5: Open the root directory of the files you unzipped in step #2, and double click the DotNetNuke_VS2008.sln (solution) file.   With the project open inside Visual Studio 2008, right click the solution file in Solution Explorer, and select “Build Solution”.

Step #6: Open SQL Server 2008 Management Studio and connect to the database server you intend to setup your project on.   Right click the “Databases” folder and select “Add New Database”.

Add New Database

With the “New Database” dialog open, enter the name you wish to have for this database.  For mine, I selected “BlogDemoDNN”.

Step #7: Under the “Security” folder, select the “Logins” folder and right click it and select “New Login”.

New SQL Login

I entered the name “blogdemodnn-user” and used an easy to remember password as well as selected my default database.  Here is a shot of how I have it setup.

New SQL Login

Now, select the “Security > Users” option under your recently created database and hit “New User”.

New BlogDemo DNN Login

From here, enter details for the user you just created.  Note that I have selected db_owner as the scheme, and role membership.

New Login

Step #8: Back inside Visual Studio 2008, you will notice there is no web.config file inside your web project.  This is because DNN5 comes with a release.config (for publishing your website online) and development.config (for working locally).   Because we are working locally, double click the development.config file to open it.  Highlight all the text in this document, and copy (ctrl+c) that content.

Step #9: Right click the web project, and select “Add New Item”.  From templates, select “XML File”, and in the Name field, enter web.config.  Once the new file is open, paste (ctrl+v) that content you took from development.config and place it in your web.config (be sure to remove the <xml>tag that was in the original file before pasting).

Step #10: There are two connection strings you will need to set.  If you are using SQL Server 2008 Express like I am, then you can use the following connection strings:

inside <connectionStrings>:

<add name=”SiteSqlServer” connectionString=”Data Source=HOME-PC\SQLExpress;Initial Catalog=BlogDemoDNN;User ID=blogdemodnn-user;Password=password” providerName=”System.Data.SqlClient” />

inside <appSettings>:

<add key=”SiteSqlServer” value=”Data Source=HOME-PC\SQLExpress;Initial Catalog=BlogDemoDNN;User ID=blogdemodnn-user;Password=password” />

Step #11: Open windows explorer (explorer.exe) and browse to the directory you unzipped your files in step #2.  Right click on the “Website” directory and select “Properties”.  Then navigate to the security tab, and ensure (as noted below) that the IIS_IUSRS group as “Full Control” over the website directory.   DotNetNuke needs this.  As a content management system, it will need to create, delete, and edit files inside the filesystem.

Step #12: Open your default web browser, and enter “http://localhost/” in your URL.   You may not proceed through your standard DotNetNuke installation.   If you see an error about security permissions, be sure you have completed step #11.  Once you reach the Database connection settings page, be sure to uncheck “Integrated Security” and enter the username/password you had created in step #7 and entered in your web.config.

Once you have progressed through the setup, you can then proceed to your newly completed website!

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Creating a .NET class file from a WSDL

February 14, 2010

A common approach when adding a web service to an ASP.net application, is to right click "Add Web Reference" and specify the path of the WSDL which outlines the interface for the service.   An alternative, and relatively simple to accomplish, alternative to this approach is to create a class that represents the xml contract outlined in a WSDL (Web Service Definition Language) file.   This WSDL could be stored locally, or specified via a full URL.  This is accomplished by using the wsdl.exe command line utility.  

The WSDL.exe command is available in the following path:
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\wsdl.exe

An simple example use of this command is:
wsdl.exe /out:WeatherService.vb /l:VB http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl

A full description of the wsdl.exe command line utility is available here: 
http://msdn.microsoft.com/en-us/library/7h3ystb6(VS.80).aspx

There are many advantages to this, including but not limited to:

  • Achieving better understanding of underlying system calls to service
  • Including an audit/trace of service calls easily
  • Examining data being transmitted and received
  • Programmatically specify a sandbox/production URL interchangeably (this I find frequently useful)

I hope this helps in your programming endeavors, it has certainly helped me.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Becoming a Technical Leader: Book Review

February 14, 2010

It’s no secret that I am a big fan of Dale Carnegie’s – How to Win Friends and Influence People, and this book extends upon the principles in Carnegie’s book and applies them directly to any technical job.

Personally, I would still advise reading Carnegie’s book first as a business book, but if you have read that already and are looking to further your development as a leader, this book does a great job at applying a more niche approach to the concept of leadership.  The subtitle of the book is “An Organic Problem-Solving Approach”.   I would agree with that assessment.  Gerald Weinberg, the author, does a great job at outlining the differences between a technical leader position, and a traditional management position, and is probably one of the very few books out there who tackle those topics.

The book begins by outlining the concept of a leader, what it takes to be a leader, and how leaders develop their character.  He uses several analogies, such as his youthful experiences with a pinball machine, through the ravines and plateaus to which adjustments to his game where made, to outline how his later career as a technical leader would develop.

The leadership overview segueways into the topics: motivation, innovation, and organization which guide the central theme of the book.  He recommends keeping a daily 5 minute journal (which I have done, and agree is a great idea), notes it is important to recognize that self-confidence is a pre-requisite for success, and he also talks about the trade-offs between technical ability and leadership ability, and how to successfully motivate others.

The final chapters of the book outline the transformative process by which technically able people become leaders.  How to handle other people, who can and will, challenge your leadership, as well as finding time to continually change and improve yourself as a leader to maintain your position.  The ability to lead in the technical field requires continual movement and improvement, without which, one will fall by the wayside.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Code Complete 2: Book Review

February 14, 2010

This book is the de-facto standard for best practices as it relates to source code and programming. User ratings and industry leaders will also concur, that this book, now in it’s second edition leads the pack as a guide.

The book is a long read, but it is by no means simply a filler to increase the weight of the book. Each chapter is significant and important in it’s own way.

Every programmer upon entering the workforce should receive a copy of this book, at a minimum, because it paves the way for your career and sets you on the right path with ideal guidelines for good programming practice. I’m sure others who have read the book feel this strongly about it also.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

ItemDataBound in a Nested Repeater

February 14, 2010

Something I struggled with early in my ASP.net development was how to handle ItemDataBound event (or any repeater event) when it was inside another repeater in the code behind logic. I am presenting my code here so that it may be of use to anyone else having the same problem.

Given MyPage.aspx


   

My Repeater

Given MyPage.aspx.vb


' **** Please note functions CategoriesDataLayer.GetList() And ItemsDataLayer.GetCategories(CategoryId)
' ****   are used for demonstration only.  You may use any collection of data (datatable, collection, etc)    

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      rptMyOuterRepeater.DataSource = CategoriesDataLayer.GetList()
      rptMyOuterRepeater.DataBind()
End Sub

Protected Sub rptMyOuterRepeater_ItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs) Handles rptMyOuterRepeater.ItemDataBound
      ' Exit function if this is not in ItemTemplate
      If Not e.Item.ItemType = ListItemType.AlternatingItem AndAlso Not e.Item.ItemType = ListItemType.Item Then Exit Sub
      Dim rptMyInnerRepeater As Repeater = e.Item.FindControl("rptMyInnerRepeater")
      rptMyInnerRepeater.DataSource = ItemsDataLayer.GetItemsByCategory(e.Item.DataItem("CategoryId"))
      AddHandler rptMyInnerRepeater.ItemDataBound, AddressOf rptMyInnerRepeater_ItemDataBound
      rptMyInnerRepeater.DataBind()
End Sub

Protected Sub rptMyInnerRepeater_ItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)
      ' Exit function if this is not in ItemTemplate
      If Not e.Item.ItemType = ListItemType.AlternatingItem AndAlso Not e.Item.ItemType = ListItemType.Item Then Exit Sub
      CType(e.Item.FindControl("ltlItem"), Literal).Text = e.Item.DataItem("ItemName")
End Sub
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

SQL Server 2005 Database Design & Optimization

February 14, 2010

The following are some basic design guidelines to use when implementing a SQL 2005 database.

1.  Enforce foreign and unique key constraints.

Foreign and unique key constraints will maintain your database integrity.  Think of it as insurance against orphaned records and duplicate data.  If you know a column is to be unique, or a relationship to another table, entering it as a constraint can be one way for your database to police your application and catch errors early on before they become a problem.

 

2.  Identify poorly performing queries and optimize them.

SQL Profiler is a great tool and provides access to meaningful data regarding the execution time and resources required to run each of your queries.  As a general rule, I try to weed out queries which take over 200 milliseconds to execute.  This may seem like a small amount of time, but when you have an large number of visitors (such as after an email blast) this can quickly become a bottleneck.  SQL Profiler can be setup to track all queries executing over X number of milliseconds, X number of reads, and you can target specific databases so it returns only the data you are looking for. 

Performance inefficient statements (LIKE, IN, NOT IN, DISTINCT) can (and probably should if possible) be rewritten using proper join operations, using EXISTS, or using temporary tables in multiple SQL statements.  This will reduce the number of reads and ultimately decrease the time to return the data you are requesting.

 

3.  Use non-clustered indexes.

Using indexes is not an exact science.  It requires a calculated effort to ascertain the advantage of using the index versus the impact which will be incurred when updating, inserting, or deleting records.  A good rule of thumb is to index foreign keys as these columns are often used frequently when performing joins on tables.  Other good candidates for indexes are columns used for data ordering ("order by") and columns used in frequent look-ups (filtering fields).

Additionally, any administrative reports which contain filtering options should be considered candidates for indexes, especially if the table has 500,000 records or more.  Be careful though, to be aware that admin reporting is used exponentially less than the table data on the front-end of the website.  Try to weigh the benefits of each, and never place a filter field for a table that has millions of records without an index.  Scanning every row in a database for a certain value is a performance nightmare.

Lastly, be careful not to cover the entire table with indexes.  Every index added results in an increase of performance when reading data, but every index also carries with a performance hit when updating, deleting, or inserting data

 

4.  Use clustered indexes.

A table is ordered physically (on the file system) by the clustered index.  As a result, it is by far the most optimal way to search for data in the table.  In a common e-commerce example, if you have order headers, shipment recipients, and line items as 3 separate tables, then each may be joined together by the OrderId column.  Making the OrderId column the clustered index, instead of the LineItemId column in the LineItems database table would make sense logically if you were always pulling data from the LineItems table using the OrderId.  Additionally, if you wanted to pull an single record from the LineItems table, if you were to specify the LineItemId in conjunction with the OrderId, your query would execute very fast in that case also since you were aware of the OrderId at the time of the lookup.

 

5.  Avoid using wildcard characters on the left side of an indexed column.

If you have an index on the field "FirstName" but you perform a look-up on that column using wild-card characters on both sides of a lookup value, then you are negating that index (ex: WHERE FirstName LIKE ‘%yl%’ OR FirstName LIKE ‘%yle’).  In this case, you could think of the index like the first few letters of each persons name at the top of the phone book.  If you start at the beginning, then you know to look, but if someone says that this is the middle of the name, or the end, then you won’t be able to use that index to lookup the person in the phone book.  The database indexes in a similar fashion, so be aware when using wildcard characters.
(Note:  SQL 2005 may still use an INDEX SEEK, but it is unlikely that will happen when a wildcard appears as the first character in the LIKE clause).

 

6.  Avoid using SELECT * whenever possible.

SQL server database records are logically ordered on the file-system in 8kb chunks.  Any data over that 8kb is stored in what is referred to as an "Overflow page".  At the end of the 8kb page, there is a 16 byte pointer to where the overflow page data is stored (think ‘text’, varchar(max), etc).  When you use SELECT * to retrieve all columns, the overflow data must also be retrieved as part of the query and as a result, the performance is impacted.

 

7.  Periodically de-fragment your indexes.

Indexes could theoretically be thought of like a fragmented hard drive.  When you create the index the first time, everything is neatly ordered and compact for quick access.  Over time however, indexes become fragmented through deletes, updates, and inserts.  Gaps find their way into the index and the CPU has to work harder to lookup the data being requested.

It is good practice to run DBCC SHOWCONTIG as a command on a recent backup of your database.  When executing this command you will see data returned about the indexes currently active in your database.  As a rule of thumb, look for indexes which have a page count > 10,000 and  (logical scan fragmentation > 20% or avg. page density < 60%).

You have three options available to de-fragment your indexes. 

  • DROP INDEX and CREATE INDEX to re-create indexes
  • DBCC DBREINDEX – Offline operation, table is unavailable when this command is running on it.  Atomic transaction, passes or fails.  Defragments all indexes on a table.
  • DBCC INDEXDEFRAG – Online operation, database can continue to function when running.  Can be stopped at anytime.  Defragments one index at a time.

Provided below is a chart showing the performance of each method.  

http://www.microsoft.com/library/media/1033/technet/images/prodtechnol/sql/2000/maintain/ss2kbp09_big.gif

8.  Use consistent naming conventions.

I don’t think there is a universal rule against a certain type of convention (plural vs. singular table names, etc), but maintaining consistency will aid in your development.  Having to keep referring back to your database to see if your column is named Desc, Description, Descrptn, etc. will prolong your develop as will having to check if a table is StoreItem or StoreItems, etc. 

 

9.  Maintain the database.

Writing a simple task (i.e.  SystemMaintenence.exe) which periodically purges old un-useful data, removes leftover image files, and generally tidies up the system is a good process to use to ensure your site is running as efficiently and effectively as possible.   If done properly, you could be removing loads of unused data, which in turn allows your system to operate at an optimal level.  Even moving data out of commonly used tables into ‘Archive’ tables where it won’t be accessed as frequently offers performance gains.

 

10.  Don’t abuse the cache.

Some people may disagree with me on this, but I would recommend not using caching at all until after a project has been live for a while and the performance bottlenecks have been identified.  Famous computer scientist Donald Knuth was quoted as saying "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.".  Many developers spend hours and hours pouring over code in a pre-release format looking for ways to optimize the code.  I personally believe that if you do your best to write it well the first time, and take the time to write it properly, then any necessary re-factoring or optimization can be done once the bottleneck is identified.

Additionally, I see many developers who have a tendency to cache as much data as they can without realizing that this cache data has to be stored in the server’s physical memory.   If that wasn’t bad enough, the system may periodically remove data from the cache if too much data is stored in the cache so that the system can continue operating properly.  Relying on the cache as a crutch for poorly designed queries/code is not a good approach to development.  However, using caching mechanisms properly,  and conservatively, is effective, especially if you are using it to address a performance problem which has presented itself in production code.

 

11.  Use the SqlBulkCopy class.

SqlBulkCopy should (in my opinion) always be used when inserting data over a couple of hundred records.  I have used this class in numerous projects in the past and it can handle tens of thousands of records in just seconds.  It doesn’t take long to use, and when reading data from your data source you can perform all your necessary computations before storing it in the in memory table (which will later be sent to the server).  Another method, would be to load everything into a temporary table, and then perform the necessary T-SQL on that temporary table to move the data into your application.  I’ve used for this moving data from an old system to a new one, reading customer uploaded .csv files before processing them in the system, and taking large files off an FTP account for processing.  I honestly can’t think of a good reason to not use this when dealing with any reasonable amount of data.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

7 Healthy Habits of Highly Effective Web Workers

February 14, 2010

I doubt Steven Covey will ever read my blog post, but I’m glad you found your way here.  Presented below, is my best effort, to provide you with the concepts that have worked for me.  All these suggestions, are merely suggestions, but they have worked well for me, so I am sharing them with you.

1.  Exercise

If it seems obvious, and not a secret, well, that is because it isn’t.  If you exercise an hour a day, you will lose weight, have increased energy levels, and a decrease in health problems.  You will be more confident, reduce your daily stress, and find yourself with deeper affection for those friends and family who are around you. 

I understand it can be a challenge to be motivated to exercise when there are a hundred other things on your plate: work, kids, wife, friends.  You might think to yourself, ‘Hey! I’m too busy to work out’.  Think of it as insurance on your number one possession: your health.  High blood pressure, high cholesterol, and stress all result in a number of very undesirable effects to your health like heart attack, stroke, diabetes, and on an on.  An hour a day may seem like a lot, but try not to think of it that way.  Think of it as investing an hour in your day to maximize the other 23 hours of your day, and insuring your body against the negative elements so you can live out your golden years writing code, reading books, or spending it with your grand-kids.  Work hard enough at it, and you could even live out your retirement running marathons.

It can be daunting to start an exercise program, and there will be days you don’t want to drag yourself out of bed.  Commit yourself to just doing something, anything, when it comes time to your exercise.  If you planned to run for an hour, and you really aren’t feeling up to it, commit to just going for a 30 minute walk.  Hey, at least you did something right?  Just committing yourself to living a healthy lifestyle is an important step to your overall health and a determining factor on how effective your efforts are.

Exercise is a great investment in yourself and your number #1 asset: your health.  As an added bonus, you’ll have a more productive work day, find yourself feeling more relaxed, and having more energy to get through those marathon coding sessions or play with your kids.

2.  Eat right

I’m from Chicago, and we have more steak houses, fast food establishments (like the infamous Portillo’s), and bars than I care to admit.  It can be very, very tempting to eat unhealthy.  You could be nervous about being mocked by your friends and colleagues for eating a salad, have a stressful day and use food to relieve the stress, or you could simply not have any other alternatives around you.

Unfortunately, there are plenty of good reasons why people choose not to eat healthy, however of those good reasons, there are no reasons good enough to justify damaging your health.  Eating large amounts of high calorie, high fat food produces unhealthy blood sugar levels, increases stress, and ultimately results in lower energy levels.  We all know what that post-Thanksgiving food coma feels like. 

Simple strategies like keeping unhealthy food out of your house/apartment, office, and car are a great first step.  Another wonderful strategy is to keep healthy snacks in your desk.  Freeze dried fruit, natural granola, pretzels, and others will help you stave off those desires to gorge yourself on a double cheeseburger and fries because you are so hungry your stomach hurts by the time lunch hour arrives.  Many offices have quick access to stores which sell fresh fruit and vegetables.

It can be hard to go for a long time without eating unhealthy, but you will find that the longer you go eating healthy, the easier it becomes.  It will, as strange as it sounds, actually become easier to eat healthy than to eat unhealthy.  Your body will have a strong reaction (upset stomach, acid-reflux) to unhealthy foods if you go long enough without them and just the thought of going through that will have you wanting to avoid that feeling altogether.

3.  Healthy Sleep

I could say sleep 8 hours, sleep 9 hours, sleep 7 hours, but I think everyone is different.   Work works for you may not work for someone else.  The important thing is to not oversleep and not sleep too little.  Your body simply will not function effectively if you do not get the correct amount of sleep.  You will make more mistakes, become more irritable and find it harder to make the right decisions about your health (drinking too much caffeine to stay awake, making poor food choices).

Just trying to get into a routine, as boring as that sounds, can have you rising with an increased energy level each day.  For me, it’s bed at 10 and up at 6.  Does that ever change?  Sure it does.  I go out with friends, hit up a late night movie, but overall I try to stick to that as close as I can.  Nothing really good ever happens after 10pm, and 6 is the perfect time for me to get my workout in before heading to work.

I understand this can be hard with kids, and with those who travel frequently, but the bottom line of it all is getting a good amount of sleep is simply important to your overall health.  You will be more productive, alert, and ready to face the day when you have had the right amount of sleep.

4.  Moderation

All things in moderation.  I’m sure you’ve heard that before.  Have a drink or two and you’ll feel fine at work the next day.  Get sloppy drunk and you will feel miserable, make poor eating choices, skip your exercise, and not get a good nights sleep.   Split a small piece of cheesecake with your friend/significant other on a special occasion and it gives you a reason to celebrate and enjoy a great tasting food item, but have McDonald’s for breakfast lunch & dinner and you’ll end up feeling like Morgan Spurlock.

Having a glass of really good tasting wine can have you really appreciating the work that went into producing that drink, or having a really good desert item on a rare occasion can have you really have your taste buds savoring that flavor.  Drink every day, watch television for hours, play video games for hours, or doing anything in excess and you will find yourself losing track of what really drew you to that in the first place. It loses it’s value and ultimately its enjoyment.

The basic premise is, enjoy the finer things in life, but don’t abuse them because then they lose their value.  Addiction isn’t something to be taken lightly, and this blog is no substitute for professional medical advice, which I encourage you to seek that advice if you feel you have a problem battling an addiction. 

5.  Spirituality

I’m sure I’ll be ostracized to some extend for including this suggestion, however I am very open about my faith.  I’m a Christian, however I am not the same Christian you see on television giving the rest of us a bad name, picketing funerals, and generally acting like someone who just got the wrong information about what it meant to be a Christian.  I encourage others to read the bible, and attend church, but I don’t force my beliefs on anyone else.  I don’t feel that is the right way to approach life and it certainly gives organized religion a bad name when others act that way.

That being said, I did title this subject ’spirituality’ because regardless of your beliefs:  Christian, Catholic, Muslim, Jewish, or simply those who are enlightened spiritually, I find that connecting with those around me, donating my time to a worthy cause, and simply praying all give me piece of mind and put things in perspective for me. 

Going to church puts my life in check, and keeps me on the right track mentally.  Hearing prayer requests for those who are struggling with medical conditions, family problems, or drug addictions helps you become more comfortable with your own mortality, be grateful for what you have in your life instead of focusing on what you don’t have, and encourages you to be a better person.  It’s enlightening and humbling at the same time. 

6.  No Television

I sometimes struggle with this myself.  I’m a diehard Chicago Cubs fan, and it is hard to not want to tune the game on, but I still feel that television is a waste of the precious (and little) time we have.  I don’t suppose it is really the point that television is terrible, rather that television is not a better alternative to reading a book, creative writing, art, photography, computer programming, or any other of a million things which all increase your overall well being.

Find a hobby, follow your dreams.  Don’t want to be a programmer?  Hey, it’s not for everyone.  Maybe you wanted to be an accountant (hahaha!).  All jokes aside, maybe you wanted to be a chef, artist, or simply just learn about history, lose yourself in a great story perhaps.  Wouldn’t that be a more enjoyable way to spend your time instead of watching someone else on t.v. live out your dream?

Think about how much time you have spent watching television in the past year.  Now try to picture how much knowledge, and experience you would possess in regard to any of those aforementioned hobbies, if you had used that same number of hours pursuing that which is important to you.  That statement is reason enough to unplug.

7.  Socialize

Being a programmer, it’s really hard for me to sit at a desk, and problem solve all day and then come home and work more.  This happened more in the beginning of my career when I was writing code for about 100% of the day, and it is less now, but it is still important for me to actively keep up friendships, keep up with friends and family, and actively communicate with other developers. 

For some, it can be nerve-wracking, or even anxiety-inducing to be in social situations, but there are plenty of strategies to be a good communicator.  You will find that by actively socializing with others, and keeping a strong social support system, you will have plenty of opportunities to have a good laugh, enjoy life and all it has to offer, get through the hard times in life, and also help others through as well.

Like anything in life, you get out what you put in.  If you put little or no effort into maintaining any level of friendships with anyone, well then you are unfortunately going to be a very lonely person.  If, on the other hand, you actively make it a point to pursue and keep up relations with those close to you, then you will find yourself benefiting from the effort you are putting in as well.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org