Happy fourth-of-July, my American brethren. Sorry Canada, I went home for the weekend!
During my flight home, I started musing some of my unread C++ ebook collection and decided to start with Effective STL by Scott Meyers, the same author as the awesome Effective C++ book I reviewed. One of the first Items covered is how range member functions are better than single elements! I find this extremely intriguing. I never heard of this and I sure wasn’t taught this amazingly simple and clearly superior concept in school.
Member declaration order for structs and classes are important. You want to order the smallest to the largest (or vice versa) in order to avoid what’s known as ‘padding’. Padding is basically what the compiler will use to keep the memory allocation of the struct/class aligned in memory. This padding tends to be wasted space unless some compiler specific enhancement is occurring.
What I learned today was that Microsoft’s C++ compiler actually has extra padding involved, by design. And the solution to avoid the extra previous memory being stolen from you? Quite elementary, how could you not know? Inheriting from an empty abstract class makes your objects smaller.
So this is something I’ve seen two large camps pitted against each other for. Programmers should always be responsible for the code they write and should always be actively trying to write responsible code in itself. I think everyone can get behind that without much quarrel. But! One camp tends to argue that the programmer should ensure there is ~absolutely~ no way for things to blow up while the other camp argues that the programmer should place ‘checks’ in the code in the possibility that it does.
Hopefully the issue is clear.
Should a programmer place checks in their code to not only protect users in the future, but also themselves? “Why wouldn’t you?” your reaction may be. Well, you might have a complex piece of code that would take a lot of resources to constantly check will work properly. The goal is to make sure your code is exception-safe as much as possible, but there is always someone out there who will holler out “at what cost?!” If something is expected to work one way, that should be the ~only~ way it will ever work they argue!
It boils down to a kind of elite purist paradigm vs a human-error safe paradigm. Both have merit!
I made a pretty timely and amateur mistake today because I was running the purist paradigm. I’ll talk about how I should have placed checks to save myself and evidently my boss about 2 hours of time. But at the same time the issue could’ve been easily avoided and no check at all would’ve been needed if I didn’t rely on my faulty memory.
I baked a ton of cream puffs for work to give out. I’m not French, so I’m at an immediate disadvantage to all things cooking but I got a pretty fantastic response. So I intend to do more of them.
More importantly, I’m trying to perfect Caneles. These are sweet, caramelized dough tubes with a hint of rum. The office raves about them and stampedes every time it gets offered. I shall bake them… and they shall come.
Also on that note I’m starting a food photo gallery. /shrug
My cooking and baking en devours. I'm starting this during my time in Canada, and maybe from ...
So GDC 2014 starts this Monday and as much as I want to go, I only went last year to shoot for an awesome internship. The people, the booths, the information were all great but its hard to justify the cost to get down there right now especially now that I do have an awesome internship at Ubisoft.
But something hilarious happened today in relation to GDC and, to some it might not be a big deal, but to me its just… WOW the coincidence. And its just so inspiring and now if I truly had the money, I’d jump right back on the plane to GDC again.
Ugh XAML. Functional its really nice, and with Windows Presentation Foundation, it makes for some really awesome GUIs. You can do all kinds of cool data binding and automatically display information. A few projects about a year or so back using WPF XAML and C# is what reinvigorated my love for programming, which admittedly was looking down for awhile. But damn is it messy. Quick example: You can make an excel grid automatically display the data members in your class. If you had a class of Customers, with all kinds of Customer info, you can bind the grid to a list/array or collection of Customer and have it automatically display this info. So awesome! But, what if you wanted a specific kind of grid with specific properties? Continue reading →
Welcome to a new column I plan on making semi-day (possibly weekly?), providing I get the chance to.
Today I Learned: Const.
Const all the things. Const the variables, const the function, const the members in the function, const even if you want to modify the data later until you get to the point you need to modify data and work backwards because plans tend to change.