Adjusting to new guidelines for code structure and software

Started by
7 comments, last by Zomgbie 10 years, 6 months ago

Hello people!

Last year i started my employment at a new company. Things have been going great, or so i thought. At a recent developers meeting i received quite a lot of critique for how i write my code. Now, i can accept that i have to adjust to a new code structure, but somethings just feels so wrong. For example, this is how i'd write an if statement:


if ($variable == "condition")
        doAction();

I was told that this is wrong and wont work, simply because the PHP log picked up an error at this line once. The error was actually caused by a missing quotation mark. So i was instructed to always encase my if statments like so:


if($variable=='condition') {
        $do_action();
}

And i just find it so hard to accept this. Sure, if he could give me a real reason to adjust to his personal coding style, i would. But blaming it on that it's "wrong and won't work" just pisses me off...

And then there is the question of coding software. I've always been using an OpenBSD box, with vim as my prefered editor. Sadly i was told that this is wrong too and i have to use Dreamweaver on Windows, because it's faster and "better".

How would you deal with this? I actually went to talk with my boss, but he said i have to accept these changes as the lead developer is way more experienced then me. Sadly i've lost a lot of productive code hours only to getting used to Dreamweaver and rewriting my code to follow his examples. What would you do? Am i just being stupid because i don't like the way he codes?

Omg, zombie! Zomgbie.
Advertisement

If you're being paid for a job, then you do the professional thing, which is to follow the client's specifications and do what they're paying you for.

In this case, the client might be an incompetent lead, and the specifications might be some stupid coding guidelines, but it doesn't matter. They're paying you to code in the way they want you to code.

Having everyone follow a common set of coding conventions is extremely useful, even if you don't agree with them. I worked at a games company with 100 other programmers, who constantly argued about stupid rules in our coding conventions... but we all followed them nonetheless, even though we all disagreed with some parts of them. By ensuring that all the code looks the same, it made all our jobs easier in the long run, when working with other people, or with other people's code.

If they truly believe that you should follow their conventions because your old style is causing bugs... well then that's a different issue. Keep your resume updated and keep your eyes out for better jobs tongue.png
Also, if that truly is the case, then don't rock the boat by being argumentative, because incompetent leaders tend to use office politics to protect the comfy role they've managed to forge in the company...
BTW, in PHP "blah" and 'blah' are different, and each is preferable in different situations. In this case, the single-quote version is more optimal.
Regarding the braces, that's something that's the cause of endless coding-style arguments. If the company has picked a style, then you've just got to suck it up and stick to it for the sake of everyone to keep the code-base from looking schizophrenic.

In your example what would happen if somebody did a find and replace on doAction(); with //doAction(); It may seem like a stupid thing to do but I have seen developers do this and things that are a lot worse.

The code style guidelines are not there to protect just you but every developer in the team. Every company has guidelines and at every company they vary. Some companies the guidelines are written by idiots and some they are written for specific reasons.

Having to use Dreamweaver though sounds a little weird. I think if I was told which tools to use to do my job I would probably just leave. Unless of course there was a monaetry reason why they wouldn't buy the tools I need but, they are free so there isn't.

...

You are indeed correct. But they are not really clients, they are colleagues. Though you are very correct, i'll have to suck it up. I guess i'm just a little sad that i have to give up my personal style, just because someone else want's theirs. It's not that we are alot of developers, we're only two. Him and me. Which is why it hurts ^^

And oh yes, i know the difference between single and double quouted strings. I just tend to stick to double qouted cause of all the years working with C.

In your example what would happen if somebody did a find and replace on doAction(); with //doAction(); It may seem like a stupid thing to do but I have seen developers do this and things that are a lot worse.

That's actually something i haven't thought of. In such a case i would just blame a really lazy developer, but it's still a valid point. Thanks!

He's reasoning for forcing Dreamweaver on me is that it works faster and can open any type of files... which... yeah... you know what i mean.

Omg, zombie! Zomgbie.

I would second Hodgman’s suggestions, even if it applies only to “coworkers” rather than to “clients”.

Unless you have been specifically placed in charge, you are the new guy and no one will respect your opinion until you prove it is the right one.

Of course, even if you were explicitly placed in charge, no one will respect your opinion until blah blah blah. Only difference is that they have to deal with it instead of you.

But from what you have proposed compared to what I would propose in a professional environment, there are reasons why a team leader would prefer everyone to use braces even when not necessarily necessary by the language.

The reason why you should “always encase your ‘if’ statements” will likely come to you at a later time. For now it’s time to suck it up and take the lower wage and status as the rest of us have and acknowledge that many others have come before you and have put certain restrictions in place for the sake of the team, rather than the individual.

Usually when someone above you says it is “better” it is just to avoid a drawn-out argument. Which that person has experienced more times than you have.

If you want to argue such a situation based on your own efficiency (these being the key words) then I would suggest only doing so in a way that is sympathetic to his or her goals, which are to eliminate redundant arguments while providing a framework consistent enough that future workers can easily adapt, while still trying to make your own case that you yourself will work faster because of your previous experience in X software, even though it is unrelated to the people who will in the future be maintaining your code, and will end up slowing them down.

In other words, give up. Do what they ask and try to use your expertise not as a way to trump them but to merge with them. Neither wins by using only the expertise from one or the other. You only win by sucking up your humility and trying to find out in time how you can help them with your unique knowledge and skills.

L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

As Hodgman said : "the code must be consistent".

About the tools.... well sometimes, we are wrong.. Personally i don't like Vim and Dreamweaver(about DW.. maybe because I'm not a web programmer)). But they may force you to use DW because of some licensing, or already developed tools that you must use, because hmm... thay generate some code for you, or more likely because your coworkers are using some project settings that you cannot maintain for your code just because you're not using it.

If you write consistent code everyone will be OK with Vim. They just want you to follow some guidelines...

BUT if there is no reason and you dont like the place ... find another job, because the most important thing after all is your tranquility!

That's actually something i haven't thought of. In such a case i would just blame a really lazy developer


It's not lazy to want automated renaming/refactoring to not break things.

I agree with most of what you said except the braces. Braces are great.

When you work in a team, abandon all your personal styles. You have to agree with the coding guidelines of the team. The worse thing is to read code that has m_inconsistent code_styLing.

Regardless of choice of editor, that should never been enforced. You can complain about that. Everyone is entitled to have his/her own personal work environment. That's kind of like having a boss telling you what to put on your cubicle. Dreamworks, vim, emacs, that's up to you, unless you have project files can only be opened on certain editors.

Now that a few days have passed, i can safely say that i was just being stubborn. After reading what you folks have written i understand that all i can do is accept this new codingstyle, and that it's for the greater good. I feel a little embaressed to say, but i belive i just thought my standards were better then his. Hence it felt so wrong to adapt to the new guidelines. I learned my lesson, so to speak. Thanks again! :)

Omg, zombie! Zomgbie.

This topic is closed to new replies.

Advertisement