Someone made fun of my style and hurt my feelings


Code: Select all
void FocusPointView::Impl::input_update( const view::InputState& input_state )
{
using namespace view;
const auto& keyboard = input_state.keyboard();
if( keyboard.is_just_down( KEY_F4 ) ) show();
if( keyboard.is_just_down( KEY_F5 ) ) hide();
if( keyboard.is_pressed( KEY_J ) ) rotate_longitude_left();
if( keyboard.is_pressed( KEY_L ) ) rotate_longitude_right();
if( keyboard.is_pressed( KEY_I ) ) rotate_latitude_up();
if( keyboard.is_pressed( KEY_K ) ) rotate_latitude_down();
if( keyboard.is_pressed( KEY_Y ) ) move_away();
if( keyboard.is_pressed( KEY_H ) ) move_closer();
if( keyboard.is_any_shift_hold() )
{
if( keyboard.is_just_down( KEY_X ) )
{
m_workqueue.push( [&] {
m_focus_point.relocate_in_world( SphereVector::UNIT_X );
} );
}
if( keyboard.is_just_down( KEY_C ) )
{
m_workqueue.push( [&] {
m_focus_point.relocate_in_world( SphereVector::UNIT_Y );
} );
}
if( keyboard.is_just_down( KEY_V ) )
{
m_workqueue.push( [&] {
m_focus_point.relocate_in_world( SphereVector::UNIT_Z );
} );
}
}
else
{
if( keyboard.is_just_down( KEY_X ) )
{
m_workqueue.push( [&] {
m_focus_point.relocate( SphereVector::UNIT_X );
} );
}
if( keyboard.is_just_down( KEY_C ) )
{
m_workqueue.push( [&] {
m_focus_point.relocate( SphereVector::UNIT_Y );
} );
}
if( keyboard.is_just_down( KEY_V ) )
{
m_workqueue.push( [&] {
m_focus_point.relocate( SphereVector::UNIT_Z );
} );
}
}
}
Code: Select all
{
int iPixelPos = yPos * scrWidth + xPos * iMult;
}
Code: Select all
{
int iPixelPos = yPos*scrWidth + xPos*iMult;
}
Oh that's very interesting actually. That's a case where I'd actually believe a coder that the style really affects their productivity. We had a blind coder on the FreeSWITCH project but I guess he just struggled through K&R. Also I doubt we would have changed styles ... C projects like that can be pretty hardcore about the style, with some coders using emacs/vim in terminal windows and feeling religious about certain things. We followed the linux kernel style.Zonder wrote:I used to not care where { and } started but I had to work with a blind programmer at Microsoft for 3 weeks and he made us all put { and } on new line as it made coding faster for him. The reason is he can trust a { and } is on a new line so he can skip control blocked he doesn't need to listen to. So it { and } always on a new line to be blind coder friendly
Yeah style is mainly about readability via consistency of the codebase. Although, I have actually seen coders add a statement to a conditional block with no {} lolmmixLinus wrote:I should add perhaps that my choice is for aesthetic reasons. I don't really believe in minimizing bugs by choosing a particular formatting.
Klaim wrote:Yeah don't worry about these kind of choices. Depending on the company you'll meet different imposed styles and as long as everyone is using the company style it's ok. Same thing for personal projects and open source ones.
I'm still experimenting different styles each time I start a new small project, just to play with the ideas.
I do agree with you that this choice isn't really that important (or at least that's how I feel ... some colleagues I have asked seem to feel differently). Just the company in question is my company, and if people think K&R is even the slightest bit restrictive then that is enough for me not to force it on them. Also not a single one of the libraries/projects I am using is K&R: Ogre/Ogitor, Bullet, Cricket, Recast/Detour. And I really want to contribute back to some of them one day without messing up their style too badlyShakespeare wrote:... there is nothing either good or bad, but thinking makes it so
Yeah that's exactly what I've heard from a few people. Which is why I'm definitely going to switch now and avoid any kind of friction, since I personally don't care what style is used. I used something close to Allman in C myself before doing some kernel work and joining a few large C projects in K&R.mkultra333 wrote:My own tastes... I think K&R looks ugly. It doesn't sit in my head right. It feels all jumbled up. I like Allman.
That formatting drives me nutsmmixLinus wrote:One thing I do at work but not at home (funny way of phrasing it?) is put spaces around operators.
+1: Again I find K&R much harder to read / grasp. With Allman I can easily spot where a block starts and ends just by the { and }. With K&R you still have the indentation level, but that just seems to not be enough for my brainmkultra333 wrote:My own tastes... I think K&R looks ugly. It doesn't sit in my head right. It feels all jumbled up. I like Allman.
Just wanted to note, the linux kernel overcomes this by forcing 8 width tabs which make blocks very clear. Of course, then there are all new complaints about the tabs being too widespacegaier wrote:With Allman I can easily spot where a block starts and ends just by the { and }. With K&R you still have the indentation level, but that just seems to not be enough for my brain
Kojack wrote:Tabs at 8? That's crazy.
HahahaKernelStyleGuide wrote: Tabs are 8 characters, and thus indentations are also 8 characters.
There are heretic movements that try to make indentations 4 (or even 2!)
characters deep, and that is akin to trying to define the value of PI to
be 3.
That makes for nice real readable code but they're the most likely for me to ignore due to habit and laziness.3.Always insert spaces in between operators and operands (x + y, not x+y)
4.Use parenthesis to make the operator precedence unambiguous, even when it is not required ((x * y) + 1, not x * y + 1)
Code: Select all
if (x)
{
stuff();
}
Code: Select all
if (x)
stuff();
Code: Select all
if (x == 0) {
dosomething();
}
Code: Select all
if (x == 0)
{
doSomething();
}
Code: Select all
if (x == 0)
doSomething();