Whatsisname
[H]F Junkie
- Joined
- Nov 15, 2000
- Messages
- 10,201
yoda style if statements are beyond obnoxious. I'd rather deal with an infrequent accidental assignment than dealing with if(0 = blah) on a regular basis.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
yoda style if statements are beyond obnoxious. I'd rather deal with an infrequent accidental assignment than dealing with if(0 = blah) on a regular basis.
void DX9Device::Present( void )
{
switch ( HRESULT ret = mDXDevice->TestCooperativeLevel() )
{
case D3DERR_DEVICELOST:
case D3DERR_DEVICENOTRESET:
mDeviceLost = true;
return;
}
if ( FAILED( mDXDevice->Present(0,0,0,0) ) )
mDeviceLost = true;
}
void Core::StartupSystems( void )
{
std::for_each( mSystems.begin(), mSystems.end(), std::mem_fun( &ISystem::vInit ) );
mRouter.PostMsg( Msg::CoreInit );
mInitialized = true;
}
void Core::GameLoop( void )
{
while ( mRunning )
{
mTime.FrameTick();
mInput.FrameTick();
std::for_each( mSystems.begin(), mSystems.end(), std::mem_fun( &ISystem::vUpdate ) );
mRouter.PostMsg( Msg::EndFrame );
}
}
void Core::ShutdownSystems( void )
{
// Note: This calls vDestroy in reverse order of vInit
std::for_each( mSystems.rbegin(), mSystems.rend(), std::mem_fun( &ISystem::vDestroy ) );
DeleteContainerReverse( mSystems );
}
You really caught him red-handed there, Mike. Well done. Bravo. And all that.
And for trivial projects, it's actually a practical approach.Having small compact functions/methods that perform ONE AND ONLY ONE task is the best way to code.
Thanks. Not to go all braggy, but I just got my detective license.
Don't you mean badge?![]()
That's a private investigator, not a detective. I was thinking police force detective... but I guess the term is interchangeable
These threads never stay on topic...
I've got the opposite problem. A bunch code for the application i'm working on is way OVERLY verbose. It's gone so far on trying to make it easy to read, that it has actually become more confusing.
Here's a sample. It's Ruby on Rails. The empty lines are actually there in the code.
Code:...
100 lines that could be compressed to less than 20. Things like if(some_Var == true) drive me crazy.
Sometimes being a nazi is not a good thing.
P.S.
BTW all the above code is supposed to do is built a new Object from the hash_IN parameter. Literally takes 2 lines.
I'll do this only if val is of type bool. For other types, I use comparison operators even if the test is zero or not-zero.Testing things for true and false in an if statement is silly. If it is bool or true when != 0 just use if(val) or the opposite if(!val).
I'll do this only if val is of type bool. For other types, I use comparison operators even if the test is zero or not-zero.
I use something like this in Perl fairly often,yoda style if statements are beyond obnoxious. I'd rather deal with an infrequent accidental assignment than dealing with if(0 = blah) on a regular basis.
while(my $line = <FILE>) {
...
}
I'll do this only if val is of type bool. For other types, I use comparison operators even if the test is zero or not-zero.
In software development, how common is it to use linting tools?