The Wizarding World of Harry Potter

Harry Potter, boy wizardMuggleNet: “Universal has announced that the Wizarding World of Harry Potter theme park will open on June 18th, 2010!” – Well, it’s about time! Would I love to go, absolutely. Will I be there day one? Nope. It would be a great experience for any Potter fan but the place will be a mad house.

Now all I need to do is convince my lovely wife we need to take a trip to visit Mr. Potter.

P.S. – I talked about my desire to have a Harry Potter themed attraction at Six Flags Magic Mountain, here in California, way back in 2003. We’re a month short of that post being seven years old. Wow.

Why derive a C++ class from a struct?

This question came up on Twitter yesterday, and got me thinking. Yeah, why would you do that? The only answer that sprang to mind was for compatibility reasons. If you have the luxury of working on a modern codebase you may not do this sort of thing, but if you have a legacy application or are working with a legacy API you may have need to call C functions that take structs and you may want to manipulate those structs in your C++ code, but do it in a C++ way. Make sense?

Here’s what I’m talking about. Take this C struct for example.

typedef struct tagABC
{
	int      a;
	long     b;
	float    c;
} ABC;

Back in the day, when the ABC structure was created, the developer also created a function to operate on this structure, something like this…

float OldSchoolCDoFancyCalculation(ABC* abc)
{
	return ((float)abc->a+(float)abc->b+abc->c);
}

That looks pretty darned straight forward. The OldSchoolCDoFancyCalculation() function takes a pointer to an ABC struct, sums the field values, and returns the result. Not uncommon. Here’s how it could be used.

	// Old school C style.
	ABC abc;
	abc.a = 10;
	abc.b = 99;
	abc.c = 99.99;

	float value = OldSchoolCDoFancyCalculation(&abc);
	printf("Old School C Struct + C Function == %f\n", value);

Moving on

Let’s say your team has decided to embrace C++ but you don’t want to go back and rewrite a bunch of code, and moving forward you’d like to make use of the nice stuff C++ has to offer. Someone may choose to do something like this with your ABC struct. I say may choose because they may do something totally different, this was the only real example I could think of, so it fits for illustration purposes.

class ABCObject :
	public ABC
{
public:
	ABCObject(int aa, long bb, float cc);
	virtual ~ABCObject();

	void DoFancyCalculation();
	void PrintValue();

private:
	float _value;
}; // ABCObject

Take note. ABCObject is derived from the struct ABC. Yes, of course you can do this in C++. When C++ was being defined this was one of those things that had to be addressed for backward compatibility with C. By default all struct members/fields have public access.

This will allow you to mix instances of ABCObject with the old C functions that operate on ABC structs. Here’s how that would look, and it’s perfectly legitimate.

	// New school C++ style, using old school C code, no problem.
	ABCObject abcObj(11, 100, 100.09);
	float value2 = OldSchoolCDoFancyCalculation(&abcObj);
	printf("New School C++ Object + C Function == %f\n", value2);

Notice we’re passing a pointer an instance of an ABCObject. What the? Sure, you can do that. It’s perfectly legal because ABCObject is derived from the ABC struct. The compiler would notice the function takes an argument of ABC* and ABCObject just happens to fit the “is-a” rule, so it can be passed as an ABC* to the function where it can be operated on like a standard ABC struct pointer.

Like I said, someone could do that. You probably wouldn’t, but the point is you could, and some folks will definitely have need to write code that looks similar to this for some very good reason. More often than not most developers would probably choose to wrap an instance of the old ABC struct as a member variable of the class and then just operate on that from within class methods.

More on the new Pelco

Security Systems News: “Would Pelco be in the same place had Schneider never purchased it? Fages, who’s been with the company seven years, took some time to think. “Would it be the same? My answer would probably be, ‘no.’ I believe Schneider is probably better prepared to fight the downturn in the economy that we are facing today. I was in charge of Asia for the last four years. The previous ownership didn’t understand what it meant to manufacture in China. All of those changes we’ve made to get more international, Schneider has stronger experience with that. The previous ownership wouldn’t have been able to implement those changes quickly and to face the economic situation.” – This is the best article I’ve read on the changes at Pelco. It’s about becoming a stronger company, period. I like that, it’s truthful, and gets beyond all the bluster of “if the prior owners were here…” because the honest truth is this, if the prior owners had been in charge of Pelco in the face of the economic crisis I’m not certain the company would still be operating. The new Pelco answers to shareholders and that’s a good thing. We have a new direction, new leadership, and some very interesting work ahead of us. Becoming a stronger company, a more agile company, will help move us forward and allow us to build the products we need to build.

The new open Pelco is a better Pelco.

I like Palm

ars technica: “In January of 2009, shares of Palm traded at a little over $3 as everyone awaited details of the once-mighty smartphone maker’s plans to save itself from certain death. In the wake of the Pre’s successful unveiling later that month at CES, Palm’s stock price more than doubled, and optimism about the Pre’s prospects eventually drove shares to a high of over $17 in October of last year. But as of this past Friday’s earnings report, sales are way below Palm’s and Wall Street’s expectations, the company has little cash left on hand, and shares of PALM have dropped all the way back down to $4. There’s a growing consensus—as expressed by the market—that there are only two possible futures for Palm: acquisition, or insolvency.” – Darn. I’ve always been a Palm fan. I had a Handspring Visor and used it for years, and I’ve even written, and contributed to, applications that run on the original Palm platform. The new Pre, and more specifically WebOS, are beautifully designed. In fact I’d put them firmly in second place to the iPhone. I would hope they won’t go away, but I’m not sure who would be interested in acquiring them at this point. A few months back I’d have said Microsoft was the perfect place for Palm but with the introduction of Windows Phone 7 (what a horrible name) I think Microsoft is now in a fairly decent position to be a good number three or four in the market. About a year ago I considered moving to Sprint for my cell service and the Pre was a natural choice, hard to beat unlimited use for $70.00 a month, the same plan on AT&T, with an iPhone, would run $119.00.

Anywho, I hope Palm can manage to stick around. They’re now offering the Pre at Verizon, which is a very popular carrier, and Verizon still doesn’t have the iPhone of course. Once the iPhone hits these other carriers it could be game over.

Addy Boy!

Hundred10 Chronicles: “We were pleased to learn that all four earned Gold ADDYs this year (hey, those entries aren’t free, we might as well get our money’s worth). But the icing on the cake came when it was announced that GetJules.com also was named Best of Interactive and Best of Show (the Big Daddy ADDY, if you will). It’s the first time an interactive entry has ever taken home that award over the best of TV, radio, or print, which makes it doubly gratifying.” – I couldn’t think of a group of folks more deserving than the gang at Hundred10. They’re a class act and they deliver the goods. Well done!

The great California Marijuana problem

Fresno Bee: “FRESNO, Calif. — The operator of Fresno marijuana dispensary is pledging to continue selling marijuana even after a being found guilty of violating a court order banning him from selling the drug.” – Personally I don’t use drugs, and yes, I include Marijuana as a drug. We have a strange system here in California that allows it to be sold for medicinal purposes, but some are obviously questioning that. I’m of two minds on this subject, here are two options to “fix” the problem.

Better control

Why are pot businesses allowed to exist? In California I can’t even buy pseudoephedrine over the counter, that’s right, it’s controlled because it’s used by knuckleheads to create meth. Why is it Medical Marijuana isn’t controlled like any other prescription drug? Look. If I go out and break an arm and the doctor decides to prescribe some sort of pain medication I have to have that prescription fill by a pharmacist, someone that’s spent many years learning about the effects, and interactions, of drugs on the mind and body. Why is it medical marijuana isn’t sold by pharmacies? If it’s such an important drug in the treatment of certain medical conditions why isn’t it better controlled? It should be, just like all other mind altering medications. That’s one way to solve the issue. Shut down the private pot distribution facilities and distribute through qualified pharmacies.

Just legalize it

I want my Cheesy Poofs!I’d imagine the first, and best option, isn’t all that popular with a certain crowd. Lets face it, most of the folks visiting the medical marijuana shops probably don’t need it for legitimate purposes. I’d bet there just addicted and like to get high. The second option is for them. Let’s just legalize it and sell it through Government controlled distribution facilities. In California we have liquor stores, but in states like Washington you have to purchase liquor through a state run facility. Why not create a state run pot store, or how about the dope store, yeah, I like that name. So if you wanted to get high you’d go to “The California Dope Store” and purchase your legal pack of marijuana cigarettes. They could tax the crap outta these things because it’s addictive and the folks that use them are desperate enough to pay for their high. Lets say a pack has five cigarettes in it and it’s, I dunno, $40.00? How much would it cost the State of California to grow and distribute this stuff versus what they could make selling it? This could be a great way to get the state out of trouble in the short term, because in the long term we’d be in trouble because all the doped up folks would quit working and spend all their food stamp money on Cheesy Poofs and more weed, but I digress. I’m not sure if the state is actually considering legislation to make the stuff legal, but it might be worth a try if it’s tightly controlled via state run farms and distribution centers. Food for thought.

Movie line of the week

And.... ACTION!Good afternoon movie liners, here’s the line, good luck!

Actor #1: So, is this how you seduce all the girls?
Actor #2: Only physicists with hypothermia who are accused of being a terrorist.

Ok, quick, what movie! Send your guesses here.

Life Lessons: Don’t spend more than you have

Save for the future.Get Rich Slowly: “I decided to only spend money I actually had, and so my purchases of toys slowed dramatically. My extravagances in life dropped to going out to eat with my roommate a couple times a week, and not at particularly fancy places. I got into bicycling as a hobby, on a used, mid-range road bike — not a brand new, high-end model like I would have bought before. And there I sat, content with the computer I already had, my modest bicycle, and the occasional trip out for dinner. I was living quite comfortably on my salary with my new outlook on life. For the first time in years, I felt comfortable with myself. I actually managed to save a few dollars from paycheck to paycheck instead of spending them!” – This is an interesting story. One I’ve read time and again, and one I do not ever want to get into. We’ve been making strides to change how we look at life. Our children are in college and we’re about to become empty nesters. We’ve decided to pay off all debt as quickly as we can, and to that end we’re just about there. Our car loan, along with the disaster I spoke about a couple of days ago with Chase, are the only remaining pieces of debt we have. The car loan will be gone soon, really, really soon, then it’s on to saving, and putting away for the future. Will we live like hermits? No, we won’t. Things will get better because we won’t have any debt, with the exception of our home loan, which we can now focus on paying off.

Read the article. You don’t need credit cards, you can survive in life on cash. It’s a good thing. Don’t spend more than you have.

My brother, the cloud guy

Jerry Fahrni: “The installation went very well. I didn’t have a single problem, which is why I’m creating this blog post on my tablet with a freshly installed Windows 7 OS. Of course I didn’t even attempt an upgrade from Windows XP Pro because it just wasn’t an option. And because I practice what I preach I had almost nothing to re-install once Windows 7 was up and running on the tablet. It’s all about the cloud making my life easier.” – I guess my brother’s obsession with web services is really paying off.

Jay, what’s up with the creepy desktop wallpaper? I hope you swapped that out?