Lazy and Sloppy Developers

October 14, 2009

Developers, please think of the poor SOB that has to maintain your code 2 years after you leave the company. I just ran in to a block of code that did not make any sense. It read “if(includeBlahItems) {do something}” that obviously only runs if there are some Blah items right?. Wrong! In this code, the boolean value called “includeBlahItems” only gets set to true when there were NOT any BlahItems to deal with?!?!

Please don’t do that. Rename the variable, or set it to false when there are not any Blah items and change the if block to “if(!includeBlahItems) {do something}”.


The Small Business Restaurant Case Against Obama-care

July 21, 2009

This is a letter written by a friend of mine:

America – as a small business restaurant owner I’m appalled that very few (politically, media) are discussing the massive impact Obama-care will have on small businesses. We simply cannot afford mandated employer health care in our industry, and keep in mind that our industry is one of the most critical backbones of the entire American economy- there are over 945,000 restaurants in America, employing over 13 million people.

Keep in mind we primarily employ entry level and relatively unskilled laborers in the restaurant business. Our business models are built on razor thin margins as our customers (the American public) demand great value for their food- we simply cannot afford to provide health insurance for our majority unskilled and frequently transitory workforce – in many cases they are already paid higher wages than their skills could demand in an unregulated market via inflation indexed mandatory minimum wage laws. Mind you we do offer solid compensation and health benefits to management and senior staff who by virtue of their skills, responsibilities, achievements and longevity have earned them. We are already hammered by mandatory minimum wage increase that have siphoned off critical profits from our business in this time of recession- contributing greatly to significant price increases and labor force reductions already. Now Obama-care is proposing an 8% payroll surtax to finance mandatory health care?! This is INSANITY. Restaurants are built on after tax cash flow business models of less than 5% (which mind you has already been chipped by about 2% for min wage increases and price discounting to maintain traffic during a recession has hurt profits as well). Given payroll represents on average 25% of a restaurant business’s sales, an 8% surtax represent another 2 % hit to the bottom line! The senate version is almost as bad. And don’t let the small business exceptions fool you as restaurants are VERY labor intensive, and even a single small restaurant operation typically employees 20-30 people- practically every restaurant in America will be impacted by the mandate. Given that most small business restaurant operators survive on scale (2-10 locations) and again at very low margins, the small business exceptions will provide no relief for those in the restaurant industry who provide the majority of jobs.

What does the administration think businesses will do in reaction to this law? For starters we will be forced to drastically reduce staffing in an effort to reduce our payrolls and offset the tax impact on our profits- I anticipate the current hiring freezes in the industry to turn into massive layoff waves, and the industry to cut back dramatically to levels that will significantly impact our service models and even our ability to continue to operate. Second we will have no choice but to raise prices significantly- the HIDDEN TAX on the American public is that all taxes are ultimately passed on to the consumer. Third, and perhaps worse, many, many, MANY restaurants will simply not be able to cope with the cost burden and will fold almost overnight, swelling the ranks of the unemployed even more drastically. Finally, the financial incentive to build new restaurants in America will be gone. Say goodbye to new and interesting and convenient cuisine options in your neighborhood as no rational investor will put money in the future into a money losing business proposition.

Don’t pretend for a second that the administration doesn’t know this. Isn’t it convenient that they have planned the tax increases to be time delayed till 2011, hopeful that the American consumer will separate cause (Obama-care passes in 2009) from effect (massive unemployment waive in 2011)? Perhaps in the interim the unemployment numbers will trend up temporarily to mask his economically unsound strategies. I can assure you that come 2011 the economic consequences will be stunning to say the least.

Also, don’t be fooled by big businesses (Wal-mart, GE, etc) which have the scale and size to absorb these costs and are supporting Obama-care/similar measures. They see the law as a means to strangle their small business competition with regulations that will overwhelm and bankrupt them, freeing up market share for them to absorb. In fact, these big business bedfellows are counting on reduced competition from the small business sector to offset their losses on health care costs. Much like the big business-government collaboration of the past (railroad regulations) and the present (green initiatives trumpeted by Goldman Sachs and GE), their support is calculated and self-interested and in no way reflects the ability of the broader small business economy to absorb misguided policy.

Please put the word out to others that the consequences of this bill are far, far reaching and dire throughout the economy to consumers and businesses alike. Obama-care could kill the small-business economic goose that has laid golden eggs almost uninterrupted since the Reagan revolution. Do we really want 20% unemployment and small-businesses shuttered up all across America? Mandate business funding of employee health costs and you will see just that. And when small businesses are no longer here to foot the bill, guess who the government will come calling to NEXT to make up for the shortfall in funding? To quote Pastor Martin Niemöller:

“In Germany, they came first for the Communists, And I didn’t speak up because I wasn’t a Communist;
And then they came for the trade unionists, And I didn’t speak up because I wasn’t a trade unionist;
And then they came for the Jews, And I didn’t speak up because I wasn’t a Jew;
And then… they came for me… And by that time there was no one left to speak up.”

Wake up America, before it’s too late!

Shane
Phoenix, AZ


Book Review: Microsoft AJAX Library Essentials

December 31, 2008

Microsoft AJAX Library Essentials is a book intended for ASP.NET developers who want to dive into client side programming and take full advantage of the Microsoft AJAX Library.

The book opens up with a brief history of the internet, http, and html. This chapter serves as a refresher for web programming veterans, or valuable information for beginners. Also provided for beginners are instructions for setting up your programming environment so you will be able to follow and try out the example code.

Next you are taken on a whirlwind tour of HTML, CSS, JavaScript, and the DOM and see examples of handling AJAX requests using XMLHttpRequest. If you have ever done any AJAX on your own (without the use of a library or framework), you could easily skip this entire chapter, if you have not, it is a wonderful tutorial on what goes on behind the scenes, and you get to see the inner workings that the libraries and frameworks provide easier access to.

The book does a very nice job of explaining how OOP principles can be used in JavaScript. I consider myself only an intermediate level JavaScript programmer, and I was able to follow the books explanations of what Closures, Prototypes, and what “this” means in relation to context and scope. For me it was an eye opening look into the potential power of JavaScript, which I have not used for much more than rudimentary AJAX calls and client-side data validation.

The rest of the book serves as a reference complete with code examples of how the Microsoft AJAX Library acts as a framework to make everything it just taught you easier. It shows the namespaces and method names (that will be familiar to Microsoft developers) which you can use in your own javascript code.

All in all, it is a nice reference and guide to using the Microsoft AJAX Library.


Static SQL With Dynamic Where Clause

October 31, 2008

I’ve been using this sort of syntax for a couple of years now to write dynamic where clauses:

SELECT
Col1
FROM
dbo.Table
WHERE
@param IS NULL OR Col1 = @param

Recent application timeouts at my company have us investigating SQL queries for performance issues. One of the things I have discovered is that queries like that one are prone to performance problems. That query example on a table that has 6800 rows in it caused 3869 reads when a the column being compared has an index, and the parameter was not null (query returned 1 row in 253 ms).

For whatever reason, rewriting the query like this:
SELECT
Col1
FROM
dbo.Table
WHERE
(Col1 = @param AND @param IS NOT NULL) OR (@param IS NULL)

The query only causes 106 reads and returns the same single row in 33 ms. I don’t pretend to understand why the query that looks worse and has a more complicated execution plan performs better, but it does. I got the idea to try it from this article

The degree to which the syntax difference helps depends on how the table is indexed, and the column involved. Sometimes that syntax change makes no difference at all. The same article also showed me another trick that works even better for performance, but only works for non-nullable columns and is more complicated because you have to provide appropriate @min and @max values, which may be difficult depending on the data type and data itself:

SELECT
Col1
FROM
dbo.Table
WHERE
Col BETWEEN COALESCE(@param, @min) AND COALESCE(@param, @max)


Overriding Web Service URL in web.config for Referenced Class Library

October 23, 2008

I do this so rarely, that I always forget how to do it. Sometimes in a web application, you reference a class library that uses a web service. The web service is not directly added to the web application, so nothing is in the web.config to override, and since it is a class library versus a web application, you need to add a sectionGroup so you won’t throw the yellow screen of death due to an unknown section “applicationSetttings”.

<configSections>

<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="ErrorHandler.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>

</configSections>
<applicationSettings>

<ErrorHandler.Properties.Settings>
<setting name="ErrorHandler_ErrorLoggingWebService_ErrorLoggingWebService"
serializeAs="String">
<value>http://localhost/errorloggingwebservice/errorloggingwebservice.asmx</value>
</setting>
</ErrorHandler.Properties.Settings>

</applicationSettings>

 

 

 

 

 

 

 


Report Viewer Auto-Sizing

June 6, 2007

I was searching for some information on the report viewer control, and accidentally stumbled upon something I always wanted, but could not seem to figure out.

A combination of 2 properties will have the control automatically size itself to fit the entire report:

 AsyncRendering=false SizeToReportContent=true

The AsyncRendering=false changes the rendering to be in-line instead of a frame, which for whatever reason is required for the SizeToReportContent to work.

A noteworthy side-effect of these settings, is that images that have the “sizing” property set to “AutoSize” do not render correctly. They get shifted and cut off. Changing the sizing to FitProportial cured the rendering problem for me. This was not a property I set myself, so AutoSize must be the default.


Report Designer in Visual Studio 2005 – Case Sensitive Fields

April 9, 2007

If you’ve never worked with the report viewer control and the report designer in VS 2005, you should give it a try if you ever have a need for a reporting services report in your web application. Anyway, a colleague of mine at work was working on a report that I designed a few months earlier. Whenever I setup a reporting services report, I use the smart tag to create a datasource to start my design from. The smart tag will create a dataset which is what the report will in theory be bound to. At runtime, I always manually bind to a dataview that I get from a business layer class, and therefore only make use of the dataset name to tie my business class to the report. So in the method I use to run the report, I do something like this:

ReportDataSource rpds = new ReportDataSource();
rpds.Name = "DataSet1_DataTable1";
rpds.Value = dv;
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(rpds);
ReportViewer1.LocalReport.ReportPath = @"MyReport.rdlc";

where “DataSet1_DataTable1″ is the name of the dataset / datatable created using the report designer smart tag, and “dv” is the local variable holding a DataView returned by my business class.

Anyway, we had a problem where one of the fields was not displaying on the report. After an hour of scratching our heads, we determined that the field names (columns in the dataview) in the report appear to be case sensitive. Once we had the case of the column name returned by the business class match the case in the dataset, the field would then display on the report. I am not certain if this is a bug with the report designer, or just a strange coicidence that matching the case fixed the problem.


Un-”Beeping”-Believable

September 20, 2006

Tracking down hardware issues can be challenging sometimes…

About 5 or six months ago I decided to fix some stability problems with my son’s computer. It was blue screening during heavy 3d gaming. I had run some basic diagnostics and found that it was failing certain extended memory tests. So I decided to buy a new DIMM for the machine, and since the case I was using was ridiculously loud, I decided to buy a quieter case at the same time. Read the rest of this entry »


Double-Byte Characters and CFQueryParam

August 31, 2006

One of the challenges we’ve had at my present company is using CFQueryParam with double-byte characters. Basically, we couldn’t. A recent post on the Phoenix CFUG list prompted me to actually read the live docs on the subject. I found a comment there that pointed out the string format option in the advanced data source settings.

By checking the “String Format” box (the one that says “Enable Unicode for data sources configured for non-Latin characters”) you can now send double byte characters successfully using CFQueryParam.

CF_Administrator_StringFormat

I am not sure when that option showed up. It is not documented in any of the on-line or printed manuals I have on administering Cold Fusion. The screen shots in the printed manual I have for MX 6 don’t even have that option…so it showed up at 6.1 or later. All I know is that it IS available in 6.1 + Updater.

It all makes sense now….but the lack of documentation is why it escaped me before. I wish I knew why its not documented. I also would like to know why its not checked by default….perhaps a performance or compatibility issue? If anyone out there knows more about this setting….please comment!


How to create multiple network profiles on Windows XP/2000.

July 28, 2006

I’ve been meaning to figure out how to do this…it was always easy to do on Macintosh systems. Someone else blogged about it for me here

I normally just use DHCP everywhere I connect. But sometimes I need special configs for networks that don’t have a DHCP server running. The problem with those special configs is that they just waste time when you need to go back to the office or your home network. Nothing works and it takes you a few minutes to remember you hosed your network settings to connect to some obscure network somewhere.

In case that link ever dies, the original content follows … Read the rest of this entry »


Follow

Get every new post delivered to your Inbox.