Thread: What would happen on the job?

  1. #1
    C lover
    Join Date
    Oct 2007
    Location
    Virginia
    Posts
    266

    What would happen on the job?

    If someone had a job as a programmer and they used bad naming convention constantly, what do you think would happen? Take for example this snippet below:

    Code:
    #include <stdio.h>
    int main(){
    
        int *__ = (int *) malloc(sizeof(int));
        int *___ = &__;
        int _____;
        int *__12__34__56____78 = (int *)malloc(sizeof(int));
        int d398w9eskj__wuj = 0;
    
    
        scanf("%d",&__);
    
    
        *___+= 1;
    
        _____ = *___+ 2;
    
        *__12__34__56____78 = 5;
    
        d398w9eskj__wuj = *__12__34__56____78;
    
        printf("%d\n",*___);
    
        printf("%d\n",_____);
    
        printf("%d\n",d398w9eskj__wuj);
    
    
        return 0;
    }
    Do you think someone would try and help them by say, letting them know that what they are doing is bad? Or do you think they would get fired? I would never do something like this, just curious. Does this type of thing ever happen in the real world?

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    I have had coworkers fired for poor coding practices. (I drove the effort on one of them, as a matter of fact.) Yes, it happens.
    Mainframe assembler programmer by trade. C coder when I can.

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Looking at that example... I would make him an offer he can't refuse.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    That's not a bad naming convention, it's a bad joke.

    At least the names are completely meaningless. I've seen far worse code, where the names had apparent meanings which had little or nothing to do with what the code was actually doing.

    A poorly chosen name for something can literally cause weeks of wasted effort. Would it get you fired? I'd rather say that it would prevent you from being hired to begin with. Anybody writing code like that who actually finds employment is clearly working for people even dumber than he is.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  5. #5
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    My first inclination is that of brewbuck...it was a joke. Were the author serious, I would think he/she would be warned and expected thereafter to follow reasonable standards.

  6. #6
    C lover
    Join Date
    Oct 2007
    Location
    Virginia
    Posts
    266
    Heh, I sometimes have the bad habit of using a single character as a variable. Say "b" or "e" for "begin" and "end" respectively. Though this is usually just some sort of draft code that never leaves my personal desktop and nobody else ever sees it. Heck, who else (at the moment) WOULD see it? I don't have a job in the field yet.

  7. #7
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    You'd better break yourself of that habit. When you DO get a job, it likely won't be tolerated in any decent shop.

  8. #8
    C lover
    Join Date
    Oct 2007
    Location
    Virginia
    Posts
    266
    Yeah, I know it just sounds ridiculous but I sometimes just find it to be quicker(as if it takes sooo long to type a few more characters). Also, this may be off topic but in class today, I had another student tell me that he dropped the computer science major and switched because they used "old crappy languages like C, C++ and Java". I thought to myself, thats most of the languages I know! He then went on to say "I wish they were using something newer like Visual Basic". Now, I've never used visual basic, but is it really that much better than C or C++? Not saying that I would drop C, Python, or C++ for VB but I'm just wondering.

  9. #9
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Syscal View Post
    Yeah, I know it just sounds ridiculous but I sometimes just find it to be quicker(as if it takes sooo long to type a few more characters). Also, this may be off topic but in class today, I had another student tell me that he dropped the computer science major and switched because they used "old crappy languages like C, C++ and Java". I thought to myself, thats most of the languages I know! He then went on to say "I wish they were using something newer like Visual Basic". Now, I've never used visual basic, but is it really that much better than C or C++? Not saying that I would drop C, Python, or C++ for VB but I'm just wondering.
    If he switched majors away from CS because of the specific programming languages being used, then it's a good thing he switched, because CS has little or nothing to do with programming languages, and he obviously had no idea what it was about.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  10. #10
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    If you seriously think that naming variables "__" and "___" isn't a horrible idea, you likely wouldn't have gotten past the hiring process in the first place. If you're joking, I would hope a co-worker doesn't think that committing code like this on a regular basis is funny. They would certainly be verbally told to knock it off as soon as someone saw it. How long would it take to get fired? Where I work - probably a long time. If it was my own business and my living partly depended on their performance, and they had already been told how obnoxious and counterproductive it is, they would probably be let go the next time I saw them do it.

    As for your other question: If your friend left the CS major because he considers C, C++ and Java "old crappy languages" in favor of Visual Basic, CS is likely not the right major for him anyway. Perhaps he would enjoy working in Graphic Design, UX Design or something like that. Even Software Development might be a better major, but CS programs generally focus on a lot more theory and mathematics / logic. Visual Basic is hardly the best language to use in teaching a class on those topics (even though I agree with brewbuck, that the language matters very little). Compared to other languages, I hear almost no talk about Visual Basic being used in a serious setting anymore. Even when it was more popular, it was really only targeted at developers who wanted to create user-applications fairly quickly.

    Incidentally, are you trying to start a flame war? You seem to be bringing up some fairly obvious points.

  11. #11
    C lover
    Join Date
    Oct 2007
    Location
    Virginia
    Posts
    266
    No, that wasn't the idea at all. I guess the "bad naming" example I proposed was a bit extreme. Besides, how would THIS start a flame war? If someone can't take the heat, so be it. Even though that isn't what I was trying to do.

  12. #12
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    <sniffs the air>

    I am not detecting any smoke, Captain.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  13. #13
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,534
    Asking questions about which language, x or y, is better can be a sore point around here. As some experienced programmers around here have pointed out, after a while, all the languages start looking the same. Which one you use depends on the job.

  14. #14
    C lover
    Join Date
    Oct 2007
    Location
    Virginia
    Posts
    266
    Quote Originally Posted by brewbuck View Post
    <sniffs the air>

    I am not detecting any smoke, Captain.
    I take it thats your way of being sarcastic?


    Kermit,

    I definitely do not consider myself an experienced programmer. Heck, I only know Python, Java, C, and C++. Aside from programming, I know Javascript, HTML and CSS. I would see no reason for someone to get mad. Everyone has an opinion. But do all languages look the same to you? Definitely not to me. I just see different ways of doing the same thing.

    EDIT: While I am at this, can I ask what a day at work is like for you guys? Is it non stop coding until your shift ends? Then only to go home and work on the project some more? What happens if someone doesn't know how to code something?
    Last edited by Syscal; 09-07-2010 at 05:58 PM.

  15. #15
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Besides, how would THIS start a flame war? If someone can't take the heat, so be it.
    For starters, bring up a discussion on programming languages generally degrades into that, and your argument for your variable naming convention seems like you're just trying to get a reaction.

    can I ask what a day at work is like for you guys? Is it non stop coding until your shift ends? Then only to go home and work on the project some more?
    It would vary depending on the exact job, but my job, as does most, also involves a bit of walking around and talking to different people to clarify what people need, trying to help someone solve a problem, bouncing ideas off people, etc... I also try and spend time writing documentation and training materials based on what I learn. When I go home, I leave work at work. I have funner things to do at home (which sometimes is coding, but on more interesting projects).

    What happens if someone doesn't know how to code something?
    After a certain level of experience, it really becomes a question of breaking down the problem correctly. Talking to other people can help, etc... But most of the people I work with almost never run into something they don't know how to at least start doing.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. crazy pipe/fork
    By fortune2k in forum C Programming
    Replies: 8
    Last Post: 03-13-2009, 11:28 AM
  2. Totally confused on assigment using linked lists
    By Uchihanokonoha in forum C++ Programming
    Replies: 8
    Last Post: 01-05-2008, 04:49 PM
  3. a VB.NET job
    By Brain Cell in forum A Brief History of Cprogramming.com
    Replies: 20
    Last Post: 05-09-2005, 06:41 PM
  4. I can't find a job.
    By Cheeze-It in forum A Brief History of Cprogramming.com
    Replies: 42
    Last Post: 06-29-2003, 08:35 PM