Archive for the ‘You’re Doing It Wrong’ Category

So-called Web “Developers”

Monday, August 26th, 2019

So, I have been seeing this more and more.  I see the term “Web Developer” being applied to anybody that can do basic HTML5 and CSS scripting.  Even worse, I see the term being applied to people that do not know enough to understand how the back end works, or cannot even spell LAMP.

If you can do your job just using Notepad and Chrome (i.e. no compiler), with no back end services, you are just a “scripter.” Just make peace with that, and stop trivializing what real developers do.  And no, you are not writing a “web app,” you are scripting web pages (although maybe for someone else’s actual app).  Does PHP executing DB queries count?  Maybe – if you also (properly) designed the database it is working with.

(more…)

How to Sell Your Arcade Game

Wednesday, March 25th, 2015

Correctly Manage Your Expectations Before You Try to Sell Your Arcade Game

Something I see far too often are outlandish prices when uninformed people try to sell a game.  I usually see this with someone that originally overpaid (badly) and is trying to make their money back or thinks all games appreciate in value.   For example, “I bought this Street Fighter II 10 years ago for $1500(!) and I am sure it is worth $2500 now!

First: It Is Not Worth What Google Tells You

Occasionally I see someone that has a busted-ass Pac-Man, in a generic converted cabinet with water damage, and a dim monitor, and they Google “Pac-Man Sale Prices” and then think that they can sell it for $1200.  And have the audacity to believe they are getting low-balled when someone offers $250.

No, you are not getting low-balled.  You just did your search (“research”)  incorrectly.  You shoulda Googled something more like “converted damaged Pac-Man prices.” But hey, you did not know any better.  Take the advice of people that know more than you about things like this.

Also, just because someone paid $xxx for that game in the past does not mean that anyone will now.

Second: It Is Not Worth What eBay Tells You

Some people search eBay for prices and use the final sale price.  But before you do that, make sure your game matches up perfectly with the listing you are looking at for your “research.”  Do not try to compare your “home use only” Star Trek pinball with one on eBay that was clean, shopped, with new rubbers and no peeling paint on the backglass or playfield.

And, remember: that price is the price that ONE person was willing to pay.  Look at the bidding history, if you can, to see what most people were willing to pay.

Bigger is Not Better

(more…)

Outlook Taking Hours to Download Email

Wednesday, March 21st, 2012

JIC it helps anyone else out there.  For no apparent reason, Outlook 2010 started taking hours to download emails that usually came down in minutes.  And when I say hours, I mean 3-5 hours!  The app would remain responsive for the most part, but would consume 100% of a CPU/core.  It would download a number of messages and then just pause for 45 minutes or more.

Turns out that the problem was my configured %TEMP% directory was filled up with almost 65,000(!) entries.  An automatic update of my Antivirus software failed, and started looping retry attempts.  This filled up the temp directory with little 1KB  files until it crashed.  It also filled up my event log.

Seems that Outlook gets really cranky when it has trouble with its temp directory.

So if you suddenly start having strange issues like this with Outlook, make sure your temp directory is not too full.

CString misuse #2

Friday, August 17th, 2007

Here is another one:

/////////////////////
LPCTSTR cpString = _T( "This was some string message..." );
//
// Later On In Code...
//
CString str( cpString );
char cChar = str.GetAt( 0 );
/////////////////////

If you write code like this, stop now and back slowly away from the keyboard – You’re Doing It Wrong!

The developer here is using a string object for a very simple operation. This is the kind of think people talk about when they say something like “using a shotgun to kill a fly”.

Extracting characters from a string (an array!) is a very basic operation – it is something we learn in our first C/C++ class or read about in our first C/C++ book. This is not something that you need a heavyweight class to help you out with.

Extracting the first character from cpString is as easy as doing one of the following:

/////////////////////
char cChar = *cpString;
//
// -Or-
//
char cChar = cpString[ 0 ];
/////////////////////

Remember – constructing and initializing an object always takes longer (i.e. has more overhead) than not constructing and initializing one. Think about wether or not you really need an object before you create one. If you can get along without it, see if doing so improves things.

For reasons mentioned in a previous post, in this case, the code is better without the CString.

CString misuse #1

Friday, August 17th, 2007

This is the first of many examples of ways to misuse and/or abuse MFC’s CString class. While this example (and following ones) are specific to MFC, they likely apply to all string classes (mutable or not). Here is the offending code:

/////////////////////
CString str( "First Part Of Message\n" );
str = str + "Second Part Of Message\n";
str = str + "Third Part Of Message";

MessageBox( str );
/////////////////////

If you write code like this, stop now and back slowly away from the keyboard – You’re Doing It Wrong!

First, the developer is adding (concatenating) strings together, but these are static/constant strings! They always add up to the same string, and as such can be made into a single constant string:

/////////////////////
"First Part Of Message\nSecond Part Of Message\nThird Part Of Message"
/////////////////////

So at a minimum, the start of the code should read:

/////////////////////
CString str( "First Part Of Message\nSecond Part Of Message\nThird Part Of Message" );
/////////////////////

Why not add up the strings separately like the original code did? Two reasons – overhead and exception opportunity. Each use of CString::operator+(…) can result in dynamic memory operations (allocation and deallocation). So you are looking at six potential heap operations (three potential allocations and deallocations including destruction, although in release builds of CString, the number of operations is less). Each operation has the potential to raise an exception and in the absence of per-thread heaps, can effectively bottleneck a multi-threaded application to the performance of a single-threaded one because the heap operations have to be serialized.

So by manually putting the strings together we have reduced heap operations from 6 to 2 – one allocation and one deallocation. That is a pretty good improvement, but we can do better!

The MessageBox(…) function does not take CStrings, it takes pointers to constant strings (LPCTSTR). So why is a CString needed here at all?

/////////////////////
MessageBox( "First Part Of Message\nSecond Part Of Message\nThird Part Of Message" );
/////////////////////

This final version of the code is simpler, will execute faster, and is more robust. Sounds like a winner to me!

Note: Some of you may be thinking about the preprocessor’s ability to automatically concatenate static strings. Yes it does, but it cannot automatically coalesce the above strings because they are separate – they are being passed (separately) as parameters to a function. If the + operator was not present in-between the parts of the string, they would be coalesced to a single string, but the unnecessary CString would still be there.

You’re Doing it Wrong!

Tuesday, July 31st, 2007

Having been inspired by the amount of photos on the internet showing various forms of spectacular failures (http://www.doingitwrong.com), ranging from failed bunny-hops to the most graceful faceplants, I thought that a coding-equivlent of it might be worth trying out.

To that end, this section will cover little snippets of “wrong” code found in the wild. Unlike the photos, where the failure is usually fairly obvious, the failures present in the code snippets are not always as obvious, so a small discussion explaining the failure will always be present.

OK – enough of the BS…! Let’s get started!