Slashdot Mirror


Ask Slashdot: How To React To Coworker Who Says My Code Is Bad?

A week ago, you read the other side of the same question. Now, an anonymous reader writes "I have been with my company for 10+ years and have seen many development cycles on our projects. We have a developer intern who has not been on the team for very long. On day one he started ripping into my code on how terrible it is. We have a code base of roughly 50,000 lines of code. When he comes to me with a complaint about the code it is simply because he does not have the experience with it to actually understand what the code is doing. He is a smart guy with lots of promise, he is asking good questions, but how do I get him to look past his own self perceived greatness enough to slow down and learn what we are doing and how we have pulled it off?"

30 of 507 comments (clear)

  1. Tell him to write goddamn login page himself? by crazyjj · · Score: 5, Funny

    After all, he's fresh from a CS program where they taught him everything.

    --
    What political party do you join when you don't like Bible-thumpers *or* hippies?
    1. Re:Tell him to write goddamn login page himself? by Anonymous Coward · · Score: 5, Funny

      Code Monkey get up get coffee / Code Monkey go to job / Code monkey have boring meeting, with boring manager Rob / Rob say Code Monkey very diligent / But his output stink / His code not functional or elegant / What do Code Monkey think? / Code Monkey think maybe manager ought to write god damn login page himself....

    2. Re:Tell him to write goddamn login page himself? by cod3r_ · · Score: 5, Informative

      Exactly. Don't hold the guy's hand. Tell him to waste all his time rewriting everything and see what the company does with him.. In the end the boss man doesn't give a shit about how clean the code is.. he give a shit about how fast the code was written and if it does everything it's supposed to and more. New guys gota learn the game too or they will have a hard life in the world of software development.

    3. Re:Tell him to write goddamn login page himself? by Anonymous Coward · · Score: 5, Funny

      Code Monkey not say it out loud. Code Monkey not crazy, just proud

    4. Re:Tell him to write goddamn login page himself? by Anrego · · Score: 5, Insightful

      As programmers its an easy trap to fall into thinking that better code always translates into those dollars and cents management seems so hung up on. Sometimes it does, sometimes it doesn't. Yes, some bad managers are too short term focused, but being able to do the math and figure out if the cost of cleaning up some code is going to be justified in the long run is part of a managers role.

      Telling management you want to re-write everything is a programmers perogative. Accepting it when the manager comes back and says "what we have now works, our customers arn't complaining, the thing is end of life in 2 years, and even if this made future maintenance free it wouldn't be worth it" is a reality.

    5. Re:Tell him to write goddamn login page himself? by Anonymous Coward · · Score: 5, Funny

      Code Monkey regret his lousy placement / Code Monkey recall his mama's basement / Code Monkey's chest still swell with pride / Recalling Natalie Portman statue, naked, petrified.

    6. Re:Tell him to write goddamn login page himself? by Nemesisghost · · Score: 5, Insightful

      This is what a lot of idealistic programmers who are just out of school fail to realize. We should be able to remember that all the code we wrote in college had to be perfect, without any flaws. At the same time, most of these programs were fairly small(

      Another problem arises when you have an older developer who is forced to learn new tech where the best practices are drastically different from those he/she is familiar with. For example, if all you've ever done is procedural code(which is what most of my college classes did), and you are tossed into a situation where most of your coding is layered event driven the best practices between the two are so different that you are bound to make mistakes. What I've then see happen in situations like this is that a new developer comes along & sees where there are places that the best practices aren't being followed 100% of the time, and therefore assumes all the code must be crap. Instead, what should happen is the new developer should look at why something was done the way it was & work with the responsible party(not necessarily the original developer) and see if there's a good reason to "fix" the bad code.

      Currently I work with a great set of managers. They understand the cost of any project and are very good at prioritizing "fixes". They know that some of the early development doesn't work with the things we are now trying to do, and are will to let us go back & fix things. But they also know that we don't have the resources to fix everything, even things that might reduce the errors & crashes. I have a fellow developer that not fixing everything drives him crazy, and that was one of his first lessons. Nothing's perfect, nothing will be, and our job is do the best we can & worry about the problems only when we are told to.

    7. Re:Tell him to write goddamn login page himself? by n7ytd · · Score: 5, Insightful

      The boss is interested in the long term effects of having code that doesn't suck, such as lower maintenance time. If the boss wouldn't care when directly told this, that just shows he has bad management skills.

      Rewriting is very often the last thing to do with working code. IChucking out working code and reproducing it usually involves relearning all of the reasons those last guys did it that horrible way.

  2. Old problem by Anonymous Coward · · Score: 5, Insightful

    This is an ancient problem, with 10 years experience I'm amazed you haven't run into this constantly throughout your entire career. New guys (even old guys) perceive everything they didn't write as shit.

    How you deal with it is dependent on a lot of things.

    First: is he right? Maybe your code does suck. Hell maybe you suck! At minimum. code that has been around for a while, has been written by multiple people over a long period of time, been adjusted and re-worked to meet changing requirements, and been done under a deadline usually does suck at least a little. Admitting this is hard.

    New guys want to re-write everything and don't understand the value of code maturity... most of the time a re-write isn't practical, and even the shittiest code usually attains remarkable stability by virtue of having all the bugs pounded out through years of use. Reminding him that this isn't a university project and a certain level of ugliness should be expected might help.

    If you don't think he's right, learn how to properly describe why you do things the way you did, and conversely expect him to explain why they are wrong. This is the biggest thing to learn when doing code reviews, and applies here. If you can't objectively describe what is wrong using with references to either standard or internal best practices or conventions, arguing code ugliness just becomes subjective. If you want to defend your code, learn how to describe how it doesn't suck.

    Having some company guidelines will really help, because it gives you something to point at in defending a decision. Ultimately what one guy considers good code may be considered bad by another. You are always going to have cases where someone thinks your code is too abstract, or not abstract enough, or sacrifices too much performance for maintainability, or too much maintainability for performance. At least with standards, the new devs will rail against the standards rather than personally attack you, and a standards document is a lot easier to defend (and yet still allows good changes without too much politics of hurt feelings).

    1. Re:Old problem by N0Man74 · · Score: 5, Insightful

      Good answer.

      Your keyword "deadline" didn't really get the emphasis it deserved. I know that I've been guilty of writing some pretty shitty code (and fully realizing it) because I simply did not have the luxury of the time to "do it right".

      Sometimes this is because I made a bad assumption early on. Sometimes there was a surprise change in the specs that didn't mesh well with the design. At times, it is because I'm working in unfamiliar territory and still learning about some aspect of the project. Sometimes it is because I am working with existing bad code someone else wrote (possibly because of one or more of the same previously given reasons), and I have to do my best to work within an existing bad implementation.

      In the real world, sometimes you have to make the choice of doing things right, or actually getting them done.

    2. Re:Old problem by gatesstillborg · · Score: 5, Interesting

      I disagree with this "perceiving everything they didn't write as shit" stance.

      I came into a new position, my first serious one (when I was in my forties, second career field, after a couple years of good community college studies). I have experienced in depth 3-6 (3 thorough exposure, 3 partial/peripheral exposure) different, substantial code bases. Two of them where horrendous ("devil spawn"), one was not exactly a work of art, but manageable, managing considerable (reporting and logging) complexity, and the other 3 were solid to the point of being elegant, and naturally readable. And mind you, this was my first serious in depth exposure, across a variety of development platforms, including both proprietary and open source.

      "Man is the measure of all things." -Protagoras

  3. Very simply by houbou · · Score: 5, Insightful

    Critique is only as good as the suggestions for improvement. So, that's your answer. I feel that if someone has issues with my code, then show me better and prove me it is better. In the end, clarity, code reuse, design patterns, performance, all of these things come to play.

  4. Is he right? by AdamStarks · · Score: 5, Insightful

    Take a step back and seriously consider his criticism, as if he were one of your 10+ year coworkers. Whether or not he's right informs the right reaction.

    1. Re:Is he right? by Anonymous Coward · · Score: 5, Funny

      Maybe, but we know that he posts to Slashdot as well.

    2. Re:Is he right? by flatt · · Score: 5, Funny

      Whether he is right or not is immaterial. Now is the time to assert your dominance. Sucker punch him and urinate on him while he's down to put him back in check.

    3. Re:Is he right? by Anonymous Coward · · Score: 5, Funny

      This works and it's a good fundamental method, but it's not extremely efficient.

      I typically like to hire them in a groups. Initially, lay quiet and see who is the more uppity of the bunch. Let him have his moment in front of the new kids and really start to build an alpha status for himself.

      Shortly there after you really want to just casually stroll up to the fresh example and just stab him in the kidneys a few times. This will deal with the problem candidate and build your reputation as someone who gets things done. In fact, it is unlikely anyone will question your authority for some time.

  5. You Are Not Your Code by Anonymous Coward · · Score: 5, Informative

    You Are Not Your Code: http://sstephenson.us/posts/you-are-not-your-code

  6. Mod this up! by ganjadude · · Score: 5, Insightful

    Might as well close the forum down, this is gonna be the best answer concerning this issue. if only I had mod points

    --
    have you seen my sig? there are many others like it but none that are the same
    1. Re:Mod this up! by del_diablo · · Score: 5, Informative

      No. You only say that until you are almost permanently awarded with mod points.

  7. Is Your Code Designed to Build Walls or Bridges? by VoidEngineer · · Score: 5, Insightful

    Recently went through this myself. Despite having used a kanban board, used version control, commented code, written unit tests, etc, some junior devs thought the code sucked. My takeaway was that there were still too many barriers to entry. Too many passwords, not enough installation instructions, etc.

    Somewhere in the process of learning to write production ready code, it occurred to me that it was necessary to work the process backwards. Begin a project by setting up your hosting or distribution environment before starting to code. Write unit tests before starting to code. And so forth.

    Getting other people to contribute to your project requires the same kind of thinking. Set up a project page before you start to code. Write a vision statement before you start to code. Write installation instructions, coding style guidelines, and operations support instructions before you start to code. That way, as you proceed in the project, you have clearly build up the documentation that other people are going to need to join your project. These things shouldn't be started after the fact.

    If you can't point a new dev to a website and say 'download the source and instructions' here, it's probably too complicated and will meet resistance.

  8. A good opportunity by Anonymous Coward · · Score: 5, Interesting

    From your description, the guy isn't mean spirited. He's likely never had to deal with multiple revision code bases before.

    On the other hand, if this is code that has been through multiple revisions and re-purposes, admit to yourself -- it probably is bad. I'm the lead engineer and dir. engineering at a company I've been at for 10+ years, and I'll be the first to tell you that the code-base I am most proud of (30-50k lines of embedded/DSP code, mostly mine) is TERRIBLE! I wouldn't wish that code-base on my worst enemy. But its also been bread and butter for the company for the last decade and is stretched to its limit.

    We've had at least two hotshots come onto the project in that time who have been terrified seeing that code-base and declaimed it as schizophrenic at best, and they are right. It is bad code, poor coding practices, and everything else bread out of necessity to keep the project(s) going and alive.

    Your mission -- accept that whatever reasons are out there for the code being the way that it is, it probably is poorly structured and could use a rewrite. SO - this is a good chance for him to learn that not every bit of code that should be rewritten can be. Its called business reasons and experience. Whatever the reasons, you probably, as a company, don't have the time or resources to rewrite from scratch (we surely don't!), but a fresh out of school developer probably has not experienced these -non-engineering- reasons for bad code, and certainly was not there for the blood, sweat, and tears that went into them. He won't know about those all nighters that "saved the company" that you and the rest of the team probably went through en-route to this codebase.

  9. How's your documentation? by dbc · · Score: 5, Insightful

    I'm sure if he re-reads your internal design specifications, coding standards, and comments in the code he will understand your design.

  10. Re:timothy is apparently easily trolled by gigne · · Score: 5, Funny

    yep.

    What next? "I am some code. How do I tell my new maintainers they suck?"

    --
    Signature v3.0, now with 42% less memory usage.
  11. Re:Possibly related? by magarity · · Score: 5, Funny

    This questioner says he's been at the company 10 years and the new kid is hassling him. That prior question says the guy he's hassling has been at the company longer than the hassler has been alive. If they've hired a 9 year old as a coder then they deserve all the atttitude they get.

  12. Define "bad" by SirGarlon · · Score: 5, Insightful

    As an engineer, I've adopted the maxim that there is no good and bad, only fitness for a particular purpose. I prefer a discussion of trade-offs to statements of principle.

    I tend to ask "what requirements does this code fail to meet?" And very often, the reviewer has invented his own new requirement! Depending on your process, your response might be anything from "good point, let's add a test case for that" to "you should submit a Requirements Change Form for that. Make sure to get all the required signatures."

    And if the criticism is for something immeasurable like "readability" or "maintainability" you can let your critic make the case to the boss why fixing this code is worth the cost.

    --
    [Sir Garlon] is the marvellest knight that is now living, for he destroyeth many good knights, for he goeth invisible.
  13. Re:Those who are not satisfied with others . . . by gstoddart · · Score: 5, Informative

    Give him a copy of "The Psychology of Computer Programming", and tell him to read the bit about egoless programming . . .

    This, a thousand times this -- but remember, it works both ways.

    The professor I worked with closely in university was a strong proponent of this. Sit down, go over the code, look at what can be made better and why, and what may need to stay crufty because it's arcane, and if someone doesn't understand something that's an excellent time to explain it. Walk through and review everything, and don't let your vanity get in the way of writing better code.

    He called it egoless programming back in the 90's (no idea how old your book is), and I've found it extremely handy -- objectively look at your stuff and see if he's right. If he's wrong, explain it to him. In the end, the better solution should win out (unless someone is being stubborn or the 'better' solution is technically feasible, which does happen).

    Get over the whole "I'm a code guru who knows everything", and be prepared to explain, justify, or even accept that you're wrong. In the end, you review your code to make sure it is as good as you can make it (within reason) and your junior guys get up to speed and understand things better. You get better code out of it, your junior guys get up to speed faster, and you might even learn something along the way.

    It's still how I work with co-workers, and it helps in a lot of ways -- instead of saying "here's the solution", you start with "here's a solution, what have I missed?"

    You won't agree about everything, but you can pick your battles and try to reach quorum -- the cats don't need to be herded when they're on-board in the first place.

    I've seen really awful, and really good ideas from junior coders -- part of the process is helping them understand which is which. In a year or so when he's got more real experience, and knows he can have the discussion, both you and he might actually be better coders for it.

    --
    Lost at C:>. Found at C.
  14. Klingon Programmers by AlienSexist · · Score: 5, Funny

    "You dare insult my code!? I'll kill you where you stand!"

  15. Re:Different philosophies by PRMan · · Score: 5, Insightful

    I've said this at several workplaces:

    What the Business values:
    1. Correctness
    2. Reliability
    3. Maintainability
    4. Speed
    5. Coolness

    What the Developer values:
    1. Coolness
    2. Speed
    3. Correctness
    4. Maintainability
    5. Reliability

    Don't believe me? Look at practically ANY open source project. Most are unreliable and impossible to contribute to. They are often incorrect, but they are usually fast and the programmer always thinks what he's doing is mega-cool.

    Developers need to adjust their mindset to be valuable to the business, but sadly most business code looks more like the second list than the first.

    --
    Peter predicted that you would "deliberately forget" creation 2000 years ago...
  16. Technical Debt by Anonymous Coward · · Score: 5, Interesting

    We always see bad code as technical debt and treat it as debt. When we have cycles we pay it off, when we don't we get some more.

    Having been doing this for 12+ years, I have come to realise I have never liked anyone's code and figured out its more of a style or personality than bad or good. Yes there is bad code, but there is no good code per say. Or put another way, if done right its good and you and I still may not like it.

    Its just the nature of the beast, its kind of like driving a car, all other drivers seem bad.

    1. Re:Technical Debt by MozeeToby · · Score: 5, Insightful

      Sometimes I don't even like my own code if I'm coming back to it a year later. It's just the nature of the game. What looks 'good' and 'right' to you changes based on what you know about coding, what problems you've encountered, what you know about the project, what you know about the budget, etc, etc.