Sometimes I see people code something up like the following:
void AwesomeFunc( void )
{
if( var == 3 )
{
if( var2 == 4 )
{
if( var4 == "napkin" )
{
if( var5 == 8495 )
{
g_flag = true;
}
else
{
Debug.Log( "var5 wasn't 8495" );
}
}
else
{
Debug.Log( "var4 was not napkin" );
}
}
else
{
Debug.Log( "var2 wasn't 4" );
}
}
else
{
Debug.Log( "var wasn't 3" );
}
}
Read more…
I was a contract employee at Microsoft, an SDET I. While I was there I learned quite a lot about testing, and I really believe it made me a much better programmer. Although my time there was short lived, I managed to retain some of my testing knowledge, and I hope to share that with you now. So I’ll quickly and briefly cover the basics of testing. I’m not talking about unit testing either. I’ll break down the types of tests you have into different categories. There may be more.
- BVT (Base verification tests)
- –Positive test cases
- FVT (Functional verification tests)
- –Positive Test Cases (Tester tests for expected failures )
- –Negative Test Cases (We catch unexpected failures during testing (hopefully) )
Read more…
Just a reminder how const-ness works. If I remember correctly.
// These two lines are the same type
// const and int can be switched around and the result is the same.
const int i;
int const j;
// If the word "const" follows the "*", it affects the pointer
int* const k;
// Both the pointer and the int are const
const int* const m;
// Same as line above, it just looks weird
int const * const n;
// Does the const affect the pointer or the int? The int..
int const * p;
2 apples peeled & chopped
2 banannas
2 cups of ice
3/4 cup apple juice
6 oz. of vanilla yogurt
3 tbsp brown sugar
1-2 tsp of cinnamon
Blend all together in blender
For garnish, add whipped cream, cinnamon, & an apple slice.
Once upon a time, there was a language that didn’t have 2 dimensional arrays. This greatly upset the programmer. Fortunately, the programmer was swift in the art of arithmetic and overcame this obstacle easily.
Lets say for example, we only have access to a 1 dimensional array data structure and it has 50 elements in it.
int data[50];
Lets break this array up into 10 rows and 5 columns to make a grid. So how do we get access to a position say data[4][3]?
There are two things I’m going to teach you now:
1) Retrieve the column & row numbers from a linear index counter.
2) Retrieve the index from a row & column numbers.
Read more…
I’ve always used the “w” key to go forward a word when highlighting stuff. There’s a problem with this though when you want to just copy a single word.
Lets say you have the sentence “you are a car.” Let’s also assume you have placed your cursor on the letter “a” in “are.”
And we want to highlight the word “are.” So we press “vw”. When you press the letter “w”, it highlights the following: “are a”. Note that it includes a space and the letter a.
So the letter “w” is the wrong key to use, so what is the key to go to the end of the word instead?
It’s the letter: e
1) 4/5 Who wants to be a millionaire? (978-1883589875)
This book was a pretty good book for what it is. It’s a very small book, so you really can’t expect much. It’s catered towards teenagers in school and you can read it in about a day. The contents are about how to save up for retirement, basically. If you do it soon enough, and correctly, you can have about a million dollars or more. The critical ideas are: mutual funds, 401Ks, roth IRAs, and insurance. I recommend it if you don’t know anything about finances or about where to put your money. Even if you don’t have any money, you can still save up, but the key is to do it early enough (when you’re young).
2) 3/5 The Complete Idiot’s Guide to String Theory (978-1592577026)
Amazingly, there aren’t any equations. There are good and bad parts and I get lots quite often. Mainly when he says “The blank-blank theory says this”… But doesn’t leave any references to say why, because I don’t know where he gets quite a few of his statements. The author is probably correct, because I don’t know any better. On a good note, the appendix has a wealth of really good links and info if you want more info. Overall, so far, it’s ok. But there’s got to be a book that explains it better. It does make some things clearer though, but I guess it’s just piecing things together piece by piece, but you will probably need other resources to complete the picture. This book just feels like a bunch of random physics statements thrown together.
3) IN PROGRESS 5/5 The Holy Bible
I won’t be reading all of it, but I will be reading all of the main narrative books that go through the main story. So far, the story is very unique and inspiring. You can’t really attempt to understand it by yourself unless you’re a history buff and know what was going on in the time period. Also knowing which books were written in which time period is very helpful as well. Who was in world power, where the old nations were located, etc. I have quite a few resources and help to figure things out, so if a regular person picked up the bible and started reading it, they’d most likely miss a good portion of the important things that require an understanding of real history. This will always be “in progress.”
I’ve been looking for a way to delete up to a character, but not including the character from within vim, and I finally figured out how to do it.
Lets say you have something like this:
big_huge_array_with_a_big_long_name[ indexThingy ] = 5;
If the cursor is at the beginning of the line, and we want to change the name of the array completely, we could type this:
df[
This will delete all the way to the bracket. Unfortunately, it deletes the bracket.
So instead, this works nicely to NOT remove the character you type:
dt[
This will delete every character up until the bracket, but leave the bracket. How nice.
So what does this “t” movement key do exactly?
It simply moves the cursor to the character right before the one specified, and it stays in “normal” mode.
If you wanted to immediately type after deleting the characters, you would use the following:
ct[
Which will delete the text, leave the “[” character, but change to insert mode right before the “[” character.
Another thing you can do is type:
de
If you want to search for the word right where your cursor is, you can do the following:
/Ctrl-r Ctrl-w
If you want to maximize your vertical or horizontal buffer splits, type one of the following:
Ctrl-w|
Ctrl-w_
If you want to equally resize all of your buffers, type the following:
Ctrl-w=
To make a vertical split a horizontal one, or visa versa, type the following:
Ctrl-w H
Ctrl-w K
To center the cursor on your screen, press:
zz
To bring up the build in “file explorer” window, type one of the following:
:E
:Ex
:n .
This question has bothered me for some time and I always forget. So I wrote it down here and added an answer.
Composition : An object contains another object. When the container object dies, so does the composited objects.
Aggregation : An object pseudo-contains another object (contains a pointer to it). When the container object dies, the containees do not.
class Container
{
public:
// Composition
Containee _c[5];
// Aggregation
Containee* _pc[5];
}
Sometimes aggregation is called composition when the difference doesn’t matter.
Note: In UML, aggregation is an unfilled diamond, whereas composition is a filled diamond.
References:
http://en.wikipedia.org/wiki/Object_composition#Aggregation
To resize your buffer up and down type the following:
<ctrl-w>- (that's minus)
<ctrl-w>+
To resize your buffer left and right, type the following:
<ctrl-w>< (that's a less than aligator symbol ;p )
<ctrl-w>>
You could make a mapping to do these without pressing the ctrl-w key combo first.
Something like this for the vertical stuff:
map + <c-w>+
map - <c-w>-
You have to put that in your .vimrc file.
Go to the first line and type the following:
^ to go to the beginning line. (probably want the top too)
Ctrl + Alt + V (to enter block highlight mode)
#j (where # is the number of lines to be commented out) Or just move the cursor manually.
I (capital i)
//
Press the esc key.
They should all be commented out now, with c++ style comments.
Last blog post, I mentioned you could clean up and reformat a file by using :retab.
This doesn’t remove unnecessary trailing whitespace though. To remove trailing whitespace, use the following:
:%s/\s\+$//
Make sure, in your .gvimrc file, that the following are set to your liking:
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
Then type the following within vim:
:set expandtab
:retab
Vim tip: Move your cursor between any of set the following: (), “”, [], {}, etc.
Then type one of the following:
yi(
di)
ci[
Or any combination. it will remove or change or yank all of the text between those braces.
At work I modify my .gvimrc file, and it’s a big hassle to have to quit mvim (mac) and reload it. So a neat command you can do is to type this:
:source <path to .gvimrc>
This will reload your .gvimrc file without leaving gvim.
This should work with regular vim too.
Do you want to know what the latest trends are in game development? Do you have a fear of being left behind in the game dev industry because you don’t know what such n’ such a technique is? Is there something you can do to make sure you’re not left behind in the dust? There is!
In this post, I’m mainly concerned with physics and graphics, but the same sort of techniques apply to other fields as well. The following items are what I do regularly to keep up to date in my field:
Read more…
I got most of this list from some other place on the internet, but I felt there could be more added to it.
I’ll continue to add to this list as I think of things or come across things.
- Test Driven Development Really Is Worth It
- Don’t Rely On Comments Too Much: Make Your Code Self-Explanatory
- Don’t Let Exceptions Disappear Into A Black Hole
- Don’t reinvent the wheel. Use libraries when possible because you know they work.
- Code like you will reuse the code for other projects.
- Learn what good design should look like an emulate it until you see why it is good design (and what you dislike about it).
- Too many newbies like to over-engineer just to pretend to be smart or having fun with resume-driven-development. In other words, implementing every pattern in the book or putting bayesian filters in every corner of the code should be avoided if they aren’t needed. Debugging, testing, maintenance will be all easier, not mentioning performance.
- Have your code reviewed often.
- Be wary of code smells (Class too big, method too big, method with too many arguments, Ask don’t Tell etc).
- Enforce standards by using checkstyle / PMD, cobertura / emma, findbugs, etc within maven build cycle to make sure code in repository is adhering to a certain quality standard.
- Make sure it meets the quality standard for the project.
- Just keep it simple. Functions should be short and sweet, and do just one thing. They should fit on one or two screenfuls of text (the ISO/ANSI screen size is 80×24, as we all know), and do one thing and do that well.
- Test, test, test.
- You will see how many times you will have to tradeoff between design and schedule. Forgive yourself but remember to refactor whenever possible.
- Use Standard Annotation Language (SAL) if you are using C or C++, to prevent bugs and make your code robust. It is found in the book “Writing Secure Code for Windows Vista.”
- Code with contracts (partially enforced with SAL).
- Avoid global mutable state, such as static variables and static singletons.
http://misko.hevery.com/2008/11/11/clean-code-talks-dependency-injection/
http://misko.hevery.com/2008/11/21/clean-code-talks-global-state-and-singletons/
- Make your methods small and well named.
http://c2.com/ppr/wiki/WikiPagesAboutRefactoring/ComposedMethod.html
http://tottinge.blogsome.com/meaningfulnames/
http://jamesshore.com/Agile-Book/simple_design.html
- Adhere to SOLID Principles
http://en.wikipedia.org/wiki/Solid_(object-oriented_design)
http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod
Simple tip: Naming functions
Examples:
GetName()
SetName()
DoAreaTransition()
CreateBird()
DestroyBird()
Note how each function name begins with a verb and usually, each function ends with a noun. Naming your functions this way helps you think more clearly about what you’re doing and helps other people understand your code more thoroughly.


I added texture mapping and blend mapping to Tsunami. The textures aren’t mine, they’re from a book and it’s associated tutorial. It looks much better now than the bland triangles from before. There isn’t a whole lot else to say about this except that I still need to add in the material system, which is next on the list.
I was able to add in a blend mapping. It just takes 3 different textures and blends them together based on what is defined in the blend map. These textures were also taken from a book’s tutorials because I don’t really care to make the textures or the blend map for that matter.