Thread: How to get a code review

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    144

    How to get a code review

    Hi everyone. I have spent the last 12 days writing a Wikipedia bot in C99. It's 5300 lines in 160 files, and it's finished. It's a fully featured bot with 12 command line options, it recovers from every recoverable error and does everything a Wikipedia bot should do. I stuck as closely as possible to Standard C, so it should run unmodified on any UNIX-like operating system and on Windows with one trivial modification. I'd be open to the idea of donating it to the GNU project. However, C is not the most natural language to write a Wikipedia bot in, and it handles XML manually instead of using an XML parser like it should, and it was written by just one guy in less than 2 weeks, so I'm not sure that it's good enough.

    How do I get a proper code review? Is there a way to get someone or several people to look over my code for errors and better ways of doing things?

    Richard

  2. #2
    Registered User \007's Avatar
    Join Date
    Dec 2010
    Posts
    179
    Get some cojones, toss it on source forge or somewhere-- people will review it.

  3. #3
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    Sure, but it depends, if you want to share your idea, if not........ try it on your own :-)

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Richardcavell View Post
    Hi everyone. I have spent the last 12 days writing a Wikipedia bot in C99. It's 5300 lines in 160 files, and it's finished. It's a fully featured bot with 12 command line options, it recovers from every recoverable error and does everything a Wikipedia bot should do. I stuck as closely as possible to Standard C, so it should run unmodified on any UNIX-like operating system and on Windows with one trivial modification. I'd be open to the idea of donating it to the GNU project. However, C is not the most natural language to write a Wikipedia bot in, and it handles XML manually instead of using an XML parser like it should, and it was written by just one guy in less than 2 weeks, so I'm not sure that it's good enough.

    How do I get a proper code review? Is there a way to get someone or several people to look over my code for errors and better ways of doing things?

    Richard
    Test if for a couple of months first...

    I can guarantee that if you wrote 5300 line in 160 files in 12 days
    a) you didn't get much sleep
    b) that software is totally untested except for your test runs after compiling
    c) there are at least 10 bugs in there waiting to get you.

    Pretty simply, nobody writes GOOD software in that short a time.

  5. #5
    Registered User
    Join Date
    Feb 2011
    Posts
    144

    Bug-free code ahoy

    Tater,

    Thanks for your support in my leet coding skillz. Yes, my code must be thoroughly tested, and yes I am exhausted after those 12 days, and yes I'll put it on sourceforge.

    Richard

  6. #6
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    I can guarantee that if you wrote 5300 line in 160 files in 12 days
    a) you didn't get much sleep
    b) that software is totally untested except for your test runs after compiling
    c) there are at least 10 bugs in there waiting to get you.

    Pretty simply, nobody writes GOOD software in that short a time.
    Haha, similar thoughts here, I have spent six months on a similar sized project! Maybe a little bigger i not counted the lines much, but still, the main code was in place around two months ago and since then it has been 'destruction' testing haha, Also writing an installer script which keeps needing little bits adding, It is the final tweaks and polish and that take the time i am finding, but i do not work on it every day that said.
    The final bugs that have come out of the woodwork are not bugs in the sense of 'it's broken, it crashes because of that' They have been more to do with ideal functionality, like "It is better to reactivate that button in this scenario so the user can..."

    But 160 files? Thats an average of around 33 lines a file? And how much of that is actual code? That seems crazy to me. I am quite happy with a hundred lines or more in a 'larger' file. I dunno, maybe those short files are appropriate for a bot project though..ni idea amigo
    Last edited by rogster001; 03-09-2011 at 03:01 AM.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  7. #7
    Registered User
    Join Date
    Feb 2011
    Posts
    144

    33 lines per file

    My idea is to make the program as modular as possible. All the functions are designed to be standalone, re-entrant, etc. Now that I've got the code working, I'm reducing the number of translation units.

    And yes, my code is brilliant.

  8. #8
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    And yes, my code is brilliant.
    Glad to hear you think so, if you can't love yourself who can you love..
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  9. #9
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Normally, you would have gotten a code review from several people as you were going along.

    A proper code review would also need access to your requirements (what it is supposed to do) and your design (how you proposed to do it). Being able to say "This looks like nice code" doesn't add much if you were supposed to write a calculator, but instead came up with a cash register.

    Also, if you're taking the time to actually understand the code (to the extent say that your "job" is going to be the maintainer of this code), and not just say "oooh - pretty", then a few hundred lines in 2 hours is all that a reviewer will manage in a single sitting.
    After 2 hours, the effectiveness of the reviewer deteriorates rapidly.

    In professional development shops, nobody does more than 2 review sessions a day if they're taking the process seriously.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  10. #10
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by rogster001 View Post
    Haha, similar thoughts here, I have spent six months on a similar sized project! Maybe a little bigger i not counted the lines much, but still, the main code was in place around two months ago and since then it has been 'destruction' testing
    Exactly... after writing the basic code the next phase is to see how easily it can be broken. Testing often takes longer than the main creation task and, if my personal experience is any guideline....

    Rule #1: Just because it compiles does not mean it works.


    But 160 files? Thats an average of around 33 lines a file? And how much of that is actual code? That seems crazy to me. I am quite happy with a hundred lines or more in a 'larger' file. I dunno, maybe those short files are appropriate for a bot project though..ni idea amigo
    I'm getting a headache trying to picture the maze of #includes at the top of each page...

  11. #11
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Richardcavell View Post
    and yes I'll put it on sourceforge.
    Any idea how much bad code has gotten out into the world that way?

  12. #12
    Registered User
    Join Date
    Feb 2011
    Posts
    144

    Thanks for your ideas

    All interesting and good ideas there.

    How does one go about a good code review? Do you start from main () and follow the program step by step, or do you review source code files alphabetically, or what?

    Richard

  13. #13
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Well, when I do it to my own code, I generally go section by section.

    I write my programs so that a given module of the program is all in the same source file... for example, my "setup" dialog will be one .c file. So my code is broken down by logical functions.

    To review a piece of given code I will ask myself a number of questions:
    1) Can I simplify this without losing functionality?
    2) Can I rewite it to be more easily maintained?
    3) Are there any conditions where it can fail?
    4) Is the code clearly organized and correctly indented?
    5) Will I be able to still read this when I come back in 5 years?
    etc.

    In general the goal is to make better code...

    As part of the review I also run the program, examine the display of that code section, looking for errors in setup, bad spelling, improved ease of use etc.

    Section by section...

  14. #14
    Registered User
    Join Date
    Feb 2011
    Posts
    144
    I see what you mean. Of course, I'm just one guy and I'm a relative newbie at C, so I think my ability to conduct a code review of my own code is limited.

  15. #15
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Richardcavell View Post
    I see what you mean. Of course, I'm just one guy and I'm a relative newbie at C, so I think my ability to conduct a code review of my own code is limited.
    If you can't look at your own code and say "Hey... I can do (this) and (this) and make it better", then either A) you are beyond perfect or B) you didn't learn a thing writing the code.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Humorous Code
    By DavidP in forum General Discussions
    Replies: 16
    Last Post: 08-28-2010, 10:40 AM
  2. Code Review for upcoming contest
    By Darryl in forum Contests Board
    Replies: 2
    Last Post: 02-28-2006, 02:39 PM
  3. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-02-2003, 04:28 AM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 06:05 PM

Tags for this Thread